0 Voturi pozitive0 Voturi negative

179 (de) vizualizări60 paginiMay 31, 2017

© © All Rights Reserved

PDF, TXT sau citiți online pe Scribd

© All Rights Reserved

179 (de) vizualizări

© All Rights Reserved

- Bonsai Elite Wavetrader
- How to Develop a Profitable Trading System
- Woodies CCI
- Honing an Algorithmic Trading Strategy
- Christopher F. BAUM - An Introduction to Modern Econometrics Using Stata
- Report Writing
- HFT
- Turtles - Breakout Trading System
- CourseraOnline.pdf
- final draft
- Personal statement for MSc in Financial Mathematics and Computation.pdf
- Goldman-Sachs-Securities-Site-Reliability-Production-Engineer.docx
- FRM 2011 Xiang Song and Qiao Zou
- term project pt 6 fnl
- syllabus
- PR Douglas Building a Better RSI Sept11
- Datye_thesis_leveragespace.pdf
- Topic 2_Portfolio Management
- Plenary
- An Introduction to Risk Parity

Sunteți pe pagina 1din 60

Lecture 1

Haksun Li

haksun.li@numericalmethod.com

www.numericalmethod.com

Outline

Definitions

IT requirements

Back testing

Scientific trading models

2

Lecturer Profile

Dr. Haksun Li

CEO, Numerical Method Inc.

(Ex-) Adjunct Professors, Advisor with the National

University of Singapore, Nanyang Technological

University, Fudan University, etc.

Quantitative Trader/Analyst, BNPP, UBS

PhD, Computer Sci, University of Michigan Ann Arbor

M.S., Financial Mathematics, University of Chicago

B.S., Mathematics, University of Chicago

3

Numerical Method Incorporated Limited

A consulting firm in mathematical modeling, esp.

quantitative trading or wealth management

Products:

SuanShu

AlgoQuant

Customers:

brokerage houses and funds all over the world

multinational corporations

very high net worth individuals

gambling groups

academic institutions

4

Overview

Quantitative trading is the systematic execution of

trading orders decided by quantitative market models.

It is an arms race to build

more reliable and faster execution platforms (computer

sciences)

more comprehensive and accurate prediction models

(mathematics)

5

Market Making

Quote to the market.

Ensure that the portfolios respect certain

risk limits, e.g., delta, position.

Money comes mainly from client flow, e.g.,

bid-ask spread.

Risk: market moves against your position

holding.

6

Statistical Arbitrage

Bet on the market direction, e.g., whether the price

will go up or down.

Look for repeatable patterns.

Money comes from winning trades.

Risk: market moves against your position

holding (guesses).

7

Prerequisite

Build or buy a trading infrastructure.

many vendors for Gateways, APIs

Reuters Tibco

Collect data, e.g., timestamps, order book history,

numbers, events.

Reuters, EBS, TAQ, Option Metrics (implied vol),

Clean and store the data.

flat file, HDF5, Vhayu, KDB, One Tick (from GS)

8

Trading Infrastructure

Gateways to the exchanges and ECNs.

ION, ECN specific API

Aggregated prices

Communication network for broadcasting and

receiving information about, e.g., order book, events

and order status.

API: the interfaces between various components, e.g.,

strategy and database, strategy and broker, strategy

and exchange, etc.

9

STP Trading Architecture Example

existing syste

Exchanges/ECNs

xchanges, CFETS: Back-office, Other

Inter-

OTC FX, e.g., Booking

., Reuters,

Bank Trading Clearanc

loomberg bonds settlements

Systems System

Adapter Protocol

Trading System Booking System Clearance

Algo Adapter,

CSTP

Adapter Adapter Adapter

Trading

System

FIX

Data Curves Management

Credit Limit

Database

The Ideal 4-Step Research Process

Hypothesis

Start with a market insight

Modeling

Translate the insight in English into mathematics in Greek

Model validation

Backtesting

Analysis

Understand why the model is working or not

11

The Realistic Research Process

Clean data Debug

Align time stamps Debug again

Read Gigabytes of data Debug more

Retuers EURUSD, tick-by-tick, is 1G/day Debug even more

Extract relevant information Debug patiently

PE, BM Debug impatiently

Handle missing data Debug frustratingly

Incorporate events, news and announcements Debug furiously

Code up the quant. strategy Give up

Code up the simulation Start to trade

Bid-ask spread

Slippage

Execution assumptions

Wait a very long time for the simulation to

complete

Recalibrate parameters and simulate again

Wait a very long time for the simulation to

complete

Recalibrate parameters and simulate again

Wait a very long time for the simulation to

complete

12

Research Tools Very Primitive

Excel

Matlab/R/other scripting languages

MetaTrader/Trade Station

RTS/other automated trading systems

13

Matlab/R

They are very slow. These scripting languages are

interpreted line-by-line. They are not built for parallel

computing.

They do not handle a lot of data well. How do you

handle two year worth of EUR/USD tick by tick data in

Matlab/R?

There is no modern software engineering tools built

for Matlab/R. How do you know your code is correct?

The code cannot be debugged easily. Ok. Matlab

comes with a toy debugger somewhat better than gdb.

It does not compare to NetBeans, Eclipse or IntelliJ

IDEA.

R/scripting languages Advantages

Most people already know it.

There are more people who know Java/C#/C++/C than

Matlab, R, etc., combined.

It has a huge collection of math functions for math

modeling and analysis.

Math libraries are also available in SuanShu (Java), Nmath

(C#), Boost (C++), and Netlib (C).

15

R Disadvantages

TOO MANY!

16

Some R Disadvantages

Way too slow

Must interpret the code line-by-line

Limited memory

How to read and process gigabytes of tick-by-tick data

Limited parallelization

Cannot calibrate/simulate a strategy in many scenarios in parallel

Inconvenient editing

No usage, rename, auto import, auto-completion

Primitive debugging tools

No conditional breakpoint, disable, thread switch and resume

Obsolete C-like language

No interface, inheritance; how to define ?

17

Rs Biggest Disadvantage

You cannot be sure your code is right!

18

Productivity

19

Free the Trader!

debugging

programming

calibrating

data extracting

data cleaning

waiting

backtesting

20

Industrial-Academic Collaboration

Where do the building blocks of ideas come from?

Portfolio optimization from Prof. Lai

Pairs trading model from Prof. Elliott

Optimal trend following from Prof. Dai

Moving average crossover from Prof. Satchell

Many more

21

Backtesting

Backtesting simulates a strategy (model) using

historical or fake (controlled) data.

It gives an idea of how a strategy would work in the

past.

It does not tell whether it will work in the future.

It gives an objective way to measure strategy

performance.

It generates data and statistics that allow further

analysis, investigation and refinement.

e.g., winning and losing trades, returns distribution

It helps choose take-profit and stoploss.

22

A Good Backtester (1)

allow easy strategy programming

allow plug-and-play multiple strategies

simulate using historical data

simulate using fake, artificial data

allow controlled experiments

e.g., bid/ask, execution assumptions, news

23

A Good Backtester (2)

generate standard and user customized statistics

have information other than prices

e.g., macro data, news and announcements

Auto calibration

Sensitivity analysis

Quick

24

Iterative Refinement

Backtesting generates a large amount of statistics and

data for model analysis.

We may improve the model by

regress the winning/losing trades with factors

identify, delete/add (in)significant factors

check serial correlation among returns

check model correlations

the list goes on and on

25

Some Performance Statistics

pnl

mean, stdev, corr

Sharpe ratio

confidence intervals

max drawdown

breakeven ratio

biggest winner/loser

breakeven bid/ask

slippage

26

Omega

1

=

=

The higher the ratio; the better.

This is the ratio of the probability of having a gain to

the probability of having a loss.

Do not assume normality.

Use the whole returns distribution.

27

Bootstrapping

We observe only one history.

What if the world had evolve different?

Simulate similar histories to get confidence interval.

White's reality check (White, H. 2000).

28

Calibration

Most strategies require calibration to update

parameters for the current trading regime.

Occams razor: the fewer parameters the better.

For strategies that take parameters from the Real line:

Nelder-Mead, BFGS

For strategies that take integers: Mixed-integer non-

linear programming (branch-and-bound, outer-

approximation)

29

Global Optimization Methods

f

Sensitivity

How much does the performance change for a small

change in parameters?

Avoid the optimized parameters merely being

statistical artifacts.

A plot of measure vs. d(parameter) is a good visual aid

to determine robustness.

We look for plateaus.

31

Summary

Algo trading is a rare field in quantitative finance

where computer sciences is at least as important as

mathematics, if not more.

Algo trading is a very competitive field in which

technology is a decisive factor.

32

Scientific Trading Models

Scientific trading models are supported by logical

arguments.

can list out assumptions

can quantify models from assumptions

can deduce properties from models

can test properties

can do iterative improvements

33

Superstition

Many quantitative models are just superstitions

supported by fallacies and wishful-thinking.

34

Lets Play a Game

Impostor Quant. Trader

Decide that this is a bull market

by drawing a line

by (spurious) linear regression

Conclude that

the slope is positive

the t-stat is significant

Long

Take profit at 2 upper sigmas

Stop-loss at 2 lower sigmas

Reality

r = rnorm(100)

px = cumsum(r)

plot(px, type='l')

Mistakes

Data snooping

Inappropriate use of mathematics

assumptions of linear regression

linearity

homoscedasticity

independence

normality

Ad-hoc take profit and stop-loss

why 2?

How do you know when the model is invalidated?

Extensions of a Wrong Model

Some traders elaborate on this idea by

using a moving calibration window (e.g., Bands)

using various sorts of moving averages (e.g., MA, WMA,

EWMA)

Fake Quantitative Models

Data snooping

Misuse of mathematics

Assumptions cannot be quantified

No model validation against the current regime

Ad-hoc take profit and stop-loss

why 2?

How do you know when the model is invalidated?

Cannot explain winning and losing trades

Cannot be analyzed (systematically)

40

A Scientific Approach

Start with a market insight (hypothesis)

hopefully without peeking at the data

Translate English into mathematics

write down the idea in math formulae

In-sample calibration; out-sample backtesting

Understand why the model is working or not

in terms of model parameters

e.g., unstable parameters, small p-values

41

MANY Mathematical Tools Available

Markov model

co-integration

stationarity

hypothesis testing

bootstrapping

signal processing, e.g., Kalman filter

returns distribution after news/shocks

time series modeling

The list goes on and on

42

A Sample Trading Idea

When the price trends up, we buy.

When the price trends down, we sell.

What is a Trend?

An Upward Trend

More positive returns than negative ones.

Positive returns are persistent.

Knight-Satchell-Tran

1-q

Zt = 0

Zt = 1

q DOWN p

UP TREND

TREND

1-p

Knight-Satchell-Tran Process

= + 1

: long term mean of returns, e.g., 0

, : positive and negative shocks, non-negative, i.i.d

1 1 11

= 1

1

2 2 21

= 2

2

What Signal Do We Use?

Lets try Moving Average Crossover.

Moving Average Crossover

Two moving averages: slow () and fast ().

Monitor the crossovers.

1 1 1 1

= =0 =0 ,>

Long when 0.

Short when < 0.

How to choose and ?

For most traders, it is an art (guess), not a science.

Lets make our life easier by fixing = 1.

Why?

What is ?

=2

=

Expected P&L

GMA(2,1)

1

E = 1

1

GMA()

E = 1 1 +

Model Benefits (1)

It makes predictions about which regime we are now

in.

We quantify how useful the model is by

the parameter sensitivity

the duration we stay in each regime

the state differentiation power

53

Model Benefits (2)

We can explain winning and losing trades.

Is it because of calibration?

Is it because of state prediction?

We can deduce the model properties.

Are 3 states sufficient?

prediction variance?

We can justify take profit and stoploss based on trader

utility function.

54

Limitations

Assumptions are not realistic.

Classical example: Markowitz portfolio optimization

http://www.numericalmethod.com:8080/nmj2ee-

war/faces/webdemo/markowitz.xhtml

Regime change.

IT problems.

Bad luck!

Variance

55

Markowitzs Portfolio Selection

For a portfolio of m assets:

expected returns of asset i =

weight of asset i = such that =1

Given a target return of the portfolio , the optimal

weighting is given by

= arg min subject to = , 1 = 1, 0

56

Stochastic Optimization Approach

Consider the more fundamental problem:

Given the past returns 1 , ,

max{ +1 +1 }

is regarded as a risk-aversion index (user input)

Instead, solve an equivalent stochastic optimization

problem

max{[ +1 +1 }

where

= arg min{ +1 2 ( +1 )}

and

= 1 + 2( )

57

Mean-Variance Portfolio Optimization when Means

and Covariances are Unknown

Summary

Market understanding gives you an intuition to a

trading strategy.

Mathematics is the tool that makes your intuition

concrete and precise.

Programming is the skill that turns ideas and

equations into reality.

59

AlgoQuant Demo

60

- Bonsai Elite WavetraderÎncărcat detthompson
- How to Develop a Profitable Trading SystemÎncărcat deeko4fx
- Woodies CCIÎncărcat deaddinfo
- Honing an Algorithmic Trading StrategyÎncărcat deameetsonavane
- Christopher F. BAUM - An Introduction to Modern Econometrics Using StataÎncărcat deNicolas D. Lopez Verhelst
- Report WritingÎncărcat deharshalp1212
- HFTÎncărcat dehengcheong
- Turtles - Breakout Trading SystemÎncărcat deRuben Topaz
- CourseraOnline.pdfÎncărcat destepper11111
- final draftÎncărcat deapi-450911422
- Personal statement for MSc in Financial Mathematics and Computation.pdfÎncărcat deAaron Lam
- Goldman-Sachs-Securities-Site-Reliability-Production-Engineer.docxÎncărcat deGabriel Dascalu
- FRM 2011 Xiang Song and Qiao ZouÎncărcat dehooker01
- term project pt 6 fnlÎncărcat deapi-292261342
- syllabusÎncărcat deGloria Manning
- PR Douglas Building a Better RSI Sept11Încărcat deZabaoglou Pavlos
- Datye_thesis_leveragespace.pdfÎncărcat desjn11
- Topic 2_Portfolio ManagementÎncărcat deWill
- PlenaryÎncărcat deYinghui Liu
- An Introduction to Risk ParityÎncărcat depta123
- Computer+lab+1Încărcat deamiruddin
- CQF Brochure 2017_newÎncărcat devostrogirl26
- rl math jobs june 2015Încărcat deapi-284565592
- Fatigue sensitivity Analysis Technique for developing accelerated durability test load cycles based on damage prediction from CAE modelÎncărcat debalaji
- Research Paper Grading Rubric Spring 2011Încărcat deJames Trinklein
- candy-exercise-simple-data-analysis.pdfÎncărcat deqazim786
- basic math coursework sem 3 2010 survey (PPSMI)Încărcat demuhamad_taufik_6
- The Value of Music in Pubs - PRS ResearchÎncărcat dedorje@blueyonder.co.uk
- Introduction dÎncărcat deHill Hermit
- Probe Into Reasons of Financial & StatisticalÎncărcat dePeter Posine

- IntroToAtcÎncărcat dedeua2004
- sdries Vsdxam WorkbookÎncărcat deron9123
- HFT_DBÎncărcat deSmile India
- NISM-SERIES-VIII--EQUITY-DERIVATIVES-EXAM-WORKBOOK.pdfÎncărcat deVrishank Shukla
- Wave RatiosÎncărcat deANIL1964
- d-adxÎncărcat deron9123
- asdper TrendÎncărcat deron9123
- dl Mdanual Ch12Încărcat deron9123
- Esignal - Elliott Wave CountsÎncărcat deMarcianopro1
- Looping in AmiBroker AFLÎncărcat deAndrey Yablonskiy
- lecture1.pdfÎncărcat deron9123
- techmilk.txtÎncărcat deron9123
- 555mudrasÎncărcat deron9123
- mudras.pdfÎncărcat deron9123
- dLuke Gromen Transcript June 2018Încărcat deron9123
- Ind ifty BankÎncărcat deRonitSing
- gd2dfgdf59287596 Vimshottari DashaÎncărcat deron9123
- Vimshottari DashaÎncărcat denavinkapil
- dd.netautomatedÎncărcat deron9123
- 668 Yes It's a Bubble.pdfÎncărcat deron9123
- erPro Back TestÎncărcat deron9123
- rdRarest PhotographsÎncărcat deron9123
- rarest photographs.pdfÎncărcat deron9123
- d3Rajendra Chola i 6292Încărcat deron9123
- f13025.1479Încărcat deron9123
- dAdvanced Trading PDFÎncărcat deron9123
- Dp 32 s Oct 11Încărcat deron9123

- A Comparative Study of the Effect of Collaborative Problem-solving in a Massively Multiplayer Online Game (Mmog) on Individual Achievement - Donna HarrisÎncărcat decathrina_mandac
- Thesis Proposal.docxÎncărcat deAmluj Noelle Bantiles
- Great Change Point DetectionÎncărcat demshchetk
- Protocol Designing in CtÎncărcat deSushma Reddy V
- Earning Quality - Evidence From the FieldÎncărcat deipins
- Discriminant Function AnalysisÎncărcat desiti nur jannah
- NBayesLogRegÎncărcat degt
- Primary and Secodary Data(VTU)Încărcat dePolice station
- Cambridge IGCSE Geography 0460 s13 ErÎncărcat debinod2500
- Chapter 8Încărcat deMariela Liganad
- Stats Revision Slides (From Maria Molina-Domene) (1)Încărcat desai
- IPC-9194 SPC StandardÎncărcat dekobra287
- Metric MethodologyÎncărcat deananda_beloshe75
- Business StatisticsÎncărcat deLokesh Baskaran
- LIkert Scale- NormalityÎncărcat deRashmi Vaishya
- Threats to Internal ValidityÎncărcat defrederick
- HW3Încărcat deDunbar Anders
- MBA Study Material - Managerial Economics- Introduction ~ CAREER CART.pdfÎncărcat deRithik Visu
- Kompensasi tidak signifikan dg kepuasan.pdfÎncărcat deFiqih Maria Kusyairi
- JNTU old question papers 2007Încărcat deSrinivasa Rao G
- Feinstein 2002 Principles of Medical StatisticsÎncărcat deAntonio Alfim Malanchini Ribeiro
- Research Techniques in Social PsychologyÎncărcat depsychegames2
- 1. Introduction to SPSSÎncărcat deValentine' FallenAngel
- a1Încărcat deapi-356847931
- inferential statistics.pptÎncărcat deNaseer Khan
- Audit Sampling QuizÎncărcat deRobert Mendoza
- A Methodology for Rock Mass Characterisation to Control Blast-Induced VibrationsÎncărcat dealvaroaac4
- FHMM1034 Chapter 5 Correlation and Regression (Student Version)Încărcat deAllen Fourever
- Frito-Lay Targets the Hispanic Market_Group 1Încărcat deAnonymous h2EnKyDb
- Application of Statistical Concepts in the Determination of Weight Variation in SamplesÎncărcat deLope Santos IV

## Mult mai mult decât documente.

Descoperiți tot ce are Scribd de oferit, inclusiv cărți și cărți audio de la editori majori.

Anulați oricând.