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
+17 -3
View File
@@ -174,9 +174,14 @@ class TeslaGridBot:
log.info(f"Highest open: ${s.highest_open_price:.2f}")
log.info(f"Lowest level: ${s.lowest_level_price:.2f}")
log.info(f"GBP/USD: {s.gbpusd:.4f}")
calc = self.calculator
spacing = calc.get_spacing_pct(s.equity)
depth = calc.get_queue_depth(s.equity)
calc = self.calculator
# Use survival-gated lookups — same as manage_orders uses
spacing = calc.get_spacing_pct(
s.equity, s.highest_open_price, s.all_levels(), s.gbpusd
)
depth = calc.get_queue_depth(
s.equity, spacing, s.highest_open_price, s.all_levels(), s.gbpusd
)
full_sim = calc._simulate_grid(
s.highest_open_price, spacing, s.gbpusd, s.all_levels()
)
@@ -410,6 +415,15 @@ class TeslaGridBot:
self.banner()
log.info("Connecting to Capital.com...")
# Fail fast if credentials are still placeholders
if config.API_KEY == "YOUR_API_KEY_HERE" or \
config.IDENTIFIER == "your@email.com" or \
config.PASSWORD == "YOUR_PASSWORD_HERE":
log.error("Credentials not set — update environment variables:")
log.error(" export CAPITAL_API_KEY=your_key")
log.error(" export CAPITAL_IDENTIFIER=your@email.com")
log.error(" export CAPITAL_PASSWORD=your_password")
sys.exit(1)
try:
self.client.create_session()
except Exception as e: