解决confirm_trade_entry bug

This commit is contained in:
zhangkun9038@dingtalk.com 2025-06-01 03:32:52 +00:00
parent 677914e3ca
commit 75ffe320d0

View File

@ -342,10 +342,12 @@ class FreqaiPrimer(IStrategy):
def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float,
time_in_force: str, current_time: datetime, **kwargs) -> bool:
# 添加调试日志:检查是否允许买入
recent_trades = Trade.get_trades(
pair=pair,
is_open=False,
close_date=current_time - datetime.timedelta(minutes=5)
recent_trades = Trade.query.filter(
and_(
Trade.pair == pair,
Trade.is_open == False, # noqa: E712
Trade.close_date > current_time - datetime.timedelta(minutes=5)
)
).all()
if len(recent_trades) > 0:
logger.info(f"[{pair}] 5分钟内有近期交易{len(recent_trades)} 笔),跳过本次入场")