31 lines
892 B
Python
31 lines
892 B
Python
from __future__ import annotations
|
|
|
|
import json
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
PACKAGE_PARENT = Path(__file__).resolve().parents[2]
|
|
if str(PACKAGE_PARENT) not in sys.path:
|
|
sys.path.insert(0, str(PACKAGE_PARENT))
|
|
|
|
from strategy32.research.hybrid_regime import run_hybrid_backtest
|
|
|
|
|
|
def main() -> None:
|
|
payload = run_hybrid_backtest()
|
|
out = Path("/tmp/strategy32_hybrid_regime_backtest.json")
|
|
out.write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
|
for label, metrics in payload["results"].items():
|
|
print(
|
|
label,
|
|
f"ret={float(metrics['total_return']) * 100:.2f}%",
|
|
f"ann={float(metrics['annualized_return']) * 100:.2f}%",
|
|
f"sharpe={float(metrics['sharpe']):.2f}",
|
|
f"mdd={float(metrics['max_drawdown']) * 100:.2f}%",
|
|
)
|
|
print(f"wrote {out}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|