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-03-21 15:33:00 +01:00
2026-03-21 23:22:58 +01:00
2026-03-22 20:30:35 +01:00
2026-03-22 00:39:34 +01:00
2026-03-22 10:32:37 +01:00
2026-03-23 08:45:18 +01:00
2026-04-22 22:03:20 +02:00
2026-03-23 12:45:06 +01:00
2026-03-23 09:35:55 +01:00
2026-03-25 19:43:26 +01:00
2026-03-25 22:53:13 +01:00
2026-03-26 00:43:58 +01:00
2026-03-27 19:52:44 +01:00
2026-03-27 19:52:44 +01:00
2026-03-27 19:52:44 +01:00
2026-03-27 20:42:37 +01:00
2026-03-31 23:30:42 +02:00
2026-04-01 21:36:40 +02:00
2026-04-04 11:49:13 +02:00
2026-04-04 11:07:47 +02:00
2026-04-04 09:28:42 +02:00
2026-04-04 00:57:49 +02:00
2026-04-04 23:00:16 +02:00
2026-04-04 17:30:18 +02:00
2026-04-05 21:25:05 +02:00
2026-04-06 22:48:07 +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 13:43:04 +02:00
2026-04-08 01:26:09 +02:00
2026-04-07 23:14:40 +02:00
2026-04-07 22:21:11 +02:00
2026-04-08 20:05:22 +02:00
2026-04-08 01:49:01 +02:00
2026-04-08 08:48:36 +02:00
2026-04-08 12:04:23 +02:00
2026-04-08 22:23:19 +02:00
2026-04-08 20:26:40 +02:00
2026-04-10 20:26:55 +02:00
2026-04-10 22:16:24 +02:00
2026-04-11 11:23:23 +02:00
2026-04-11 13:30:12 +02:00
2026-04-13 09:26:14 +02:00
2026-04-13 14:51:30 +02:00
2026-04-13 20:13:39 +02:00
2026-04-13 11:29:05 +02:00
2026-04-14 21:40:03 +02:00
2026-04-14 23:46:27 +02:00
2026-04-14 22:14:49 +02:00
2026-04-15 20:46:05 +02:00
2026-04-15 18:44:18 +02:00
2026-04-15 08:52:17 +02:00
2026-04-16 01:24:03 +02:00
2026-04-16 23:51:45 +02:00
2026-04-16 01:29:11 +02:00
2026-04-16 17:30:01 +02:00
2026-04-16 23:43:55 +02:00
2026-04-16 01:24:03 +02:00
2026-04-17 09:01:53 +02:00
2026-04-16 21:44:35 +02:00
2026-04-18 14:59:57 +02:00
2026-04-18 16:03:45 +02:00
2026-04-18 23:59:35 +02:00
2026-04-18 22:04:41 +02:00
2026-04-19 12:10:49 +02:00
2026-04-19 23:47:04 +02:00
2026-04-20 18:58:35 +02:00
2026-04-20 08:51:42 +02:00
2026-04-20 08:17:34 +02:00
2026-04-20 22:03:14 +02:00
2026-04-20 14:29:53 +02:00
2026-04-21 02:05:28 +02:00
2026-04-22 08:42:50 +02:00
2026-04-21 21:06:33 +02:00
2026-04-22 11:43:17 +02:00
2026-04-22 08:51:51 +02:00
2026-04-22 16:56:36 +02:00
2026-04-22 09:09:09 +02:00
2026-04-22 09:06:50 +02:00
2026-04-21 11:04:51 +02:00
2026-04-23 10:15:16 +02:00
2026-04-23 21:18:19 +02:00
2026-04-23 09:12:01 +02:00
2026-04-24 21:03:57 +02:00
2026-04-29 16:02:53 +02:00
2026-04-27 18:22:40 +02:00
2026-04-29 22:59:00 +02:00
2026-04-30 08:36:32 +02:00
2026-05-01 14:07:10 +02:00
2026-05-01 19:54:02 +02:00
2026-05-02 01:36:48 +02:00
2026-05-03 00:11:26 +02:00
2026-05-03 20:33:36 +02:00
2026-05-03 22:24:14 +02:00
2026-05-04 11:30:52 +02:00
2026-05-04 18:41:57 +02:00
2026-05-04 23:18:58 +02:00
2026-05-05 17:21:17 +02:00
2026-05-06 08:58:28 +02:00
2026-05-09 00:25:06 +02:00
2026-05-09 20:49:07 +02:00
2026-05-10 22:19:28 +02:00
2026-05-15 20:32:47 +02:00
2026-05-15 20:42:35 +02:00
2026-05-15 22:08:31 +02:00
2026-05-16 23:17:33 +02:00
2026-05-17 23:13:32 +02:00
2026-05-18 23:24:01 +02:00
2026-05-18 13:20:26 +02:00
2026-05-18 10:20:38 +02:00
2026-05-18 01:51:11 +02:00
2026-05-20 00:40:14 +02:00
2026-05-19 16:27:38 +02:00
2026-05-20 08:10:00 +02:00
2026-05-19 00:54:45 +02:00
2026-05-19 00:54:45 +02:00
2026-05-20 20:15:28 +02:00
2026-05-20 22:59:49 +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-24 16:28:39 +02:00
2026-05-25 21:41:10 +02:00
2026-05-25 23:00:40 +02:00
2026-05-26 00:00:00 +02:00
2026-05-25 20:09:14 +02:00
2026-05-26 09:39:17 +02:00
2026-05-26 08:59:51 +02:00
2026-05-26 00:37:30 +02:00
2026-05-26 01:30:29 +02:00
2026-05-30 15:41:51 +02:00
2026-05-30 20:52:28 +02:00