Bought XSP (mini-SPX) options ohlcv-1d 2013-2026 = $66.86 (hard-capped $70, get_cost-gated, year-chunked vs 504, 2025 backfilled) + SPY $0.01. CORRECTION: index VRP is NOT $900 (that was SPY root); clean instrument XSP $66.86/13y or SPX $143/13y. THREE measurement attempts all gave spurious NEGATIVE VRP (RV 28-33% vs implied ~16%) = MEASUREMENT ERROR not finding (contradicts decades of SPX VRP evidence). Bugs: noisy parity underlying; ~469/2800 days survive -> multi-day gaps inflate RV; SPY!=XSP divergence corrupts ATM. Root: XSP EOD ohlcv too sparse to reconstruct clean underlying+ATM-IV. Implied (16.7%) reads right. Frontier real+affordable+in-hand but proper extraction is a real options-quant build (denser SPX +$76 or IV-surface w/ quotes), not a gate. Did NOT record -2.7 as a result (artifact). Crypto momentum+VRP remains only deploy-grade edge. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
50 lines
2.0 KiB
Python
50 lines
2.0 KiB
Python
#!/usr/bin/env python3
|
|
"""Fetch XSP (mini-SPX) options daily OHLCV for the equity-index VRP test. HARD-CAPPED.
|
|
|
|
get_cost-gated: prints the exact cost and ABORTS if above CAP — no surprise charges.
|
|
Single dataset/schema/symbol/window. ohlcv-1d only (NOT definition).
|
|
"""
|
|
import os
|
|
import sys
|
|
|
|
import databento as db
|
|
|
|
CAP = 70.00 # hard cap — abort if cost exceeds this
|
|
DS, SCH, SYM = "OPRA.PILLAR", "ohlcv-1d", "XSP.OPT"
|
|
START, END = "2013-04-01", "2026-06-05"
|
|
OUT = "data/surfer/xsp_ohlcv1d.dbn"
|
|
|
|
|
|
def main():
|
|
c = db.Historical(os.environ["DATABENTO_API_KEY"])
|
|
if os.path.exists(OUT):
|
|
print(f"already downloaded: {OUT}"); return 0
|
|
cost = c.metadata.get_cost(dataset=DS, symbols=[SYM], schema=SCH, start=START, end=END, stype_in="parent")
|
|
gb = c.metadata.get_billable_size(dataset=DS, symbols=[SYM], schema=SCH, start=START, end=END, stype_in="parent") / 1e9
|
|
print(f"EXACT get_cost = ${cost:.2f} ({gb:.2f} GB) CAP = ${CAP:.2f}")
|
|
if cost > CAP:
|
|
print(f"ABORT: ${cost:.2f} exceeds cap ${CAP:.2f} — NOTHING downloaded.")
|
|
return 1
|
|
print(f"under cap by ${CAP - cost:.2f} -> downloading {SYM} {SCH} year-chunked (same total cost)")
|
|
os.makedirs("data/surfer/xsp", exist_ok=True)
|
|
for yr in range(2013, 2027):
|
|
ys = f"{yr}-01-01" if yr > 2013 else "2013-04-01"
|
|
ye = f"{yr+1}-01-01" if yr < 2026 else "2026-06-05"
|
|
out = f"data/surfer/xsp/xsp_{yr}.dbn"
|
|
if os.path.exists(out):
|
|
print(f" {yr}: exists"); continue
|
|
for attempt in range(3):
|
|
try:
|
|
d = c.timeseries.get_range(dataset=DS, symbols=[SYM], schema=SCH, start=ys, end=ye, stype_in="parent")
|
|
d.to_file(out)
|
|
print(f" {yr}: saved ({os.path.getsize(out)/1e6:.1f} MB)")
|
|
break
|
|
except Exception as e:
|
|
print(f" {yr}: attempt {attempt+1} {type(e).__name__}; retry")
|
|
print(f"DONE -> data/surfer/xsp/")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|