Quantitative Trading with Python
Harshit Tyagi
Начните с количественного анализа, чтобы разработать и протестировать торговые стратегии с помощью:
- Применения техник финансового анализа с использованием Python.
- Извлечения данных из разных источников, таких как Quandl, Pandas-Datareader и т.д.
- Понимания принципов количественного анализа данных о ценах акций на конец дня.
- Основываться на математических и статистических основах.
- Сформулируйте и разработайте торговые стратегии на Python на основе momentum indicator, скользящих средних (moving averages), расчета скользящего окна и методов кроссовера (rolling window calculation and crossover techniques).
- Статистически проверить стратегии, которые вы сформулировали на Quantopian.
- Проектировать и разрабатывать основы тестирования.
- Понять метрики оценки риска.
- Разработайте и создайте свой собственный алгоритм тестирования на истории и научитесь тестировать его с помощью Quantopian.
Харшит Тяги (Harshit Tyagi) - инженер по обработке данных в Elucidata, кембриджской компании, занимающейся данными. Он разрабатывает алгоритмы для ученых-исследователей в лучших медицинских школах мира, таких как Йельский университет, Калифорнийский университет в Лос-Анджелесе и Массачусетский технологический институт. Он разработал алгоритмы и основы тестирования на истории для фирмы по управлению инвестициями.
Курс на английском, 19 лекций.
Get started with quantitative analysis to develop & backtest trading strategies:
Harshit Tyagi is a Data Engineer at Elucidata, a Cambridge based data science company. He develops algorithms for research scientists at the world’s best medical schools like Yale, UCLA, and MIT. He has designed and developed algorithms and backtesting frameworks for an investment management firm. His passion for e-learning is evident by his contributions to tech communities like Google Developers Group, Python User groups and many more. In addition to that, Harshit has been mentoring prospective full stack developers and data analysts for ~3 years now.
Curriculum
Module 1: Course Overview and Exploratory Data Analysis
Lecture 1 Overview - Stocks and Trading
We discuss the strategy and guidelines to make the most of this course. We walk through over the concept of stocks and trading.
Lecture 2 Setting up the Workspace
In this video, we'll be covering the technical requirements to set up the workspace for the entire course. We'll go through: - Python version - Creating a virtual environment which will have all the packages required - Jupyter notebook - How to write python code in Jupyter notebook
Lecture 3 Data Extraction from Quandl
Without wasting much time, let's get started with the collection of data. Getting your hands on the right dataset is very important. In this video, we're going to learn about Quandl and how can we use the Quandl API using Python to get Apple's EOD stock pricing data. We'll cover the introduction to pandas and how you can save the data to a CSV file.
Lecture 4 Exploratory Analysis on Time-series Data
Throughout the course, we'll be using data manipulation package, pandas along with NumPy, SciPy, Matplotlib, and a few others. In this lecture, we'll mainly focus on dealing with time series data, what each column in the dataframe represents and means. We'll cover slicing, subsetting and resampling techniques using pandas.
Quiz 1 Extract Microsoft Data Using your Own API Key
Here is the first assignment where you've to use the Quandl API to extract MSFT(Microsoft) EOD stock pricing data from 1st Jan, 2011 to 1st Jan, 2019.
Module 2: Performing financial analyses on stocks
Lecture 5 Calculation of Returns
The lecture would cover the common financial analyses which every quant trader should learn. We'll cover various methods of calculating returns. Here are the python functions we'll use: - pct_change() - resample() - np.log - for log returns - Plot the returns using plot() function.
Lecture 6 Cumulative Returns and Portfolio Stocks Analysis
The lecture will walk you through the importance of cumulative returns for different time windows(daily, monthly, quarterly, yearly). We'll learn to capture data from pandas_datareader package which uses yahoo_finance. Compare the returns of a range of stocks extracted from the pdr package.
Lecture 7 Rolling Window Statistics
In this lecture, we're going to learn about moving window statistics: - How to calculate the rolling mean, rolling variance, rolling median, etc. - How moving window statistics eliminates the fluctuations and spikes in the data. - Python functions: rolling_mean(), rolling_std(), etc
Lecture 8 Volatility Calculations
In this lecture, we're going to learn about risk assessment using volatility: - We'll calculate the variance of a stock over a period of time. - Understanding the volatility of a stock compared with other stocks and assessing how risky is the investment. - Formulating historical volatility on log returns.
Lecture 9 Ordinary Least-Squares (OLS) Regression Method
The lecture covers the concept of regression analysis using the statsmodel package. We are using the Ordinary Least-Squares Regression model to understand the pattern of the dependent variable(log returns of stocks) and the independent variable. - Learn about the goodness of fit. - Probability using F-statistics - How to use t-tests. - The skewness of the curve.
Quiz 2 Perform Financial Analysis on the MSFT Data
Using the data collected in the previous quiz, you have to perform a few tasks and answer the following questions.
Module 3: Formulation and development of trading strategies
Lecture 10 Introduction to Trading Strategies
The lecture covers the basics of trading strategies and common algorithms used to trade securities. In general, there are two common trading strategies: the momentum strategy and the reversion strategy. You'll learn about various types of algorithms you can develop in each of them.
Lecture 11 Steps to Formulate the Trading Strategy
A step-by-step guide to formulating the Moving average crossover algorithm. - Translate each step into code in Jupyter notebook. - Learn about the implementation of rolling statistics in SMA.
Lecture 12 Visualizing the Trading Signals
Learn about the matplotlib's plotting methods, we'll: - plot the short, long moving averages - mark the buy and sell signals in the data. - learn about adding conditions in the plot function
Quiz 3 Let's Revise the Trading Strategies Concepts
Module 4: Developing your own backtesting framework
Lecture 13 Introduction to Backtesting
In this lecture, we'll cover: - The basic definition and importance of backtesting. - Pitfalls of backtesting and factors you need to take care of while designing the backtesting framework. - Essential components of backtesting
Lecture 14 Step-by-step Guide to Developing a Backtester
We'll be moving forward to developing a simple backtester consisting of a strategy, a data handler, and a portfolio. - We'll be following a set of instructions and translate each of them to pythonic statements using pandas dataframe. - We'll generate the backtester which will track all our expenses, total funds, P&L, etc.
Lecture 15 Plotting the Portfolio Values
Learn about the matplotlib's plotting methods, we'll: - plot the portfolio's total column and visualise our holdings - introduction to quantopian
Module 5: Backtesting on Quantopian and Risk Assessment
Lecture 16 Quantopian Walk-through
In this lecture, we're going to learn about the free, community-centered platform called Quantopian: - Advantages of backtesting on quantopian. - How to write and backtest an algorithm on quantopian - Learn about the backtesting results
Lecture 17 Backtesting the SMA Strategy on Quantopian
This lecture is going to cover the entire process of backtesting the strategy that we developed on quantopian. We'll see the entire dashboard of results of the backtesting. Learn about different measures on the dashboard and what they represent.
Lecture 18 Risk Assessment Metrics
After all the backtesting, you'll need to evaluate the strategy, here you'll learn about: - Sharpe ratio - Maximum drawdown - Compound annual growth rate (CAGR) You'll code these in python using statsmodel, pandas and run it over your strategy's output.
Lecture 19 What's Next?
This is the last video in which we'll look at the next steps after the course, prospective projects you can take up to master the skill and links to resources and books to subscribe to. This is a defined list of resources which can help you get more clarity on quantitative trading algorithms and concepts.
Quiz 4 Test your Backtesting Skills!
- Financial Analyses techniques using Python.
- Extract data from different sources like quandl, pandas-datareader, etc.
- Understand the principles of quantitative analysis of end of day stock pricing data.
- Build upon mathematical and statistical fundamentals.
- Formulate and develop trading strategies in Python based on momentum indicator, moving averages, rolling window calculation and crossover techniques.
- Statistically test the strategies that you have formulated on quantopian.
- Design and develop backtesting framework.
- Understand the risk assessment metrics.
- Design and develop your own backtesting algorithm and learn how to backtest using Quantopian.
Harshit Tyagi is a Data Engineer at Elucidata, a Cambridge based data science company. He develops algorithms for research scientists at the world’s best medical schools like Yale, UCLA, and MIT. He has designed and developed algorithms and backtesting frameworks for an investment management firm. His passion for e-learning is evident by his contributions to tech communities like Google Developers Group, Python User groups and many more. In addition to that, Harshit has been mentoring prospective full stack developers and data analysts for ~3 years now.
Curriculum
Module 1: Course Overview and Exploratory Data Analysis
Lecture 1 Overview - Stocks and Trading
We discuss the strategy and guidelines to make the most of this course. We walk through over the concept of stocks and trading.
Lecture 2 Setting up the Workspace
In this video, we'll be covering the technical requirements to set up the workspace for the entire course. We'll go through: - Python version - Creating a virtual environment which will have all the packages required - Jupyter notebook - How to write python code in Jupyter notebook
Lecture 3 Data Extraction from Quandl
Without wasting much time, let's get started with the collection of data. Getting your hands on the right dataset is very important. In this video, we're going to learn about Quandl and how can we use the Quandl API using Python to get Apple's EOD stock pricing data. We'll cover the introduction to pandas and how you can save the data to a CSV file.
Lecture 4 Exploratory Analysis on Time-series Data
Throughout the course, we'll be using data manipulation package, pandas along with NumPy, SciPy, Matplotlib, and a few others. In this lecture, we'll mainly focus on dealing with time series data, what each column in the dataframe represents and means. We'll cover slicing, subsetting and resampling techniques using pandas.
Quiz 1 Extract Microsoft Data Using your Own API Key
Here is the first assignment where you've to use the Quandl API to extract MSFT(Microsoft) EOD stock pricing data from 1st Jan, 2011 to 1st Jan, 2019.
Module 2: Performing financial analyses on stocks
Lecture 5 Calculation of Returns
The lecture would cover the common financial analyses which every quant trader should learn. We'll cover various methods of calculating returns. Here are the python functions we'll use: - pct_change() - resample() - np.log - for log returns - Plot the returns using plot() function.
Lecture 6 Cumulative Returns and Portfolio Stocks Analysis
The lecture will walk you through the importance of cumulative returns for different time windows(daily, monthly, quarterly, yearly). We'll learn to capture data from pandas_datareader package which uses yahoo_finance. Compare the returns of a range of stocks extracted from the pdr package.
Lecture 7 Rolling Window Statistics
In this lecture, we're going to learn about moving window statistics: - How to calculate the rolling mean, rolling variance, rolling median, etc. - How moving window statistics eliminates the fluctuations and spikes in the data. - Python functions: rolling_mean(), rolling_std(), etc
Lecture 8 Volatility Calculations
In this lecture, we're going to learn about risk assessment using volatility: - We'll calculate the variance of a stock over a period of time. - Understanding the volatility of a stock compared with other stocks and assessing how risky is the investment. - Formulating historical volatility on log returns.
Lecture 9 Ordinary Least-Squares (OLS) Regression Method
The lecture covers the concept of regression analysis using the statsmodel package. We are using the Ordinary Least-Squares Regression model to understand the pattern of the dependent variable(log returns of stocks) and the independent variable. - Learn about the goodness of fit. - Probability using F-statistics - How to use t-tests. - The skewness of the curve.
Quiz 2 Perform Financial Analysis on the MSFT Data
Using the data collected in the previous quiz, you have to perform a few tasks and answer the following questions.
Module 3: Formulation and development of trading strategies
Lecture 10 Introduction to Trading Strategies
The lecture covers the basics of trading strategies and common algorithms used to trade securities. In general, there are two common trading strategies: the momentum strategy and the reversion strategy. You'll learn about various types of algorithms you can develop in each of them.
Lecture 11 Steps to Formulate the Trading Strategy
A step-by-step guide to formulating the Moving average crossover algorithm. - Translate each step into code in Jupyter notebook. - Learn about the implementation of rolling statistics in SMA.
Lecture 12 Visualizing the Trading Signals
Learn about the matplotlib's plotting methods, we'll: - plot the short, long moving averages - mark the buy and sell signals in the data. - learn about adding conditions in the plot function
Quiz 3 Let's Revise the Trading Strategies Concepts
Module 4: Developing your own backtesting framework
Lecture 13 Introduction to Backtesting
In this lecture, we'll cover: - The basic definition and importance of backtesting. - Pitfalls of backtesting and factors you need to take care of while designing the backtesting framework. - Essential components of backtesting
Lecture 14 Step-by-step Guide to Developing a Backtester
We'll be moving forward to developing a simple backtester consisting of a strategy, a data handler, and a portfolio. - We'll be following a set of instructions and translate each of them to pythonic statements using pandas dataframe. - We'll generate the backtester which will track all our expenses, total funds, P&L, etc.
Lecture 15 Plotting the Portfolio Values
Learn about the matplotlib's plotting methods, we'll: - plot the portfolio's total column and visualise our holdings - introduction to quantopian
Module 5: Backtesting on Quantopian and Risk Assessment
Lecture 16 Quantopian Walk-through
In this lecture, we're going to learn about the free, community-centered platform called Quantopian: - Advantages of backtesting on quantopian. - How to write and backtest an algorithm on quantopian - Learn about the backtesting results
Lecture 17 Backtesting the SMA Strategy on Quantopian
This lecture is going to cover the entire process of backtesting the strategy that we developed on quantopian. We'll see the entire dashboard of results of the backtesting. Learn about different measures on the dashboard and what they represent.
Lecture 18 Risk Assessment Metrics
After all the backtesting, you'll need to evaluate the strategy, here you'll learn about: - Sharpe ratio - Maximum drawdown - Compound annual growth rate (CAGR) You'll code these in python using statsmodel, pandas and run it over your strategy's output.
Lecture 19 What's Next?
This is the last video in which we'll look at the next steps after the course, prospective projects you can take up to master the skill and links to resources and books to subscribe to. This is a defined list of resources which can help you get more clarity on quantitative trading algorithms and concepts.
Quiz 4 Test your Backtesting Skills!
https://www.experfy.com/training/courses/quantitative-trading-with-python
$150-> $120 по коду скидки 20% "DISCOUNT20" или "YOUTUBE20" = 8400 р.