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

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

View File

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

View File

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

View File

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

View File

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