8c3868cb31
Angolo term-structure DVOL / calendar-vol. Scan di fattibilita' PRIMA del backtest:
la storia per-scadenza NON e' pubblica su Deribit (DVOL solo 30g; trade-history IV
solo per strumenti vivi; il front rotola/espira -> serie continua front-vs-back
irricostruibile). Per la metodologia (niente edge senza OOS su dati certi) -> STOP,
niente backtest su uno snapshot.
Unica via legittima: costruire il dato IN AVANTI. Aggiunto logger forward idempotente
che interpola l'ATM IV a tenor fissi {7,30,60,90,180}g e accumula data/raw/vol_term_*.
Seminati i primi snapshot (oggi: contango lieve su BTC/ETH). Non auto-cablato in cron.
- scripts/research/probe_vol_termstructure.py (scan fattibilita')
- scripts/research/log_vol_termstructure.py (forward dataset builder)
- tests/test_vol_termstructure.py (interpolazione offline)
- docs/diary/2026-06-26-vol-termstructure-feasibility.md
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
27 lines
1.2 KiB
Python
27 lines
1.2 KiB
Python
"""Test offline del logger forward della vol term-structure (2026-06-26). La STORIA per-scadenza
|
|
non e' pubblica su Deribit -> calendar-vol non backtestabile ora; questo logger costruisce il dataset
|
|
in avanti. Si testa la pura interpolazione ai tenor fissi. Diario 2026-06-26-vol-termstructure-feasibility.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 log_vol_termstructure import build_row, TENORS # type: ignore
|
|
|
|
|
|
def test_build_row_interpolates_all_tenors():
|
|
"""Curva sintetica in contango -> riga con tutti i tenor + slope positivo."""
|
|
curve = [(7, 40.0), (30, 45.0), (90, 50.0), (180, 55.0)]
|
|
row = build_row(100000.0, curve, now_ms=1_700_000_000_000)
|
|
assert all(f"iv_{t}d" in row for t in TENORS)
|
|
assert abs(row["iv_30d"] - 45.0) < 1e-6 # nodo esatto
|
|
assert 45.0 < row["iv_60d"] < 50.0 # interpolato tra 30 e 90
|
|
assert row["slope_7_180"] > 0 # contango -> slope positivo
|
|
|
|
|
|
def test_build_row_needs_two_points():
|
|
assert build_row(100.0, [(30, 50.0)], now_ms=1_700_000_000_000) is None
|
|
assert build_row(100.0, [], now_ms=1_700_000_000_000) is None
|