From d70e0ea304f89ebd9e210235ee6f04ff9b0fb8bc Mon Sep 17 00:00:00 2001 From: msincenselee Date: Fri, 14 Feb 2020 10:06:48 +0800 Subject: [PATCH] [bug fix] --- vnpy/app/cta_strategy_pro/cta_grid_trade.py | 5 +++-- vnpy/app/cta_strategy_pro/template.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/vnpy/app/cta_strategy_pro/cta_grid_trade.py b/vnpy/app/cta_strategy_pro/cta_grid_trade.py index 71bc9a7e..f8d890e2 100644 --- a/vnpy/app/cta_strategy_pro/cta_grid_trade.py +++ b/vnpy/app/cta_strategy_pro/cta_grid_trade.py @@ -81,7 +81,7 @@ class CtaGrid(object): j = OrderedDict() j['id'] = self.id - j['direction'] = self.direction + j['direction'] = self.direction.value if self.direction else '' j['open_price'] = self.open_price # 开仓价格 j['close_price'] = self.close_price # 平仓价格 j['stop_price'] = self.stop_price # 止损价格 @@ -107,7 +107,8 @@ class CtaGrid(object): """从JSON恢复""" try: self.id = j.get('id', str(uuid.uuid1())) - self.direction = j.get('direction', Direction.NET) + s = j.get('direction', '') + self.direction = Direction(s) if len(s) > 0 else None self.close_price = j.get('close_price', 0) self.open_price = j.get('open_price', 0) self.stop_price = j.get('stop_price', 0) diff --git a/vnpy/app/cta_strategy_pro/template.py b/vnpy/app/cta_strategy_pro/template.py index 6baf7eed..f1731777 100644 --- a/vnpy/app/cta_strategy_pro/template.py +++ b/vnpy/app/cta_strategy_pro/template.py @@ -759,7 +759,7 @@ class CtaProTemplate(CtaTemplate): if self.position.long_pos > 0: for g in self.gt.get_opened_grids(direction=Direction.LONG): vt_symbol = g.snapshot.get('mi_symbol', self.vt_symbol) - open_price = g.snapshot.get('open_price', g.openPrice) + open_price = g.snapshot.get('open_price', g.open_price) pos_list.append({'vt_symbol': vt_symbol, 'direction': 'long', 'volume': g.volume - g.traded_volume,