修复部分vn.strategy的bug

This commit is contained in:
WOLF 2015-05-28 10:09:59 +08:00
parent d20e89c2eb
commit 6e4aa7eb8c
3 changed files with 8 additions and 11 deletions

6
.gitignore vendored
View File

@ -28,4 +28,8 @@ Release/
*.opensdf *.opensdf
# 本地持久化文件 # 本地持久化文件
*.vn *.vn
# word文档
*.doc
*.docx

View File

@ -234,14 +234,11 @@ class SimpleEmaStrategy(StrategyTemplate):
self.short(self.currentTick.lowerLimit, 1) self.short(self.currentTick.lowerLimit, 1)
# 记录日志 # 记录日志
log = self.name + u'当前时间:' + str(time) + \ log = self.name + u'K线时间:' + str(time) + '\n' + \
u'快速EMA' + str(self.fastEMA) + u'慢速EMA' + \ u'快速EMA' + str(self.fastEMA) + u'慢速EMA' + \
str(self.slowEMA) str(self.slowEMA)
self.engine.writeLog(log) self.engine.writeLog(log)
print 'onBar', o, h, l, c, time
print 'fastEMA:', self.fastEMA, '|slowEMA:', self.slowEMA
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def strToTime(self, t, ms): def strToTime(self, t, ms):
"""从字符串时间转化为time格式的时间""" """从字符串时间转化为time格式的时间"""
@ -278,7 +275,7 @@ def main():
me.login(userid, password, brokerid, mdAddress, tdAddress) me.login(userid, password, brokerid, mdAddress, tdAddress)
# 等待10秒钟初始化合约数据等 # 等待10秒钟初始化合约数据等
sleep(10) sleep(5)
# 创建策略引擎对象 # 创建策略引擎对象
se = StrategyEngine(me.ee, me) se = StrategyEngine(me.ee, me)

View File

@ -360,10 +360,8 @@ class StrategyEngine(object):
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def __updateTrade(self, event): def __updateTrade(self, event):
"""成交更新""" """成交更新"""
print 'updateTrade'
data = event.dict_['data'] data = event.dict_['data']
orderRef = data['OrderRef'] orderRef = data['OrderRef']
print 'trade:', orderRef
if orderRef in self.__dictOrderRefStrategy: if orderRef in self.__dictOrderRefStrategy:
@ -405,8 +403,6 @@ class StrategyEngine(object):
offset) offset)
self.__dictOrderRefStrategy[ref] = strategy self.__dictOrderRefStrategy[ref] = strategy
print 'ref:', ref
print 'strategy:', strategy.name
return ref return ref
@ -585,7 +581,7 @@ class StrategyTemplate(object):
return None return None
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def cover(self, price, volume, StopOrder=False): def cover(self, price, volume, stopOrder=False):
"""买入平仓""" """买入平仓"""
if self.trading: if self.trading:
if stopOrder: if stopOrder: