21 / Ventures & FinancePrediction Market
Reinforcement-Learning Trader for Live NBA Markets
An LSTM forecaster and a PPO agent trading live basketball markets in simulation, with a post-mortem of the result
- 893NBA games of trade data, turned into 2.8 million one-minute candles
- 43 MTraining steps for the largest agent, 13 hours on one GPU workstation
- 179Validation games used to score the agents
- = randomHow the trained agents scored against a policy acting at random
Objective and outcome
During an NBA game, a prediction-market contract on the winner swings between a few cents and nearly a dollar as the score changes. The objective was to test whether a model could learn to trade those swings using only the price history, with no knowledge of the game itself.
I built the whole pipeline: data, an LSTM that forecasts the price five minutes ahead, a trading simulator, and a reinforcement-learning agent that reads the LSTM’s internal state and decides each minute whether to buy, sell or wait.
The approach did not produce an edge, and the post-mortem identified why. The forecaster had no skill, the agent memorized its training games, and a policy acting at random made as much money in my simulator, which means the simulator was the problem. Nothing was ever traded.
Backtests only. The comparison with a random policy and the corrected accounting come from a later review that replayed my saved agents through my own simulator code.
Pipeline components
- Data
Trade data for 893 games
A downloader that pulled every public trade print for NBA game-winner markets from April 2025 to February 2026 and built one-minute price candles: 2.8 million minutes in all.
- Prediction
LSTM price forecaster
A two-layer LSTM in PyTorch that reads ten minutes of 13 technical indicators and predicts the price five minutes ahead, with a second output for direction.
- Simulator
Custom trading environment
A Gymnasium environment in which an agent can hold, buy YES, buy NO or close each minute, with a one-minute delay between decision and fill.
- Agent
PPO trading agent
A reinforcement-learning agent (Stable-Baselines3) that observes the LSTM’s internal state and learns a trading policy across 16 parallel games on a GPU workstation.
Model details: the LSTM has 221,954 parameters and two heads, one predicting the price and one predicting direction. The agent is a PPO policy with separate 64-by-64 networks for policy and value, trained on 714 games and validated on the 179 most recent, split by date.
Two-stage model training
The LSTM is trained first, on labelled history. The agent does not observe prices directly: its market input is the LSTM’s 128-number summary, plus its own position and how much of the game remains. Reward is the change in portfolio value each minute.

- −7.2%The forecaster’s error against predicting “no change”, on unseen games: worse than the no-change baseline
- 50.2%Direction accuracy on minutes where the price moved: equivalent to chance
- 625×Times the longest run replayed each training game
- $22.85 vs $3.03That agent’s paper profit per game on training games, and on games it had not seen
Validation results and accounting correction
My own report at the end of the project showed a loss of $893 over 179 validation games, and I stopped there. The conclusion was correct but the figure was not: it counted every position still open at the final minute as worthless.

| How the result is measured | 5.4 M-step agent | 43 M-step agent | What it shows |
|---|---|---|---|
| My original report | −$893.14 | – | Counted every position still open at the end as a total loss: an accounting bug |
| Same trades, open positions valued properly | +$235.52 | +$542.73 | A profit, but only inside a simulator with no spread and almost no fees |
| Without the single best game | −$60.94 | – | One game, where the price went 98¢ → 1¢ → 76¢ in 40 minutes, supplied more than the whole total |
| Repriced with the exchange’s real fees | −$379.88 | −$2,343.82 | Before any bid-ask spread |
Random-policy baseline comparison
- Uniformly random policy (three seeds)no model+$165 to +$503
- Agent trained for 5.4 million stepsthe version in my report+$236
- Agent trained for 43 million steps13 hours of training+$543
The grey bar is the range across three random seeds
Replaying the validation games with a policy that picks its action at random produced a paper profit of $165 to $503. My trained agents made $236 and $543. Tens of millions of training steps produced no improvement over random actions.
When random behaviour is profitable, the environment is rewarding something that does not exist in the real market. Every dollar of profit, for both agents, came from contracts priced at five cents or less. Everything else netted to a small loss.
Simulator flaws
- Fills
Fills at the last traded price
With no bid and ask, buying costs nothing extra. A real order pays the spread, which on a contract worth one or two cents is a large share of its price.
- Sizing
Fixed-dollar position sizing
Fixed-dollar sizing made the cheapest contracts the largest positions: a fixed $10 bought 1,000 contracts at 1¢. Contracts at 1.5¢ or less showed an average one-minute “return” of +9.3%, entirely from bouncing off the 1¢ price floor.
- Fees
Understated fee model
The simulator charged $45.60 on trades that the exchange’s real fee schedule would have charged $615.40, which is 2.6 times the agent’s entire paper profit.
- Clock
Look-ahead in the game-clock input
The “share of game complete” input was measured back from the final trade. In live trading the time of the last trade is not known in advance, so this input gave the agent future information.
Conclusion. No edge. The forecaster was worse than assuming no change, the agents matched a random policy, the paper profit came from one-cent contracts and a single game, and real fees turned it into a loss. Some practices were sound: the data was split by date, the agent traded with a one-minute delay, and every checkpoint and log was saved, which is why the full post-mortem was possible nine months later.
Every figure is from a simulation; nothing was traded. This was an early project, and the controls it lacked are the ones my later research is built around. Past performance does not predict future results. Nothing here is investment advice.