Udacity: Machine Learning for Trading

Recently I’m interested in ML in terms of trading and I found course on Udacity platform which dedicated exactly for this topic.

Course structured as 3 big chunks:

1) Data reading and normalisation, vector algebra, regression using python(numpy, pandas) – mostly practice-focused
2) Market mechanics is for whom like me who doesn’t know anything how trading works. Module covers market data and some market indicators like Daily Return, Moving Average, Bollinger Bands, etc. It’s less practical but it’s still possible to code all formulas provided
3) Machine Learning overview. This module mostly about ML approaches, mostly focused on Q-Learning. It’s mostly theoretical, hence you have to go deep into details of implementation yourself. But yet it gives you sense of variety of options you’ve got.

Main takeaways

Module 1

Seems Python is one of the best options for this sort of task. It has a lot of ready to use libraries, performance-critical parts of them are written in c modules. I fall in love with pandas and numpy – just with one line of code it possible to read zipped csv, build dataframe with index, detect columns format, etc.
Python isn’t that great without jupyter – web app running on local machine or in the cloud allows us to write, execute and organise code right in the browser:

How cool is that?

One more example:
Just few more lines and you can select specific stocks and chart weekly return! Pandas has very flexible and intuitive query language

Module 2: Market mechanics

In that module lecturer explains basics of trading, terms and introduces a few metrics such as Momentum, Moving Average, Bollinger Bands. Seems there a hundreds of them! They produce signals which trader/robot analyse later. The problem manual trading is too many signals, human’s brain can’t absorb but computers and machine learning can.

Using that information I was able to build Bollinger Bands and MA for my trading dataset:

And it’s up to student to turn technical analysis into actionable data for trading

Module 3: Reinforcement Learning

Unfortunately there is no practical examples but it gives you sense of how does it work, what types of neural network works better and about their caveats. Later that module lecture introduce Q-Learning and simulation. The main idea of reinforcement learning is define network which can be rewarded or penalised for some actions, so it can learn different strategies.

Lecturer shows how trading strategies in ML are similar to the self-taught navigation system for robot.


It’s way more difficult than you expected even you thought it is difficult :) Otherwise every single PHP developer could program this sort of gold miners