Files
foxhunt/scripts/argo-alpha-cv.sh
jgrusewski 10f4bcc15b feat(alpha): decision-stride + cluster 9-fold CV workflow
Two complementary additions to validate the minute-horizon alpha
hypothesis at IBKR-realistic costs:

1. `alpha_baseline --decision-stride N`: emits a new action every N
   steps; between decisions force action=0 (wait) so an open position
   is held rather than re-decided per bar. Cuts per-bar trade counts
   ~stride× and removes the coin-flip overtrading. Local 2Q sweep
   showed stride=200 + scaled training (8K episodes × 25 envs × H=1200)
   flipped Sharpe at ¼-tick from -4.29 (per-bar, 3-fold mean) to +1.78,
   with std collapsing from ±8.8 to ±1.15. Break-even cost moved from
   <¼-tick to ~1-tick — for the first time positive at IBKR-realistic
   passive-execution frictions.

2. `alpha_train_stacker --max-rows N`: optional cap on bars consumed
   from the fxcache. Used during local 2Q smoke (--max-rows 4M against
   the 17.8M-row 9Q fxcache) to fit Mamba2 training on a 4 GB consumer
   GPU; on the cluster (--no-cap) it sees all 9Q.

3. New Argo workflow `alpha-cv`: standalone template that compiles
   alpha_train_stacker + alpha_baseline + alpha_fill_coeffs.json,
   trains the stacker on the 9Q fxcache, then runs 9 sequential
   walk-forward folds of alpha_baseline on disjoint 1.9M-bar windows
   (one per quarter). Launcher script `scripts/argo-alpha-cv.sh`
   mirrors argo-train.sh conventions.

The local 2Q test that motivated this commit is summarised inline in
the alpha-cv template comments; the verdict was "framing was the bug —
once decision cadence matches the multi-minute alpha horizon, the
strategy is positive at IBKR commission".

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-16 18:04:34 +02:00

82 lines
2.7 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# Submit the alpha-cv workflow: stacker train on 9Q + 9-fold walk-forward.
#
# Defaults match the validated 2Q config (decision-stride=200,
# scaled training H=1200 × N_par=25 × 8K episodes).
#
# Usage:
# ./scripts/argo-alpha-cv.sh # submit on current HEAD
# ./scripts/argo-alpha-cv.sh --branch main
# ./scripts/argo-alpha-cv.sh --decision-stride 100 --horizon 2000
set -euo pipefail
SHA=HEAD
BRANCH=main
DECISION_STRIDE=200
HORIZON=1200
N_TRAIN_PAR=25
N_TRAIN_EPISODES=8000
FOLD_WINDOW=1900000
GPU_POOL=ci-training-l40s
WATCH=false
usage() {
cat <<EOF
Usage: $0 [OPTIONS]
--sha <commit> Git SHA (default: HEAD)
--branch <branch> Git branch (default: main)
--decision-stride <n> Decisions every N bars (default: 200)
--horizon <n> Episode length in bars (default: 1200)
--n-train-par <n> Parallel envs during training (default: 25)
--n-train-episodes <n> Total training episodes (default: 8000)
--fold-window <n> Bars per fold window (default: 1900000)
--gpu-pool <p> GPU pool (default: ci-training-l40s)
--watch Follow logs via argo watch
EOF
}
while [[ $# -gt 0 ]]; do
case "$1" in
--sha) SHA="$2"; shift 2 ;;
--branch) BRANCH="$2"; shift 2 ;;
--decision-stride) DECISION_STRIDE="$2"; shift 2 ;;
--horizon) HORIZON="$2"; shift 2 ;;
--n-train-par) N_TRAIN_PAR="$2"; shift 2 ;;
--n-train-episodes) N_TRAIN_EPISODES="$2"; shift 2 ;;
--fold-window) FOLD_WINDOW="$2"; shift 2 ;;
--gpu-pool) GPU_POOL="$2"; shift 2 ;;
--watch) WATCH=true; shift ;;
-h|--help) usage; exit 0 ;;
*) echo "Unknown option: $1"; usage; exit 1 ;;
esac
done
case "$GPU_POOL" in
ci-training-l40s) SM=89 ;;
ci-training-h100*|ci-training-h100x2|ci-training-h100-sxm) SM=90 ;;
*) echo "Unknown gpu-pool: $GPU_POOL"; exit 1 ;;
esac
echo "Submitting alpha-cv workflow..."
echo " branch: $BRANCH"
echo " sha: $SHA"
echo " decision-stride: $DECISION_STRIDE"
echo " horizon: $HORIZON"
echo " n-train-par: $N_TRAIN_PAR"
echo " n-train-episodes: $N_TRAIN_EPISODES"
echo " fold-window: $FOLD_WINDOW"
echo " gpu-pool: $GPU_POOL (sm_$SM)"
argo submit -n foxhunt --from=wftmpl/alpha-cv \
-p commit-sha="$SHA" \
-p git-branch="$BRANCH" \
-p cuda-compute-cap="$SM" \
-p gpu-pool="$GPU_POOL" \
-p decision-stride="$DECISION_STRIDE" \
-p horizon="$HORIZON" \
-p n-train-par="$N_TRAIN_PAR" \
-p n-train-episodes="$N_TRAIN_EPISODES" \
-p fold-window="$FOLD_WINDOW" \
$($WATCH && echo "--watch" || echo "")