feat(surfer): fxhnt combined-book forward-track cron + dynamic fetch END

fetch_daily.py: END now clamps to the GLBX dataset range-end (was hardcoded 2026-06-05; clamp handles the
~1-3d exchange lag — END=today failed get_cost). scripts/surfer/fxhnt_forward_cron.sh: daily wrapper —
fetch crypto_pit (free) + futures (Databento, cost-capped) + 'fxhnt forward-track' to book the new paper-
NAV day of the validated combined book (crypto X-sec momentum alpha + futures trend hedge). Crontab: daily
23:30 UTC -> data/surfer/fxhnt_forward.log. Sources DATABENTO key from ~/.secrets (never printed).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-06-14 00:09:40 +02:00
parent 54e3d50db8
commit f9b62d108c
2 changed files with 24 additions and 1 deletions

View File

@@ -4,6 +4,7 @@
Re-confirms get_cost (free, no download) and ABORTS if over the cap before spending.
Saves raw DBN to data/surfer/ (gitignored). Reads DATABENTO_API_KEY from env (never printed).
"""
import datetime
import os
import sys
@@ -14,7 +15,7 @@ PER_ROOT_CAP = 10.00 # per-root sanity cap
DS = "GLBX.MDP3"
SCHEMA = "ohlcv-1d"
START = "2010-06-06"
END = "2026-06-05"
END = datetime.date.today().isoformat() # fetch through today (dynamic) — was hardcoded; needed for daily forward-track
ROOTS = ["ES", "NQ", "YM", "RTY", "ZN", "ZB", "ZF", "ZT", "6E", "6J", "6B", "6A",
"6C", "GC", "SI", "HG", "CL", "NG", "RB", "ZC", "ZS", "ZW"]
# parent symbology = all outright expiries per root (fast; continuous chain resolution 504s).
@@ -29,6 +30,15 @@ def main():
print("DATABENTO_API_KEY not set"); return 2
client = db.Historical(key)
global END
try: # clamp END to the dataset's available end (GLBX lags ~1-3d)
rng = client.metadata.get_dataset_range(dataset=DS)
avail = (rng.get("end") or "")[:10]
if avail:
END = min(END, avail)
except Exception:
pass
os.makedirs(OUT_DIR, exist_ok=True)
print(f"fetching {SCHEMA} per-root ({len(ROOTS)} roots, {STYPE}) {START}..{END}; "
f"per-root get_cost gate (≤${PER_ROOT_CAP}), cumulative cap ${CAP_USD}")

View File

@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# fxhnt combined-book daily forward-validation.
# Refresh the data, then book the new day's paper-NAV into the frozen forward track.
# - crypto X-sec momentum sleeve (alpha): free Binance fetch, advances daily
# - futures trend sleeve (hedge): Databento ohlcv, cost-capped in fetch_daily.py
# - fxhnt forward-track: books only days AFTER inception (genuine out-of-sample-in-time)
set -u
cd /home/jgrusewski/Work/foxhunt || exit 1
[ -f "$HOME/.secrets" ] && . "$HOME/.secrets" # DATABENTO_API_KEY (gitignored, never printed)
echo "===== $(date -u '+%Y-%m-%d %H:%M UTC') ====="
python3 scripts/surfer/fetch_crypto_pit.py 2>&1 | tail -1
python3 scripts/surfer/fetch_daily.py 2>&1 | tail -2
/home/jgrusewski/.local/bin/fxhnt forward-track 2>&1 | grep -vE "BentoWarning|Warning|RuntimeWarning|divide|invalid value|stddev"