Algorithmic Trading As A Science - Numericalmethod

2y ago
11 Views
3 Downloads
635.17 KB
57 Pages
Last View : 23d ago
Last Download : 2m ago
Upload by : Evelyn Loftin
Transcription

Algorithmic Trading as a ScienceHaksun .com

Speaker Profile Haksun Li, Numerical Method Inc.Quantitative TraderQuantitative AnalystPhD, Computer Science, University of Michigan AnnArborM.S., Financial Mathematics, University of ChicagoB.S., Mathematics, University of Chicago

Definition Quantitative trading is the systematic execution oftrading orders decided by quantitative market models.It is an arms race to build more comprehensive and accurate prediction models(mathematics)more reliable and faster execution platforms (computerscience)

Scientific Trading Models Scientific trading models are supported by logicalarguments. can list out assumptionscan quantify models from assumptionscan deduce properties from modelscan test propertiescan do iterative improvements

Superstition Many β€œquantitative” models are just superstitionssupported by fallacies and wishful-thinking.

Let’s Play a Game

Impostor Quant. Trader Decide that this is a bull marketby drawing a line by (spurious) linear regression Conclude thatthe slope is positive the t-stat is significant LongTake profit at 2 upper sigmasStop-loss at 2 lower sigmas

Reality r rnorm(100)px cumsum(r)plot(px, type 'l')

Mistakes Data snoopingInappropriate use of mathematics assumptions of linear regression Ad-hoc take profit and stop-loss linearityhomoscedasticityindependencenormalitywhy 2?How do you know when the model is invalidated?

Fake Quantitative Models Assumptions cannot be quantifiedNo model validation against the current regimeCannot explain winning and losing tradesCannot be analyzed (systematically)

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)

A Scientific Approach Start with a market insight (hypothesis) Translate English into mathematics hopefully without peeking at the datawrite down the idea in math formulaeIn-sample calibration; out-sample backtestingUnderstand why the models work or failin terms of model parameters e.g., unstable parameters, small p-values

MANY Mathematical Tools Available Markov modelco-integrationstationarityhypothesis testingbootstrappingsignal processing, e.g., Kalman filterreturns distribution after news/shockstime series modelingThe list goes on and on

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-qqZt 0DOWNTRENDZt 1UP TREND1-pp

Knight-Satchell-Tran Process 𝑅𝑑 πœ‡π‘™ 𝑍𝑑 πœ€π‘‘ 1 𝑍𝑑 𝛿𝑑 πœ‡π‘™ : long term mean of returns, e.g., 0πœ€π‘‘ , 𝛿𝑑 : positive and negative shocks, non-negative, i.i.dπ‘“πœ€ π‘₯ 𝑓𝛿 π‘₯ πœ†1 𝛼1 π‘₯ 𝛼1 1 πœ† π‘₯𝑒 1Ξ“ 𝛼1πœ†2 𝛼2 π‘₯ 𝛼2 1 πœ† π‘₯𝑒 2Ξ“ 𝛼2

How Signal Do We Use? Let’s try Moving Average Crossover.

Moving Average Crossover Two moving averages: slow (𝑛) and fast (π‘š).Monitor the crossovers.1π‘šπ‘š 1𝑗 0 𝑃𝑑 𝑗 𝐡𝑑 Long when 𝐡𝑑 0.Short when 𝐡𝑑 0. 1𝑛𝑛 1𝑗 0 𝑃𝑑 𝑗,𝑛 π‘š

How to choose 𝑛 and π‘š? For most traders, it is an art (guess), not a science.Let’s make our life easier by fixing π‘š 1. Why?

GMA(n , 1) 𝐡𝑑 0 iff 𝑃𝑑 𝑅𝑑 𝑛 2 𝑛 𝑗 1𝑗 1 𝑛 1𝐡𝑑 0 iff 𝑃𝑑 𝑅𝑑 𝑛 1𝑗 0 𝑃𝑑 𝑗𝑅𝑑 𝑗 (by taking log)𝑛 1𝑗 0 𝑃𝑑 𝑗𝑛 2 𝑛 𝑗 1𝑗 1 𝑛 11𝑛1𝑛𝑅𝑑 𝑗 (by taking log)

What is 𝑛? 𝑛 2𝑛

GMA(2, 1) Assume the long term mean is 0, πœ‡π‘™ 0.𝐡𝑑 0 𝑅𝑑 0 𝑍𝑑 1𝐡𝑑 0 𝑅𝑑 0 𝑍𝑑 0

NaΓ―ve MA Trading Rule Buy when the asset return in the present period ispositive.Sell when the asset return in the present period isnegative.

How Much Money Will I Make? 𝑇 Period Return: 𝑅𝑅𝑇 𝑇𝑑 1 𝑅𝑑 𝐼 𝐡𝑑 1 0hold𝐡𝑇 001𝑇Sell at this time point

Expected Holding Time 𝑃 𝑁 𝑇 𝑃 𝐡𝑇 0, 𝐡𝑇 1 0, , 𝐡1 0, 𝐡0 0 𝑃 𝑍𝑇 0, 𝑍𝑇 1 1, , 𝑍1 1, 𝑍0 1 𝑃 𝑍𝑇 0, 𝑍𝑇 1 1, , 𝑍1 1 𝑍0 1 𝑃 𝑍0 1Π𝑝𝑇 1 1 𝑝 , T 1 1 Ξ , T 0Stationary probabilities Ξ  1 π‘ž2 𝑝 π‘ž

My Returns Distribution (1) Φ𝑅𝑅𝑇 𝑁 𝑇 𝑠 E 𝑒𝑖𝑇𝑑 1 𝑅𝑑 𝐼 𝐡𝑑 1 0𝑠 𝑁 𝑇 E 𝑒𝑖𝑇𝑑 1 𝑅𝑑 𝐼 𝐡𝑑 1 0𝑠 𝐡𝑇 0, 𝐡𝑇 1 0, , 𝐡0 0 E 𝑒𝑖𝑇𝑑 1 𝑅𝑑 E 𝑒𝑖 πœ€1 πœ€π‘‡ 1 𝛿𝑇 𝑠 Ξ¦πœ€ 𝑇 1 𝑠 Φ𝛿 𝑠 , T 1 Φ𝛿 𝑠 , T 0 𝑠 𝑍𝑇 0, 𝑍𝑇 1 1, , 𝑍1 1

My Returns Distribution (2) Φ𝑅𝑅𝑇 𝑠 𝑇 0 E 𝑒𝑖 𝑇 1Π𝑝𝑇 1 𝑇𝑑 1 𝑅𝑑 𝐼 𝐡𝑑 1 0𝑠 𝑁 𝑇 𝑃 𝑁 𝑇1 𝑝 Ξ¦πœ€ 𝑇 1 𝑠 Φ𝛿 𝑠 1 Ξ  Φ𝛿 𝑠 1 Ξ  Φ𝛿 𝑠 Ξ  1 𝑝Φ𝛿 𝑠1 π‘Ξ¦πœ€ 𝑠

Expected P&L E 𝑅𝑅𝑇 𝑖Φ𝑅𝑅𝑇 β€² 0 11 π‘Ξ π‘πœ‡πœ€ 1 𝑝 πœ‡π›Ώ

When Will My Strategy Make Money? The expected return is positive when1 π‘πœ‡ ,Π𝑝 𝛿 πœ‡πœ€ πœ‡πœ€ πœ‡π›Ώ , shock impactΠ𝑝 1 𝑝, if πœ‡πœ€ πœ‡π›Ώ , persistence shock impact

What About GMA( ,1) Repeat the steps above.E 𝑅𝑅𝑇 1 𝑝 1 Ξ πœ‡πœ€ πœ‡π›Ώ

When Will GMA( ,1) Make Money?

Model Benefits (1) It makes β€œpredictions” about which regime we are nowin.We quantify how useful the model is by the parameter sensitivitythe duration we stay in each regimethe state differentiation power

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 2 states sufficient? prediction variance? We can justify take-profit and stop-loss based ontrader utility function.

Backtesting Backtesting simulates a strategy (model) usinghistorical or fake (controlled) data.It gives an idea of how a strategy would work in thepast. It gives an objective way to measure strategyperformance.It generates data and statistics that allow furtheranalysis, investigation and refinement. It does not tell whether it will work in the future.e.g., winning and losing trades, returns distributionIt helps choose take-profit and stop-loss.

Some Performance Statistics p&lmean, stdev, corrSharpe ratioconfidence intervalsmax drawdownbreakeven ratiobiggest winner/loserbreakeven bid/askslippage

Omega

Performance on MSCI Singapore

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).

Fake Data

Returns: AR(1) 𝑋𝑑 𝛼𝑋𝑑 1 πœ€π‘‘ Auto-correlation is required to be profitable.The smaller the order, the better. (quicker response)

Returns: AR(1)

Returns: ARMA(1, 1)AR MA𝑋𝑑 πœ‡ 𝑝 𝑋𝑑 1 πœ‡ πœ€π‘‘ π‘žπœ€π‘‘ 1Prices tend to move in one direction (trend) for aperiod of time and then change in a random andunpredictable fashion.

Returns: ARMA(1, 1)no systematicwinneroptimalorder

Returns: ARIMA(0, d, 0) 𝑑 𝑋𝑑 πœ‡ 𝑒𝑑Irregular, erratic, aperiodic cycles.

Returns: ARIMA(0, d, 0)

ARCH GARCH The presence of conditional heteroskedasticity, ifunrelated to serial dependencies, may be neither asource of profits nor losses for linear rules.

A good Backtester (1) allow easy strategy programmingallow plug-and-play multiple strategiessimulate using historical datasimulate using fake, artificial dataallow controlled experiments e.g., bid/ask, execution assumptions, news

A good Backtester (2) generate standard and user customized statisticshave information other than prices e.g., macro data, news and announcementsAuto calibrationSensitivity analysisQuick

Matlab/R They are very slow. These scripting languages areinterpreted line-by-line. They are not built for parallelcomputing.They do not handle a lot of data well. How do youhandle two year worth of EUR/USD tick by tick data inMatlab/R?There is no modern software engineering tools builtfor Matlab/R. How do you know your code is correct?The code cannot be debugged easily. Ok. Matlabcomes with a toy debugger somewhat better than gdb.It does not compare to NetBeans, Eclipse or IntelliJIDEA.

Calibration Most strategies require calibration to updateparameters for the current trading regime.Occam’s razor: the fewer parameters the better.For strategies that take parameters from the Real line:Nelder-Mead, BFGSFor strategies that take integers: Mixed-integer nonlinear programming (branch-and-bound, outerapproximation)

Global Optimization Methodsf

Sensitivity How much does the performance change for a smallchange in parameters?Avoid the optimized parameters merely beingstatistical artifacts.A plot of measure vs. d(parameter) is a good visual aidto determine robustness.We look for plateaus.

Iterative Refinement Backtesting generates a large amount of statistics anddata for model analysis.We may improve the model byregress 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

Implementation Connectivity to exchanges e.g., ION, RTSPlatform dependent APIsProgramming languages Java, C , C#, VBA, Matlab

Summary Market understanding gives you an intuition to atrading strategy.Mathematics is the tool that makes your intuitionconcrete and precise.Programming is the skill that turns ideas andequations into reality.

Algorithmic Trading as a Science Haksun Li haksun.li@numericalmethod.com www.numericalmethod.com . Speaker Profile . trading orders decided by quantitative market models. . Matlab

Related Documents:

Algo trading TOTAL TRADING ALGORITHMIC TRADING HIGH FREQUENCY TRADING . Algorithmic trading: In simple words an algorithmic trading strategy is a step-by-step instruction for trading actions taken by computers (au

Algorithmic trading From Wikipedia, the free encyclopedia Jump to: navigation, search In electronic financial markets, algorithmic trading or automated trading, also known as algo trading, black-box trading or robo trading, is the use of computer programs for entering trading orders with the computer algorithm deciding on aspects of the order such as

Treleaven et al. (2013), algorithmic trading accounted for more than 70% of American stocks trading volume in 2011. Therefore, algorithmic trading systems are the main focus of regulatory agencies. There are several challenges that algorithmic trading faces. American stocks usually exhibit drastic fluctuations in end-of-day (EOD).

United States by algorithmic trading. (3) An analysis of whether the activity of algorithmic trading and entities that engage in algorithmic trading are subject to appropriate Federal supervision and regulation. (4) A recommendation of whether (A) based on the analysis described in paragraphs (1), (2), and (3), any

Chapter 1: Overview of the Algorithmic Trading Accelerator The Algorithmic Trading Accelerator (ATA) installs with the Capital Markets Foundation (CMF). Unlike solutions that offer commoditized, pre-defined strategies, the ATA enables you to quickly develop, refine, and deploy unique algorithmic trading strategies built upon your own intellectual

2 Algorithmic trading and market quality The rapidly expanding literature on algorithmic trading (AT) focuses on whether such trading enhances the ability of markets to improve long term investor welfare and capital e ciency for rms. Theory suggests that high frequency trading, a subset of AT, can have both positive and negative con-tributions.

Algorithmic Trading Table: Proportions of trading volume contributed by di erent category of algorithmic and non-algorithmic traders in the NSE spot and equity derivatives segment (for the period Jan-Dec 2015) Custodian Proprietary NCNP Total Spot Market Algo 21.34% 13.18% 7.76% 42.28% Non-

v. Who is doing algorithmic trading? Many algorithmic trading firms are market makers. This is a firm that stands ready to buy and sell a stock on a regular and continuous basis at a publicly quoted price. Customers use them to place large trades. Large quantitative funds (also called investment or hedge funds) and banks have an algorithmic .