69e3517f1b
Provato l'angolo basis/cash-and-carry (l'altro proposto; il funding cross-sectional FC01 era gia' SCARTATO 2026-06-22). Delta-neutral long-spot/short-perp -> r=funding, zero esposizione prezzo. Premio di funding REALE (~+8-14%/anno aggregato, positivo ogni anno in-sample, ortogonale a TP01). MA Sharpe modellato 11-13 = ARTEFATTO: rischi di coda fuori dal dataset (manca il 2022; procyclico +23% 2024 -> +1.7% 2026; liquidazione/slippage non modellati). Il mark-to-market della base (premium col) sgonfia solo 13->11 -> il basis-from-data non e' il rischio vero. NON eseguibile a $600 (spot+perp, funding HL non Deribit) -> STAT-MODE. LEAD da rivedere a scala, non uno sleeve. Sottoprodotto: CC01 passa ogni gate del marginal scorer -> punto cieco (manca un gate 'Sharpe implausibile -> rischio nascosto'). - scripts/research/cash_carry_hl.py (CC-static/gated, BTC-ETH + 19-major, basis MtM, reality-check) - tests/test_cash_carry.py (lock del fatto economico, non dello Sharpe) - docs/diary/2026-06-26-cash-carry-hl.md - CLAUDE.md: riga nella sintesi di ricerca Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
37 lines
1.7 KiB
Python
37 lines
1.7 KiB
Python
"""Lock della conclusione 2026-06-26 (CC01 cash-and-carry): il premio di funding e' REALE e
|
|
positivo, ma PROCYCLICO (si comprime nel bear) — NON un edge all-weather. Lo Sharpe headline ~13 e'
|
|
un artefatto (rischi di coda assenti dal dataset) -> non testiamo lo Sharpe, testiamo il FATTO
|
|
economico e la procyclicita'. Diario docs/diary/2026-06-26-cash-carry-hl.md."""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
sys.path.insert(0, str(ROOT))
|
|
sys.path.insert(0, str(ROOT / "scripts" / "research"))
|
|
|
|
from cash_carry_hl import cc_returns, load_funding_panel, metrics # type: ignore
|
|
|
|
|
|
def test_funding_premium_is_real_and_positive():
|
|
"""Il carry esiste: funding aggregato BTC/ETH positivo, CC-static con CAGR > 0."""
|
|
r = cc_returns(["BTC", "ETH"], mode="static")
|
|
m = metrics(r)
|
|
assert m["gross_ann"] > 0.0 # premio di funding netto positivo
|
|
assert m["cagr"] > 0.0
|
|
|
|
|
|
def test_basis_markup_does_not_explain_high_sharpe():
|
|
"""Aggiungere il mark-to-market della base (Δpremium) NON sgonfia lo Sharpe in modo materiale:
|
|
prova che il rischio vero e' FUORI dal dataset (2022/liquidazione), non nel basis dei dati."""
|
|
naive = metrics(cc_returns(["BTC", "ETH"], mode="static"))["sharpe"]
|
|
basis = metrics(cc_returns(["BTC", "ETH"], mode="static", with_basis=True))["sharpe"]
|
|
assert basis > 0.7 * naive # cala poco -> il basis-from-data non e' il rischio nascosto
|
|
|
|
|
|
def test_carry_is_procyclical_fades_in_bear():
|
|
"""Il carry e' procyclico: il funding aggregato del toro 2024 supera quello del bear 2026."""
|
|
FUND, _ = load_funding_panel(["BTC", "ETH"])
|
|
agg = FUND.mean(axis=1)
|
|
by_year = agg.groupby(agg.index.year).sum()
|
|
assert by_year.get(2024, 0.0) > by_year.get(2026, 0.0)
|