Merge remote-tracking branch 'refs/remotes/vnpy/master'
Conflicts: .gitignore vn.trader/CTP_connect.json vn.trader/ContractData.vt vn.trader/LTS_connect.json vn.trader/ctaEngine.py vn.trader/ctaStrategies.py vn.trader/ctaStrategyTemplate.py vn.trader/ctpGateway.py vn.trader/ltsGateway.py vn.trader/uiBasicWidget.py vn.trader/uiCtaWidget.py vn.trader/uiMainWindow.py vn.trader/vtConstant.py vn.trader/vtEngine.py vn.trader/vtGateway.py
This commit is contained in:
commit
83e50ac220
6
.gitignore
vendored
6
.gitignore
vendored
@ -38,12 +38,15 @@ Release/
|
||||
*.dump
|
||||
*.vssettings
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
vnpy.pyproj.user
|
||||
.idea/workspace.xml
|
||||
.idea/.name
|
||||
.idea/vnpy.iml
|
||||
*.xml
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
<<<<<<< HEAD
|
||||
# 不想同步的
|
||||
@ -53,8 +56,11 @@ vn.ctp/build/*
|
||||
vn.lts/build/*
|
||||
.idea
|
||||
>>>>>>> 65aac25731772259bf2d4049e7adbe92750ea01d
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
*.json
|
||||
*.json
|
||||
*.json
|
||||
*.pickle
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
@ -1,6 +1,7 @@
|
||||
{
|
||||
"brokerID": "9999",
|
||||
"tdAddress": "tcp://180.168.146.187:10000",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
"password": "19890624",
|
||||
"mdAddress": "tcp://180.168.212.228:41213",
|
||||
@ -10,4 +11,9 @@
|
||||
"mdAddress": "tcp://180.168.212.228:41213",
|
||||
"userID": "simnow申请"
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
"password": "simnow申请",
|
||||
"mdAddress": "tcp://180.168.212.228:41213",
|
||||
"userID": "simnow申请"
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
"mdAddress": "tcp://211.144.195.163:54513",
|
||||
"productInfo": "LTS-Test",
|
||||
"authCode": "N3EHKP4CYHZGM9VJ",
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
"tdPassword": "150601",
|
||||
"mdPassword": "123",
|
||||
@ -14,4 +15,9 @@
|
||||
"mdPassword": "华宝证券申请",
|
||||
"userID": "华宝证券申请"
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
"tdPassword": "华宝证券申请",
|
||||
"mdPassword": "华宝证券申请",
|
||||
"userID": "华宝证券申请"
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
}
|
@ -7,10 +7,14 @@ from collections import OrderedDict
|
||||
from eventEngine import *
|
||||
from vtConstant import *
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
from vtGateway import VtOrderReq, VtCancelOrderReq
|
||||
=======
|
||||
from vtGateway import VtSubscribeReq, VtOrderReq, VtCancelOrderReq, VtLogData
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
from vtGateway import VtSubscribeReq, VtOrderReq, VtCancelOrderReq, VtLogData
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
from ctaConstant import *
|
||||
from ctaStrategies import strategyClassDict
|
||||
@ -142,6 +146,12 @@ class CtaEngine(object):
|
||||
self.workingStopOrderDict = {} # 停止单撤销后会从本字典中删除
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
# 注册事件监听
|
||||
self.registerEvent()
|
||||
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
# 注册事件监听
|
||||
self.registerEvent()
|
||||
@ -253,9 +263,15 @@ class CtaEngine(object):
|
||||
del self.workingStopOrderDict[so.stopOrderID]
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
def procecssTick(self, tick):
|
||||
"""处理行情推送"""
|
||||
=======
|
||||
def procecssTickEvent(self, event):
|
||||
"""处理行情推送"""
|
||||
tick = event.dict_['data']
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
def procecssTickEvent(self, event):
|
||||
"""处理行情推送"""
|
||||
@ -270,8 +286,13 @@ class CtaEngine(object):
|
||||
ctaTick = CtaTickData()
|
||||
d = ctaTick.__dict__
|
||||
for key in d.keys():
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
d[key] = tick.__getattribute__(key)
|
||||
=======
|
||||
if key != 'datetime':
|
||||
d[key] = tick.__getattribute__(key)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
if key != 'datetime':
|
||||
d[key] = tick.__getattribute__(key)
|
||||
@ -285,28 +306,40 @@ class CtaEngine(object):
|
||||
strategy.onTick(tick)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
def processOrder(self, order):
|
||||
"""处理委托推送"""
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
def processOrderEvent(self, event):
|
||||
"""处理委托推送"""
|
||||
order = event.dict_['data']
|
||||
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
if order.vtOrderID in self.orderStrategyDict:
|
||||
strategy = self.orderStrategyDict[order.vtOrderID]
|
||||
strategy.onOrder(order)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
def processTrade(self, trade):
|
||||
"""处理成交推送"""
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
def processTradeEvent(self, event):
|
||||
"""处理成交推送"""
|
||||
trade = event.dict_['data']
|
||||
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
if trade.vtOrderID in self.orderStrategyDict:
|
||||
strategy = self.orderStrategyDict[order.vtOrderID]
|
||||
@ -315,10 +348,16 @@ class CtaEngine(object):
|
||||
#----------------------------------------------------------------------
|
||||
def registerEvent(self):
|
||||
"""注册事件监听"""
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
self.eventEngine.register(EVENT_TICK, self.procecssTick)
|
||||
self.eventEngine.register(EVENT_ORDER, self.processOrder)
|
||||
self.eventEngine.register(EVENT_TRADE, self.processTrade)
|
||||
=======
|
||||
self.eventEngine.register(EVENT_TICK, self.procecssTickEvent)
|
||||
self.eventEngine.register(EVENT_ORDER, self.processOrderEvent)
|
||||
self.eventEngine.register(EVENT_TRADE, self.processTradeEvent)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
self.eventEngine.register(EVENT_TICK, self.procecssTickEvent)
|
||||
self.eventEngine.register(EVENT_ORDER, self.processOrderEvent)
|
||||
@ -379,9 +418,12 @@ class CtaEngine(object):
|
||||
"""初始化策略"""
|
||||
# 防止策略重名
|
||||
if name not in self.strategyDict:
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
self.strategyDict[name] = strategyClass(self, paramDict) # 创建策略对象
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
# 创建策略对象
|
||||
strategy = strategyClass(self, name, paramDict)
|
||||
self.strategyDict[name] = strategy
|
||||
@ -401,6 +443,9 @@ class CtaEngine(object):
|
||||
req.symbol = contract.symbol
|
||||
req.exchange = contract.exchange
|
||||
self.mainEngine.subscribe(req, contract.gatewayName)
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
else:
|
||||
self.writeCtaLog(u'存在策略对象重名:' + name)
|
||||
@ -472,8 +517,12 @@ class CtaEngine(object):
|
||||
break
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
def getStrategyVarialbe(self, name):
|
||||
=======
|
||||
def getStrategyVar(self, name):
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
def getStrategyVar(self, name):
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
@ -493,8 +542,12 @@ class CtaEngine(object):
|
||||
return None
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
def getStrategyParameter(self, name):
|
||||
=======
|
||||
def getStrategyParam(self, name):
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
def getStrategyParam(self, name):
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
@ -502,6 +555,7 @@ class CtaEngine(object):
|
||||
if name in self.strategyDict:
|
||||
strategy = self.strategyDict[name]
|
||||
d = strategy.__dict__
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
varDict = OrderedDict()
|
||||
|
||||
@ -511,6 +565,8 @@ class CtaEngine(object):
|
||||
|
||||
return varDict
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
paramDict = OrderedDict()
|
||||
|
||||
for key in strategy.paramList:
|
||||
@ -518,6 +574,9 @@ class CtaEngine(object):
|
||||
paramDict[key] = d[key]
|
||||
|
||||
return paramDict
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
else:
|
||||
self.writeCtaLog(u'策略对象不存在:' + name)
|
||||
|
@ -4,6 +4,7 @@
|
||||
在本文件中引入所有希望在系统中使用的策略类
|
||||
'''
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
strategyClassDict = {}
|
||||
=======
|
||||
@ -12,3 +13,9 @@ from ctaStrategyTemplate import TestStrategy
|
||||
strategyClassDict = {}
|
||||
strategyClassDict[u'TestStrategy'] = TestStrategy
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
from ctaStrategyTemplate import TestStrategy
|
||||
|
||||
strategyClassDict = {}
|
||||
strategyClassDict[u'TestStrategy'] = TestStrategy
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
@ -1,6 +1,10 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
from vtConstant import *
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
from vtConstant import *
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
@ -17,6 +21,7 @@ class CtaStrategyTemplate(object):
|
||||
paramList = ['vtSymbol']
|
||||
|
||||
# 变量列表,保存了变量的名称
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
varList = []
|
||||
|
||||
@ -25,6 +30,8 @@ class CtaStrategyTemplate(object):
|
||||
"""Constructor"""
|
||||
self.ctaEngine = ctaEngine
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
varList = ['trading']
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -32,6 +39,9 @@ class CtaStrategyTemplate(object):
|
||||
"""Constructor"""
|
||||
self.ctaEngine = ctaEngine
|
||||
self.name = name
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
self.vtSymbol = EMPTY_STRING # 交易的合约vt系统代码
|
||||
@ -167,8 +177,12 @@ class CtaStrategyTemplate(object):
|
||||
d = self.__dict__
|
||||
for key in self.paramList:
|
||||
if key in setting:
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
d[key] = paramDict[key]
|
||||
=======
|
||||
d[key] = setting[key]
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
d[key] = setting[key]
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
@ -178,8 +192,11 @@ class CtaStrategyTemplate(object):
|
||||
"""查询当前日期"""
|
||||
return self.ctaEngine.getToday()
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
#----------------------------------------------------------------------
|
||||
def writeCtaLog(self, content):
|
||||
"""记录CTA日志"""
|
||||
@ -247,6 +264,9 @@ class TestStrategy(CtaStrategyTemplate):
|
||||
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
|
@ -384,13 +384,19 @@ class CtpMdApi(MdApi):
|
||||
#----------------------------------------------------------------------
|
||||
def subscribe(self, subscribeReq):
|
||||
"""订阅合约"""
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
self.subscribeMarketData(str(subscribeReq.symbol))
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
# 这里的设计是,如果尚未登录就调用了订阅方法
|
||||
# 则先保存订阅请求,登录完成后会自动订阅
|
||||
if self.loginStatus:
|
||||
self.subscribeMarketData(str(subscribeReq.symbol))
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
self.subscribedSymbols.add(subscribeReq)
|
||||
|
||||
|
@ -393,14 +393,20 @@ class LtsMdApi(MdApi):
|
||||
req = {}
|
||||
req['InstrumentID'] = str(subscribeReq.symbol)
|
||||
req['ExchangeID'] = str(subscribeReq.exchange)
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
self.subscribeMarketData(req)
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
# 这里的设计是,如果尚未登录就调用了订阅方法
|
||||
# 则先保存订阅请求,登录完成后会自动订阅
|
||||
if self.loginStatus:
|
||||
self.subscribeMarketData(req)
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
self.subscribedSymbols.add(subscribeReq)
|
||||
@ -573,11 +579,14 @@ class LtsTdApi(TdApi):
|
||||
#----------------------------------------------------------------------
|
||||
def onRtnOrder(self, data):
|
||||
"""报单回报"""
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
print '-'*20
|
||||
for k, v in data.items():
|
||||
print k, ':', v
|
||||
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
# 更新最大报单编号
|
||||
@ -673,11 +682,14 @@ class LtsTdApi(TdApi):
|
||||
#----------------------------------------------------------------------
|
||||
def onErrRtnOrderInsert(self, data, error):
|
||||
"""发单错误回报(交易所)"""
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
print '-'*20
|
||||
for k, v in data.items():
|
||||
print k, ':', v
|
||||
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
err = VtErrorData()
|
||||
|
@ -27,13 +27,19 @@ class BasicCell(QtGui.QTableWidgetItem):
|
||||
#----------------------------------------------------------------------
|
||||
def setContent(self, text):
|
||||
"""设置内容"""
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
self.setText(text)
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
if text == '0' or text == '0.0':
|
||||
self.setText('')
|
||||
else:
|
||||
self.setText(text)
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
|
||||
@ -540,9 +546,12 @@ class TradingWidget(QtGui.QFrame):
|
||||
EXCHANGE_DCE,
|
||||
EXCHANGE_CZCE,
|
||||
EXCHANGE_SSE,
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
EXCHANGE_SZSE]
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
EXCHANGE_SZSE,
|
||||
EXCHANGE_SMART,
|
||||
EXCHANGE_GLOBEX,
|
||||
@ -557,6 +566,9 @@ class TradingWidget(QtGui.QFrame):
|
||||
PRODUCT_OPTION]
|
||||
|
||||
gatewayList = ['']
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -569,6 +581,12 @@ class TradingWidget(QtGui.QFrame):
|
||||
|
||||
self.symbol = ''
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
# 添加交易接口
|
||||
self.gatewayList.extend(mainEngine.gatewayDict.keys())
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
|
||||
# 添加交易接口
|
||||
@ -596,6 +614,12 @@ class TradingWidget(QtGui.QFrame):
|
||||
labelPriceType = QtGui.QLabel(u'价格类型')
|
||||
labelExchange = QtGui.QLabel(u'交易所')
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
labelCurrency = QtGui.QLabel(u'货币')
|
||||
labelProductClass = QtGui.QLabel(u'产品类型')
|
||||
labelGateway = QtGui.QLabel(u'交易接口')
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
labelCurrency = QtGui.QLabel(u'货币')
|
||||
labelProductClass = QtGui.QLabel(u'产品类型')
|
||||
@ -624,9 +648,12 @@ class TradingWidget(QtGui.QFrame):
|
||||
self.comboPriceType.addItems(self.priceTypeList)
|
||||
|
||||
self.comboExchange = QtGui.QComboBox()
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
self.comboExchange.addItems(self.exchangeList)
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
self.comboExchange.addItems(self.exchangeList)
|
||||
|
||||
self.comboCurrency = QtGui.QComboBox()
|
||||
@ -637,6 +664,9 @@ class TradingWidget(QtGui.QFrame):
|
||||
|
||||
self.comboGateway = QtGui.QComboBox()
|
||||
self.comboGateway.addItems(self.gatewayList)
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
gridleft = QtGui.QGridLayout()
|
||||
@ -649,11 +679,17 @@ class TradingWidget(QtGui.QFrame):
|
||||
gridleft.addWidget(labelPriceType, 6, 0)
|
||||
gridleft.addWidget(labelExchange, 7, 0)
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
gridleft.addWidget(labelCurrency, 8, 0)
|
||||
gridleft.addWidget(labelProductClass, 9, 0)
|
||||
gridleft.addWidget(labelGateway, 10, 0)
|
||||
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
gridleft.addWidget(self.lineSymbol, 0, 1)
|
||||
gridleft.addWidget(self.lineName, 1, 1)
|
||||
@ -664,6 +700,12 @@ class TradingWidget(QtGui.QFrame):
|
||||
gridleft.addWidget(self.comboPriceType, 6, 1)
|
||||
gridleft.addWidget(self.comboExchange, 7, 1)
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
gridleft.addWidget(self.comboCurrency, 8, 1)
|
||||
gridleft.addWidget(self.comboProductClass, 9, 1)
|
||||
gridleft.addWidget(self.comboGateway, 10, 1)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
gridleft.addWidget(self.comboCurrency, 8, 1)
|
||||
gridleft.addWidget(self.comboProductClass, 9, 1)
|
||||
@ -778,11 +820,14 @@ class TradingWidget(QtGui.QFrame):
|
||||
#----------------------------------------------------------------------
|
||||
def updateSymbol(self):
|
||||
"""合约变化"""
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
symbol = unicode(self.lineSymbol.text())
|
||||
exchange = unicode(self.comboExchange.currentText())
|
||||
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
# 读取组件数据
|
||||
symbol = unicode(self.lineSymbol.text())
|
||||
exchange = unicode(self.comboExchange.currentText())
|
||||
@ -791,11 +836,15 @@ class TradingWidget(QtGui.QFrame):
|
||||
gatewayName = unicode(self.comboGateway.currentText())
|
||||
|
||||
# 查询合约
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
if exchange:
|
||||
vtSymbol = '.'.join([symbol, exchange])
|
||||
contract = self.dataEngine.getContract(vtSymbol)
|
||||
else:
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
contract = self.dataEngine.getContract(symbol)
|
||||
|
||||
@ -845,6 +894,8 @@ class TradingWidget(QtGui.QFrame):
|
||||
# 更新组件当前交易的合约
|
||||
self.symbol = contract.vtSymbol
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
vtSymbol = symbol
|
||||
contract = self.dataEngine.getContract(symbol)
|
||||
|
||||
@ -896,6 +947,9 @@ class TradingWidget(QtGui.QFrame):
|
||||
|
||||
# 更新组件当前交易的合约
|
||||
self.symbol = vtSymbol
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -931,16 +985,22 @@ class TradingWidget(QtGui.QFrame):
|
||||
self.labelAskVolume5.setText(str(tick.askVolume5))
|
||||
|
||||
self.labelLastPrice.setText(str(tick.lastPrice))
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
rt = (tick.lastPrice/tick.preClosePrice)-1
|
||||
self.labelReturn.setText(('%.2f' %(rt*100))+'%')
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
if tick.preClosePrice:
|
||||
rt = (tick.lastPrice/tick.preClosePrice)-1
|
||||
self.labelReturn.setText(('%.2f' %(rt*100))+'%')
|
||||
else:
|
||||
self.labelReturn.setText('')
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -951,11 +1011,14 @@ class TradingWidget(QtGui.QFrame):
|
||||
#----------------------------------------------------------------------
|
||||
def sendOrder(self):
|
||||
"""发单"""
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
symbol = str(self.lineSymbol.text())
|
||||
exchange = str(self.comboExchange.currentText())
|
||||
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
symbol = unicode(self.lineSymbol.text())
|
||||
exchange = unicode(self.comboExchange.currentText())
|
||||
currency = unicode(self.comboCurrency.currentText())
|
||||
@ -963,11 +1026,15 @@ class TradingWidget(QtGui.QFrame):
|
||||
gatewayName = unicode(self.comboGateway.currentText())
|
||||
|
||||
# 查询合约
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
if exchange:
|
||||
vtSymbol = '.'.join([symbol, exchange])
|
||||
contract = self.dataEngine.getContract(vtSymbol)
|
||||
else:
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
contract = self.dataEngine.getContract(symbol)
|
||||
|
||||
@ -982,6 +1049,8 @@ class TradingWidget(QtGui.QFrame):
|
||||
req.offset = unicode(self.comboOffset.currentText())
|
||||
self.mainEngine.sendOrder(req, contract.gatewayName)
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
vtSymbol = symbol
|
||||
contract = self.dataEngine.getContract(symbol)
|
||||
|
||||
@ -1001,6 +1070,9 @@ class TradingWidget(QtGui.QFrame):
|
||||
req.productClass = productClass
|
||||
|
||||
self.mainEngine.sendOrder(req, gatewayName)
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -2,8 +2,11 @@
|
||||
|
||||
'''CTA模块相关的GUI控制组件'''
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
from uiBasicWidget import QtGui, QtCore, BasicCell
|
||||
from eventEngine import *
|
||||
|
||||
@ -247,5 +250,9 @@ class CtaEngineManager(QtGui.QWidget):
|
||||
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
@ -4,7 +4,11 @@ import psutil
|
||||
|
||||
from uiBasicWidget import *
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
from uiCtaWidget import CtaEngineManager
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
from uiCtaWidget import CtaEngineManager
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
@ -82,6 +86,12 @@ class MainWindow(QtGui.QMainWindow):
|
||||
connectWindAction.triggered.connect(self.connectWind)
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
connectIbAction = QtGui.QAction(u'连接IB', self)
|
||||
connectIbAction.triggered.connect(self.connectIb)
|
||||
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
connectIbAction = QtGui.QAction(u'连接IB', self)
|
||||
connectIbAction.triggered.connect(self.connectIb)
|
||||
@ -100,6 +110,12 @@ class MainWindow(QtGui.QMainWindow):
|
||||
contractAction.triggered.connect(self.openContract)
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
ctaAction = QtGui.QAction(u'CTA策略', self)
|
||||
ctaAction.triggered.connect(self.openCta)
|
||||
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
ctaAction = QtGui.QAction(u'CTA策略', self)
|
||||
ctaAction.triggered.connect(self.openCta)
|
||||
@ -113,6 +129,10 @@ class MainWindow(QtGui.QMainWindow):
|
||||
sysMenu.addAction(connectLtsAction)
|
||||
sysMenu.addAction(connectWindAction)
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
sysMenu.addAction(connectIbAction)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
sysMenu.addAction(connectIbAction)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
@ -122,6 +142,10 @@ class MainWindow(QtGui.QMainWindow):
|
||||
functionMenu = menubar.addMenu(u'功能')
|
||||
functionMenu.addAction(contractAction)
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
functionMenu.addAction(ctaAction)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
functionMenu.addAction(ctaAction)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
@ -174,6 +198,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.mainEngine.connect('Wind')
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
def testSubscribe(self):
|
||||
"""测试订阅"""
|
||||
@ -207,6 +232,8 @@ class MainWindow(QtGui.QMainWindow):
|
||||
req.exchange = EXCHANGE_CZCE
|
||||
self.mainEngine.subscribe(req, 'Wind')
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
def connectIb(self):
|
||||
"""连接Ib"""
|
||||
self.mainEngine.connect('IB')
|
||||
@ -232,6 +259,9 @@ class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
req.symbol = 'GE'
|
||||
self.mainEngine.subscribe(req, 'IB')
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -252,7 +282,10 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.contractM = ContractMonitor(self.mainEngine.dataEngine)
|
||||
self.contractM.show()
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def openCta(self):
|
||||
@ -262,6 +295,9 @@ class MainWindow(QtGui.QMainWindow):
|
||||
except AttributeError:
|
||||
self.ctaM = CtaEngineManager(self.mainEngine.ctaEngine, self.eventEngine)
|
||||
self.ctaM.show()
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -13,6 +13,10 @@ DIRECTION_SHORT = u'空'
|
||||
DIRECTION_UNKNOWN = u'未知'
|
||||
DIRECTION_NET = u'净'
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
DIRECTION_SELL = u'卖出' # IB接口
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
DIRECTION_SELL = u'卖出' # IB接口
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
@ -39,6 +43,10 @@ PRODUCT_OPTION = u'期权'
|
||||
PRODUCT_INDEX = u'指数'
|
||||
PRODUCT_COMBINATION = u'组合'
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
PRODUCT_FOREX = u'外汇'
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
PRODUCT_FOREX = u'外汇'
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
@ -62,9 +70,12 @@ EXCHANGE_SHFE = u'SHFE' # 上期所
|
||||
EXCHANGE_CZCE = u'CZCE' # 郑商所
|
||||
EXCHANGE_DCE = u'DCE' # 大商所
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
EXCHANGE_UNKNOWN = 'UNKNOWN'# 未知交易所
|
||||
EXCHANGE_NONE = '' # 空交易所
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
EXCHANGE_UNKNOWN = 'UNKNOWN'# 未知交易所
|
||||
EXCHANGE_NONE = '' # 空交易所
|
||||
@ -76,5 +87,9 @@ EXCHANGE_IDEALPRO = u'IDEALPRO' # IB外汇ECN
|
||||
# 货币类型
|
||||
CURRENCY_USD = 'USD' # 美元
|
||||
CURRENCY_CNY = 'CNY' # 人民币
|
||||
<<<<<<< HEAD
|
||||
CURRENCY_UNKNOWN = 'UNKNOWN' # 未知货币
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
CURRENCY_UNKNOWN = 'UNKNOWN' # 未知货币
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
@ -2,6 +2,10 @@
|
||||
|
||||
import shelve
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
from collections import OrderedDict
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
from collections import OrderedDict
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
@ -13,15 +17,21 @@ from eventEngine import *
|
||||
from ctpGateway import CtpGateway
|
||||
from ltsGateway import LtsGateway
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
from windGateway import WindGateway
|
||||
from vtGateway import *
|
||||
import uiBasicWidget
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
#from windGateway import WindGateway
|
||||
from ibGateway import IbGateway
|
||||
from vtGateway import *
|
||||
import uiBasicWidget
|
||||
from ctaEngine import CtaEngine
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
|
||||
@ -52,10 +62,13 @@ class MainEngine(object):
|
||||
|
||||
#self.addGateway(WindGateway, 'Wind') # 没有Wind的请注释掉这一行
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
# MongoDB数据库相关
|
||||
self.dbClient = None # MongoDB客户端对象
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
self.addGateway(IbGateway, 'IB')
|
||||
|
||||
# MongoDB数据库相关
|
||||
@ -63,6 +76,9 @@ class MainEngine(object):
|
||||
|
||||
# CTA引擎
|
||||
self.ctaEngine = CtaEngine(self, self.eventEngine, self.dataEngine)
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -79,8 +95,11 @@ class MainEngine(object):
|
||||
else:
|
||||
self.writeLog(u'接口不存在:%s' %gatewayName)
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -396,7 +396,10 @@ class VtOrderReq:
|
||||
self.direction = EMPTY_STRING # 买卖
|
||||
self.offset = EMPTY_STRING # 开平
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
# 以下为IB相关
|
||||
self.productClass = EMPTY_UNICODE # 合约类型
|
||||
@ -404,6 +407,9 @@ class VtOrderReq:
|
||||
self.expiry = EMPTY_STRING # 到期日
|
||||
self.strikePrice = EMPTY_FLOAT # 行权价
|
||||
self.optionType = EMPTY_UNICODE # 期权类型
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user