40 lines
1.2 KiB
Python
40 lines
1.2 KiB
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.adverse_regime import run_adverse_regime_search
|
|
|
|
|
|
def main() -> None:
|
|
payload = run_adverse_regime_search(
|
|
cache_path="/tmp/strategy32_fixed66_bundle.pkl",
|
|
eval_days=1825,
|
|
initial_capital=1000.0,
|
|
)
|
|
out = Path("/tmp/strategy32_adverse_regime_engine_search.json")
|
|
out.write_text(json.dumps(payload, indent=2), encoding="utf-8")
|
|
|
|
for regime, rows in payload["by_regime"].items():
|
|
print(regime)
|
|
for row in rows:
|
|
print(
|
|
" ",
|
|
row["name"],
|
|
f"ret={float(row['total_return']) * 100:.2f}%",
|
|
f"sharpe={float(row['sharpe']):.2f}",
|
|
f"mdd={float(row['max_drawdown']) * 100:.2f}%",
|
|
f"active={float(row['active_bar_ratio']) * 100:.2f}%",
|
|
f"rebalance={int(row['rebalance_count'])}",
|
|
)
|
|
print(f"wrote {out}")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|