add get_trade

This commit is contained in:
zhiyong 2025-05-16 15:29:38 +08:00
parent c57c96fe64
commit 90ae3f286b

View File

@ -231,6 +231,7 @@ class XtTrader(BaseTrader):
"stock_name": self.get_stock_name(t.stock_code),
"order_id": t.order_id,
"traded_id": t.traded_id,
"order_sysid": t.order_sysid,
"traded_time": t.traded_time,
"traded_price": t.traded_price,
"traded_volume": t.traded_volume,
@ -240,6 +241,15 @@ class XtTrader(BaseTrader):
]
return []
def get_trade(self, order_sysid):
trades = self.get_today_trades()
for t in trades:
if t['order_sysid'] == order_sysid:
return t
return None
def get_today_orders(self):
if not self.is_available():
return []
@ -251,6 +261,7 @@ class XtTrader(BaseTrader):
"account_id": o.account_id,
"stock_code": o.stock_code,
"order_id": o.order_id,
"order_sysid": o.order_sysid,
"order_time": o.order_time,
"order_type": "buy" if o.order_type == xtconstant.STOCK_BUY else "sell",
"order_volume": o.order_volume,
@ -274,6 +285,7 @@ class XtTrader(BaseTrader):
"account_id": order.account_id,
"stock_code": order.stock_code,
"order_id": order.order_id,
"order_sysid": order.order_sysid,
"order_time": order.order_time,
"order_type": "buy" if order.order_type == xtconstant.STOCK_BUY else "sell",
"order_volume": order.order_volume,