In an attempt to solve the classical question, “Can machine learning predict the market?”, I landed on Forex GBPUSD as a challenging financial series with an abundant and free data set. Although there are tens of stories on this platform on stock ML prediction and a handful on Forex ML prediction, here you will see me delve into the peculiarities that are often missed and aim to take my model to the reality spectrum:

  • By implementing multi-step predictions such as 30 or 60 steps (minutes in this case) or more, as opposed to a single step (1 minute) prediction
  • By consuming the model using an algorithmic trading bot to let the profit, or loss, be the judge (the next story)

At the end of the story, readers with some Python and ML experience will be able to use the concepts and modify the linked code to produce their own variation of the model. In part 2, reader will be able to use a commercial algo trading platform with the model.

Source Code and Following Along

The model is built in Python 3.8 using TensorFlow/Keras 2.3. To keep this story focused on concepts, the full source code and the environment preparation, along with the explanation related to running and changing the code are here:

Also, you can view the environment setup and the steps to run the model, visually explained:

Explaining the environment setup and the steps to run the model

Table of Contents

Forex Trading Primer

  • What is Forex?
  • Commission, Spread and Pips
  • Tick Data
  • Open High Low Close Data
  • Candlestick Charts
  • Forex Trading
  • Algorithmic Trading
  • Backtesting

The ML Model: Concept and Plan

  • Model Choice
  • Technical Stack Choice
  • Hardware Choice
  • The Plan

1 — Data Sourcing

2 — Data Preparation

  • Time Interval and OHLC
  • Smoothing
  • Stationarity
  • Batch Size
  • Train, Test Split
  • Process Summary
  • Scaling
  • LSTM Data Input Overview
  • Windows Size
  • Converting Samples

3 — Model Training

  • Training Statistics

4 — Predictions

  • Single-Step Prediction
  • Multi-Step Prediction

#tensorflow #algorithmic-trading #forex-trading #deep-learning #lstm

Pragmatic Deep Learning Model for Forex Forecasting
11.10 GEEK