Dev Patel
Artifact MAY – AUG 2023Source

Algorithmic Trading Model

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

Classification
Artifact
Client
Personal
Window
MAY 2023 → AUG 2023
Duration
3 MO
Status
Research
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.

Measured

Measured

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.
Plan

Plan

Plan

5 items · scale 1:1
YAHOO FINANCEhistorical series1FEATURE PREPPandas · NumPy2LSTMTensorFlow · Keras3MEAN REVERSIONsignal blend4BACKTESTwalk-forward5
Note · The backtest is the only box that decides whether the others were worth building.
What I'd redraw

What I'd redraw

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.

Materials

Materials

PythonTensorFlowKerasLSTMPandasNumPyYahoo Finance API