From Quantwiki
Jump to: navigation, search



Machine Learning for Trading 2014

keywords: algorithmic, algorithms, trading, machine learning, ML, finance, equities, markets, quantitative finance, georgia tech, gt, Tucker Balch

Important Announcements


Course Overview

This course introduces students to the real world challenges of implementing machine learning based trading strategies including the algorithmic steps from information gathering to market orders. The focus is on how to apply probabilistic machine learning approaches to trading decisions. We consider statistical approaches like linear regression, KNN and regression trees and how to apply them to actual stock trading situations.

Who the Course is For

The course is open to and intended for graduate and upper level undergraduate students in Computing, ISYE, Math & Management.

Prerequisites: Students should have strong coding skills and some familiarity with equity markets. No finance or machine learning experience is assumed. Here's a short test to check if you have strong programming skills: quiz. If you don't do well on that quiz, you should either drop the course, or be sure to plan so that you can devote extra time to the course.

Note that this course serves CS major students with machine learning experience, as well as students in other majors such as ISYE, MGMT, or MATH who have different experiences. All types of students are welcome! The ML topics might be "review" for CS students, while finance parts will be review for finance students. However, even if you have experience in these topics, you will find that we consider them in a different way than you might have seen before, in particular with an eye towards implementation for trading.

Student Responsibilities

  • Read the emails sent to the course email list. Check at least daily.
  • Participate in class and via the piazza site.
  • Don't plagiarize.

Course Logistics

  • Instructor: Associate Professor Tucker Balch
    • Office hours: Tu/Th 4:30-5:30 (after class) or by appointment
    • firstname at
    • phone 678-523-8685
  • TAs: Brian Hrolenok, Alex Moreno, Jayita Bhattacharya
  • Course Website: (this webpage)
  • Required textbook: What Hedge Funds Really Do
  • Some parts of the course will be based on readings from "Machine Learning: A Probabilistic Perspective" by Kevin Murphy.
  • Prerequisites: Machine learning and portfolio management experience is not assumed; the course is designed to provide students with the necessary background they will need on these topics. Programming will be in the Python language. Students are expected to be strong programmers (or willing to invest significant effort in learning to program in Python).
  • Computing_environment_for_ML4Trading
  • GT T-Square site for the class: [TBD].
  • discussion forum on
  • Resources

Goals For the Course

By the end of this course, students should be able to:

  • Understand data structures used for algorithmic trading.
  • Know how to construct software to access live equity data, assess it, and make trading decisions.
  • Understand 3 popular machine learning algorithms and how to apply them to trading problems.
  • Understand how to assess a machine learning algorithm's performance for time series data (stock price data).
  • Know how and why data mining (machine learning) techniques fail.
  • Construct a stock trading software system that uses current daily data.

Some limitations/constraints:

  • We use daily data. This is not an HFT course, but many of the concepts here are relevant.
  • We don't interact (trade) directly with the market, but we will generate equity allocations that you could trade if you wanted to.


  • Projects: 70%
  • Midterm Exam: 10%
  • Homework and pop quizzes: 20%

Late Policy

  • -5% per day late


In most cases I expect all code that you submit was written by you. I will present some libraries in class that you are allowed to use (such as pandas and numpy). Otherwise, all source code, images and write ups you provide should have been created by you alone.

What is allowed:

  • Meeting with other students to discuss implementations. You should talk about solutions at the pseudo code level.
  • Sharing snippets of code to solve specific (small) problems such as examples of how to address sections of arrays in Python. In this case the shared code should not be more than 5 lines.
  • Searching the web for other solution outlines that you may draw on (but not copy directly). If you are inspired by a solution on the web, you MUST cite that code with comments in your code.

What is not allowed:

  • Copying sections of code longer than 5 lines. Note that merely changing variable names does not suffice.
  • Copying code from the web.
  • Use of ideas from the web that are not cited in comments.

Week 1

Tuesday 19 Aug 2014
Course Overview, Project 1 A Assignment

Thursday 21 Aug 2014
Overview of Project 1
N files, leave one out
Instructor will outline one solution in class: Not required that you follow it
Bag of words model
Hashing trick

Week 2

Tuesday 26 August 2014
Project 1A due tonight, questions?
Project 1B definition
tf(t,d) definition
idf(t,D) definition
Project 1C definition
Overall: How would instructor solve the problem

Thursday 28 August 2014
How to solve Project 1B
Words by documents size matrix: word_count, tf, tfidf
Words array: words, idf
How to get words array?
Review of solutions to Project 1A

Week 3

Monday 1 September 2014: GT Holiday

Tuesday 2 September 2014
Review of reference solution to Project 1B
Intro to ML: Parametric, Non-Parametric
How to use ML for trading
Selecting X and Y
Relative change, not absolute price
Market relative change is important
How long/short works: Sort SP500 and long 250, short other 250

Thursday 4 September 2014
How supervised training works for time series data
Roll forward cross validation
Example ML trading strategies? (maybe)
KNN intro from Murphy book.

Murphy: Chapter 1

Week 4

Tuesday 9 September 2014
Final assignment/description of Project 1C
Definition of the regression problem
Show example with data
What's the API for a regression learner?

  • learner = KNNLearner( k = 3)
  • learner.addEvidence( Xtrain, Ytrain)
  • Yquery = learner.query(Xtest)

How do we compare the quality of two regression learners?

  • Error, RMS
  • Correlation with ground truth

Andrew Moore's slides on KNN [[1]]

Thursday 11 September 2014

Any questions about Project 1C (due next Tuesday)?
Review how to measure similarity of d1 & d2 via cosine
Overview of next few weeks:

  • Implement and test KNN learner
  • Install QSTK

How to implement KNN
Pop quiz
Friday 12 September 2014: Coursera course starts

Week 5

Tuesday 16 September 2014
Review: Parameterized polynomial model
degrees of polynomial + 1 = degrees of freedom
In sample error versus degrees of freedom
Out of sample error versus degrees of freedom
Definition of overfitting
Module 11: Overview of Fin part
Module 21: So you want to be a fund manager?
Module 22: Common metrics to assess fund performance

Murphy 1.4.7 (overfitting)
Chapters 1, 2, 3, 4 in course textbook
Slide decks [[2]]

Thursday 18 September 2014
Module 23: Common metrics, pt 2
Module 24: Excel demo of metrics

Slide decks [[3]]

Week 6

Tuesday 23 September 2014
QSTK Installation Workshop

Chapters 1, 2, 3, 4 in course textbook

Thursday 25 September 2014
Module 31: Market Mechanics
Module 32: Order Book, Short Selling
Module 33: How Hedge Funds Exploit, Market Mechanics

Slide decks [[4]]

Week 7

Tuesday 30 September 2014
Mid-term review
fin_proj1 review

Thursday 2 October 2014
Mid-term exam

Week 8

Tuesday 7 October 2014
Module 34: The computing inside a hedge fund
Module 91: Where does info come from? Arbitrage
Module 92: 3 Versions of EMH
Module 93: Event Studies


Chapters 8, 10, 11 in course textbook
Slide decks [[5]]

Thursday 9 October 2014
3 ways to assess company value: Book, Market Cap, Intrinsic
Module 41: Intrinsic Value
Module 43: Fundamental analysis of company value

Slide decks [[6]]

Friday 10 October 2014: Drop Day

Week 9

Tuesday 14 October 2014: Fall Break

Thursday 16 October 2014
Module 121: Review Events, and Survivor Bias
How to tell how much money we'd make?
A backtester!
fin_project3: due in one week
Module 43: Fundamental analysis of company value
Back to: 3 ways to assess company value: Book, Market Cap, Intrinsic
Review Intrinsic Value ($1/year for 1M years)
Module 41: Intrinsic Value

Slide decks [[7]]
Hints on how to build marketsim: media:marketsim-guidelines.pdf

Week 10

Tuesday 21 October 2014
Module 42: How news affects prices
Module 71: Capital Assets Pricing Model
Module 72: What is Beta
Module 73: How Hedge Funds use CAPM
Module 122: Actual vs Adjusted Prices (Dividends & Splits)
Module 123: Data Scrubbing (Checking for Sanity)

Chapter 7, 12, 13, 14 in the course textbook
Slide decks [[8]]

Thursday 23 October 2014
Module 112: The Inputs and Outputs of a Portfolio Optimizer
Module 113: The Importance of Correlation and Covariance (in daily returns)
Module 114: The Efficient Frontier
Module 115: How Optimizers Work (In general, not just for portfolios)
fin_proj4 introduction

Week 11

Tuesday 28 October 2014
Module 151: Coin Flipping
Module 152: Fundamental Law Part 1
Module 153: Fundamental Law Part 2
Module 141: CAPM recap, overview for portfolios
Module 142: Example use of CAPM for long/short bet removing market risk

Chapter 9 in the course textbook

Thursday 30 October 2014
Module 191: Example Information Feeds
Module 192: Intro to Technical Analysis
Module 193: Some Example Technical Indicators
Module 194: Bollinger Bands
introduction to fin_proj5

Week 12

Tuesday 4 November 2014

Thursday 6 November 2014

Week 13

Tuesday 11 November 2014

Thursday 13 November 2014

Week 14

Tuesday 18 November 2014

Thursday 20 November 2014

Week 15

Tuesday 26 November 2014: No Class

Thursday 27 November 2014: Thanksgiving Break

Week 16 (Dead Week)

Tuesday 2 December 2014

Thursday 4 December 2014

Week 17 (Finals Week)

Tuesday 9 December 2014

Thursday 11 December 2014


DATE ------------------------ TOPICS-------------------------------------------------------------- NOTES---------------------------------------

In preparation


DATE ------------------------ TOPICS-------------------------------------------------------------- NOTES---------------------------------------
XXXXXX XXX XX Video: [9]

Cramer's Guide to the Stock Market

XXXXXX XXX XX Efficient Markets Hypothesis (3 versions)

Technical analysis
Fundamental analysis
A bit about data

Paper of interest: Markets are efficient iff P=NP


Instance-based learning
Andrew Moore's slides [[10]] Linear regression
KNN introduction


Formulation of problem in context of time series


Recap of approach to KNN (making problem fit KNN)
Assessing a learning algorithm.


DATE ------------------------ TOPICS-------------------------------------------------------------- NOTES---------------------------------------

Simplified to learn simpler "straight" data
Assessing a learning algorithm.

XXXXXX XXX XX Decision Trees

How to use one if you have one
How to learn one
Seminal paper on trees: Quinlan Paper
Cross validation
Roll forward cross validation

XXXXXX XXX XX Random Trees

Decision Trees Recap
Data Structure for Decision Trees
Ensemble learners wikipedia
Bagging wikipedia
Boosting wikipedia
Bagging and boosting trees Diettrich
Perfect Ensembles of Random Trees Cutler
Use technical indicator to generate trades
Random forests (Project 3)

XXXXXX XXX XX Random Forests

Definition of RF Project
Tricks with leaves
Regression Leaves

XXXXXX XXX XX Yes we will have class on this day

Integrating your learner with a trader Project

XXXXXX XXX XX Thanksgiving (no class)
XXXXXX XXX XX More on integrating learner with trader
XXXXXX XXX XX Recap of Course Objectives

Class Survey Review
Student Review
Feature selection


DATE ------------------------ TOPICS-------------------------------------------------------------- NOTES---------------------------------------
XXXXXX XXX XX Random Forest Review and ML on Stock Data
XXXXXX XXX XX Project Random Forests Due
XXXXXX XXX XX Final Exam Week

No Class

XXXXXX XXX XX Final Exam Week

No Class

Combine ML & Trading Due

Slide Decks

Old Homework & Projects From 2013

Old Homework & Projects From 2012

Other Resources

Projects from Past Versions of the Course

These are from last year. We will be changing them for this year.

Personal tools