Dev Patel
May 2023 → Aug 2023Source

Algorithmic Trading Model

An LSTM in TensorFlow and Keras for price movement, combined with mean reversion and backtested honestly.

Close price, RSI and MACD over the same window — the features the model actually reads.
Type
Artifact
Where
Personal
When
May 2023 → Aug 2023
Duration
3 mo
Status
Research
Source
GitHub
The problem

The problem

Predicting price from price alone is close to the hardest version of a forecasting problem, and it is very easy to build something that looks profitable and is actually reading the future.

What I built

What I built

An LSTM built in TensorFlow and Keras over historical series pulled from the Yahoo Finance API, combined with regression and a mean-reversion signal.

The part that mattered was the backtest — walking the model forward over held-out history rather than scoring it on data it had already seen.

Results

Results

LSTMsequence model
Backtestedheld-out history
2signals combined
  • Working sequence model over real historical data.
  • Backtesting harness that scores on unseen history rather than training data.
  • Two independent signals combined rather than one over-trusted.
Architecture

Architecture

Yahoo Financehistorical seriesFeature prepPandas · NumPyLSTMTensorFlow · KerasMean reversionsignal blendBacktestwalk-forward
The backtest is the only box that decides whether the others were worth building.
In hindsight

In hindsight

I did not model transaction costs or slippage. A strategy that trades often can be profitable on paper and unprofitable the moment you charge it for every trade — that omission makes the returns indicative at best, and I'd treat it as the first thing to fix.

Stack

Stack

PythonTensorFlowKerasLSTMPandasNumPyYahoo Finance API