Skip to content

Commit

Permalink
修复部分vn.strategy的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
chenxy123 committed May 28, 2015
1 parent d20e89c commit 6e4aa7e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,8 @@ Release/
*.opensdf

# 本地持久化文件
*.vn
*.vn

# word文档
*.doc
*.docx
7 changes: 2 additions & 5 deletions vn.strategy/strategydemo/demoStrategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,14 +234,11 @@ def onBar(self, o, h, l, c, volume, time):
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:' + \
str(self.slowEMA)
self.engine.writeLog(log)

print 'onBar', o, h, l, c, time
print 'fastEMA:', self.fastEMA, '|slowEMA:', self.slowEMA

#----------------------------------------------------------------------
def strToTime(self, t, ms):
"""从字符串时间转化为time格式的时间"""
Expand Down Expand Up @@ -278,7 +275,7 @@ def main():
me.login(userid, password, brokerid, mdAddress, tdAddress)

# 等待10秒钟(初始化合约数据等)
sleep(10)
sleep(5)

# 创建策略引擎对象
se = StrategyEngine(me.ee, me)
Expand Down
6 changes: 1 addition & 5 deletions vn.strategy/strategydemo/strategyEngine.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,8 @@ def __updateOrder(self, event):
#----------------------------------------------------------------------
def __updateTrade(self, event):
"""成交更新"""
print 'updateTrade'
data = event.dict_['data']
orderRef = data['OrderRef']
print 'trade:', orderRef

if orderRef in self.__dictOrderRefStrategy:

Expand Down Expand Up @@ -405,8 +403,6 @@ def sendOrder(self, symbol, direction, offset, price, volume, strategy):
offset)

self.__dictOrderRefStrategy[ref] = strategy
print 'ref:', ref
print 'strategy:', strategy.name

return ref

Expand Down Expand Up @@ -585,7 +581,7 @@ def buy(self, price, volume, stopOrder=False):
return None

#----------------------------------------------------------------------
def cover(self, price, volume, StopOrder=False):
def cover(self, price, volume, stopOrder=False):
"""买入平仓"""
if self.trading:
if stopOrder:
Expand Down

0 comments on commit 6e4aa7e

Please sign in to comment.