Machine Learning for Trading

Want to become an expert in Python 3 and Django 3?

Don’t Miss the #TwitterFiles!

Machine Learning for Stock Trading, Forex Trading, Daytrading or even long-term investing is already here. You can opt to use a fee-based or performance based service and let them manage your money.

If, on the other hand, you are an active investor or trader, you might want to develop your own trading system with your own unique insights. This tutorial will shortly lay out the landscape of such a system. Also, in our On-Demand Course (Machine Learning for Trading) you can learn how to develop such a system on your own.

Data Source / API

First, you need data. Data is key for a machine learning System. Without proper data, nothing else matters. You can get free data from your broker (like Oanda). But with that data your chances to build a profitable system are slim.

It’s therefore advised to make use of paid alternative data. Such data can cost anywhere from 99$ per month to 4999$ per month or even higher. (Example:


You’ll need to have your own database. For one, you want to save the data you pay for. You also want to save the manipulated data you create (e.g. when you compute the moving average or similar indicators). Also, you need to keep track of your trades, wins, losses, etc.

For this you want to use MySQL or NoSQL (MongoDB) database. If you don’t want to operate and manage a Database yourself, you should take a look at AWS RDS and Goole Cloud SQL Services. They’ll make your life easier in this aspect.

Machine Learning System

This is the actual brain of you system, the one that decides what to do with the incoming chunk of data from your data provider. Do you execute a trade? Do you close a current one? Do you do just nothing?

Your system can be a supervised machine learning model (like a neural net) or it can be an autonomous agent (see: Reinforcement Learning). The latter is gaining momentum in the algorithmic trading scene.

You want to host your system on a performant but most importantly a reliable Computing Machine. Here again, I advise you to use a Cloud Service (AWS EC2, Google Cloud Computer, MS Azure, …).


Before you unleash your system onto your real account, you want backtest it. For this you need your own backtesting system or use a library for that (Example: Only after a backtest seems to be promising, should you release the system onto your demo account. And only after that onto your real account.

Execute Calls (Buy, Close, Change SL)

This is where the magic hits the real world. You need to keep a close eye on your system. If it fails for a few hours and you don’t notice it, it might leave a short trade that should have been closed. Automatic Alerts are a common thing in the Cloud Service Providers – they’ll even notify you via SMS.

Also, since your System will be running on the servers, without any User Interface, you should think about how you will get a current statement of your account. Maybe you have to build one yourself. Maybe your Broker has one.

Andrey Bulezyuk
Andrey Bulezyuk

Andrey Bulezyuk is a Lead AI Engineer and Author of best-selling books such as „Algorithmic Trading“, „Django 3 for Beginners“, „#TwitterFiles“. Andrey Bulezyuk is giving speeches on, he is coaching Dev-Teams across Europe on topics like Frontend, Backend, Cloud and AI Development.

Protocol Wars

Understanding the Key Players: Ethernet, Wi-Fi, Bluetooth, and Zigbee The Invisible Battles: How Data Streams Clash in the Airwaves Adapting to an Evolving Tech Landscape: New Contenders and Challenges User Empowerment: How Our Choices Determine the Winning Protocol...

Google Earth 3D Models Now Available as Open Standard (GlTF)

Unleashing the Power of 3D: A Comprehensive Guide to Google Earth's GlTF Models From Virtual to Reality: How to Utilize Google Earth's GlTF Models for Your Projects Breaking Down the Barriers: The Impact of Open Access to Google Earth's 3D Models on the IT Industry...

When you lose the ability to write, you also lose some of your ability to think

Reviving the Creative Process: How to Overcome Writer's Block in IT Staying Sharp: Techniques for Keeping Your Mind Active in the Tech World From Pen to Keyboard: Transitioning Your Writing Skills to the Digital Age Collaboration and Communication: The Importance of...

Reverse engineering Dell iDRAC to get rid of GPU throttling

Understanding Dell iDRAC: An Overview of Integrated Remote Access Controller Breaking Down the Barriers: How to Disable iDRAC GPU Throttling for Maximum Performance Optimizing Your Dell Server: Tips and Tricks for GPU Throttle-Free Operation Maintaining Stability and...