Commit Graph

2 Commits

Author SHA1 Message Date
jgrusewski
fab9c0e324 fix(cuda): disable hard stop-loss — dones override creates state mismatch
Setting dones[b]=1 in rl_drawdown_stop without actually closing the
lobsim position created a lie: Q trained on false trade-closes while
the position stayed open. Result: done_count=0 from step 99 onward,
990 trades total in 2000 steps (should be ~80k), training collapsed.

The drawdown penalty (per-step min(0, unrealized_r) × rate) is kept —
it creates exit gradient without corrupting the lobsim state. Hard
stop-loss needs to override the ACTION (to FlatL/FlatS) BEFORE the
lobsim step, not set dones after. Tracked for future implementation.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 22:17:12 +02:00
jgrusewski
35d21cb42f feat(rl): four-layer loss defense + perf sync removal
Loss minimization (wr=0.561 but PnL negative — losses 32% > wins):

A1: Exempt FlatL/FlatS from confidence gate — exit actions never
    blocked, model can always close losing positions.

A2+A3: New rl_drawdown_stop kernel — per-step drawdown penalty
    (min(0, unrealized_r) × rate) creates continuous exit gradient.
    Hard stop-loss force-closes when unrealized_r < -threshold.
    Both ISV-driven (slots 586, 587).

A4: Adaptive LOSS clamp — tracks observed neg/pos EMA ratio instead
    of static 3.0. LOSS = clamp(1.0, ratio×1.1, 3.0). Q sees
    accurate loss magnitudes.

Performance:

B0: Remove gratuitous stream.synchronize() in apply_snapshot
    (sim/mod.rs) — same-stream ordering makes it unnecessary.
    Expected: -12-49ms/step.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-27 22:06:59 +02:00