O'Reilly logo
live online training icon Live Online training

Quantitative trading with Python

enter image description here

Build a momentum trading strategy to predict stock prices

Topic: Business
Harshit Tyagi

Join expert Harshit Tyagi to learn the basics of quantitative analysis, from data processing to trading signal generation with stocks. In this practical, hands-on training course, you'll use Python to work with historical stock data and develop trading strategies based on the momentum indicator. You'll then discover how to perform a statistical test on the mean of the returns to conclude if there is alpha in the signal.

Whether you want to pursue a new job in finance, get started on the path to a quant trading career, or master the latest AI applications in quantitative finance, this course offers you the opportunity to master valuable data and AI skills that will get you there.

What you'll learn-and how you can apply it

By the end of this live online course, you’ll understand:

  • How to backtest a trading strategy
  • Market mechanics
  • How to generate signals with stocks

And you’ll be able to:

  • Build a trading strategy based on momentum and momentum crashes
  • Implement and test your strategy in Python
  • Statistically test the strategies you've built

This training course is for you because...

  • You're a programmer or data scientist with a background in fintech who wants to pursue a job in finance or launch yourself on the path to becoming a quant trader.
  • You're a data analyst (or you have strong fundamentals in programming and statistics), and you want to work as a quant analyst at an investment bank or a hedge fund.


  • A working knowledge of Python, pandas, and Matplotlib
  • A basic understanding of statistics, linear algebra, and calculus
  • Familiarity with momentum trading

Recommended preparation:

About your instructor

  • Harshit Tyagi is a full stack developer and data engineer at Elucidata, a biotech company based in Cambridge, where he develops algorithms for research scientists at some of the world’s best medical schools, including Yale, UCLA, and MIT. Previously, he was a systems development engineer at the investment management firm Tradelogic, where he designed a framework to analyze financial news from prominent sources to produce accurate trading signals. He’s a Python evangelist and loves to contribute to tech communities, including Google Developers Groups and Python Delhi User Groups, as well as other online learning platforms.


The timeframes are only estimates and may vary according to how the class is progressing

Introduction to quantitative trading (50 minutes)

  • Lecture: Quantitative trading overview; how to access data of any stock or instrument from Oanda
  • Group discussion: What is momentum trading? What are log returns? Why should you use Python for trading? How do you get the data for algorithm trading?
  • Hands-on exercise: Read and plot data; correct the format of data extracted
  • Q&A
  • Break (10 minutes)

Building your strategy on the data collected (50 minutes)

  • Lecture: Statistical time series analysis; calculating log returns; using NumPy to calculate log returns and add them to the data frame; building your strategy over those intervals
  • Group discussion: Types of log returns, different ways of calculating log returns, deciding intervals/periods over which the log returns are to be calculated
  • Hands-on exercise: Plot the strategies and return
  • Q&A
  • Break (10 minutes)

Backtest the strategy (50 minutes)

  • Lecture: The statistical theory behind backtesting strategies; the significance of p-value, t-tests, and the Sharpe ratio
  • Group discussion: What is p-value? What is hypothetical testing? What is the Sharpe ratio?
  • Hands-on exercise: Backtest your strategy in IPython
  • Wrap-up and Q&A (10 minutes)

Take-home exercise:

  • Working with historical data of a given stock universe, generate a trading signal based on a momentum indicator. Then compute the signal, produce projected returns, and perform a statistical test to conclude if there is alpha in the signal.