Fix all audit issues: survival check performance, display consistency, atomic config write, credential validation, TP null handling, highest_open preservation, stale docstring

This commit is contained in:
2026-05-27 07:45:25 +01:00
parent 1b505e0b90
commit ea428b5025
5 changed files with 56 additions and 31 deletions
+9 -3
View File
@@ -106,10 +106,16 @@ class BotState:
) / 2.0
# Highest open position entry price
# When no positions are open, keep the last known value rather than
# falling back to current price — this prevents the grid floor from
# collapsing to current_price * 0.40 after all positions close.
open_prices = [pos_level(p) for p in positions]
self.highest_open_price = (
max(open_prices) if open_prices else self.current_price
)
if open_prices:
self.highest_open_price = max(open_prices)
elif self.highest_open_price == 0.0:
# First run with no positions — use current price as seed
self.highest_open_price = self.current_price
# else: keep existing highest_open_price from previous loop
# Lowest level across all positions and orders
order_prices = [ord_level(o) for o in orders]