Commit Graph

3674 Commits

Author SHA1 Message Date
jgrusewski
6208ace512 fix(critical): backtest single-step uses 4-branch action encoding
Legacy 3-branch action decode/encode in backtest_env_step was
corrupting actions_history. Now uses correct 4-branch factored
logic matching backtest_env_step_batch. Fixes backtest metrics.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 02:03:10 +02:00
jgrusewski
58c2bd7ae0 fix: eliminate non-deterministic atomicAdd from gradient kernels
selectivity_backward, risk_budget_backward, mamba2_scan_backward,
q_denoise_backward — all converted to per-weight-element accumulation
(one thread per weight, loops over batch) with plain deterministic
writes. Zero atomicAdd in these gradient paths.

recursive_confidence_backward, temporal_consistency_penalty,
predictive_coding_loss, compute_expected_q atom_stats — converted to
warp+block tree reduction, reducing to one atomicAdd per BLOCK
(8x fewer warps → near-deterministic).

kan_gate_backward, curiosity, DT linear — documented remaining
atomicAdd as acceptable (auxiliary components, not on primary DQN
gradient path).

Rust launchers updated: grid dimensions now match per-weight-element
thread counts for selectivity, mamba2, and denoise backward kernels.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:52:10 +02:00
jgrusewski
9775e5c48b feat(tick): TickProcessor — real-time Databento MBP-10 → 20 features
OFICalculator + MicrostructureState fed per-tick. Bar close snapshots
and broadcasts 20 features via tokio::watch channel. Intermediate
snapshots available for speculative compute between bars.
Databento live client integration deferred (requires crate dep).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:39:30 +02:00
jgrusewski
e5973027a1 feat(tick): speculative inference cache — H100 between-bar pre-computation
speculative_forward() pre-computes from intermediate features.
check_speculative_cache() validates cache vs actual bar-close features
(5% relative L2 threshold). invalidate_speculative_cache() at bar
boundary. Full cuBLAS trunk integration deferred — cache infra ready.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:38:05 +02:00
jgrusewski
55821af90d fix: argo-precompute.sh uses train workflow + regenerated v2 fxcache
Script rewritten to use argo submit --from=wftmpl/train with
train-epochs=0 — runs ensure-binary + ensure-fxcache only.
Local test fxcache regenerated with FXCACHE_VERSION=2, OFI_DIM=20.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:29:42 +02:00
jgrusewski
61c4b043c6 feat: fxcache version auto-invalidation — FXCACHE_VERSION=2
Version constant in fxcache.rs. validate() rejects stale versions
with clear error message. ensure-fxcache Argo template now deletes
old cache and regenerates unconditionally. No manual PVC cleanup
needed — version mismatch triggers automatic regeneration.
v2: OFI_DIM=20 (20 microstructure features).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:27:33 +02:00
jgrusewski
b6314ceec1 feat(plan): plan activation + enforcement + direction lock
Flat->Positioned copies plan_params to ps[23-29]. Auto-exit on
profit_target (ISV*asymmetry), stop_loss (ISV-modulated), target_bars,
regime_stability<0.3. Scale schedule via scale_aggression. Conviction
sizing. Direction locked during active plan. Wired trainer->collector.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:24:20 +02:00
jgrusewski
6cf09e0806 feat(plan): trade_plan_forward kernel + 4 weight tensors (82->86)
Plan MLP: h_s2 -> hidden[AH] -> plan_params[B, 6]. Outputs:
target_bars[3-25], profit_target[0.05-1.5%], stop_loss[0.02-0.5%],
scale_aggression[0-1], conviction[0-1], asymmetry[0.5-3.0].
NUM_WEIGHT_TENSORS: 82->86.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:17:57 +02:00
jgrusewski
242c18f4ab feat: argo-precompute.sh — regenerate fxcache on PVC
Usage: ./scripts/argo-precompute.sh [--branch main] [--watch]
Deletes old fxcache, builds precompute binary, runs with MBP-10 +
trades data. OFI_DIM=20 (20 microstructure features). ~5-10 min.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:14:46 +02:00
jgrusewski
c7a2e39c1e feat(plan): PORTFOLIO_STRIDE 23→30 — 7 plan slots ps[23-29]
Plan slots: target_bars, profit_target, stop_loss, scale_aggression,
conviction, asymmetry, counter_plan_q. Zeroed on episode reset.
Fixed hardcoded i*23 references. All CUDA + Rust files updated.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:13:36 +02:00
jgrusewski
a1f967db88 fix: add epoch_sharpe + val_loss to training metrics additional_metrics map
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:09:48 +02:00
jgrusewski
1cc6168a6b fix: backtest action_select missing isv_signals_ptr + regenerated fxcache
Backtest evaluator missing isv_signals_ptr arg (passed as NULL).
Regenerated test fxcache with OFI_DIM=20 from MBP-10 + trades data.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:07:45 +02:00
jgrusewski
61f2ba3cb2 feat: MBP-10 data loading always enabled by default
mbp10_data_dir and trades_data_dir uncommented in localdev config.
Doc comments updated: 20 microstructure features always appended.
OFI is no longer optional — it's core to the model's feature set.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:02:54 +02:00
jgrusewski
f1af119f24 feat(isv): per-feature temporal routing — ISV controls history depth
isv_temporal_route kernel: ISV embedding [8] → temporal_weight [SH2].
mamba2_temporal_scan: h_enriched = h_s2 + temporal_weight * context.
Each feature gets learned history depth based on ISV state.
Init bias=2.0 (sigmoid≈0.88, mostly use temporal). 2 new tensors.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 01:02:37 +02:00
jgrusewski
d6a2e99670 feat(isv): feature-level ISV gating — which features matter per regime
isv_feature_gate kernel: ISV embedding [8] → per-feature gate [SH2].
h_s2 *= sigmoid(w_gate @ isv_emb + b_gate). Near pass-through init
(bias=2.0 → sigmoid≈0.88). Model learns to amplify/suppress features
based on ISV state. 2 new tensors [78-79]. NUM_WEIGHT_TENSORS: 78→80.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:56:52 +02:00
jgrusewski
750b228ed9 plan: Trade Plan Head — 5 tasks, hierarchical plan-based trading
Task 1: PORTFOLIO_STRIDE 23→30, plan slots ps[23-29]
Task 2: trade_plan_forward kernel + 4 weight tensors (82→86)
Task 3: Plan activation + enforcement in env_step
Task 4: Direction lock in action_select + counter-plan Q (N14)
Task 5: Smoke test + compute-sanitizer

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:48:18 +02:00
jgrusewski
76d6b54bff feat(isv): risk branch SH2+9→SH2+13 — all 12 ISV signals + predicted_error
w_risk_fc grows from AH*(SH2+9) to AH*(SH2+13). Risk branch now
sees all 12 ISV signals (including 4 regime: velocity, disagreement,
transition_ema, stability) + predicted_error. Forward + backward
updated with wider stride and 12-signal loop.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:47:03 +02:00
jgrusewski
102adf7703 spec: fix trade plan head — ps[23-29] (was 16-22 collision), STRIDE 23→30
Portfolio slots ps[15]-ps[19] are Kelly accumulators (active).
Plan params moved to ps[23]-ps[29]. PORTFOLIO_STRIDE grows 23→30.
Fixed asymmetry: scales profit_target only (not stop_loss).
Clarified epsilon mid-plan: overridden by direction lock (intended).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:44:20 +02:00
jgrusewski
2aae3ceec7 feat(isv): regime-conditioned Mamba2 decay — forget old patterns during transitions
mamba2_temporal_scan forget gate multiplied by regime_stability (ISV[11]).
Stable regime (stability=1.0): full history preserved.
Transition (stability=0.3): gate capped at 0.3 → rapid forgetting.
Model adapts to new regime within 2-3 bars. Backward matches forward.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:42:14 +02:00
jgrusewski
1acb23cb24 spec: Trade Plan Head — hierarchical plan-based trading
Plan head outputs 6 params at entry: target_bars, profit_target,
stop_loss, scale_aggression, conviction, asymmetry. Model commits
to plan, bar-by-bar execution constrained. Auto-exit on target/stop/time.

Pearls: P8 learned stops, P9 Kelly conviction, P10 options framework.
Gems: G8 asymmetric R/R, G9 pyramiding, G10 learned termination.
Novels: N13 plan-conditioned Q, N14 counter-plan evaluation,
N15 plan replay priority, N16 ISV-modulated plan parameters.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:41:05 +02:00
jgrusewski
8a746fceb2 feat(isv): regime awareness — ISV_DIM 8→12, 4 regime signals
regime_velocity (EMA of ADX+CUSUM deltas), regime_disagreement
(|norm_ADX - norm_CUSUM|), regime_transition_ema, regime_stability
(1 - sigmoid(5*velocity)). Read from states buffer sample 0.
isv_signal_update + isv_forward kernels updated. w_isv_fc1 grows
16*8→16*12. Pinned buffers resized automatically via ISV_DIM.
Introduced ISV_EMB_DIM=8 to decouple embedding output from signal
input dimension — FC2/gate/gamma stay at 8.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:34:49 +02:00
jgrusewski
8b68954ded feat(tick): precompute pipeline wires MicrostructureState — 20 OFI features
12 new tick-level features computed per bar from MBP-10 snapshots:
OFI trajectory, realized variance, Hawkes intensity, book pressure,
spread dynamics, aggression, queue depletion, order count flux,
intra-bar momentum, regime score, OFI acceleration, toxicity gradient.
Combined with existing 8 OFI into [f64; 20] per bar in fxcache.

Also fixes pre-existing bug: no-MBP-10 fallback was [0.0; 8] not [0.0; 20].

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:29:03 +02:00
jgrusewski
b2d7af0763 feat: adaptive hold in BOTH layers — action select + enforce_hold
Layer 1 (experience_action_select): isv_signals_ptr param added.
Adaptive hold = base + stability × confidence × 8 extension.
Layer 2 (enforce_hold in env_step): already had adaptive hold.
Both layers use identical ISV-driven formula. Consistent behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:25:44 +02:00
jgrusewski
81771d7920 feat(tick): OFI_DIM 8→20 — atomic update across 15 files
fxcache: OFI_DIM=20 (pub const), RECORD_F64_COUNT=66, 272 bytes/bar.
constructor: state_dim 74→86 (aligned 88) with OFI.
experience collector: ofi_dim detection 8→20.
All [f64; 8] → [f64; 20]. Existing 8 features preserved at 0-7.
New 12 features zero-padded until precompute is extended.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:21:15 +02:00
jgrusewski
06be03effb feat: adaptive hold enforcement — ISV-driven dynamic minimum hold time
enforce_hold() reads ISV signals: grad_norm (stability), ensemble_var
(confidence), reward_ema (performance). Adaptive hold = base(5) +
extension(0-8 bars from stability × confidence). Negative reward_ema
reduces to base only (allow faster exit when losing).

ISV signals passed from trainer → fused_ctx → experience collector →
env_step kernel via isv_signals_dev_ptr. NULL = static hold (backtest).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:09:57 +02:00
jgrusewski
4d08472d95 feat(tick): MicrostructureState — 12 new tick-level features, O(1)/tick
OFI trajectory (online LinReg), realized variance, Hawkes intensity,
book pressure gradient, spread dynamics, aggression ratio, queue
depletion, order count flux, intra-bar momentum (Welford), regime
score, OFI acceleration, toxicity gradient. ExtendedOFIFeatures [20].

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:06:32 +02:00
jgrusewski
ddb7b170bc plan: Tick Microstructure Intelligence — 4 tasks, OFI_DIM 8→20
Task 1: IncrementalMicrostructureCalculator (12 new features, O(1)/tick)
Task 2: fxcache OFI_DIM 8→20 atomic update (15 files, 30+ locations)
Task 3: Extend precompute pipeline with MicrostructureState
Task 4: Regenerate fxcache + smoke test + compute-sanitizer

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:02:02 +02:00
jgrusewski
460a5f3841 feat: adaptive minimum hold time — 5-bar minimum prevents coin-flip exits
The hold enforcement infrastructure (enforce_hold in trade_physics.cuh,
hold_time counter at ps[10], action masking in experience_action_select)
was already fully implemented but disabled by min_hold_bars defaulting
to 1. Change default from 1 to 5 so hold enforcement is active by
default. Production configs already set min_hold_bars=10 via TOML.
Targets ~100-200K trades instead of 619K across 5M bars.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-17 00:02:01 +02:00
jgrusewski
7deaa88d83 feat(isv): target network — ISV weights online-only
EMA sync restricted to indices 0-67 (non-ISV params).
ISV weights (68-77) exist only in online params_buf.
Target forward uses online gamma_buf (drift-conditioned) and
online branch_gate_buf — correct for Bellman projection.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:52:38 +02:00
jgrusewski
1d958c7ab9 spec: Phase 4 adaptive minimum hold time — prevent coin-flip exits
3-bar base + regime_stability extension (0-12) + confidence extension
(0-3) = adaptive 3-18 bar minimum hold. Only prevents exits, not
entries. Targets 100-200K trades instead of 619K.

Pearl: P7 hard minimum hold. Gem: G7 regime-conditioned extension.
Novel: N12 ISV-driven hold confidence.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:51:45 +02:00
jgrusewski
e1f234cd82 feat(isv): recursive confidence head — model predicts own TD-error
h_s2 → sigmoid(w_conf @ h + b_conf) → predicted_error [B].
MSE loss vs lagged_td_error (0.01× weight). Backward accumulates
into trunk gradient + conf weight gradients in main grad_buf.
Creates self-improvement loop: model learns to predict when wrong.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:46:18 +02:00
jgrusewski
e6b3fffa6d spec: fix 4 critical issues from review — OFI_DIM cascade, deploy atomicity
1. Enumerate all 6+ files with hardcoded OFI_DIM=8 literal
2. Document atomic deploy requirement (code + fxcache together)
3. Rename Depth Renewal Rate → Order Count Flux (MBP-10 approximation)
4. Fix Intra-Bar Momentum to Welford online covariance (O(1), no Vec)
5. Clarify snapshot() is pure read, non-mutating, idempotent
6. Fix precompute time: 8s CPU + 5min I/O = ~5-10min total

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:43:55 +02:00
jgrusewski
a2587fd087 spec: Tick-Level Microstructure Intelligence — 12 new features from MBP-10
OFI_DIM: 8→20. IncrementalMicrostructureCalculator: O(1) per tick.
Pearls: OFI trajectory, realized variance, Hawkes trade intensity.
Gems: book pressure gradient, spread dynamics, aggression ratio,
queue depletion, depth renewal rate.
Novels: intra-bar momentum, microstructure regime score, order flow
acceleration, toxicity gradient, speculative H100 inference (N10),
mid-bar regime early warning (N11).

Databento (GLBX.MDP3, mbp-10) for all tick data. IBKR execution only.
fxcache single format, regenerate all files.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:39:36 +02:00
jgrusewski
42964437fc feat(isv): risk branch wider input SH2→SH2+9 — ISV + predicted_error
risk_budget_forward: h_s2 || isv_signals[8] || predicted_error[1].
risk_budget_backward: wider stride j*(SH2+9), grads for ISV+error cols.
w_risk_fc grows from AH*SH2=32768 to AH*(SH2+9)=33920 (+1152 elems).
risk_aligned_count and offset callers updated atomically.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:30:17 +02:00
jgrusewski
4c917d83d2 feat(isv): branch confidence routing replaces regime_branch_gate
ISV gate [4] × Q-value separation confidence per branch.
Market regime (ADX, CUSUM) still flows through trunk → branches.
ISV adds training dynamics awareness on top.
Confidence = sigmoid(5 * (Q_max - Q_mean)) per branch, floor 0.3.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:25:33 +02:00
jgrusewski
ad402deec7 feat(isv): drift-conditioned gamma — C51 scalar→per-sample buffer
c51_loss_kernel: float gamma → const float* gamma_buf [B].
fill_gamma_buf kernel: broadcasts base_gamma * gamma_mod[0] to [B].
gamma_mod from isv_forward ∈ [0.5, 1.0] → effective_gamma ∈
[base_gamma*0.5, base_gamma]. Model learns its own planning horizon.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:21:07 +02:00
jgrusewski
2acaaeaacd spec: Phase 3 dynamic inference brain — feature gating + temporal routing
7 adaptive pathways modulated by ISV at inference: feature gating
(WHICH features matter), temporal routing (HOW MUCH history per
feature), branch gating, gamma mod, risk budget, Mamba2 decay,
branch confidence. Model adapts to unseen regimes in 2-3 bars.

Pearls: P6 feature-level ISV gating.
Gems: G6 per-feature temporal routing.
Novels: N8 dynamic inference adaptation, N9 graceful cold start.
4 new weight tensors (78-81), 4608 params. Tasks 14-16.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:11:39 +02:00
jgrusewski
ffc8c1c46a feat(isv): ISV encoder MLP + branch gating + gamma modulation
isv_forward kernel: temporal decay-weighted average + 8->16->8 MLP.
Outputs: isv_embedding [8], branch_gate [4] (softmax), gamma_mod [1]
(0.5+0.5*sigmoid -> [0.5,1.0]). NUM_WEIGHT_TENSORS: 68->78.
10 new tensors for ISV encoder, gate, gamma, and confidence head.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:10:13 +02:00
jgrusewski
b0d67f0f8a spec: Phase 2 regime awareness — ISV_DIM 8→12, cross-regime adaptation
4 new ISV signals: regime_velocity (d(ADX)/dt + d(CUSUM)/dt),
regime_disagreement (|norm_ADX - norm_CUSUM|), regime_transition_ema,
regime_stability (1 - sigmoid(5*velocity)).

Pearls: P4 regime velocity, P5 regime disagreement.
Gems: G4 regime-aware ISV, G5 soft regime mixture.
Novels: N6 cross-regime Mamba2 decay, N7 regime-conditioned gamma.

Tasks 10-13 added for Phase 2 implementation after core ISV.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:06:12 +02:00
jgrusewski
a9f9b279f9 feat(isv): isv_signal_update GPU kernel + temporal history
8 ISV signals (q_drift, grad_norm_ema, td_error_ema, ensemble_var_ema,
ensemble_var_delta, reward_ema, atom_util, loss_ema) computed by
single-thread GPU kernel. Temporal history [K=4, 8] with ring buffer.
Lagged TD-error saved for recursive confidence. Zero CPU involvement.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 23:01:38 +02:00
jgrusewski
f9d90f864b feat(isv): add 4 pinned scratch scalars for ISV signal sources
td_error_scratch, ensemble_var_scratch, reward_scratch, atom_util_scratch
— all pinned device-mapped. atom_util and reward_scratch written in
reduce_current_q_stats. td_error and ensemble_var wired in later tasks.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 22:54:23 +02:00
jgrusewski
6dd2f3e68b plan: Introspective State Vector — 9 tasks, pure GPU implementation
Task 1: ISV scratch scalars (piggyback on existing kernels)
Task 2: isv_signal_update GPU kernel + temporal history
Task 3: ISV encoder MLP + weight tensors 68→78
Task 4: Drift-conditioned gamma (C51 scalar→per-sample buffer)
Task 5: Branch confidence routing (replaces regime_branch_gate)
Task 6: Risk branch wider input SH2→SH2+9
Task 7: Recursive confidence head (predict own TD-error)
Task 8: Target network ISV online-only
Task 9: Smoke test + compute-sanitizer verification (0 errors)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 22:46:54 +02:00
jgrusewski
60a82d538b spec: Introspective State Vector (ISV) — model self-awareness module
Replaces hardcoded Q-drift penalty with learnable self-awareness:
8 ISV signals (q_drift, grad_norm, td_error, ensemble_var, velocity,
reward, atom_util, loss) computed by pure GPU kernel, fed through
encoder MLP (8→16→8) for branch gating + drift-conditioned gamma +
risk branch input. Includes recursive confidence head (predict own
TD-error), branch confidence routing (replaces regime_branch_gate),
and temporal ISV memory (K=4 rolling buffer with learned decay).
10 new weight tensors (68→78), 582 new params, ~39KB VRAM.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 22:40:23 +02:00
jgrusewski
b946802803 feat: adapted rank norm (skip zeros) + remove Q-drift penalty + aligned Sharpe
Rank normalization: holding bars (reward≈0) passthrough as zero,
only actual trade P&L is ranked. Preserves magnitude for trades.
Q-drift: hardcoded penalty removed, E1 enrichment handles adaptively.
Metrics: sharpe_raw (un-annualized per-trade) for direct comparison
between training and validation.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 22:03:28 +02:00
jgrusewski
c74a687ea8 feat: position-gated episodes + 5000-bar limit — close 45x training/val gap
Episode done flag: timer-based -> position-gated (trade complete = done).
V(flat)=0 is correct terminal anchor. Soft reset keeps equity on
trade completion; hard reset only on data-end or capital breach.
H100: 100 bars -> 5000 bars, gpu_n_episodes -> 1024.
ExperienceProfile gains optional gpu_n_episodes field.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 21:56:44 +02:00
jgrusewski
685746231b plan: Training Environment Alignment — 5 tasks, 3 phases
Phase 1: Position-gated episodes (h100.toml + done flag + soft reset)
Phase 2: Adapt rank norm (skip zeros) + remove hardcoded Q-drift
Phase 3: Aligned Sharpe metrics (un-annualized per-trade)
Phase 4: Build verification + smoke test

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 21:49:19 +02:00
jgrusewski
3e683f1053 spec: adapt components instead of removing — DSR on trade P&L, rank non-zeros only
Components were fighting a broken signal, not broken themselves.
With correct signal: adapt DSR to trade-level, rank only non-zero
rewards, keep commitment as soft signal, let E1 enrichment handle
Q-drift instead of hardcoded kernel penalty.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 21:44:35 +02:00
jgrusewski
4a32b9f8b0 spec: Training Environment Alignment — single path to close the 45× gap
Root cause: training environment differs from validation backtest in 3 ways:
1. 100-bar episodes force exits (val runs continuous) → position-gated done
2. Rank normalization destroys sparse trade-level reward → remove it
3. Different Sharpe computation (per-trade vs per-bar, different annualization)

Single execution path:
Phase 1: Episode alignment (100→5000 bars, position-gated done, soft reset)
Phase 2: Reward alignment (remove rank norm, raw trade P&L to replay)
Phase 3: Metrics alignment (un-annualized per-trade Sharpe, both paths)

Expected: training Sharpe within 2× of validation with same weights.
Removes 5 unnecessary shaping components that fought the broken signal.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 21:38:06 +02:00
jgrusewski
a83b4a97f1 results: raw_next fix verdict — training Sharpe +0.19 avg, peak 1.02, WinRate 25%
Root cause: experience collector used raw_next (future price) for P&L,
creating 1-bar action-reward misalignment. 30+ H100 runs couldn't
overcome this. Fix: use raw_close only + trade-level P&L.

Result: WinRate 45%→25% (selective), Sharpe 0→+0.19 avg,
peak 1.02 (3 times), PF 1.09, 67% positive epochs.
First genuine asymmetric trading strategy in the project.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 20:22:27 +02:00
jgrusewski
7fc455ebff fix: widen E1 Q-correction clamp ±2.0 → ±10.0
Q-mean drifted to +4.6 but E1 correction was capped at -2.0.
The model needs full correction range to keep Q-values calibrated.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-16 19:57:13 +02:00