forked from animatedread/Warrior_EA
37 lines
1.9 KiB
Python
37 lines
1.9 KiB
Python
"""Summarise WarriorGapFade real-tick tester runs: python gf_summary.py claude_gf2_EURCHF_d0 ..."""
| |||
from __future__ import annotations
| |||
import sys
| |||
import numpy as np
| |||
sys.path.insert(0, __file__.rsplit("\\", 1)[0] if "\\" in __file__ else ".")
| |||
import grid_summary as gs # noqa: E402
| |||
| |||
COMMON = gs.COMMON
| |||
| |||
if __name__ == "__main__":
| |||
print(f"{'run':<24}{'n':>5}{'net':>9}{'PF':>6}{'eqDD':>7}{'win':>6}{'target':>8}{'stop':>6}{'time':>6}"
| |||
f"{'bp/trade':>10}{'2016-20':>9}{'2021-26':>9}")
| |||
for nm in sys.argv[1:]:
| |||
try:
| |||
rp = gs.report(nm)
| |||
raw = np.genfromtxt(rf"{COMMON}\gapfade_trades_{nm}.csv", delimiter=",", skip_header=1,
| |||
dtype=str, encoding="ansi")
| |||
except Exception as e: # noqa: BLE001
| |||
print(f"{nm:<24} unreadable: {e}")
| |||
continue
| |||
if raw.ndim == 1:
| |||
raw = raw[None, :]
| |||
net = raw[:, 7].astype(float)
| |||
ep = raw[:, 3].astype(float)
| |||
vol = raw[:, 4].astype(float)
| |||
why = raw[:, 8]
| |||
yr = np.array([int(x[:4]) for x in raw[:, 2]])
| |||
#--- price return per trade, independent of lot size, in bp
| |||
xp = raw[:, 6].astype(float)
| |||
side = raw[:, 12].astype(float)
| |||
bp = side * (xp - ep) / ep * 1e4
| |||
early, late = bp[yr <= 2020], bp[yr >= 2021]
| |||
print(f"{nm:<24}{len(net):>5}{net.sum():>+9.0f}{rp.get('pf', float('nan')):>6.2f}{rp.get('eqdd', float('nan')):>7.2%}"
| |||
f"{np.mean(net > 0):>6.0%}{np.sum(why == 'target'):>8}{np.sum(why == 'stop'):>6}{np.sum(why == 'expert'):>6}"
| |||
f"{bp.mean():>+10.1f}{early.mean() if len(early) else float('nan'):>+9.1f}{late.mean() if len(late) else float('nan'):>+9.1f}")
| |||
print("bp/trade = fill-to-fill price move (spread paid at both fills); 'target' exits are in-EA closes"
| |||
" counted by the journal as expert, so the split is approximate.")
|