From 2f3f65c694aee146807f3d108f630778fac6cf5c Mon Sep 17 00:00:00 2001 From: msincenselee Date: Mon, 2 Mar 2020 18:05:08 +0800 Subject: [PATCH] =?UTF-8?q?[bug=20fix]=20=E4=BF=AE=E5=A4=8D=E5=A4=9A?= =?UTF-8?q?=E4=B8=AA=E5=AE=9E=E4=BE=8Bklines=E5=BD=B1=E5=93=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vnpy/app/cta_strategy_pro/template.py | 30 ++++++++++++++------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/vnpy/app/cta_strategy_pro/template.py b/vnpy/app/cta_strategy_pro/template.py index 41609904..bd096c84 100644 --- a/vnpy/app/cta_strategy_pro/template.py +++ b/vnpy/app/cta_strategy_pro/template.py @@ -566,14 +566,7 @@ class CtaProTemplate(CtaTemplate): symbol_size = 10 # 商品得合约乘数 margin_rate = 0.1 # 商品的保证金 - cur_datetime = None # 当前Tick时间 - cur_mi_tick = None # 最新的主力合约tick( vt_symbol) - cur_99_tick = None # 最新得指数合约tick( idx_symbol) - - cur_mi_price = None # 当前价(主力合约 vt_symbol) - cur_99_price = None # 当前价(tick时,根据tick更新,onBar回测时,根据bar.close更新) - - last_minute = None # 最后的分钟,用于on_tick内每分钟处理的逻辑 + # 委托类型 order_type = OrderType.LIMIT cancel_seconds = 120 # 撤单时间(秒) @@ -582,12 +575,7 @@ class CtaProTemplate(CtaTemplate): max_invest_margin = 0 # 资金上限 0,不限制 max_invest_pos = 0 # 单向头寸数量上限 0,不限制 - position = None # 仓位组件 - policy = None # 事务执行组件 - gt = None # 网格交易组件 - - klines = {} # K线字典: kline_name: kline - + # 是否回测状态 backtesting = False # 逻辑过程日志 @@ -597,6 +585,20 @@ class CtaProTemplate(CtaTemplate): def __init__(self, cta_engine, strategy_name, vt_symbol, setting): """""" + self.position = None # 仓位组件 + self.policy = None # 事务执行组件 + self.gt = None # 网格交易组件 + self.klines = {} # K线组件字典: kline_name: kline + + self.cur_datetime = None # 当前Tick时间 + self.cur_mi_tick = None # 最新的主力合约tick( vt_symbol) + self.cur_99_tick = None # 最新得指数合约tick( idx_symbol) + + self.cur_mi_price = None # 当前价(主力合约 vt_symbol) + self.cur_99_price = None # 当前价(tick时,根据tick更新,onBar回测时,根据bar.close更新) + + self.last_minute = None # 最后的分钟,用于on_tick内每分钟处理的逻辑 + super(CtaProTemplate, self).__init__( cta_engine, strategy_name, vt_symbol, setting )