=>Py3.5
This commit is contained in:
parent
32b6c4977d
commit
b10e62152c
@ -1,3 +1,5 @@
|
||||
### “当你想放弃时,想想你为什么开始。”
|
||||
|
||||
#Fork版本主要改进如下:
|
||||
1、增加CtaLineBar,CtaPosition,CtaPolicy,UtlSinaClient等基础组件
|
||||
2、增加自动断线重连功能,在开盘前启动,收盘后重连CTP
|
||||
@ -76,6 +78,12 @@ QQ/Wechat:28888502
|
||||
#5、碰到的问题:version `GLIBCXX_3.4.21' not found
|
||||
conda install libgcc
|
||||
|
||||
#6、碰到的问题:在3.5 env下安装RqPlus时,报错:talib/common.c:242:28: fatal error: ta-lib/ta_defs.h: No such file or directory
|
||||
locate ta_defs.h
|
||||
找到地址:/home/user/anaconda3/pkgs/ta-lib-0.4.9-np111py27_0/include/ta-lib
|
||||
# 复制一份到/usr/include目录下
|
||||
sudo cp /home/user/anaconda3/pkgs/ta-lib-0.4.9-np111py27_0/include/ta-lib /usr/include -R
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------------------
|
||||
# vn.py - 基于python的开源交易平台开发框架
|
||||
|
@ -9,4 +9,6 @@ zmq
|
||||
qtpy
|
||||
pyqt
|
||||
qdarkstyle
|
||||
SortedContainers
|
||||
SortedContainers
|
||||
statsmodels
|
||||
openpyxl
|
@ -262,7 +262,7 @@ class BasicMonitor(QtWidgets.QTableWidget):
|
||||
self.setColumnCount(col)
|
||||
|
||||
# 设置列表头
|
||||
labels = [d['chinese'] for d in self.headerDict.values()]
|
||||
labels = [d['chinese'] for d in list(self.headerDict.values())]
|
||||
self.setHorizontalHeaderLabels(labels)
|
||||
|
||||
# 关闭左边的垂直表头
|
||||
@ -383,7 +383,7 @@ class BasicMonitor(QtWidgets.QTableWidget):
|
||||
|
||||
try:
|
||||
if not os.path.exists(path):
|
||||
with open(path, 'wb') as f:
|
||||
with open(path, 'w',encoding='utf8') as f:
|
||||
writer = csv.writer(f)
|
||||
|
||||
# 保存标签
|
||||
@ -1359,7 +1359,7 @@ class SettingEditor(QtWidgets.QWidget):
|
||||
filePath = jsonPathDict[self.currentFileName]
|
||||
self.labelPath.setText(filePath)
|
||||
|
||||
with open(filePath,'rb',encoding='utf8') as f:
|
||||
with open(filePath,'r',encoding='utf8') as f:
|
||||
self.editSetting.clear()
|
||||
|
||||
for line in f:
|
||||
@ -1375,7 +1375,7 @@ class SettingEditor(QtWidgets.QWidget):
|
||||
|
||||
filePath = jsonPathDict[self.currentFileName]
|
||||
|
||||
with open(filePath, 'wb', encoding='utf8') as f:
|
||||
with open(filePath, 'w', encoding='utf8') as f:
|
||||
content = self.editSetting.toPlainText()
|
||||
#content = content.encode('UTF-8')
|
||||
f.write(content)
|
||||
|
@ -208,7 +208,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
|
||||
self.statusLabel.setText(info)
|
||||
if self.connectGatewayDict:
|
||||
s = u','.join(str(e) for e in self.connectGatewayDict.values())
|
||||
s = u','.join(str(e) for e in list(self.connectGatewayDict.values()))
|
||||
|
||||
if not self.connected:
|
||||
s = s + u' [已断开]'
|
||||
@ -218,7 +218,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
# 定时断开
|
||||
if self.connected and self.trade_off() and self.autoDisConnect:
|
||||
self.disconnect()
|
||||
self.mainEngine.writeLog(u'断开连接{0}'.format(self.connectGatewayDict.values()))
|
||||
self.mainEngine.writeLog(u'断开连接{0}'.format(list(self.connectGatewayDict.values())))
|
||||
self.mainEngine.writeLog(u'清空数据引擎')
|
||||
self.mainEngine.clearData()
|
||||
self.mainEngine.writeLog(u'清空委托列表')
|
||||
@ -238,7 +238,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
self.widgetOrderM.clearData()
|
||||
self.mainEngine.writeLog(u'清空交易列表')
|
||||
self.widgetTradeM.clearData()
|
||||
s = u''.join(str(e) for e in self.connectGatewayDict.values())
|
||||
s = u''.join(str(e) for e in list(self.connectGatewayDict.values()))
|
||||
self.mainEngine.writeLog(u'重新连接{0}'.format(s))
|
||||
|
||||
for key in self.connectGatewayDict.keys():
|
||||
@ -423,7 +423,7 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||
QtWidgets.QMessageBox.No, QtWidgets.QMessageBox.No)
|
||||
|
||||
if reply == QtWidgets.QMessageBox.Yes:
|
||||
for widget in self.widgetDict.values():
|
||||
for widget in list(self.widgetDict.values()):
|
||||
widget.close()
|
||||
self.saveWindowSettings('custom')
|
||||
|
||||
|
@ -27,7 +27,7 @@ def createQApp():
|
||||
import qdarkstyle
|
||||
qApp.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
|
||||
except :
|
||||
print( "Unexpected error when import darkStyle:", sys.exc_info()[0])
|
||||
print("Unexpected error when import darkStyle:", sys.exc_info()[0])
|
||||
|
||||
# 设置Windows底部任务栏图标
|
||||
if 'Windows' in platform.uname():
|
||||
|
@ -4,8 +4,8 @@ import subprocess
|
||||
import os
|
||||
import sys
|
||||
import platform
|
||||
base_path = os.path.dirname(os.path.realpath(sys.argv[0]))
|
||||
gpid_file = os.path.abspath(os.path.join(base_path, 'logs','gpid.txt'))
|
||||
|
||||
gpid_file = os.path.abspath(os.path.join(os.path.dirname(__file__), 'logs','gpid.txt'))
|
||||
|
||||
def _check_gpid(gpid):
|
||||
plat = str(platform.system())
|
||||
|
@ -2,8 +2,8 @@
|
||||
|
||||
from collections import OrderedDict
|
||||
|
||||
from vtGateway import *
|
||||
from setup_logger import setup_logger
|
||||
from .vtGateway import *
|
||||
from .setup_logger import setup_logger
|
||||
|
||||
########################################################################
|
||||
class BasicMonitor(object):
|
||||
|
@ -183,10 +183,7 @@ class ClientEngine(object):
|
||||
#----------------------------------------------------------------------
|
||||
def main():
|
||||
"""客户端主程序入口"""
|
||||
# 重载sys模块,设置默认字符串编码方式为utf8
|
||||
reload(sys)
|
||||
sys.setdefaultencoding('utf8')
|
||||
|
||||
|
||||
# 设置Windows底部任务栏图标
|
||||
if 'Windows' in platform.uname() :
|
||||
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID('vn.trader')
|
||||
|
@ -13,6 +13,12 @@ COLOR_RED = u'Red' # 上升K线
|
||||
COLOR_BLUE = u'Blue' # 下降K线
|
||||
COLOR_EQUAL = u'Equal' # 平K线
|
||||
|
||||
# 策略若干判断状态
|
||||
NOTRUN = u'NotRun' # 没有运行;
|
||||
RUNING = u'Runing' # 正常运行;
|
||||
FORCECLOSING = u'ForceClosing' #正在关闭
|
||||
FORCECLOSED = u'ForceClosed' #:已经关闭
|
||||
|
||||
from vnpy.trader.language import constant
|
||||
|
||||
# 将常量定义添加到vtConstant.py的局部字典中
|
||||
|
@ -5,6 +5,7 @@ print( 'load vtEngine.py')
|
||||
import shelve
|
||||
from collections import OrderedDict
|
||||
import os
|
||||
import copy
|
||||
|
||||
from pymongo import MongoClient
|
||||
from pymongo.errors import ConnectionFailure
|
||||
@ -21,9 +22,9 @@ from vnpy.trader.setup_logger import get_logger,setup_logger
|
||||
|
||||
import psutil
|
||||
try:
|
||||
from util_mail import *
|
||||
from .util_mail import *
|
||||
except:
|
||||
pass
|
||||
print('import util_mail fail')
|
||||
|
||||
########################################################################
|
||||
class MainEngine(object):
|
||||
@ -228,6 +229,18 @@ class MainEngine(object):
|
||||
else:
|
||||
return 0, 0, 0, 0
|
||||
|
||||
def qryAccountNo(self,gatewayName):
|
||||
"""
|
||||
根据gateway名称,返回账号
|
||||
:param gatewayName:
|
||||
:return:
|
||||
"""
|
||||
if gatewayName in self.gatewayDict:
|
||||
gateway = self.gatewayDict[gatewayName]
|
||||
if gateway.accountID:
|
||||
return copy.copy(gateway.accountID)
|
||||
|
||||
return gatewayName
|
||||
# ----------------------------------------------------------------------
|
||||
def qryPosition(self, gatewayName):
|
||||
"""查询特定接口的持仓"""
|
||||
|
@ -20,7 +20,7 @@ class VtGateway(object):
|
||||
self.eventEngine = eventEngine
|
||||
self.gatewayName = gatewayName
|
||||
self.logger = None
|
||||
|
||||
self.accountID = 'AccountID'
|
||||
self.createLogger()
|
||||
|
||||
# ----------------------------------------------------------------------
|
||||
@ -87,7 +87,9 @@ class VtGateway(object):
|
||||
event2 = Event(type_=EVENT_ACCOUNT+account.vtAccountID)
|
||||
event2.dict_['data'] = account
|
||||
self.eventEngine.put(event2)
|
||||
|
||||
|
||||
# 更新账号ID
|
||||
self.accountID = account.vtAccountID
|
||||
# ----------------------------------------------------------------------
|
||||
def onError(self, error):
|
||||
"""错误信息推送"""
|
||||
|
@ -7,15 +7,14 @@ print('load vtGlobal.py')
|
||||
import os
|
||||
import traceback
|
||||
import json
|
||||
|
||||
from .vtFunction import getJsonPath
|
||||
globalSetting = {} # 全局配置字典
|
||||
|
||||
settingFileName = "VT_setting.json"
|
||||
path = os.path.abspath(os.path.dirname(__file__))
|
||||
settingFileName = os.path.join(path, settingFileName)
|
||||
settingFilePath = getJsonPath(settingFileName, __file__)
|
||||
|
||||
try:
|
||||
with open(settingFileName,'r',encoding="utf8") as f:
|
||||
with open(settingFilePath,'r',encoding="utf8") as f:
|
||||
globalSetting = json.load(f)
|
||||
except:
|
||||
traceback.print_exc()
|
Loading…
Reference in New Issue
Block a user