From 7068a019e2d6f176b7e869b82e624fc5369b2376 Mon Sep 17 00:00:00 2001 From: "zhangkun9038@dingtalk.com" Date: Thu, 27 Nov 2025 15:23:46 +0800 Subject: [PATCH] add log+1 --- user_data/strategies/staticgrid.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/user_data/strategies/staticgrid.py b/user_data/strategies/staticgrid.py index 7d847fe..9861a11 100644 --- a/user_data/strategies/staticgrid.py +++ b/user_data/strategies/staticgrid.py @@ -47,6 +47,11 @@ class StaticGrid(IStrategy): current_price = dataframe['close'].iloc[-1] candle_index = len(dataframe) - 1 + print(f"[StaticGrid] {pair} populate_indicators - 价格: {current_price:.2f}, candle: {candle_index}", + file=sys.stderr, flush=True) + print(f"[StaticGrid] {pair} GridManager 范围: {grid_manager.lower_price:.2f}-{grid_manager.upper_price:.2f}", + file=sys.stderr, flush=True) + # 更新网格管理器状态 grid_manager.update_state(current_price, candle_index) @@ -74,18 +79,26 @@ class StaticGrid(IStrategy): # 否则等待第一次 populate_indicators 更新价格后再初始化 if recovered_state: current_price = recovered_state.get('current_price', 0) + print(f"[StaticGrid] {pair} 从 Redis 恢复价格: {current_price}", + file=sys.stderr, flush=True) else: # 这里暂时用占位符,会在 populate_indicators 中更新 current_price = 0 + print(f"[StaticGrid] {pair} 使用占位符价格,会在第一次 populate_indicators 中更新", + file=sys.stderr, flush=True) # 计算动态的上下沿 if current_price > 0: lower_price = current_price * (1 - percent) upper_price = current_price * (1 + percent) + print(f"[StaticGrid] {pair} 计算动态上下沿 - 价格: {current_price}, 范围: {lower_price:.2f}-{upper_price:.2f}", + file=sys.stderr, flush=True) else: # 如果没有价格信息,使用默认值(会在第一次更新时重新计算) lower_price = 1000 upper_price = 5000 + print(f"[StaticGrid] {pair} 使用默认上下沿: {lower_price}-{upper_price}", + file=sys.stderr, flush=True) print(f"[StaticGrid] {pair} 动态网格范围 - 下沿: {lower_price:.2f}, 上沿: {upper_price:.2f}", file=sys.stderr, flush=True)