动态步长-fix
This commit is contained in:
parent
6d7225e39d
commit
e69d556737
@ -53,9 +53,12 @@ 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:
|
||||
# 说明用的是默认占位符,需要更新为实际价格
|
||||
# 动态更新网格范围(仅在第一次初始化时)
|
||||
# 检查是否需要从占位符更新为实际价格
|
||||
has_placeholder = grid_manager.lower_price <= 1000 and grid_manager.upper_price <= 5000
|
||||
|
||||
if has_placeholder:
|
||||
# 第一次初始化,从占位符更新为实际价格
|
||||
config = self.GRID_CONFIG.get(pair, {"percent": 0.20})
|
||||
percent = config.get("percent", 0.20)
|
||||
|
||||
@ -75,7 +78,7 @@ class StaticGrid(IStrategy):
|
||||
grid_manager.grid_prices = [new_lower + i * step for i in range(grid_manager.total_grid_levels)]
|
||||
grid_manager.step = step # 更新步长
|
||||
|
||||
# 重新初始化 grid_states(应对范围和步长的变化)
|
||||
# 重新初始化 grid_states(仅在第一次,之后保留已有的 FILLED 状态)
|
||||
grid_manager.grid_states.clear()
|
||||
for price in grid_manager.grid_prices:
|
||||
grid_manager.grid_states[price] = GridLevel(
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user