fix: get_today_entrust 中, 将order_type, price_type 转换成英文
This commit is contained in:
parent
0a1fe76218
commit
c185fccd24
@ -144,9 +144,9 @@ class XtTrader:
|
||||
"stock_code": o.stock_code,
|
||||
"order_id": o.order_id,
|
||||
"order_time": o.order_time,
|
||||
"order_type": o.order_type,
|
||||
"order_type": "buy" if o.order_type == xtconstant.STOCK_BUY else "sell",
|
||||
"order_volume": o.order_volume,
|
||||
"price_type": o.price_type,
|
||||
"price_type": self._convert_price_type(o.price_type),
|
||||
"price": o.price,
|
||||
"traded_volume": o.traded_volume,
|
||||
"traded_price": o.traded_price,
|
||||
@ -155,7 +155,20 @@ class XtTrader:
|
||||
} for o in orders
|
||||
]
|
||||
return []
|
||||
|
||||
|
||||
def _convert_price_type(self, price_type):
|
||||
"""Convert numeric price type to readable string"""
|
||||
price_type_map = {
|
||||
xtconstant.LATEST_PRICE: "latest_price", # 最新价
|
||||
xtconstant.FIX_PRICE: "limit_price", # 指定价/限价
|
||||
xtconstant.MARKET_BEST: "market_best", # 市价最优价
|
||||
xtconstant.MARKET_CANCEL: "market_cancel", # 市价即成剩撤
|
||||
xtconstant.MARKET_CANCEL_ALL: "market_cancel_all", # 市价全额成交或撤销
|
||||
xtconstant.MARKET_PEER_PRICE_FIRST: "market_peer_best", # 对手方最优价格
|
||||
xtconstant.MARKET_MINE_PRICE_FIRST: "market_mine_best", # 本方最优价格
|
||||
}
|
||||
return price_type_map.get(price_type, f"unknown_{price_type}")
|
||||
|
||||
def buy(self, code, price, amount):
|
||||
order_id = self.xt_trader.order_stock(
|
||||
self.account, code, xtconstant.STOCK_BUY, amount, xtconstant.FIX_PRICE, price, self._strategy_name, self._remark
|
||||
|
Loading…
x
Reference in New Issue
Block a user