merge
This commit is contained in:
parent
d7c225e9fe
commit
a1050d84f6
Binary file not shown.
@ -6,15 +6,8 @@ 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
|
||||
@ -145,18 +138,10 @@ class CtaEngine(object):
|
||||
self.stopOrderDict = {} # 停止单撤销后不会从本字典中删除
|
||||
self.workingStopOrderDict = {} # 停止单撤销后会从本字典中删除
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
# 注册事件监听
|
||||
self.registerEvent()
|
||||
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
# 注册事件监听
|
||||
self.registerEvent()
|
||||
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def sendOrder(self, vtSymbol, orderType, price, volume, strategy):
|
||||
"""发单"""
|
||||
@ -263,20 +248,11 @@ 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):
|
||||
"""处理行情推送"""
|
||||
tick = event.dict_['data']
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
# 收到tick行情后,先处理本地停止单(检查是否要立即发出)
|
||||
self.processStopOrder(tick)
|
||||
|
||||
@ -286,17 +262,10 @@ 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)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
# 添加datetime字段
|
||||
ctaTick.datetime = datetime.strptime(' '.join([tick.date, tick.time]), '%Y%m%d %H:%M:%S.%f')
|
||||
|
||||
@ -306,41 +275,23 @@ 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]
|
||||
strategy.onTrade(trade)
|
||||
@ -348,22 +299,11 @@ 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)
|
||||
self.eventEngine.register(EVENT_TRADE, self.processTradeEvent)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def insertData(self, dbName, collectionName, data):
|
||||
"""插入数据到数据库(这里的data可以是CtaTickData或者CtaBarData)"""
|
||||
@ -418,12 +358,7 @@ 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
|
||||
@ -443,10 +378,7 @@ 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)
|
||||
|
||||
@ -517,15 +449,8 @@ 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
|
||||
|
||||
"""获取策略当前的变量字典"""
|
||||
if name in self.strategyDict:
|
||||
strategy = self.strategyDict[name]
|
||||
@ -542,31 +467,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
|
||||
"""获取策略的参数字典"""
|
||||
if name in self.strategyDict:
|
||||
strategy = self.strategyDict[name]
|
||||
d = strategy.__dict__
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
varDict = OrderedDict()
|
||||
|
||||
for key in strategy.paramList:
|
||||
if key in d:
|
||||
varDict[key] = d[key]
|
||||
|
||||
return varDict
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
paramDict = OrderedDict()
|
||||
|
||||
for key in strategy.paramList:
|
||||
@ -574,10 +480,7 @@ class CtaEngine(object):
|
||||
paramDict[key] = d[key]
|
||||
|
||||
return paramDict
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
else:
|
||||
self.writeCtaLog(u'策略对象不存在:' + name)
|
||||
return None
|
||||
|
@ -4,18 +4,7 @@
|
||||
在本文件中引入所有希望在系统中使用的策略类
|
||||
'''
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
strategyClassDict = {}
|
||||
=======
|
||||
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,13 +1,7 @@
|
||||
# encoding: UTF-8
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
from vtConstant import *
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
from vtConstant import *
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
from ctaConstant import *
|
||||
|
||||
|
||||
@ -21,17 +15,7 @@ class CtaStrategyTemplate(object):
|
||||
paramList = ['vtSymbol']
|
||||
|
||||
# 变量列表,保存了变量的名称
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
varList = []
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __init__(self, ctaEngine, setting=None):
|
||||
"""Constructor"""
|
||||
self.ctaEngine = ctaEngine
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
varList = ['trading']
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
@ -39,11 +23,7 @@ class CtaStrategyTemplate(object):
|
||||
"""Constructor"""
|
||||
self.ctaEngine = ctaEngine
|
||||
self.name = name
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
|
||||
self.vtSymbol = EMPTY_STRING # 交易的合约vt系统代码
|
||||
|
||||
self.tickDbName = EMPTY_STRING # tick数据库名称
|
||||
@ -177,26 +157,15 @@ 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
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def getToday(self):
|
||||
"""查询当前日期"""
|
||||
return self.ctaEngine.getToday()
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def writeCtaLog(self, content):
|
||||
"""记录CTA日志"""
|
||||
@ -264,9 +233,3 @@ class TestStrategy(CtaStrategyTemplate):
|
||||
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
|
@ -27,20 +27,11 @@ 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
|
||||
|
||||
|
||||
########################################################################
|
||||
@ -546,12 +537,6 @@ class TradingWidget(QtGui.QFrame):
|
||||
EXCHANGE_DCE,
|
||||
EXCHANGE_CZCE,
|
||||
EXCHANGE_SSE,
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
EXCHANGE_SZSE]
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
EXCHANGE_SZSE,
|
||||
EXCHANGE_SMART,
|
||||
EXCHANGE_GLOBEX,
|
||||
@ -566,10 +551,6 @@ class TradingWidget(QtGui.QFrame):
|
||||
PRODUCT_OPTION]
|
||||
|
||||
gatewayList = ['']
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def __init__(self, mainEngine, eventEngine, dataEngine, parent=None):
|
||||
@ -580,18 +561,9 @@ class TradingWidget(QtGui.QFrame):
|
||||
self.dataEngine = dataEngine
|
||||
|
||||
self.symbol = ''
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
|
||||
# 添加交易接口
|
||||
self.gatewayList.extend(mainEngine.gatewayDict.keys())
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
|
||||
# 添加交易接口
|
||||
self.gatewayList.extend(mainEngine.gatewayDict.keys())
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
self.initUi()
|
||||
self.connectSignal()
|
||||
@ -613,18 +585,10 @@ class TradingWidget(QtGui.QFrame):
|
||||
labelVolume = QtGui.QLabel(u'数量')
|
||||
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'产品类型')
|
||||
labelGateway = QtGui.QLabel(u'交易接口')
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
self.lineSymbol = QtGui.QLineEdit()
|
||||
self.lineName = QtGui.QLineEdit()
|
||||
@ -648,12 +612,7 @@ 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()
|
||||
@ -664,10 +623,6 @@ 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()
|
||||
gridleft.addWidget(labelSymbol, 0, 0)
|
||||
@ -678,19 +633,12 @@ class TradingWidget(QtGui.QFrame):
|
||||
gridleft.addWidget(labelVolume, 5, 0)
|
||||
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)
|
||||
gridleft.addWidget(self.comboDirection, 2, 1)
|
||||
@ -699,18 +647,9 @@ class TradingWidget(QtGui.QFrame):
|
||||
gridleft.addWidget(self.spinVolume, 5, 1)
|
||||
gridleft.addWidget(self.comboPriceType, 6, 1)
|
||||
gridleft.addWidget(self.comboExchange, 7, 1)
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
gridleft.addWidget(self.comboCurrency, 8, 1)
|
||||
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)
|
||||
gridleft.addWidget(self.comboGateway, 10, 1)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
# 右边部分
|
||||
labelBid1 = QtGui.QLabel(u'买一')
|
||||
@ -820,14 +759,7 @@ 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())
|
||||
@ -836,16 +768,12 @@ 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)
|
||||
|
||||
if contract:
|
||||
@ -893,9 +821,7 @@ class TradingWidget(QtGui.QFrame):
|
||||
|
||||
# 更新组件当前交易的合约
|
||||
self.symbol = contract.vtSymbol
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
vtSymbol = symbol
|
||||
contract = self.dataEngine.getContract(symbol)
|
||||
|
||||
@ -947,10 +873,6 @@ class TradingWidget(QtGui.QFrame):
|
||||
|
||||
# 更新组件当前交易的合约
|
||||
self.symbol = vtSymbol
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def updateTick(self, event):
|
||||
@ -985,23 +907,12 @@ 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
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def connectSignal(self):
|
||||
@ -1011,14 +922,7 @@ 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())
|
||||
@ -1026,31 +930,10 @@ 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)
|
||||
|
||||
if contract:
|
||||
req = VtOrderReq()
|
||||
req.symbol = symbol
|
||||
req.exchange = contract.exchange
|
||||
req.price = self.spinPrice.value()
|
||||
req.volume = self.spinVolume.value()
|
||||
req.direction = unicode(self.comboDirection.currentText())
|
||||
req.priceType = unicode(self.comboPriceType.currentText())
|
||||
req.offset = unicode(self.comboOffset.currentText())
|
||||
self.mainEngine.sendOrder(req, contract.gatewayName)
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
vtSymbol = symbol
|
||||
contract = self.dataEngine.getContract(symbol)
|
||||
|
||||
@ -1070,11 +953,7 @@ class TradingWidget(QtGui.QFrame):
|
||||
req.productClass = productClass
|
||||
|
||||
self.mainEngine.sendOrder(req, gatewayName)
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def cancelAll(self):
|
||||
"""一键撤销所有委托"""
|
||||
|
@ -2,11 +2,7 @@
|
||||
|
||||
'''CTA模块相关的GUI控制组件'''
|
||||
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
from uiBasicWidget import QtGui, QtCore, BasicCell
|
||||
from eventEngine import *
|
||||
|
||||
@ -241,18 +237,3 @@ class CtaEngineManager(QtGui.QWidget):
|
||||
self.signal.connect(self.updateCtaLog)
|
||||
self.eventEngine.register(EVENT_CTA_LOG, self.signal.emit)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<<<<<<< HEAD
|
||||
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
@ -3,15 +3,8 @@
|
||||
import psutil
|
||||
|
||||
from uiBasicWidget import *
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
|
||||
=======
|
||||
from uiCtaWidget import CtaEngineManager
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
from uiCtaWidget import CtaEngineManager
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
########################################################################
|
||||
class MainWindow(QtGui.QMainWindow):
|
||||
@ -85,18 +78,11 @@ class MainWindow(QtGui.QMainWindow):
|
||||
connectWindAction = QtGui.QAction(u'连接Wind', self)
|
||||
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)
|
||||
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
testAction = QtGui.QAction(u'测试', self)
|
||||
testAction.triggered.connect(self.testSubscribe)
|
||||
|
||||
@ -109,18 +95,11 @@ class MainWindow(QtGui.QMainWindow):
|
||||
contractAction = QtGui.QAction(u'查询合约', self)
|
||||
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)
|
||||
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
# 创建菜单
|
||||
menubar = self.menuBar()
|
||||
|
||||
@ -128,28 +107,17 @@ class MainWindow(QtGui.QMainWindow):
|
||||
sysMenu.addAction(connectCtpAction)
|
||||
sysMenu.addAction(connectLtsAction)
|
||||
sysMenu.addAction(connectWindAction)
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
sysMenu.addAction(connectIbAction)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
sysMenu.addAction(connectIbAction)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
sysMenu.addAction(testAction)
|
||||
sysMenu.addAction(exitAction)
|
||||
|
||||
functionMenu = menubar.addMenu(u'功能')
|
||||
functionMenu.addAction(contractAction)
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
|
||||
functionMenu.addAction(ctaAction)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
functionMenu.addAction(ctaAction)
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
|
||||
helpMenu = menubar.addMenu(u'帮助')
|
||||
helpMenu.addAction(aboutAction)
|
||||
|
||||
@ -198,42 +166,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
self.mainEngine.connect('Wind')
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
def testSubscribe(self):
|
||||
"""测试订阅"""
|
||||
req = VtSubscribeReq()
|
||||
req.symbol = '600000'
|
||||
req.exchange = EXCHANGE_SSE
|
||||
self.mainEngine.subscribe(req, 'Wind')
|
||||
|
||||
req = VtSubscribeReq()
|
||||
req.symbol = '000062'
|
||||
req.exchange = EXCHANGE_SZSE
|
||||
self.mainEngine.subscribe(req, 'Wind')
|
||||
|
||||
req = VtSubscribeReq()
|
||||
req.symbol = 'IF1511'
|
||||
req.exchange = EXCHANGE_CFFEX
|
||||
self.mainEngine.subscribe(req, 'Wind')
|
||||
|
||||
req = VtSubscribeReq()
|
||||
req.symbol = 'CU1601'
|
||||
req.exchange = EXCHANGE_SHFE
|
||||
self.mainEngine.subscribe(req, 'Wind')
|
||||
|
||||
req = VtSubscribeReq()
|
||||
req.symbol = 'C1601'
|
||||
req.exchange = EXCHANGE_DCE
|
||||
self.mainEngine.subscribe(req, 'Wind')
|
||||
|
||||
req = VtSubscribeReq()
|
||||
req.symbol = 'SR1601'
|
||||
req.exchange = EXCHANGE_CZCE
|
||||
self.mainEngine.subscribe(req, 'Wind')
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
def connectIb(self):
|
||||
"""连接Ib"""
|
||||
self.mainEngine.connect('IB')
|
||||
@ -259,11 +192,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
|
||||
req.symbol = 'GE'
|
||||
self.mainEngine.subscribe(req, 'IB')
|
||||
<<<<<<< HEAD
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def openAbout(self):
|
||||
"""打开关于"""
|
||||
@ -281,11 +210,7 @@ class MainWindow(QtGui.QMainWindow):
|
||||
except AttributeError:
|
||||
self.contractM = ContractMonitor(self.mainEngine.dataEngine)
|
||||
self.contractM.show()
|
||||
<<<<<<< HEAD
|
||||
<<<<<<< HEAD
|
||||
=======
|
||||
=======
|
||||
>>>>>>> refs/remotes/vnpy/master
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def openCta(self):
|
||||
@ -295,11 +220,8 @@ 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
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def closeEvent(self, event):
|
||||
"""关闭事件"""
|
||||
|
Loading…
Reference in New Issue
Block a user