Skip to content

Add CI workflow using uv for testing - #3

Open
lee101 wants to merge 105 commits into
mainfrom
codex/add-github-ci-with-uv-package-manager
Open

Add CI workflow using uv for testing#3
lee101 wants to merge 105 commits into
mainfrom
codex/add-github-ci-with-uv-package-manager

Conversation

@lee101

@lee101 lee101 commented May 22, 2025

Copy link
Copy Markdown
Owner

Summary

  • add GitHub Actions workflow to install uv and run pytest using it

Testing

  • pytest -q (fails: Unknown config option and errors during collection)

lee101 added a commit that referenced this pull request Mar 18, 2026
Key findings from 15-trial 8-symbol daily sweep (fee=0):
- clip_anneal is #1: +18.84% OOS (~108% annualized), 100% profitable
- slip_10bps #2: +14.35%, wd_05 #3: +8.73% — all 100% profitable
- trade_penalty COUNTERPRODUCTIVE with zero fees (was #1 at 10bps fee)
  - trade_pen_05: -17.2% on 8-sym/fee=0 vs +20% on 5-sym/10bps
  - Zero fees mean more trading = more opportunity, not waste
- 8 symbols >> 3 symbols (FDUSD-3 all negative, 8-sym has 3 winners)
- Binance data download for 10 new USDT symbols in progress

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Mar 18, 2026
23-symbol mixed stock+crypto daily sweep (11/35 trials):
- ALL configs positive and 100% profitable so far
- ent_anneal #1: +30.85% OOS, Sortino 2.38
- baseline #2: +30.09%, Sortino 2.51 (highest risk-adjusted)
- clip_anneal #3: +21.40%, Sortino 1.90
- Even weakest config (wd_005) at +10.95%

8-sym crypto daily (32/35): ent_001 (+5.27%) and ent_01 (+3.49%) new positives
10 Chronos2 LoRA models trained (AAPL-V), 8/10 Binance downloads done

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Mar 24, 2026
Key findings from 15-trial 8-symbol daily sweep (fee=0):
- clip_anneal is #1: +18.84% OOS (~108% annualized), 100% profitable
- slip_10bps #2: +14.35%, wd_05 #3: +8.73% — all 100% profitable
- trade_penalty COUNTERPRODUCTIVE with zero fees (was #1 at 10bps fee)
  - trade_pen_05: -17.2% on 8-sym/fee=0 vs +20% on 5-sym/10bps
  - Zero fees mean more trading = more opportunity, not waste
- 8 symbols >> 3 symbols (FDUSD-3 all negative, 8-sym has 3 winners)
- Binance data download for 10 new USDT symbols in progress

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Mar 24, 2026
23-symbol mixed stock+crypto daily sweep (11/35 trials):
- ALL configs positive and 100% profitable so far
- ent_anneal #1: +30.85% OOS, Sortino 2.38
- baseline #2: +30.09%, Sortino 2.51 (highest risk-adjusted)
- clip_anneal #3: +21.40%, Sortino 1.90
- Even weakest config (wd_005) at +10.95%

8-sym crypto daily (32/35): ent_001 (+5.27%) and ent_01 (+3.49%) new positives
10 Chronos2 LoRA models trained (AAPL-V), 8/10 Binance downloads done

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Mar 25, 2026
s87 is now #3 overall at +3315% ann (honest=4.70x/180d), beating s70 (+3303%)
s83 is #5 at +2527% ann (pool_val=3.75, wr=68.6%)
s85 is #8 at +1510% ann

All saved to crypto70_champions/. Long queue reordered: s71→s87→s70→s83...

crypto15: s78 still champion (+497% ann), 14/77 seeds genuine, at s129.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Mar 25, 2026
s101 is the new #3 at 5bps (tied with s70 at +3487%):
- 5bps: p50=+3470% ann, p05=+3101% floor, Sortino=5.52, WR=65%
- 8bps: honest=4.88x (+3537% ann) — very consistent, robust seed!
- Now at position 3 in long queue (1800s): s92 → s71 → s101 → s87...

5bps production leaderboard update:
s71(+9381%) >> s70(+3487%) ≈ s101(+3470%) > s65(+3257%) > s87(+3074%) > s98(+2964%)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Mar 25, 2026
- crypto70 long s61-120: s92(+10526%)=same, s71(+9827%)=same, s118(+8108%)=same, s123(+6191%)=same at 1800s
- crypto70 s121-200 (partial): s123=#3 (+6191%@8bps/+6837%@5bps), s129=+2873%@8bps/+4265%@5bps, s138=+4140%@8bps/+4230%@5bps
- crypto15 s50-200: s78 champion (+497%) still holds, s166(+322%), s161(+303%) emerging
- Key finding: top seeds fully converged at 300s — 1800s training gives same results

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Mar 25, 2026
…5bps)

Major discoveries from extended seed sweep (s401-700):
- s507: +8273% ann @ 5bps, Sortino=6.43 — NEW #2 (5bps > 8bps, ultra-robust)
- s404: +7319% ann @ 5bps, Sortino=6.28 — NEW #3 (5bps ≈ 8bps, perfectly robust)
- s602: +2595% ann @ 5bps, Sortino=5.46 — new top-25
- s171: +2199% ann @ 5bps, Sortino=5.30 — new top-25

Updated 5bps top-5: s71(+9381%) > s507(+8273%) > s118(+7426%) > s404(+7319%) > s123(+6837%)

Active sweeps: 6 parallel crypto70 pools covering s121-700 (300s budget).
Redirected all 3 crypto15 pools to crypto70 (crypto15 maxes at +497% vs +9381% for c70).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Mar 25, 2026
… s602 #22 (+2595%), s704 #28 (+1927%)

Key finds from 7 parallel pools:
- s404: +7319%@5bps, Sortino=6.28, 5bps≈8bps (perfectly robust) — NEW #3 in production leaderboard
- s602: +2595%@5bps, Sortino=5.46, 5bps≈8bps (very robust) — NEW #22
- s704: +1927%@5bps, Sortino=5.36, 5bps≈8bps (very robust) — NEW #28
- s217-s218-s220 mini-cluster in s201-300 (+1196%/+1063%/+1171%@5bps)
- s171: +2199%@5bps (s121-200) — NEW #24
- Crypto15 600s retrain: all seeds << original 300s s78 (+141%/180d). Long sweep rule confirmed again.

s401-500/s501-600/s601-700/s701-800 sweeps all launched, monitors with champion auto-save running.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Mar 25, 2026
Seed s240 from the s201-300 sweep is the new production champion:
- 5bps: +17,642% ann, Sortino=7.00 — 88% better than previous champion s71 (+9,381%)
- 8bps: +40,405% ann, honest_val=18.32x in 180 days
- Pool_val=16.99, fully saved to champions dir
- Isolated spike: s239=+262%, s241=+448%

Also new today:
- s507: +8,273% @5bps (new #3)
- s520: +6,132% @5bps, Sortino=7.70 (new #8)
- s523: +5,919% @5bps, Sortino=7.56 (new #9)
- s404: +7,319% @5bps, Sort=6.28 (new #5)
- s416: +4,099% @5bps, Sort=6.19 (new #13)
- s609: +4,450% @5bps, Sort=5.04 (new #12)

7-9 parallel pool sweeps now covering s1-1000.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Mar 25, 2026
Leaderboard updated (169 evaluated at 5bps):
#1 s275: +23,595% (Sortino=9.0, ultra-robust: 5bps > 8bps)
#2 s240: +17,642%
#3 s434: +10,359%
#4 s71:  +9,381%
#5 s456: +8,802% (new)
#6 s507: +8,273%
#7 s452: +8,002% (new)

Top-10 mean: +10,796% ann | 7/10 ultra-robust (5bps >= 8bps)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 12, 2026
…age stress tests

- Document 2-model cross-variant ensemble: C s31 + D s29 u200 (adamw + muon)
  - 0/50 neg, med=18.84%, p10=6.25%, worst=+4.04%, sortino=48.81
  - Slippage stress test passed at 0/5/10/20 bps fill_buffer
- Fix key learning #3: same-variant ensemble hurts; cross-variant ensemble helps
- Update leaderboard with ensemble row and D s39 (6/50 neg)
- Update active sweep status (C 51-70 dead on TMPDIR crashes; current: 71-100, D 30-50)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 13, 2026
s87 is now #3 overall at +3315% ann (honest=4.70x/180d), beating s70 (+3303%)
s83 is #5 at +2527% ann (pool_val=3.75, wr=68.6%)
s85 is #8 at +1510% ann

All saved to crypto70_champions/. Long queue reordered: s71→s87→s70→s83...

crypto15: s78 still champion (+497% ann), 14/77 seeds genuine, at s129.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 13, 2026
s101 is the new #3 at 5bps (tied with s70 at +3487%):
- 5bps: p50=+3470% ann, p05=+3101% floor, Sortino=5.52, WR=65%
- 8bps: honest=4.88x (+3537% ann) — very consistent, robust seed!
- Now at position 3 in long queue (1800s): s92 → s71 → s101 → s87...

5bps production leaderboard update:
s71(+9381%) >> s70(+3487%) ≈ s101(+3470%) > s65(+3257%) > s87(+3074%) > s98(+2964%)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 13, 2026
- crypto70 long s61-120: s92(+10526%)=same, s71(+9827%)=same, s118(+8108%)=same, s123(+6191%)=same at 1800s
- crypto70 s121-200 (partial): s123=#3 (+6191%@8bps/+6837%@5bps), s129=+2873%@8bps/+4265%@5bps, s138=+4140%@8bps/+4230%@5bps
- crypto15 s50-200: s78 champion (+497%) still holds, s166(+322%), s161(+303%) emerging
- Key finding: top seeds fully converged at 300s — 1800s training gives same results

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 13, 2026
…5bps)

Major discoveries from extended seed sweep (s401-700):
- s507: +8273% ann @ 5bps, Sortino=6.43 — NEW #2 (5bps > 8bps, ultra-robust)
- s404: +7319% ann @ 5bps, Sortino=6.28 — NEW #3 (5bps ≈ 8bps, perfectly robust)
- s602: +2595% ann @ 5bps, Sortino=5.46 — new top-25
- s171: +2199% ann @ 5bps, Sortino=5.30 — new top-25

Updated 5bps top-5: s71(+9381%) > s507(+8273%) > s118(+7426%) > s404(+7319%) > s123(+6837%)

Active sweeps: 6 parallel crypto70 pools covering s121-700 (300s budget).
Redirected all 3 crypto15 pools to crypto70 (crypto15 maxes at +497% vs +9381% for c70).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 13, 2026
… s602 #22 (+2595%), s704 #28 (+1927%)

Key finds from 7 parallel pools:
- s404: +7319%@5bps, Sortino=6.28, 5bps≈8bps (perfectly robust) — NEW #3 in production leaderboard
- s602: +2595%@5bps, Sortino=5.46, 5bps≈8bps (very robust) — NEW #22
- s704: +1927%@5bps, Sortino=5.36, 5bps≈8bps (very robust) — NEW #28
- s217-s218-s220 mini-cluster in s201-300 (+1196%/+1063%/+1171%@5bps)
- s171: +2199%@5bps (s121-200) — NEW #24
- Crypto15 600s retrain: all seeds << original 300s s78 (+141%/180d). Long sweep rule confirmed again.

s401-500/s501-600/s601-700/s701-800 sweeps all launched, monitors with champion auto-save running.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 13, 2026
Seed s240 from the s201-300 sweep is the new production champion:
- 5bps: +17,642% ann, Sortino=7.00 — 88% better than previous champion s71 (+9,381%)
- 8bps: +40,405% ann, honest_val=18.32x in 180 days
- Pool_val=16.99, fully saved to champions dir
- Isolated spike: s239=+262%, s241=+448%

Also new today:
- s507: +8,273% @5bps (new #3)
- s520: +6,132% @5bps, Sortino=7.70 (new #8)
- s523: +5,919% @5bps, Sortino=7.56 (new #9)
- s404: +7,319% @5bps, Sort=6.28 (new #5)
- s416: +4,099% @5bps, Sort=6.19 (new #13)
- s609: +4,450% @5bps, Sort=5.04 (new #12)

7-9 parallel pool sweeps now covering s1-1000.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 13, 2026
Leaderboard updated (169 evaluated at 5bps):
#1 s275: +23,595% (Sortino=9.0, ultra-robust: 5bps > 8bps)
#2 s240: +17,642%
#3 s434: +10,359%
#4 s71:  +9,381%
#5 s456: +8,802% (new)
#6 s507: +8,273%
#7 s452: +8,002% (new)

Top-10 mean: +10,796% ann | 7/10 ultra-robust (5bps >= 8bps)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 13, 2026
…age stress tests

- Document 2-model cross-variant ensemble: C s31 + D s29 u200 (adamw + muon)
  - 0/50 neg, med=18.84%, p10=6.25%, worst=+4.04%, sortino=48.81
  - Slippage stress test passed at 0/5/10/20 bps fill_buffer
- Fix key learning #3: same-variant ensemble hurts; cross-variant ensemble helps
- Update leaderboard with ensemble row and D s39 (6/50 neg)
- Update active sweep status (C 51-70 dead on TMPDIR crashes; current: 71-100, D 30-50)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 19, 2026
…uy price (HARD RULE #3)

Prior to this fix xgbnew/live_trader.py submitted raw Alpaca MarketOrderRequests
without feeding either side of the death-spiral guard:

  - BUY path never called record_buy_price() → guard had no cost basis.
  - SELL path never called guard_sell_against_death_spiral() → runaway
    panic-sells at >50 bps below the most recent buy would NOT crash the loop.

This violated HARD RULE #3 in CLAUDE.md for any future live deploy.

Changes
-------
- BUY: poll the submitted order's filled_avg_price (new
  _poll_filled_avg_price helper, 30s timeout) and feed that to
  record_buy_price; fall back to last_close if the fill poll times out.
- SELL: new _get_position_details helper reads current_price +
  avg_entry_price from Alpaca's Position objects; guard fires with
  current_price before each submit. Guard RuntimeError propagates (the
  documented "crash the loop" behaviour), supervisor autorestart handles
  the rest.
- Both paths now import from src.alpaca_singleton so the state lives in
  the same alpaca_live_writer_buys.json that alpaca_wrapper uses.

Tests
-----
- tests/test_xgbnew_live_trader_guard.py (new, 6 tests): filled-avg-price
  poll happy path + cancel path, Position detail extraction, guard
  raise/allow round-trip with 50 bps tolerance, buy-price round-trip
  to disk.
- tests/test_alpaca_singleton.py (16 tests) still green — HARD RULE #4.
lee101 added a commit that referenced this pull request Apr 19, 2026
…emble

Supervisor unit xgb-daily-trader-live (pid 2343601) holds the
alpaca_live_writer singleton lock as of 2026-04-19 10:40 UTC. First
real trading session Monday 2026-04-20 09:30 ET.

Replaces daily-rl-trader + trading-server (both stopped). XGB OOS
backtest is +32.48%/mo median, 0/34 neg windows — structural beat over
the RL ensemble's +7.47%/mo.

HARD RULE #3 enforced via record_buy_price + guard_sell_against_death_spiral
in xgbnew/live_trader.py (commit 83b9a62).
lee101 added a commit that referenced this pull request Apr 19, 2026
New path: run_session_hold_through. When today's picks == held
positions, skip the round-trip entirely. When picks differ, sell
only dropped-out names and buy only new entries at the open. No
15:50 close-sell; positions carry across gaps and are reassessed
next session.

HARD RULE #3 preserved: every sell still calls
guard_sell_against_death_spiral with a real price before submit.
Every buy still records fill via record_buy_price.

Gated behind --hold-through (default False → legacy buy-at-open
+ sell-at-close unchanged). Backtest-validated Δmed +2.17%/mo
at lev=1.0, +2.54%/mo at lev=1.25, same 4/113 neg
(docs/xgbnew_hold_through_20260419.md).

9 new tests cover the rotation decision table:
  - flag default off / on
  - held == picks → no orders
  - held ∖ picks → sell-with-guard
  - picks ∖ held → buy-with-record
  - intersection carried (no trade)
  - flat → picks (fresh entry)
  - non-trading-day gate skips scoring
  - dry-run submits nothing
  - run_session dispatches to hold_through

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 19, 2026
Activate hold_through + min_score=0.85 + allocation=2.0 on the live 5-seed
alltrain ensemble. Prior bare lev=1 alloc=0.25 snapshot archived to
old_prod/2026-04-19-1040-xgb_alltrain_lev1_bare.md.

Ensemble OOS 60-window validation (2025-01 → 2026-04-19):
  deploy-cost (fb=5 fee=0.28): +141%/mo med, p10 +96%, 0/60 neg
  36× fee stress (fb=15 fee=10): +108%/mo med, p10 +68%, 0/60 neg

HARD RULE #3 enforced via record_buy_price + guard_sell_against_death_spiral
in both run_session and run_session_hold_through.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 22, 2026
…bps / overnight 500bps)

The death-spiral guard's flat 50 bps tolerance is correct for same-day
round-trips (09:30 → 15:50) but crashes the daemon in a restart loop
when hold-through mode rotates positions at next-open and a normal
overnight drop of 100-300 bps is observed.

Tolerance is now regime-aware based on the age of the recorded buy:
- age ≤ 8h  → tight 50 bps intraday (catches intra-session scraping)
- age > 8h  → wide 500 bps overnight (survives normal gap, still catches
              catastrophic >5% gap-downs — halt, delisting, bad fill)
- explicit tolerance_bps= on the call overrides regime selection

HARD RULE #3 preserved: guard still raises RuntimeError and crashes the
loop on refusal; supervisor autorestart is the intended behaviour. New
refusal log line includes regime label so post-mortems are readable.

4 new tests (overnight allow / overnight refuse on big crash / intraday
still tight / explicit override). 20/20 singleton tests green, 41/41
singleton + live-trader-guard + hold-through tests green.

CLAUDE.md + AGENTS.md HARD RULE #3 updated in lockstep per CLAUDE.md
directive.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 22, 2026
…points

Motivation: code-quality pass before further prod hardening. `radon cc -s -n C`
on the live-trading entry point found three offenders:

  run_session              CC 48 (F)  →  13 (C)
  run_session_hold_through CC 43 (F)  →  11 (C)
  main                     CC 21 (D)  →  below threshold

Extracted 9 helpers (pure and independently testable):

  _emit_session_start(tlog, args, client, *, mode)
  _wait_for_market_open()
  _announce_picks(picks, today_str, top_n, tlog, *, tag)
  _execute_buys(client, picks, buy_notional, tlog, *, target_syms=None)
  _execute_sells(client, position_details, sell_syms, tlog)
  _load_models(args)
  _next_session_open_et(now_et)
  _sleep_until_next_session()
  _make_trade_logger(args, session_date)

Behavioral invariants preserved:

  - HARD RULE #3: every sell runs `guard_sell_against_death_spiral` before
    `_submit_market_order` (covered by test_execute_sells_calls_guard_before_submit).
  - Buy prices recorded via `record_buy_price` for each fill
    (test_execute_buys_records_buy_price_for_each_fill).
  - fill_price→last_close fallback preserved in buy logging.
  - avg_entry_price fallback on current_price==0 preserved in sell loop.
  - trade-log event sequence (session_start / scored / filtered / pick /
    buy_submitted / buy_filled / sell_submitted / session_end) unchanged.

Tests: tests/test_xgbnew_live_trader_helpers.py — 22 helper tests, all green.
Full xgbnew suite still passes in isolation. No behavior change is intended.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 22, 2026
…_bps/1e4

Brings C env exit accounting onto parity with evaluate_holdout.py. Before
this, close_position on trading_env.c:358-364 deducted only fee_rate and
ignored fill_slippage_bps entirely, so PPO training saw a rosier exit
than the Python eval sim / prod. Backward compatible: fill_slippage_bps
defaults to 0 in binding.c, preserving legacy fee-only behavior.

Integration test (wide flat bars, fee=0, slip=10bps) asserts round-trip
total_return ≈ -0.002 (entry+exit both slipped); regression to fee-only
would show -0.001 one-sided.

_write_mktd_v1_binary now accepts range_bps so future probes can make
room for entry-side slippage inside the bar; death-spiral tests stay
flat by default.

250 pufferlib_market regression tests green.

Closes audit priority #3 from project_sim_audit_2026_04_22.md.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
lee101 added a commit that referenced this pull request Apr 23, 2026
… acceptance

Mirrors hourly_replay._resolve_limit_fill_price: market must overshoot the
target by fill_buffer_bps before the C env accepts the fill. buffer=0 (the
default) preserves existing classical "target-in-bar" semantics, so no
training-run behaviour changes until a caller sets a positive value.

Closes the last outstanding item in project_sim_audit_2026_04_22.md priority #3
(binding.c default swap to 5/5 intentionally deferred — that would invalidate
all existing checkpoints' training-dynamics comparisons and should land with
its own retraining memo).

Test coverage:
  test_c_env_buffer_zero_fills                — default path still fills
  test_c_env_buffer_blocks_fill_when_market_too_tight
                                              — buffer > bar range → no fill
  test_c_env_buffer_boundary_just_fits        — inclusive trigger
  test_c_env_buffer_negative_clamped_to_zero  — binding.c clamp

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant