1 of 31

Time Series for �Algo Trading

Wed 11/11/2020 17:00 - 18:00 GMT

@Wazir Kahar

2 of 31

House Rules

The session is recorded. Turn off your camera if you would not like to appear. (or leave on to be more engaged ;) )

Raise hand / type in chat if you have any questions

Have your microphone muted when you are not speaking to avoid disruptions

3 of 31

Outcome:�Primer for Quantitative Finance

4 of 31

Table of Contents

  • Random Walk
  • Important Statistical Properties
    • Stationarity
    • Autocorrelation
  • Indicators
    • Moving Average
    • Bollinger Bands
    • Hurst Exponent
  • Types of strategies
    • Mean-Reversion
    • Trend-Following

5 of 31

Table of Contents

  • Moving Average Crossover Strategy
  • Bollinger Bands Mean Reversion Strategy
  • Oanda API
  • Further Reading

6 of 31

The Scenario...

Consider a fictional stock of a company. At the beginning of each day, a fair coin will be flipped. If it lands heads, price of the stock increases by $1. If it lands tails, price of the stock decreases by $1.

Is it possible to devise a strategy to profit from the stock?

7 of 31

Simple Random Walk

  • Impossible to ‘beat’
  • Each movement is independent of the previous one
  • Markovian (Memoryless)

Do prices/returns in finance follow random walk?

8 of 31

9 of 31

10 of 31

Stationarity

Time series do not depend on the time at which the series is observed

Let X be the returns of a stock/asset

For all t, E(X) =mu , Var(X) =sigma^2

In a nutshell:

Mean and variance are constant over time

Test for stationarity: Augmented Dickey-Fuller Test

11 of 31

Examples

12 of 31

Stationarity Test

Augmented Dickey Fuller Test

  • Tests the null hypothesis that a unit root is present in a time series sample.
  • The alternative hypothesis is different depending on which version of the test is used, but is usually stationarity or trend-stationarity.
  • If ADF statistic is smaller than the critical value, rejects null hypothesis (Time Series is stationary)

13 of 31

Autocorrelation

Autocorrelation is a mathematical representation of the degree of similarity between a given time series and a lagged version of itself over successive time intervals

In a nutshell : is there a relationship between the past value and the current value

14 of 31

Mean Reversion

Asset prices/returns eventually will revert to the long-run mean or average level

15 of 31

Application of Mean Reversion

  • Fixed Income
    • Cross Market RV
    • Bond RV
  • Equities
    • Mergearb
    • Value stocks
    • Long-Short
  • FX
    • Central Banks monetary policies
  • Statarb

16 of 31

Trend Following

Asset prices/returns tend to follow upward/downward trends

17 of 31

Application of Trend Following

  • Fixed Income
    • Betting on rate cuts/hike
  • Equities
    • Growth stock
  • FX
    • Betting on economies/interest rate

18 of 31

Hurst Exponent

  • It quantifies the relative tendency of a time series either to regress strongly to the mean or to cluster in a direction.
  • Takes value between 0 - 1
  • A value H in the range 0.5–1 indicates a time series with long-term positive autocorrelation
  • A value in the range 0 – 0.5 indicates a time series with long-term switching between high and low values in adjacent pairs.

19 of 31

Hurst Exponent: 0.027818

20 of 31

Hurst Exponent: 0.636744

21 of 31

Moving Average

  • It calculates the average price over the last n days
  • Uses rolling window, not expanding
  • The longer the lookback period, the less sensitive it is to changes in the time series

22 of 31

23 of 31

Bollinger Bands

24 of 31

Things to look out for when using indicators

  • Different time frames might exhibit different properties

  • Hurst requires (relatively) a lot of data points to ensure the exponent is stable

  • Backward looking/lagging by nature

25 of 31

MA Crossover Strategy

  • Short Term MA indicates the short term trend
  • Long Term MA indicates the long term trend
  • STMA > LTMA indicates that the time series is trending downwards (Long Signal)
  • STMA < LTMA indicates that the time series is trending downwards (Short Signal)

26 of 31

27 of 31

Bollinger Bands Mean Reversion Strategy

  • Upper Band shows 2 s.d away upwards
  • Lower Band shows 2 s.d away downwards
  • If Price > Upper Band; overpriced/overbought (Short Signal)
  • If Price < Lower Band; underpriced/oversold (Long Signal)

28 of 31

29 of 31

Questions?

Anything to explain more clearly?

If you’re watching this on recording send us a message on the #helpdesk stream in Zulip ! https://dsatlse.zulipchat.com/

30 of 31

Further Reading / Resources

LSE Courses

  • FM320 Quantitative Finance
  • ST326 Financial Statistics
  • ST304 Time Series
  • Danielsson, Jon. Financial Risk Forecasting

31 of 31

Algo Trading Challenge

£20 Amazon Voucher prize for challenge based on this workshop. �Task: backtest a trading strategy. (Handicap for first years)

Deadline: 21st Nov 2020

Starter Notebook:

https://colab.research.google.com/drive/1Bp6nWc7Ef13v_8blAo8celxG46Ig-9Vp?usp=sharing