This commit is contained in:
vn.py 2017-12-02 22:38:12 +08:00
parent 55b57ca781
commit 05a58c24ba
5 changed files with 33 additions and 3 deletions

View File

@ -62,6 +62,11 @@ class AtrRsiStrategy(CtaTemplate):
'rsiBuy', 'rsiBuy',
'rsiSell'] 'rsiSell']
# 同步列表,保存了需要保存到数据库的变量名称
syncList = ['pos',
'intraTradeHigh',
'intraTradeLow']
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def __init__(self, ctaEngine, setting): def __init__(self, ctaEngine, setting):
"""Constructor""" """Constructor"""
@ -154,7 +159,7 @@ class AtrRsiStrategy(CtaTemplate):
# 计算多头移动止损 # 计算多头移动止损
longStop = self.intraTradeHigh * (1-self.trailingPercent/100) longStop = self.intraTradeHigh * (1-self.trailingPercent/100)
# 发出本地止损委托,并且把委托号记录下来,用于后续撤单 # 发出本地止损委托
self.sell(longStop, abs(self.pos), stop=True) self.sell(longStop, abs(self.pos), stop=True)
# 持有空头仓位 # 持有空头仓位
@ -165,6 +170,9 @@ class AtrRsiStrategy(CtaTemplate):
shortStop = self.intraTradeLow * (1+self.trailingPercent/100) shortStop = self.intraTradeLow * (1+self.trailingPercent/100)
self.cover(shortStop, abs(self.pos), stop=True) self.cover(shortStop, abs(self.pos), stop=True)
# 同步数据到数据库
self.saveSyncData()
# 发出状态更新事件 # 发出状态更新事件
self.putEvent() self.putEvent()

View File

@ -77,6 +77,11 @@ class BollChannelStrategy(CtaTemplate):
'longStop', 'longStop',
'shortStop'] 'shortStop']
# 同步列表,保存了需要保存到数据库的变量名称
syncList = ['pos',
'intraTradeHigh',
'intraTradeLow']
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def __init__(self, ctaEngine, setting): def __init__(self, ctaEngine, setting):
"""Constructor""" """Constructor"""
@ -173,6 +178,9 @@ class BollChannelStrategy(CtaTemplate):
self.cover(self.shortStop, abs(self.pos), True) self.cover(self.shortStop, abs(self.pos), True)
# 同步数据到数据库
self.saveSyncData()
# 发出状态更新事件 # 发出状态更新事件
self.putEvent() self.putEvent()

View File

@ -54,6 +54,9 @@ class DoubleMaStrategy(CtaTemplate):
'slowMa0', 'slowMa0',
'slowMa1'] 'slowMa1']
# 同步列表,保存了需要保存到数据库的变量名称
syncList = ['pos']
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def __init__(self, ctaEngine, setting): def __init__(self, ctaEngine, setting):
"""Constructor""" """Constructor"""

View File

@ -56,6 +56,9 @@ class DualThrustStrategy(CtaTemplate):
'shortEntry', 'shortEntry',
'exitTime'] 'exitTime']
# 同步列表,保存了需要保存到数据库的变量名称
syncList = ['pos']
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def __init__(self, ctaEngine, setting): def __init__(self, ctaEngine, setting):
"""Constructor""" """Constructor"""

View File

@ -57,6 +57,11 @@ class KkStrategy(CtaTemplate):
'kkUp', 'kkUp',
'kkDown'] 'kkDown']
# 同步列表,保存了需要保存到数据库的变量名称
syncList = ['pos',
'intraTradeHigh',
'intraTradeLow']
#---------------------------------------------------------------------- #----------------------------------------------------------------------
def __init__(self, ctaEngine, setting): def __init__(self, ctaEngine, setting):
"""Constructor""" """Constructor"""
@ -146,6 +151,9 @@ class KkStrategy(CtaTemplate):
abs(self.pos), True) abs(self.pos), True)
self.orderList.extend(l) self.orderList.extend(l)
# 同步数据到数据库
self.saveSyncData()
# 发出状态更新事件 # 发出状态更新事件
self.putEvent() self.putEvent()