add log+1
This commit is contained in:
parent
1b4a86198d
commit
7068a019e2
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user