jgrusewski
285d42aa7b
feat(rl): adaptive risk-management stack — 5 layers, all ISV-driven
Layered risk stack per spec docs/superpowers/specs/2026-05-30-adaptive-risk-management-design.md:
Layer 1 (CMDP) hard session-DD, cooldown, max-open, inventory limits
Layer 2 (IQN τ) risk-averse action selection adapts to session drawdown
Layer 3 (Inventory) Avellaneda-Stoikov penalty β scales with reward magnitude
and inventory variance
Layer 4 (Kelly) half-Kelly fraction sizing from observed win-rate +
R-multiple, warmup-gated until cumulative_dones >= 1000
Layer D (Trail) wire dead a7/a8 (TrailTighten/Loosen) via independent
ISV factors, replacing the symmetric reciprocal
Architecture: every threshold ISV-driven (22 new slots, RL_SLOTS_END 662→684).
Every adaptive bound follows the canonical Wiener-α blend with floor 0.4,
sentinel-zero bootstrap, and asymmetric Schulman where applicable.
Kernels:
rl_cmdp_constraints_check session pnl + cooldown + consec-loss tracking
rl_iqn_action_tau_controller τ = clamp(0.5 - 5·dd_frac, τ_min, 1.0)
rl_inventory_beta_controller β_target = 0.01·E|reward| / (2·σ_inventory)
rl_kelly_fraction_controller f = clamp(safety · (p·b - q)/b, 0, 1)
rl_win_rate_ema_update closed-trade win-rate EMA from rewards + dones
rl_avg_win_loss_ema_update separate avg-win and avg-loss EMAs
rl_inventory_variance_update Welford variance of net-position-per-batch
Integration:
- All 7 new cubins loaded in IntegratedTrainer + launched per step in spec order
(CMDP after reward pipeline, before actions_to_market_targets reads override
flags; Layer 2/3/4 controllers in rl_fused_controllers.cu).
- actions_to_market_targets.cu: Layer 1 hard overrides (DD-triggered → 0 lots;
cooldown → 0 lots; max-open → block opening actions; inventory cap → block
one-sided expansion) and Layer 4 Kelly fraction scaling on target lots.
- rl_fused_reward_pipeline.cu: Layer 3 inventory penalty term in reward shaping.
- rl_trail_mutate.cu: a7 multiplies trail by RL_TRAIL_TIGHTEN_FACTOR_INDEX,
a8 by RL_TRAIL_LOOSEN_FACTOR_INDEX (was symmetric reciprocal — pearls
pearl_dead_trail_stop_actions_a7_a8).
Validation:
- 12 GPU-oracle invariants pass (tests/risk_stack_invariants.rs):
G1-G4 CMDP, G5-G7 IQN τ, G8-G9 inventory β, G10-G12 Kelly.
- 20/20 trade_management_kernels.rs tests pass (a7/a8 migrated).
- 5/5 controller_adaptive_floors.rs tests still pass.
- integrated_trainer_smoke passes (end-to-end pipeline launch).
- Local 1k smoke b=128: completes 1000/1000 steps, no NaN, controllers steady.
- compute-sanitizer memcheck (5 steps b=128): ERROR SUMMARY: 0 errors.
Plan: docs/superpowers/plans/2026-05-30-adaptive-risk-management-plan.md
2026-05-30 20:52:28 +02:00
..
2026-04-02 21:26:24 +02:00
2026-04-02 23:29:04 +02:00
2026-04-02 23:29:04 +02:00
2026-04-04 08:56:44 +02:00
2026-04-04 08:56:44 +02:00
2026-04-03 08:46:30 +02:00
2026-04-04 11:49:13 +02:00
2026-04-04 11:12:47 +02:00
2026-04-04 09:36:10 +02:00
2026-04-04 01:02:00 +02:00
2026-04-05 21:45:51 +02:00
2026-04-06 11:15:24 +02:00
2026-04-07 13:58:11 +02:00
2026-04-06 11:15:24 +02:00
2026-04-07 23:14:40 +02:00
2026-04-07 23:14:40 +02:00
2026-04-08 01:26:09 +02:00
2026-04-07 23:14:40 +02:00
2026-04-08 20:05:22 +02:00
2026-04-08 02:25:58 +02:00
2026-04-08 10:03:54 +02:00
2026-04-08 14:12:12 +02:00
2026-04-08 20:05:22 +02:00
2026-04-08 22:23:19 +02:00
2026-04-08 20:26:40 +02:00
2026-04-09 22:05:46 +02:00
2026-04-09 20:04:01 +02:00
2026-04-10 20:36:03 +02:00
2026-04-10 18:52:21 +02:00
2026-04-10 10:33:36 +02:00
2026-04-10 22:23:16 +02:00
2026-04-11 12:27:56 +02:00
2026-04-11 11:28:59 +02:00
2026-04-11 22:40:47 +02:00
2026-04-11 23:10:25 +02:00
2026-04-11 13:35:15 +02:00
2026-04-12 07:58:02 +02:00
2026-04-12 14:33:56 +02:00
2026-04-13 14:56:27 +02:00
2026-04-13 11:32:23 +02:00
2026-04-14 21:42:57 +02:00
2026-04-14 23:26:13 +02:00
2026-04-14 22:30:29 +02:00
2026-04-15 20:33:03 +02:00
2026-04-15 19:43:50 +02:00
2026-04-15 08:40:09 +02:00
2026-04-16 22:46:54 +02:00
2026-04-16 01:32:16 +02:00
2026-04-16 17:34:14 +02:00
2026-04-17 00:02:02 +02:00
2026-04-17 00:48:18 +02:00
2026-04-16 21:49:19 +02:00
2026-04-17 23:58:32 +02:00
2026-04-18 16:07:06 +02:00
2026-04-18 21:26:40 +02:00
2026-04-19 23:47:04 +02:00
2026-04-19 12:15:04 +02:00
2026-04-19 23:21:24 +02:00
2026-04-19 00:06:05 +02:00
2026-04-20 19:12:41 +02:00
2026-04-20 14:36:03 +02:00
2026-04-22 11:18:28 +02:00
2026-04-21 21:06:33 +02:00
2026-04-24 18:29:34 +02:00
2026-04-24 19:04:56 +02:00
2026-04-25 09:15:43 +02:00
2026-04-25 11:53:10 +02:00
2026-04-24 10:06:25 +02:00
2026-04-27 08:10:42 +02:00
2026-04-27 08:10:42 +02:00
2026-04-29 17:26:22 +02:00
2026-04-27 08:10:42 +02:00
2026-04-27 18:22:40 +02:00
2026-04-29 23:21:26 +02:00
2026-04-30 08:49:36 +02:00
2026-05-01 14:07:10 +02:00
2026-05-01 20:01:27 +02:00
2026-05-02 01:47:07 +02:00
2026-05-03 00:35:07 +02:00
2026-05-04 00:40:36 +02:00
2026-05-05 08:27:49 +02:00
2026-05-05 17:36:56 +02:00
2026-05-06 10:32:10 +02:00
2026-05-08 03:01:13 +02:00
2026-05-08 18:56:58 +02:00
2026-05-08 20:57:28 +02:00
2026-05-09 00:25:06 +02:00
2026-05-10 00:30:33 +02:00
2026-05-10 22:19:28 +02:00
2026-05-15 01:13:42 +02:00
2026-05-15 22:08:31 +02:00
2026-05-15 10:42:14 +02:00
2026-05-20 20:25:05 +02:00
2026-05-16 20:48:14 +02:00
2026-05-16 21:51:48 +02:00
2026-05-16 20:48:14 +02:00
2026-05-16 20:48:14 +02:00
2026-05-17 23:27:20 +02:00
2026-05-17 21:41:02 +02:00
2026-05-18 13:22:48 +02:00
2026-05-18 02:18:18 +02:00
2026-05-20 00:40:14 +02:00
2026-05-19 16:39:17 +02:00
2026-05-19 23:32:38 +02:00
2026-05-19 00:40:15 +02:00
2026-05-19 01:04:30 +02:00
2026-05-20 20:18:45 +02:00
2026-05-20 17:37:24 +02:00
2026-05-21 15:05:28 +02:00
2026-05-21 15:05:28 +02:00
2026-05-21 15:05:28 +02:00
2026-05-21 15:05:28 +02:00
2026-05-21 15:05:28 +02:00
2026-05-22 15:56:31 +02:00
2026-05-22 15:56:31 +02:00
2026-05-22 15:56:31 +02:00
2026-05-22 15:56:31 +02:00
2026-05-22 22:07:45 +02:00
2026-05-22 15:56:31 +02:00
2026-05-22 15:56:31 +02:00
2026-05-22 20:48:05 +02:00
2026-05-23 09:34:07 +02:00
2026-05-25 23:00:40 +02:00
2026-05-26 08:59:51 +02:00
2026-05-26 00:49:42 +02:00
2026-05-26 00:04:03 +02:00
2026-05-26 01:32:56 +02:00
2026-05-30 15:41:51 +02:00
2026-05-30 20:52:28 +02:00