[Mod]修改WebTrader数据推送细节
This commit is contained in:
parent
6e23c0460b
commit
6798a2234f
@ -596,7 +596,11 @@ api.add_resource(CtaStrategyVar, '/ctastrategy/var')
|
||||
def handleEvent(event):
|
||||
"""处理事件"""
|
||||
eventType = event.type_
|
||||
eventData = event.dict_['data'].__dict__
|
||||
eventData = event.dict_['data']
|
||||
|
||||
if not isinstance(eventData, dict):
|
||||
eventData = eventData.__dict__
|
||||
|
||||
socketio.emit(eventType, eventData)
|
||||
#print eventData
|
||||
|
||||
|
@ -266,6 +266,9 @@ class CtaEngine(object):
|
||||
def processTickEvent(self, event):
|
||||
"""处理行情推送"""
|
||||
tick = event.dict_['data']
|
||||
|
||||
tick = copy(tick)
|
||||
|
||||
# 收到tick行情后,先处理本地停止单(检查是否要立即发出)
|
||||
self.processStopOrder(tick)
|
||||
|
||||
@ -571,8 +574,10 @@ class CtaEngine(object):
|
||||
event.dict_['data'] = d
|
||||
self.eventEngine.put(event)
|
||||
|
||||
d2 = {k:str(v) for k,v in d.items()}
|
||||
d2['name'] = name
|
||||
event2 = Event(EVENT_CTA_STRATEGY)
|
||||
event2.dict_['data'] = d
|
||||
event2.dict_['data'] = d2
|
||||
self.eventEngine.put(event2)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -340,7 +340,7 @@ class BarGenerator(object):
|
||||
"""
|
||||
K线合成器,支持:
|
||||
1. 基于Tick合成1分钟K线
|
||||
2. 基于1分钟K线合成X分钟K线(X可以是2、3、5、10、15、30、60)
|
||||
2. 基于1分钟K线合成X分钟K线(X可以是2、3、5、10、15、30 )
|
||||
"""
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
@ -216,6 +216,8 @@ class MultiSignalStrategy(TargetPosTemplate):
|
||||
self.cciSignal.onTick(tick)
|
||||
self.maSignal.onTick(tick)
|
||||
|
||||
self.calculateTargetPos()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def onBar(self, bar):
|
||||
"""收到Bar推送(必须由用户继承实现)"""
|
||||
@ -225,6 +227,11 @@ class MultiSignalStrategy(TargetPosTemplate):
|
||||
self.cciSignal.onBar(bar)
|
||||
self.maSignal.onBar(bar)
|
||||
|
||||
self.calculateTargetPos()
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
def calculateTargetPos(self):
|
||||
"""计算目标仓位"""
|
||||
self.signalPos['rsi'] = self.rsiSignal.getSignalPos()
|
||||
self.signalPos['cci'] = self.cciSignal.getSignalPos()
|
||||
self.signalPos['ma'] = self.maSignal.getSignalPos()
|
||||
|
@ -100,7 +100,7 @@ class MultiTimeframeStrategy(CtaTemplate):
|
||||
#----------------------------------------------------------------------
|
||||
def onTick(self, tick):
|
||||
"""收到行情TICK推送(必须由用户继承实现)"""
|
||||
# 只需要要在一个BM中合成1分钟K线
|
||||
# 只需要要在一个BarGenerator中合成1分钟K线
|
||||
self.bg5.updateTick(tick)
|
||||
|
||||
#----------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user