log增强

This commit is contained in:
Ubuntu 2025-07-30 22:01:14 +08:00
parent 6a2e1c612b
commit 34bec934a6
2 changed files with 29 additions and 2 deletions

Binary file not shown.

View File

@ -494,13 +494,40 @@ class FreqaiPrimer(IStrategy):
if conditions:
combined_condition = reduce(lambda x, y: x & y, conditions)
dataframe.loc[combined_condition, 'enter_long'] = 1
# 创建条件总结列表
conditions_summary = [
("&-price_value_divergence", divergence_value, "<", self.buy_threshold, cond1.iloc[-1]),
("volume_z_score", volume_z_score_value, ">", volume_z_score_threshold, cond2.iloc[-1]),
("rsi", rsi_value, "<", rsi_threshold, cond3.iloc[-1]),
("close <= bb_lowerband", bb_close_value, "<=", bb_lower_value, cond4.iloc[-1]),
("stochrsi_k", stochrsi_value, "<", stochrsi_threshold, cond5.iloc[-1]),
("非熊市", None, None, None, cond6.iloc[-1]),
("STOCHRSI未持续超买", None, None, None, cond7.iloc[-1]),
]
# 输出每个条件的状态
logger.info(f"[{pair}] === 买入条件检查 ===")
satisfied_conditions = []
for name, value, operator, threshold, result in conditions_summary:
status = "" if result else ""
if value is not None and threshold is not None:
logger.info(f"[{pair}] {status} {name}: {value:.6f} {operator} {threshold:.6f}")
else:
logger.info(f"[{pair}] {status} {name}")
if result:
satisfied_conditions.append(name)
# 总结满足的条件
if combined_condition.any():
logger.info(f"[{pair}] 买入信号触发,趋势得分:{trend_score:.2f}")
logger.info(f"[{pair}] 买入信号触发,满足条件: {', '.join(satisfied_conditions)},趋势得分:{trend_score:.2f}")
else:
logger.info(f"[{pair}] 买入条件未满足")
logger.info(f"[{pair}] ❌ 买入条件未满足")
else:
logger.info(f"[{pair}] 无有效买入条件")
# 记录各条件触发率
logger.info(f"[{pair}] 各条件触发率 - "
f"cond1: {cond1.mean():.2%}, "
f"cond2: {cond2.mean():.2%}, "