删除不必要的min_grids_for_exit条件 - 止盈只由ROI信号决定,与加仓次数无关
This commit is contained in:
parent
2196de16ec
commit
9ee9e57114
@ -260,7 +260,7 @@ class GridManager:
|
||||
)
|
||||
self.is_completed = False # GridManager 是否完结
|
||||
self.completion_reason: Optional[str] = None # 完结原因 (take_profit / stop_loss)
|
||||
self.min_grids_for_exit = 20 # 至少加仓到约20个网格才能触发止盈,保证按照预与加仓足够次
|
||||
# ❌ 删除min_grids_for_exit - 止盈与加仓次数无关,只由ROI信号决定
|
||||
|
||||
# ✅ GridManager 不变量:沉求下来就不改了(除非网格范围更新)
|
||||
# 便于 Redis 序列化保存
|
||||
@ -301,18 +301,17 @@ class GridManager:
|
||||
file=sys.stderr, flush=True)
|
||||
|
||||
# ✅ 自监测:检查是否需要止盈/止损
|
||||
# 仅在加仓超过最低网格数时才触发,保证有足够的持仓
|
||||
# 只要有持仓,就检查是否触发止盈/止损条件
|
||||
if not self.is_completed and self.total_quantity > 0:
|
||||
filled_count = sum(1 for gs in self.grid_states.values() if gs.status == "filled")
|
||||
if filled_count >= self.min_grids_for_exit:
|
||||
exit_reason = self.monitor.get_exit_reason(current_price, self.avg_entry_price)
|
||||
if exit_reason:
|
||||
self.is_completed = True
|
||||
self.completion_reason = exit_reason
|
||||
profit_pct = (current_price - self.avg_entry_price) / self.avg_entry_price * 100
|
||||
print(f"[GridManager] {self.pair} 自监测触发✅ - 原因: {exit_reason}, "
|
||||
f"利润: {profit_pct:.2f}%, 当前价: {current_price:.2f}, 网格数: {filled_count}",
|
||||
file=sys.stderr, flush=True)
|
||||
exit_reason = self.monitor.get_exit_reason(current_price, self.avg_entry_price)
|
||||
if exit_reason:
|
||||
self.is_completed = True
|
||||
self.completion_reason = exit_reason
|
||||
profit_pct = (current_price - self.avg_entry_price) / self.avg_entry_price * 100
|
||||
filled_count = sum(1 for gs in self.grid_states.values() if gs.status == "filled")
|
||||
print(f"[GridManager] {self.pair} 自监测触发✅ - 原因: {exit_reason}, "
|
||||
f"利润: {profit_pct:.2f}%, 当前价: {current_price:.2f}, 网格数: {filled_count}",
|
||||
file=sys.stderr, flush=True)
|
||||
|
||||
def apply_adjustment(self, adjustment: PositionRecord) -> None:
|
||||
"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user