[Mod]修改WebTrader数据推送细节

This commit is contained in:
vn.py 2018-02-08 12:35:28 +08:00
parent 6e23c0460b
commit 6798a2234f
5 changed files with 20 additions and 4 deletions

View File

@ -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

View File

@ -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)
#----------------------------------------------------------------------

View File

@ -340,7 +340,7 @@ class BarGenerator(object):
"""
K线合成器支持
1. 基于Tick合成1分钟K线
2. 基于1分钟K线合成X分钟K线X可以是23510153060
2. 基于1分钟K线合成X分钟K线X可以是235101530
"""
#----------------------------------------------------------------------

View File

@ -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()

View File

@ -100,7 +100,7 @@ class MultiTimeframeStrategy(CtaTemplate):
#----------------------------------------------------------------------
def onTick(self, tick):
"""收到行情TICK推送必须由用户继承实现"""
# 只需要要在一个BM中合成1分钟K线
# 只需要要在一个BarGenerator中合成1分钟K线
self.bg5.updateTick(tick)
#----------------------------------------------------------------------