fix: validate active five-market trader

This commit is contained in:
pnannery committed 2026-09-12 09:09:44 -04:00
1 parent 9fd3077cae
commit dc297399d4
3 files changed
+11 -8

No files matched your search

+9 -6
View File
@@ -8,9 +8,9 @@ from urllib.request import urlopen
from zoneinfo import ZoneInfo
ROOT = Path(__file__).resolve().parent
STATE = ROOT / "data" / "state.json"
TRADES = ROOT / "data" / "trades.jsonl"
CONFIG = ROOT / "config.json"
STATE = ROOT / "data" / "five-market" / "state.json"
TRADES = ROOT / "data" / "five-market" / "trades.jsonl"
CONFIG = ROOT / "config-five.json"
LOCAL_TZ = ZoneInfo("America/New_York")
@@ -49,13 +49,13 @@ def main():
with urlopen("https://trader.nannery.pro", timeout=20) as r:
body = r.read(200).decode("utf-8", "ignore")
public_code = str(r.status)
public_ok = r.status == 200 and "Local Crypto Dip Agent" in body
public_ok = r.status == 200 and "Local Trading Agent" in body
except Exception as e:
public_code = type(e).__name__
if not public_ok:
problems.append(f"public dashboard validation failed: {public_code}")
cfg_check = sh("python3 bot.py --config-check", timeout=30)
cfg_check = sh("python3 five_market.py --config-check", timeout=30)
if cfg_check.returncode != 0:
problems.append("bot config-check failed")
@@ -88,7 +88,10 @@ def main():
drawdown_pct = ((peak - equity) / peak * 100) if peak else 0.0
positions = st.get("positions", {})
exposure = sum(float(p.get("notional_usd", 0)) for p in positions.values())
max_exposure = equity * float(cfg.get("max_total_position_pct_of_equity", 1.0))
if "max_total_position_pct_of_equity" in cfg:
max_exposure = equity * float(cfg.get("max_total_position_pct_of_equity", 1.0))
else:
max_exposure = equity * float(cfg.get("max_total_exposure_pct", 100.0)) / 100.0
if exposure > max_exposure + 0.01:
problems.append(f"exposure too high: {money(exposure)} > cap {money(max_exposure)}")