From f9b62d108c47460f0dd0fca5c6ee209efb980f00 Mon Sep 17 00:00:00 2001 From: jgrusewski Date: Sun, 14 Jun 2026 00:09:40 +0200 Subject: [PATCH] feat(surfer): fxhnt combined-book forward-track cron + dynamic fetch END MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- scripts/surfer/fetch_daily.py | 12 +++++++++++- scripts/surfer/fxhnt_forward_cron.sh | 13 +++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 scripts/surfer/fxhnt_forward_cron.sh diff --git a/scripts/surfer/fetch_daily.py b/scripts/surfer/fetch_daily.py index cee8287da..b08cef544 100644 --- a/scripts/surfer/fetch_daily.py +++ b/scripts/surfer/fetch_daily.py @@ -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}") diff --git a/scripts/surfer/fxhnt_forward_cron.sh b/scripts/surfer/fxhnt_forward_cron.sh new file mode 100755 index 000000000..a1bcf5c53 --- /dev/null +++ b/scripts/surfer/fxhnt_forward_cron.sh @@ -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"