fix: order timeout
This commit is contained in:
parent
28472a3bb1
commit
292866257a
@ -251,7 +251,7 @@ class PositionManager:
|
||||
try:
|
||||
with open(self.data_path, "w") as f:
|
||||
json.dump(data_to_save, f)
|
||||
logger.info("成功保存实盘策略数据")
|
||||
logger.debug("成功保存实盘策略数据")
|
||||
except Exception as e:
|
||||
logger.error(f"保存实盘策略数据失败: {str(e)}")
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import time
|
||||
import threading
|
||||
import schedule
|
||||
import datetime
|
||||
from datetime import datetime
|
||||
from xtquant import xtconstant
|
||||
from logger_config import get_logger
|
||||
from config import Config
|
||||
@ -186,13 +186,7 @@ class RealTraderManager:
|
||||
for order_id, order_info in pending_orders.items():
|
||||
# 如果订单类型为限价单,则检查是否超时
|
||||
if order_info.order_type == ORDER_TYPE_LIMIT:
|
||||
# 将datetime对象转换为时间戳进行比较
|
||||
if isinstance(order_info.created_time, datetime.datetime):
|
||||
created_timestamp = order_info.created_time.timestamp()
|
||||
duration = time.time() - created_timestamp
|
||||
else:
|
||||
duration = time.time() - order_info.created_time
|
||||
|
||||
duration = (datetime.now() - order_info.created_time).total_seconds()
|
||||
if duration > Config.RTM_ORDER_TIMEOUT:
|
||||
logger.info(f"限价单超时: ID={order_id}, 策略={strategy_name}, 持续时间={duration}秒")
|
||||
self.trader.cancel(order_id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user