fix: validate active five-market trader
This commit is contained in:
1 parent
9fd3077cae
commit
dc297399d4
3 files changed
+11
-8
No files matched your search
@@ -21,7 +21,7 @@ def test_closed_report_counts_entry_fee_once(tmp_path, monkeypatch, capsys, pref
|
||||
status = 200
|
||||
def __enter__(self): return self
|
||||
def __exit__(self, *args): pass
|
||||
def read(self, size): return b'Local Crypto Dip Agent'
|
||||
def read(self, size): return b'Local Trading Agent'
|
||||
monkeypatch.setattr(validate, 'urlopen', lambda *a, **kw: Response())
|
||||
assert validate.main() == 0
|
||||
output = capsys.readouterr().out
|
||||
|
||||
@@ -16,7 +16,7 @@ def report(monkeypatch, tmp_path, capsys):
|
||||
status=200
|
||||
def __enter__(self): return self
|
||||
def __exit__(self,*a): pass
|
||||
def read(self,n): return b'Local Crypto Dip Agent'
|
||||
def read(self,n): return b'Local Trading Agent'
|
||||
monkeypatch.setattr(validate, 'urlopen', lambda *a,**kw: Response())
|
||||
def run():
|
||||
status=validate.main()
|
||||
|
||||
+9
-6
@@ -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)}")
|
||||
|
||||
|
||||
Reference in new issue
Block a user