[bug fix]

This commit is contained in:
msincenselee 2020-02-14 10:06:48 +08:00
parent 895a668eed
commit d70e0ea304
2 changed files with 4 additions and 3 deletions

View File

@ -81,7 +81,7 @@ class CtaGrid(object):
j = OrderedDict() j = OrderedDict()
j['id'] = self.id j['id'] = self.id
j['direction'] = self.direction j['direction'] = self.direction.value if self.direction else ''
j['open_price'] = self.open_price # 开仓价格 j['open_price'] = self.open_price # 开仓价格
j['close_price'] = self.close_price # 平仓价格 j['close_price'] = self.close_price # 平仓价格
j['stop_price'] = self.stop_price # 止损价格 j['stop_price'] = self.stop_price # 止损价格
@ -107,7 +107,8 @@ class CtaGrid(object):
"""从JSON恢复""" """从JSON恢复"""
try: try:
self.id = j.get('id', str(uuid.uuid1())) 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.close_price = j.get('close_price', 0)
self.open_price = j.get('open_price', 0) self.open_price = j.get('open_price', 0)
self.stop_price = j.get('stop_price', 0) self.stop_price = j.get('stop_price', 0)

View File

@ -759,7 +759,7 @@ class CtaProTemplate(CtaTemplate):
if self.position.long_pos > 0: if self.position.long_pos > 0:
for g in self.gt.get_opened_grids(direction=Direction.LONG): for g in self.gt.get_opened_grids(direction=Direction.LONG):
vt_symbol = g.snapshot.get('mi_symbol', self.vt_symbol) 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, pos_list.append({'vt_symbol': vt_symbol,
'direction': 'long', 'direction': 'long',
'volume': g.volume - g.traded_volume, 'volume': g.volume - g.traded_volume,