Merge pull request #1530 from 1122455801/Fix_AtrRsi
[FIX] 修改Boll_Channel, Double_ma, Dual_thrust策略代码风格
This commit is contained in:
commit
b5fda56f55
@ -13,7 +13,7 @@ from vnpy.app.cta_strategy import (
|
||||
class BollChannelStrategy(CtaTemplate):
|
||||
""""""
|
||||
|
||||
author = '用Python的交易员'
|
||||
author = "用Python的交易员"
|
||||
|
||||
boll_window = 18
|
||||
boll_dev = 3.4
|
||||
@ -32,10 +32,10 @@ class BollChannelStrategy(CtaTemplate):
|
||||
long_stop = 0
|
||||
short_stop = 0
|
||||
|
||||
parameters = ['boll_window', 'boll_dev', 'cci_window',
|
||||
'atr_window', 'sl_multiplier', 'fixed_size']
|
||||
variables = ['boll_up', 'boll_down', 'cci_value', 'atr_value',
|
||||
'intra_trade_high', 'intra_trade_low', 'long_stop', 'short_stop']
|
||||
parameters = ["boll_window", "boll_dev", "cci_window",
|
||||
"atr_window", "sl_multiplier", "fixed_size"]
|
||||
variables = ["boll_up", "boll_down", "cci_value", "atr_value",
|
||||
"intra_trade_high", "intra_trade_low", "long_stop", "short_stop"]
|
||||
|
||||
def __init__(self, cta_engine, strategy_name, vt_symbol, setting):
|
||||
""""""
|
||||
|
@ -11,7 +11,7 @@ from vnpy.app.cta_strategy import (
|
||||
|
||||
|
||||
class DoubleMaStrategy(CtaTemplate):
|
||||
author = '用Python的交易员'
|
||||
author = "用Python的交易员"
|
||||
|
||||
fast_window = 10
|
||||
slow_window = 20
|
||||
@ -22,8 +22,8 @@ class DoubleMaStrategy(CtaTemplate):
|
||||
slow_ma0 = 0.0
|
||||
slow_ma1 = 0.0
|
||||
|
||||
parameters = ['fast_window', 'slow_window']
|
||||
variables = ['fast_ma0', 'fast_ma1', 'slow_ma0', 'slow_ma1']
|
||||
parameters = ["fast_window", "slow_window"]
|
||||
variables = ["fast_ma0", "fast_ma1", "slow_ma0", "slow_ma1"]
|
||||
|
||||
def __init__(self, cta_engine, strategy_name, vt_symbol, setting):
|
||||
""""""
|
||||
|
@ -14,13 +14,13 @@ from vnpy.app.cta_strategy import (
|
||||
class DualThrustStrategy(CtaTemplate):
|
||||
""""""
|
||||
|
||||
author = u'用Python的交易员'
|
||||
author = "用Python的交易员"
|
||||
|
||||
fixed_size = 1
|
||||
k1 = 0.4
|
||||
k2 = 0.6
|
||||
|
||||
barList = []
|
||||
bars = []
|
||||
|
||||
day_open = 0
|
||||
day_high = 0
|
||||
@ -34,8 +34,8 @@ class DualThrustStrategy(CtaTemplate):
|
||||
long_entered = False
|
||||
short_entered = False
|
||||
|
||||
parameters = ['k1', 'k2', "fixed_size"]
|
||||
variables = ['range', 'long_entry', 'short_entry', 'exit_time']
|
||||
parameters = ["k1", "k2", "fixed_size"]
|
||||
variables = ["range", "long_entry", "short_entry", "exit_time"]
|
||||
|
||||
def __init__(self, cta_engine, strategy_name, vt_symbol, setting):
|
||||
""""""
|
||||
@ -45,7 +45,7 @@ class DualThrustStrategy(CtaTemplate):
|
||||
|
||||
self.bg = BarGenerator(self.on_bar)
|
||||
self.am = ArrayManager()
|
||||
self.barList = []
|
||||
self.bars = []
|
||||
|
||||
def on_init(self):
|
||||
"""
|
||||
@ -78,12 +78,12 @@ class DualThrustStrategy(CtaTemplate):
|
||||
"""
|
||||
self.cancel_all()
|
||||
|
||||
self.barList.append(bar)
|
||||
if len(self.barList) <= 2:
|
||||
self.bars.append(bar)
|
||||
if len(self.bars) <= 2:
|
||||
return
|
||||
else:
|
||||
self.barList.pop(0)
|
||||
last_bar = self.barList[-2]
|
||||
self.bars.pop(0)
|
||||
last_bar = self.bars[-2]
|
||||
|
||||
if last_bar.datetime.date() != bar.datetime.date():
|
||||
if self.day_high:
|
||||
|
Loading…
Reference in New Issue
Block a user