Haksun Li haksun.li@numericalmethod.com www.numericalmethod.com MY EXPERIENCE WITH ALGORITHMIC TRADING



Similar documents
Introduction to Algorithmic Trading Strategies Lecture 1

Algorithmic Trading Session 1 Introduction. Oliver Steinki, CFA, FRM

From Particles To Electronic Trading. Simon Bevan

Algorithmic Trading: A Quantitative Approach to Developing an Automated Trading System

Turk s ES ZigZag Day Trading Strategy

Fixed Income Trading Platform Architecture

Introduction to Algorithmic Trading Strategies Lecture 2

MATLAB as an Automated Execution System

Algorithmic Presentation to European Central Bank. Jean-Marc Orlando, EFX Global Head BNP PARIBAS

International Academy of Exchange Trading. Lesson 4: Orders

Trading. Theory and Practice

From thesis to trading: a trend detection strategy

Algorithmic Trading Session 6 Trade Signal Generation IV Momentum Strategies. Oliver Steinki, CFA, FRM

Forex Diamond EA. User Guide - 1 -

Forex Trade Copier 2 User manual

White Paper Electronic Trading- Algorithmic & High Frequency Trading. PENINSULA STRATEGY, Namir Hamid

There is a shortening time cycle in the

FX Trading: The Next Generation FX Trading and Technology Trends in 2010

Developing Algo Trading Applications with SmartQuant Framework The Getting Started Guide SmartQuant Ltd Dr. Anton B.

Execution Costs. Post-trade reporting. December 17, 2008 Robert Almgren / Encyclopedia of Quantitative Finance Execution Costs 1

Aggregation of an FX order book based on complex event processing

Spike Trading: Spot FX Vs Futures

Transaction Cost Analysis and Best Execution

Man vs Machine: Coping with the Changing Face of Financial Technology. Pierre FELIGIONI Head of Real Time Product Strategy S&P Capital IQ

Fast Trading and Prop Trading

Volatility Dispersion Presentation for the CBOE Risk Management Conference

Modelling Electricity Spot Prices A Regime-Switching Approach

Hedging Illiquid FX Options: An Empirical Analysis of Alternative Hedging Strategies

sqore.swissquote.eu EURUSD USER GUIDE sqore.swissquote.eu OILUSD USDJPY OILUSD 1


alta5 Risk Disclosure Statement

SOLUTION BRIEF. TIBCO StreamBase for Foreign Exchange

Model Validation Turtle Trading System. Submitted as Coursework in Risk Management By Saurav Kasera

LMAX Exchange FIX4.4 & API FAQs April 2015

COOLTRADE PERFROMANCE TIPS By Regina Guinn. Here are some things that subscribers should be aware of when running an automated trading platform.

AlphaTrader Environment

Design of an FX trading system using Adaptive Reinforcement Learning

Non Linear Dependence Structures: a Copula Opinion Approach in Portfolio Optimization

2DAY EXECUTIVE WORKSHOP ON ALGORITHMIC TRADING

Mean Reversion - Illustration of Irregular Returns in US Equity and Fixed Income Markets

NDD execution: NDD can help remove the conflict of interest >>> providing a confl ict free environment for Retail FX traders CLIENT.

Case Package Rotman Online Trading Competition

Contents Risk Disclaimer... 3 Introduction... 4 Choosing the Right Broker... 4 The Financial Markets... 5 The Forex Market...

Intraday FX Trading: An Evolutionary Reinforcement Learning Approach

Intraday Trading Invariance. E-Mini S&P 500 Futures Market

Simple Linear Regression

Hedge Fund Index Replication - A Numerical Approach using Futures

Using Macro News Events in Automated FX Trading Strategy

Whether you re new to trading or an experienced investor, listed stock

AN INTRODUCTION TO BACKTESTING WITH PYTHON AND PANDAS

Trading System: BatFink Daily Range (A) Investment Market: Forex

Index tracking UNDER TRANSACTION COSTS:

How To Build A Trading Engine In A Microsoft Microsoft Matlab (A Trading Engine)

A practical guide to FX Arbitrage

Pairs Trading STRATEGIES

One Click Trader. Manual

Bernard S. Donefer Distinguished Lecturer Baruch College, CUNY

The OptionWorks Daily Strategy Report provides unique trading ideas available nowhere else.

WallStreet FOREX Robot User Guide

5 Pitfalls To. Avoid For. Sucessful

Performance Workload Design

CS 522 Computational Tools and Methods in Finance Robert Jarrow Lecture 1: Equity Options

Forex Basics brought to you by MatrasPlatform.com

Big Data to trade bonds/fx & Python demo on FX intraday vol

The Merits of Absolute Return Quantitative Investment Strategies

Testing Intelligent Device Communications in a Distributed System

RIT Installation Instructions

MetaTrader 4 and MetaEditor

MT4i Internet Trade Mirror - Receiver

Valdi. Equity Trading

Take it E.A.S.Y.! Dean Malone 4X Los Angeles Group - HotComm January 2007

My EA Builder 1.1 User Guide

Terms and definitions

Financial Market Efficiency and Its Implications

Lecture 23: Pairs Trading Steven Skiena. skiena

SAXO BANK S BEST EXECUTION POLICY

FTS Real Time Client: Equity Portfolio Rebalancer

SWFX - Swiss FX Marketplace Manual V

EUR/USD Trading Strategy

Chapter 5 Option Strategies

Valdi for Equity Trading High performance trading solutions for global markets

Order Handling Risk Management Recommendations for Executing Brokers

1 DAY MANAGEMENT DEVELOPMENT PROGRAM ON "Systematic Trading Strategies

Chapter 7 - Find trades I

Jim Gatheral Scholarship Report. Training in Cointegrated VAR Modeling at the. University of Copenhagen, Denmark

INCORPORATION OF LIQUIDITY RISKS INTO EQUITY PORTFOLIO RISK ESTIMATES. Dan dibartolomeo September 2010

Trading the E-Micro Currency Futures Contracts

Introduction to Mathematical Finance

Find the Hidden Signal in Market Data Noise

TECHNICAL ANALYSIS & SYSTEMATIC TECHNICAL TRADING (Chart and Non-Chart Based) IS A ONE DAY EXECUTIVE WORKSHOP

Measurable Results: Establish service excellence. Reduce errors by 50% The choice for progressive medical centers.

Optimal order placement in a limit order book. Adrien de Larrard and Xin Guo. Laboratoire de Probabilités, Univ Paris VI & UC Berkeley

How to Win the Stock Market Game

CONTENT

Forecasting Trade Direction and Size of Future Contracts Using Deep Belief Network

FINANCIAL ECONOMICS OPTION PRICING

Transcription:

Haksun Li haksun.li@numericalmethod.com www.numericalmethod.com MY EXPERIENCE WITH ALGORITHMIC TRADING

SPEAKER PROFILE Haksun Li, Numerical Method Inc. Quantitative Trader Quantitative Analyst PhD, Computer Science, University of Michigan Ann Arbor M.S., Financial Mathematics, University of Chicago B.S., Mathematics, University of Chicago

OVERVIEW Algo trading is the automated 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)

MARKET MAKING Quote to the market. Ensure that the portfolios respect certain risk limits, e.g., delta. Money comes mainly from client flow, e.g., bidask spread.

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.

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 Clean and store the data. flat file, HDF5, Vhayu, KDB, One Tick

TRADING INFRASTRUCTURE Gateways to the exchanges and ECNs. ION, ECN specific API 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.

PROCESS 1. Generate or improve a trading idea. 2. Quantify the idea and build a model for it. 3. Back test the strategy. 4. Collect the performance statistics. 5. If the statistics are not good enough, go back to #1. 6. If the strategy does not add significant value to the existing portfolio, go back to #1. 7. Implement the strategy on the execution platform. 8. Trade.

SAMPLE TRADING SYSTEM DESIGN a strategy a strategy a strategy a strategy a strategy a strategy a strategy a strategy broker Exchanges

BROKER JUSTIFICATIONS Mimic how a human trader and broker work. Separation of responsibilities.

BROKER JUSTIFICATIONS A strategy implements the trading logic; needs not wait/block for handshake messages from the exchanges. Broker handles all the complicated order routing protocols with the exchanges acts an internal market to aggregate and reuse orders to optimize execution; acts as a guard to catch errors.

PRACTICAL ISSUES Filtration Consistency Internal Order Matching Rapid Strategy Implementation Safety

FILTRATION PROBLEM A strategy is quick and mostly CPU computations. The broker is slow and may wait/block for messages. By the time the broker serves a strategy request, the order conditions may no longer be valid. This problem is especially prominent for a strategy that sends out orders at a very high rate.

FILTRATION CONCEPTUAL DIAGRAM event queue event 1 event 2 event event 3 2000 quick strategy act 1 for event 1 act 2 for event 2 act 5 for event 5 slow broker Is executing act 5 still the right thing to do?

FILTRATION SOLUTIONS Manage only one order at a time; always wait for confirmation. This is only appropriate for low frequency strategies that do not anticipate orders to optimize execution. Allow error margins for, e.g., overfilling. Catch and correct the cumulated errors afterward.

FILTRATION SOLUTION: VERIFICATION Implement the notion of Change. Ignore a strategy request if an order condition is invalidated due to Change. This implementation needs to be very efficient to avoid it becoming the bottleneck.

CONSISTENCY pos = 2 inconsistency logic pos = 3 The market states may change during strategy computation. For example, an order-fill message may arrive to update the position information.

CONSISTENCY SOLUTION Take a snapshot before strategy computation.

INTERNAL ORDER MATCHING Reuse existing orders in the Market as much as we can. Canceling and adding back a limit order will put the order at the end of queue. Increase execution probability. Reduce slippage.

RAPID STRATEGY IMPLEMENTATION PROBLEM We want to release a strategy to production in hours if not sooner after research. Our experience is that the majority of the code is about order manipulations. This is especially true for high frequency trading for which clever order manipulations are necessary to reduce slippage.

ORDER ANTICIPATION EXAMPLE Suppose the current price is 100. We place a limit order to buy at 90. The price moves up to 110, leaving the order unfilled. We cancel the order at 90, place a new limit order at 100, chasing the market. Code: delete an old order, wait for confirmation, add a new order, etc.

MESSY CODE There are also the exceptions to handle. what if the old order is already filled before the delete command arrives at the Market? what if the old order is partially filled and then deleted? what if the confirmation arrives very late (or never arrives)? what if the price changes before the new order is placed? what if the new order is rejected by the Market? what if the gateway, market, or adaptor is down?

KEEP THE STRATEGY SIMPLE DON T MIX TRADING LOGIC WITH ORDER ROUTING/MANIPULATION CODE.

A STRATEGY LOGIC AS A FUNCTION A strategy is a function that maps a set of states into a set of orders. F, state, state, order, order, state 1 2 3 1 2 The function is Markovian in terms of the states for easy debugging (unit test). This enforces simple coding but not necessarily simple strategy.

SAFETY Putting the proper risk controls in place is the number one priority because an out-of-control or out-of-expectation system puts the firm at a HUGE risk. All trading constraints, e.g., position limit, stoploss, must be respected regardless of what a strategy does. This needs to remain true even if we have a buggy, malfunctioned or even ill-intentional code.

CHECKS Internal vs. External limit checker. Position limits. Individual vs. Global stoploss. Throttling number of orders sent.

A SAMPLE TRADING IDEA Two simple strategies mean reversion: buy when price goes down; sell otherwise trend following: buy when price goes up; sell otherwise When to use #1 and when to use #2?

HIDDEN MARKOV MODEL Decide the hidden states: up trend, mean reverting, down trend p 12 p 32 p 11 p 33 UP μ >> 0 p 21 MEAN REVERTING p 23 μ 0 DOWN μ >> 0 p 22 p 31 p 13

THE MATH MODEL X t Z S t : the states, time dependent X t : the time series of interests, time dependent, e.g., the log returns Z t : the matrix of factors, time dependent β, σ: the linear regression results; state (hence time) dependent ε: white noise t S t S t t

Z T THE FACTORS historical returns (lags in the AR model) ranges of returns historical volatilities past pnls any other information you may think useful, e.g., interest rates, events

THE MATH PROBLEM We need to estimate β and σ for each state. We need to estimate the transition matrix {p ij }.

THE MATH SOLUTION We ultimately want to know X t+1 from the information available at time t. estimate the probabilities of which state we are in at time t, S t use the β and σ for the most likely state plug the numbers into the equation to compute X t

THE MATH PROCEDURES Maximum likelihood (Hamilton 1989) EM Algorithm (Hamilton 1990) Smoothed probabilities (Kim 1994) Back test the strategy!

SUANSHU INITIATIVES The majority of traders do not have the math training to understand the mathematics details. For a capable quant, it may take 1 to 2 months to code a robust estimation procedure with elegant code, extensive test cases and professional documentations. Too expensive and time-consuming for a small hedge fund or prop. team in a bank.

SUANSHU OBJECTIVES SuanShu is a java numerical library of numerical methods and for numerical analysis. It has a collection of mathematics concepts and algorithms. It alleviates the users from writing infrastructural math code so they can focus on their applications. SuanShu has thousands of test cases and is professionally documented.

BACKTESTING Backtesting tells you whether a strategy worked in the past and not whether it will work in the future. It gives an objective way to measure performance, and hence confidence to the strategy. It allows systematic analysis of winning and losing trades, which in turn can be used to refine the strategy. It helps decide stoploss and take-profit.

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

SAMPLE BACKTESTER DESIGN data source: Reuters data source: EBS data source: CME data cache macro economics data, e.g., interest rate event database sim market, order book, e.g., USDJPY sim market, order book, e.g., EURUSD controller, time synchronizer, looping over simulated time trade blotter broker pnl tracker a strategy components stoploss real market, order book, e.g., EURUSD broker a strategy components broker a strategy components pnl tracker pnl tracker trade blotter stoploss trade blotter stoploss

SOME PERFORMANCE STATISTICS pnl mean, stdev, corr (confidence interval of) Sharpe ratio Omega breakeven bid/ask max drawdown breakeven ratio biggest winner/loser

OPTIMIZER Most strategies require calibration to update parameters for the current trading regime. Occam s 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)

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.

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.