report(shape): integra SH01 (sleeve SHAPE) nel report per-anno e nell'integrazione MASTER
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,7 @@ from scripts.analysis.honest_improve2 import _daily_equity, _norm
|
||||
from scripts.analysis.pairs_research import pairs_sim
|
||||
from scripts.analysis.tsmom_research import tsmom_sim
|
||||
from scripts.strategies.PR01_pairs_reversion import PAIRS
|
||||
from scripts.analysis.shape_ml_validate import shape_daily_equity
|
||||
|
||||
YEARS = sorted(set(IDX.year))
|
||||
|
||||
@@ -47,7 +48,8 @@ def build_everything():
|
||||
pairs[f"PR_{a}{b}"] = daily_from(r["eq_ts"], r["eq_v"])
|
||||
t = tsmom_sim()
|
||||
tsm = {"TSM01": daily_from(t["eq_ts"], t["eq_v"])}
|
||||
return S, pairs, tsm
|
||||
shape = {f"SH_{a}": _norm(shape_daily_equity(a, IDX)) for a in ("BTC", "ETH")}
|
||||
return S, pairs, tsm, shape
|
||||
|
||||
|
||||
def yrow(label, dr):
|
||||
@@ -62,8 +64,8 @@ def metric_block(label, dr):
|
||||
|
||||
|
||||
def main():
|
||||
print("Costruzione (puo' richiedere ~1-2 min)...\n")
|
||||
S, pairs, tsm = build_everything()
|
||||
print("Costruzione (puo' richiedere ~2-3 min)...\n")
|
||||
S, pairs, tsm, shape = build_everything()
|
||||
fade = {k: v for k, v in S.items() if k.startswith("MR")}
|
||||
honest = {k: v for k, v in S.items() if not k.startswith("MR")}
|
||||
|
||||
@@ -72,10 +74,12 @@ def main():
|
||||
"HONEST": port_returns(honest),
|
||||
"PAIRS": port_returns(pairs),
|
||||
"TSM01": tsm["TSM01"].pct_change().fillna(0.0),
|
||||
"SHAPE": port_returns(shape),
|
||||
}
|
||||
master9 = port_returns(S)
|
||||
master_p = port_returns({**S, **pairs})
|
||||
master_x = port_returns({**S, **pairs, **tsm})
|
||||
master_xs = port_returns({**S, **pairs, **tsm, **shape})
|
||||
|
||||
# ---------- (A) per anno, per FAMIGLIA + portafogli ----------
|
||||
print("=" * 110)
|
||||
@@ -89,12 +93,13 @@ def main():
|
||||
print(yrow("MASTER-9", master9))
|
||||
print(yrow("MASTER+pairs", master_p))
|
||||
print(yrow("MASTER-esteso", master_x))
|
||||
print(yrow("MASTER+shape", master_xs))
|
||||
|
||||
# ---------- (B) per anno, per STRATEGIA singola ----------
|
||||
print("\n" + "=" * 130)
|
||||
print(" (B) RET% NETTO PER ANNO — per STRATEGIA singola (tutti gli sleeve)")
|
||||
print("=" * 130)
|
||||
allsl = {**S, **pairs, **tsm}
|
||||
allsl = {**S, **pairs, **tsm, **shape}
|
||||
cols = list(allsl)
|
||||
print(f" {'Anno':>5s}" + "".join(f"{c.replace('_',''):>11s}" for c in cols))
|
||||
print(" " + "-" * 124)
|
||||
@@ -112,12 +117,14 @@ def main():
|
||||
print(metric_block("MASTER-9", master9))
|
||||
print(metric_block("+pairs", master_p))
|
||||
print(metric_block("+TSM01", port_returns({**S, **tsm})))
|
||||
print(metric_block("+shape", port_returns({**S, **shape})))
|
||||
print(metric_block("MASTER-esteso", master_x))
|
||||
print(metric_block("MASTER+shape", master_xs))
|
||||
# correlazione media nuove vs master-9
|
||||
dr_all = pd.DataFrame({k: v.pct_change().fillna(0.0) for k, v in {**S, **pairs, **tsm}.items()})
|
||||
dr_all = pd.DataFrame({k: v.pct_change().fillna(0.0) for k, v in {**S, **pairs, **tsm, **shape}.items()})
|
||||
corr = dr_all.corr(); old = list(S)
|
||||
print(" " + "-" * 80)
|
||||
for k in list(pairs) + list(tsm):
|
||||
for k in list(pairs) + list(tsm) + list(shape):
|
||||
print(f" corr {k:<11s} vs MASTER-9 = {corr.loc[k, old].mean():+.2f}")
|
||||
|
||||
# ---------- (D) numeri sobri ----------
|
||||
|
||||
Reference in New Issue
Block a user