fix: okx convert return format
This commit is contained in:
1 file changed
+11
-3
@@ -314,15 +314,23 @@ class BotSpotTrade:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.warning("查询闪兑结果失败: %s(使用创建返回的数据)", str(e))
|
self.logger.warning("查询闪兑结果失败: %s(使用创建返回的数据)", str(e))
|
||||||
|
|
||||||
|
# 查询接口查不到时(如 OKX 按 clTReqId 查历史查不到)ccxt 返回字段全为
|
||||||
|
# None 的空壳结构而不抛错,此时必须回退用创建时返回的数据
|
||||||
|
if trade_detail is not None and (
|
||||||
|
trade_detail.get("toAmount") is None or trade_detail.get("fromAmount") is None
|
||||||
|
):
|
||||||
|
self.logger.warning("查询闪兑结果无有效成交数据: %s(使用创建返回的数据)", trade_detail)
|
||||||
|
trade_detail = None
|
||||||
|
|
||||||
final_data = trade_detail or convert_trade
|
final_data = trade_detail or convert_trade
|
||||||
|
|
||||||
record_data = {
|
record_data = {
|
||||||
"symbol": symbol,
|
"symbol": symbol,
|
||||||
"id": trade_id,
|
"id": trade_id,
|
||||||
"filled": final_data.get("toAmount", 0.0),
|
"filled": final_data.get("toAmount") or 0.0,
|
||||||
"cost": final_data.get("fromAmount", 0.0),
|
"cost": final_data.get("fromAmount") or 0.0,
|
||||||
"side": side,
|
"side": side,
|
||||||
"timestamp": final_data.get("timestamp", int(time.time() * 1000)),
|
"timestamp": final_data.get("timestamp") or int(time.time() * 1000),
|
||||||
}
|
}
|
||||||
|
|
||||||
if not self._tool_record_transaction(record_data, is_convert=True):
|
if not self._tool_record_transaction(record_data, is_convert=True):
|
||||||
|
|||||||
Reference in New Issue
Block a user