Files
momentum-system/nightly_tune.sh
T
momentum devandClaude Opus 4.8 c7bfb3512a Self-tuning loop: per-setup report + nightly re-sweep + live learned-params
(a) learn_params.per_setup_report: permanent per-setup P&L/earliness breakdown
    in the harness (forces all-setups so the ORB-vs-rest comparison is visible).
(b) nightly_tune.py + nightly_tune.sh: backfill latest bars, sweep ORB params
    over accumulated gapper sessions, write the best PROFITABLE config to
    data/learned_params.json. run_live_paper reads it on boot and applies the
    tuned ready_score / min_bars (explicit env still wins); won't overwrite with
    a losing or thin-sample config. Cron-scheduled after the close.

Verified: 75/75 tests; boot logs the learned params and applies them.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-16 22:45:03 -04:00

15 lines
716 B
Bash

#!/usr/bin/env bash
# Nightly self-tuning: backfill latest bars, sweep ORB params, write
# data/learned_params.json (which run_live_paper.py reads on boot).
#
# Schedule it after the close. Examples:
# crontab -e -> 30 17 * * 1-5 /mnt/c/code/momentum/nightly_tune.sh
# (WSL: cron may need `sudo service cron start`, or use Windows Task Scheduler
# to run: wsl bash /mnt/c/code/momentum/nightly_tune.sh )
ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
VENV_PY="/home/philip/.venvs/momentum/bin/python"
cd "$ROOT" || exit 1
mkdir -p "$ROOT/data"
echo "=== nightly_tune $(date) ===" >> "$ROOT/data/nightly_tune.log"
PYTHONPATH="$ROOT" "$VENV_PY" nightly_tune.py >> "$ROOT/data/nightly_tune.log" 2>&1