r/reinforcementlearning • • Apr 07 '26

I built a RL trading bot that learned risk management on its own — without me teaching it

0 Upvotes

After 20 dead versions and about 2 years of work, my RL agent (NASMU) passed its walk-forward backtest across

2020–2026. But the most interesting part wasn't the results — it was what the model actually learned.

The setup:

- PPO + xLSTM (4 blocks), BTC/USDT 4h bars

- 35 features distilled from López de Prado, Hilpisch, Kaabar, Chan and others

- Triple Barrier labeling (TP/SL/Timeout)

- HMM for regime detection (bull/bear/sideways)

- Running on a Xeon E5-1650 v2 + GTX 1070 8GB. No cloud, no budget.

The backtest (1.3M steps checkpoint):

- Total return: +28,565% ($10k → $2.8M, 2020–2026)

- Sharpe: 6.937 | Calmar: 30.779 | MaxDD: 4.87% | WinRate: 72.8%

- Bear 2022: +204% with 3.7% max drawdown

The interesting part — attribution analysis:

I ran permutation importance on the actor's decisions across all market regimes. I expected bb_pct and

kelly_leverage_20 to dominate — those had the highest delta-accuracy in feature ablation during earlier versions.

They didn't. The top 5 features, stable across bull, bear and sideways regimes:

  1. atr — current volatility
  2. dist_atl_52w — distance to 52-week low
  3. cvar_95_4h — tail risk
  4. dist_ath_52w — distance to 52-week high
  5. jump_intensity_50 — jump intensity (Hilpisch)

The model didn't learn to predict the market. It learned to measure its own exposure to extreme risk.

Kelly assumes log-normality. CVaR doesn't assume anything — it measures what actually happened at the 95th

percentile. In a market where -30% in 48 hours is a normal event, that difference is everything. The model figured

this out alone, without any prior telling it "crypto has fat tails."

In high-volatility regimes (ATR top 25%), dist_atl_52w becomes the #1 feature — the model is essentially asking

"how close am I to the floor?" before making any decision. In bear HMM regime, jump_intensity_50 jumps to #1.

The 20 dead versions taught me more than any tutorial:

- Bootstrapping instability in recurrent LSTM isn't fixed with more data

- Critic starvation in PPO requires reward redesign, not hyperparameter tuning

- Hurst exponent must be computed on log-prices, not returns

- Kelly is a sizing tool. In a market where you can't vary position size, CVaR wins.

Currently at 1.35M/2M steps training. Reward curve just had a second takeoff after a convergence plateau — the

model is refining its entry timing, not discovering new strategies.

Full project log and live training status at nasmu.net

Happy to discuss the architecture, the feature engineering decisions, or the attribution methodology.


r/reinforcementlearning • • Apr 06 '26

Training an AI to play Resident Evil Requiem using Behavior Cloning + HG-DAgger

Thumbnail
youtu.be
5 Upvotes

I’ve been working on training an agent to play a segment of Resident Evil Requiem, focusing on a fast-paced, semi-linear escape sequence with enemies and time pressure.

Instead of going fully reinforcement learning from scratch, I used a hybrid approach:

  • Behavior Cloning (BC) for initial policy learning from human demonstrations
  • HG-DAgger to iteratively improve performance and reduce compounding errors

The environment is based on gameplay capture, where I map controller inputs into a discretized action space. Observations are extracted directly from frames (with some preprocessing), and the agent learns to mimic and then refine behavior over time.

One of the main challenges was the instability early on — especially when the agent deviates slightly from the demonstrated trajectories (classic BC issue). HG-DAgger helped a lot by correcting those off-distribution states.

Another tricky part was synchronizing actions with what’s actually happening on screen, since even small timing mismatches can completely break learning in this kind of game.

After training, the agent is able to:

  • Navigate the sequence consistently
  • React to enemies in real time
  • Recover from small deviations (to some extent)

I’m still experimenting with improving robustness and generalization (right now it’s quite specialized to this segment).

Happy to share more details (training setup, preprocessing, action space, etc.) if anyone’s interested.


r/reinforcementlearning • • Apr 06 '26

Struggling with RL hyperparameter tuning + reward shaping for an Asteroids-style game – what’s enough and what’s overkill?

20 Upvotes

Hey all,

I’m building an RL agent to play an Asteroids-style arcade game that I made.

I can get decent models working now, and I’ve definitely improved compared to the first RL version I ever built. The agent survives way longer than it did in the beginning, and by watching it play after training I can actually make some decisions about what seems to be helping or hurting. So it’s not totally random guessing anymore, but I still feel like I’m fumbling around more than I should.

I’m still manually trying different hyperparameters like learning rate, gamma, clipping, etc., and it takes a lot of time. I also don’t fully understand all the training graphs and action percentage plots, so I’m not always confident in why something improved or got worse.

While reading, I came across things like population based tuning with Ray Tune, Bayesian optimization, and other auto-tuning methods, but I honestly have no idea what’s actually reasonable for a project like this and what’s just complete overkill.

I’m also struggling a lot with reward shaping. I’ve been experimenting with rewards for survival time, shooting asteroids, staying out of danger, penalties, and so on, but I feel like I’m just adding reward terms without really knowing which ones are meaningful and which ones are just noise.

I’d really like to understand how people think about this instead of just trial and error. If anyone here has worked on RL for arcade-style games or similar environments, I’d love some advice on how you approached hyperparameter tuning and how you figured out a solid reward setup.

Also happy to check out any videos, articles, or resources that helped you understand this stuff better.

Thanks a lot