add log+2
This commit is contained in:
parent
7068a019e2
commit
97f1a7ce2e
@ -52,6 +52,29 @@ class StaticGrid(IStrategy):
|
||||
print(f"[StaticGrid] {pair} GridManager 范围: {grid_manager.lower_price:.2f}-{grid_manager.upper_price:.2f}",
|
||||
file=sys.stderr, flush=True)
|
||||
|
||||
# 动态更新网格范围(如果初始化时用的是占位符价格)
|
||||
if grid_manager.lower_price <= 1000 and grid_manager.upper_price <= 5000:
|
||||
# 说明用的是默认占位符,需要更新为实际价格
|
||||
config = self.GRID_CONFIG.get(pair, {"percent": 0.20, "step": 100})
|
||||
percent = config.get("percent", 0.20)
|
||||
step = config.get("step", 100)
|
||||
|
||||
new_lower = current_price * (1 - percent)
|
||||
new_upper = current_price * (1 + percent)
|
||||
|
||||
# 更新 GridManager 的范围
|
||||
grid_manager.lower_price = new_lower
|
||||
grid_manager.upper_price = new_upper
|
||||
|
||||
# 重新计算总网格数
|
||||
grid_manager.total_grid_levels = int((new_upper - new_lower) / step) + 1
|
||||
grid_manager.grid_prices = [new_lower + i * step for i in range(grid_manager.total_grid_levels)]
|
||||
|
||||
print(f"[StaticGrid] {pair} 更新网格范围 - 从 1000-5000 更新为 {new_lower:.2f}-{new_upper:.2f}",
|
||||
file=sys.stderr, flush=True)
|
||||
print(f"[StaticGrid] {pair} 新网格数: {grid_manager.total_grid_levels}",
|
||||
file=sys.stderr, flush=True)
|
||||
|
||||
# 更新网格管理器状态
|
||||
grid_manager.update_state(current_price, candle_index)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user