fix 返回值key不正确
This commit is contained in:
parent
cc85330f29
commit
57c8615faa
@ -15,6 +15,7 @@ import json
|
|||||||
import atexit
|
import atexit
|
||||||
from simulation_trader import SimulationTrader
|
from simulation_trader import SimulationTrader
|
||||||
import datetime
|
import datetime
|
||||||
|
from xtquant import xtconstant
|
||||||
|
|
||||||
# 策略仓位管理
|
# 策略仓位管理
|
||||||
strategy_positions = {} # 存储各策略持仓
|
strategy_positions = {} # 存储各策略持仓
|
||||||
@ -186,11 +187,11 @@ def update_pending_orders():
|
|||||||
|
|
||||||
# 更新委托状态
|
# 更新委托状态
|
||||||
for order_id, order_info in list(pending_orders.items()):
|
for order_id, order_info in list(pending_orders.items()):
|
||||||
entrust = next((e for e in today_entrusts if e.get('委托编号') == order_id), None)
|
entrust = next((e for e in today_entrusts if e.get('order_id') == order_id), None)
|
||||||
if entrust:
|
if entrust:
|
||||||
if entrust.get('状态') in ['已成', '部分成交']:
|
if entrust.get('order_status') in [xtconstant.ORDER_SUCCEEDED, xtconstant.ORDER_PART_SUCC]:
|
||||||
# 成交量计算
|
# 成交量计算
|
||||||
traded_amount = int(entrust.get('成交数量', 0))
|
traded_amount = int(entrust.get('traded_volume', 0))
|
||||||
|
|
||||||
# 更新策略持仓
|
# 更新策略持仓
|
||||||
update_strategy_position(
|
update_strategy_position(
|
||||||
@ -201,11 +202,11 @@ def update_pending_orders():
|
|||||||
)
|
)
|
||||||
|
|
||||||
# 如果完全成交,从待处理列表中移除
|
# 如果完全成交,从待处理列表中移除
|
||||||
if entrust.get('状态') == '已成':
|
if entrust.get('order_status') == xtconstant.ORDER_SUCCEEDED:
|
||||||
del pending_orders[order_id]
|
del pending_orders[order_id]
|
||||||
|
|
||||||
# 如果已撤单、废单等终态,也从待处理列表中移除
|
# 如果已撤单、废单等终态,也从待处理列表中移除
|
||||||
elif entrust.get('状态') in ['已撤', '废单']:
|
elif entrust.get('order_status') in [xtconstant.ORDER_CANCELED, xtconstant.ORDER_JUNK]:
|
||||||
del pending_orders[order_id]
|
del pending_orders[order_id]
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.error(f"更新未完成委托状态失败: {str(e)}")
|
logger.error(f"更新未完成委托状态失败: {str(e)}")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user