Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan...

107
Nitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic Trading Bangkok, 7-Oct-2014

Transcript of Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan...

Page 1: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Nitesh Khandelwal & Rajib Ranjan Borah

QuantInsti

Options Workshop: Algorithmic & Automated Trading

Introduction to Algorithmic Trading

Bangkok, 7-Oct-2014

Page 2: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Trading in the markets

If you have a profitable trading strategy, then …

Page 3: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

If you have a profitable trading strategy, then …

• do it as frequently (don’t miss any opportunity)

• scale it up (trade as many financial instruments)

• don’t let emotions affect (greed & fear: traders’ biggest enemies)

Trading in the markets

Page 4: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

If you have a profitable trading strategy, then …

• do it as frequently (don’t miss any opportunity)

• scale it up (trade as many financial instruments)

• don’t let emotions affect (greed & fear: traders’ biggest enemies)

Computers:

• always at their seats

• respond to opportunities in

microseconds

Trading in the markets

Page 5: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

If you have a profitable trading strategy, then …

• do it as frequently (don’t miss any opportunity)

• scale it up (trade as many financial instruments)

• don’t let emotions affect (greed & fear: traders’ biggest enemies)

Human eye can monitor 10-

15 stocks.

Computers can track

thousands simultaneously

Trading in the markets

Page 6: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

If you have a profitable trading strategy, then …

• do it as frequently (don’t miss any opportunity)

• scale it up (trade as many financial instruments)

• don’t let emotions affect (greed & fear: traders’ biggest enemies)

Computers have no

emotions

Trading in the markets

Page 7: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

If you have a profitable trading strategy, then … • do it as frequently (don’t miss any opportunity)

• scale it up (trade as many financial instruments)

• don’t let emotions affect (greed & fear: traders’ biggest enemies)

Trading is all about Probability & Computations.

And computers do calculations faster!

Trading in the markets

Page 8: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Inevitably, machines have taken over human beings

Trading today

Page 9: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Inevitably, machines have taken over human beings

Trading today

Page 10: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Trading shifted from pits …

Page 11: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

…to computers

Page 12: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

…and even more computers

Page 13: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Trading Landscape changes

This revolution has been fast

Page 14: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Effect of Algo - Trading

Growth in trading activity

Options

FX

Equity

Page 15: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Options

FX

Equity

Growth in trading activity

Effect of Algo - Trading

Page 16: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Options

FX

Equity

Growth in trading activity

Effect of Algo - Trading

Page 17: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Unfortunately… Computers don’t think The price dropped from $796 to $775 in about 3/4 of a second, then rebounded to $793 a second later. The drop involved 307 trades and 57,255 shares from 10 exchanges + dark pools.

Effect of Algo - Trading

Page 18: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Pros and Cons

Trading algorithmically is generally more profitable

Page 19: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Trading algorithmically is generally more profitable

• Less downtime • No emotions (Greed & Fear) • React faster • Higher scalability • Accurate and faster calculations

Pros and Cons

Page 20: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Trading algorithmically is generally more profitable

But…

Systems are getting

more complicated

Traditional trading system

Pros and Cons

Page 21: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Trading algorithmically is generally more profitable

But…

Systems are getting

more complicated

Thereby Increasing

likelihood of errors

Automated trading system

Pros and Cons

Page 22: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Trading algorithmically is generally more profitable …

… It can be riskier

Pros and Cons

Page 23: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Benefits of High-Frequency Trading

• Improves scalability – Non-automated trader can monitor not a lot of

information

• Increased system uptime – Trader need not be on his toes all the time

– No system fatigue

• Faster response to events – Respond in microseconds

• Trade more opportunities – Non-automated trading sometimes cannot

respond in time while opportunity exists

• Better risk and portfolio management

Benefits to traders

Benefits to market

Spillover benefits

Page 24: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

• Improved market liquidity • Reduced costs of trading

– Aite Grp estimates avg retail trader saves ~$500 a year on tightened bid-ask spreads

• Reduced volatility of markets (higher stability)

• Increased market efficiency • Reduced dependency on brokers (DMA) • Improved infrastructure at the exchange

– Level playing field (transparency & efficiency) – Faster exchange response time => lower exposure time for market makers => better risk management & quotes

Benefits to traders

Benefits to market

Spillover benefits

Benefits of High-Frequency Trading

Page 25: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Benefits

to traders

Benefits to market

Spillover benefits

• Several spillover benefits to technological sector in general: • Automatic complex event processing in

microseconds • Artificial intelligence systems greatly evolved

(algorithmic trading systems use artificial intelligence to think like humans)

• Ability to process huge amount of information flow (market data)

• Real time mission critical stable systems • Statistical systems to process & analyse

monstrous amounts of data (Big Data) • Accelerated hardware • Hardware programming (FPGA, etc)

Benefits of High-Frequency Trading

Page 26: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Copyright © 2014 by QuantInsti Quantitative Learning Private Limited.

Although great care has been taken to ensure accuracy of the information

in this presentation – however the author (and QuantInsti) accepts no

liability or warranty for the precision, correctness or completeness of any

statement, estimate or opinion. QuantInsti also accepts no liability for the

consequences of any actions taken on the basis of the information

provided.

The slides of this presentation cannot be taken separately from the whole

set of slides.

Prior approval from QuantInsti is necessary before usage of this

presentation for educational and (or) commercial purposes.

This document provides an outline of a presentation and is incomplete

without the accompanying oral commentary and discussion.

Disclaimer

Page 27: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

System Architecture - impact on trading performance

Options Workshop: Algorithmic & Automated Trading

Nitesh Khandelwal & Rajib Ranjan Borah

QuantInsti Bangkok 7-Oct-2014

Page 28: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

2

Table of Contents • System architecture of a traditional trading

system

• System architecture of an algorithmic trading system

• System architecture of external components

Page 29: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

3

Table of Contents • System architecture of a traditional trading

system

• System architecture of an algorithmic trading system

• System architecture of external components

Traditional systems → Automated systems → Internal components → External components → QA

Page 30: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

4

System Architecture of a Traditional Trading System

• Traditionally a trading system would consist of

– A system to read data from the market

– A storehouse of historical data

– A tool to analyse historical data

– A system where the trader can input his trading decisions

– A system to route orders to the exchange

Traditional systems → Automated systems → Internal components → External components → QA

Page 31: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

5

System Architecture of a Traditional Trading System

• A system to read data from the market

Market Data Exchange

Traditional systems → Automated systems → Internal components → External components → QA

Page 32: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

6

System Architecture of a Traditional Trading System

• A storehouse of historical data – Which could also be directly purchased from third party data vendor

directly

Market Data Exchange

Data

Warehouse

/

Storehouse

of

historical

data

Data

Vendor

Traditional systems → Automated systems → Internal components → External components → QA

Page 33: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

7

System Architecture of a Traditional Trading System

• A subset of the database is queried and stored locally for operational uses

Market Data

Operational Data Store

Exchange

Data

Warehouse

/

Storehouse

of

historical

data

Data

Vendor

Traditional systems → Automated systems → Internal components → External components → QA

Page 34: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

8

System Architecture of a Traditional Trading System

• The trader’s tool would then analyze current data against patterns discovered in the operational data store

Trader’s tool

Main Centre of operations

– analyzing market data

wrt to historical data in

operational data store

and generating orders

Market Data

Operational Data Store

Exchange

Data

Warehouse

/

Storehouse

of

historical

data

Data

Vendor

Traditional systems → Automated systems → Internal components → External components → QA

Page 35: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

9

System Architecture of a Traditional Trading System

• The trader’s tool would then generate orders which will be forwarded to the order management tool

Order Manager

Market Data

Operational Data Store

Exchange

Data

Warehouse

/

Storehouse

of

historical

data

Data

Vendor

Trader’s tool

Main Centre of operations –

analyzing market data wrt

to historical data in

operational data store and

generating orders

Traditional systems → Automated systems → Internal components → External components → QA

Page 36: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

10

System Architecture of a Traditional Trading System

• The order manager would then route the orders to the exchange

Order Manager

Market Data

Operational Data Store

Exchange

Data

Warehouse

/

Storehouse

of

historical

data

Data

Vendor

Trader’s tool

Main Centre of operations –

analyzing market data wrt

to historical data in

operational data store and

generating orders

Traditional systems → Automated systems → Internal components → External components → QA

Page 37: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

11

System Architecture of a Traditional Trading System

• The data warehouse would also probably store records of orders sent out

Order Manager

Market Data

Operational Data Store

Exchange

Data

Warehouse

/

Storehouse

of

historical

data

Data

Vendor

Trader’s tool

Main Centre of operations –

analyzing market data wrt

to historical data in

operational data store and

generating orders

Traditional systems → Automated systems → Internal components → External components → QA

Page 38: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

12

System Architecture of a Traditional Trading System

• The whole system could be broken down to three components

Order Manager

Market Data

Operational Data Store

Exchange

Data

Warehouse

/

Storehouse

of

historical

data

Data

Vendor

Trader’s tool

Main Centre of operations –

analyzing market data wrt

to historical data in

operational data store and

generating orders

Traditional systems → Automated systems → Internal components → External components → QA

Page 39: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

13

System Architecture of a Traditional Trading System

• The exchange (and other data sources) – i.e. the external world

Order Manager

Market Data

Operational Data Store

Exchange

Data

Warehouse

/

Storehouse

of

historical

data

Data

Vendor

Trader’s tool

Main Centre of operations –

analyzing market data wrt

to historical data in

operational data store and

generating orders

Exchange

Traditional systems → Automated systems → Internal components → External components → QA

Page 40: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

14

System Architecture of a Traditional Trading System

• The server – which is mostly a data store

Order Manager

Market Data

Operational Data Store

Exchange

Data

Warehouse

/

Storehouse

of

historical

data

Data

Vendor

Trader’s tool

Main Centre of operations –

analyzing market data wrt

to historical data in

operational data store and

generating orders

Server Exchange

Traditional systems → Automated systems → Internal components → External components → QA

Page 41: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

15

System Architecture of a Traditional Trading System

• The applications in the trader’s pc which do all the processing

Order Manager

Market Data

Operational Data Store

Exchange

Data

Warehouse

/

Storehouse

of

historical

data

Data

Vendor

Trader’s tool

Main Centre of operations –

analyzing market data wrt

to historical data in

operational data store and

generating orders

Application Server Exchange

Traditional systems → Automated systems → Internal components → External components → QA

Page 42: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

16

System Architecture of a Traditional Trading System

• If data operations are simple… operational data store can be in application layer (trader’s pc)

Order Manager

Market Data

Operatio

nal Data

Store

Exchange

Data

Warehouse

/

Storehouse

of

historical

data

Data

Vendor

Trader’s tool

Main Centre of operations –

analyzing market data wrt

to historical data in

operational data store and

generating orders

Application Server Exchange

Traditional systems → Automated systems → Internal components → External components → QA

Page 43: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

17

Table of Contents

• System architecture of a traditional trading system

• System architecture of an algorithmic trading system

• System architecture of external components

Traditional systems → Automated systems → Internal components → External components → QA

Page 44: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

18

System Architecture of an Automated Trading System

• With the advent of DMA & automated trading, the following changes in architecture took place:

– Latency between Event Occurrence & Order Generation had to be reduced to an order of milliseconds and lower.

– Order Management had to be made more robust to handle generation of thousands of orders in a second

– Risk Management had to be done in real time and without human intervention

Traditional systems → Automated systems → Internal components → External components → QA

Page 45: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

19

System Architecture of an Automated Trading System

• To generate orders quickly, market events are now handled in the server instead of the application - in the CEP module

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Traditional systems → Automated systems → Internal components → External components → QA

Page 46: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

20

System Architecture of an Automated Trading System

• Complex mathematical operations are handled in a dedicated calculation block in the server block (e.g. Options Greeks calculations)

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Maths

Calc

Traditional systems → Automated systems → Internal components → External components → QA

Page 47: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

21

System Architecture of an Automated Trading System

• The role of the application layer has reduced drastically – (i) an input screen for strategy settings

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

Maths

Calc

Traditional systems → Automated systems → Internal components → External components → QA

Page 48: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

22

System Architecture of an Automated Trading System

• The role of the application layer has reduced drastically – (ii) a monitor of position & orders

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt

(PnL +

Position)

Order /

Execution

Monitor

Maths

Calc

Traditional systems → Automated systems → Internal components → External components → QA

Page 49: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

23

System Architecture of an Automated Trading System

• The role of the application layer has reduced drastically – (iii) preliminary fat finger RMS checker

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

applicatio

n RMS

Maths

Calc

Traditional systems → Automated systems → Internal components → External components → QA

Page 50: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

24

System Architecture of an Automated Trading System

• RMS is now automated and checked by the OMS before an order is generated

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

application

RMS

Maths

Calc

RMS

Traditional systems → Automated systems → Internal components → External components → QA

Page 51: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

25

System Architecture of an Automated Trading System

• Because RMS is automated, a second level of monitoring is necessary – an overall global position monitor

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

application

RMS

Maths

Calc

RMS

Admin

Monitor

Traditional systems → Automated systems → Internal components → External components → QA

Page 52: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

26

System Architecture of an Automated Trading System

• With Multiple destinations being connected to the automated systems, standardized protocols (FIX) became the norm

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

application

RMS

Maths

Calc

RMS

Exchange

2

F

I

X

F

I

X

Admin

Monitor

Traditional systems → Automated systems → Internal components → External components → QA

Page 53: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

27

System Architecture of an Automated Trading System

• This also necessitated adding data normalizer block in the market data adaptors to convert data from multiple exchanges into a standard format

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

application

RMS

Maths

Calc

RMS

Exchange

2

F

I

X

F

I

X

Data

Normalizer

Admin

Monitor

Traditional systems → Automated systems → Internal components → External components → QA

Page 54: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

28

System Architecture of an Automated Trading System

• Moreover, an Order Router had to be added to the OMS to route orders from the same OMS to multiple exchanges

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

application

RMS

Maths

Calc

RMS

Exchange

2

F

I

X

F

I

X

Data

Normalizer

Order

Router Admin

Monitor

Traditional systems → Automated systems → Internal components → External components → QA

Page 55: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

29

System Architecture of an Automated Trading System

• Regulatory requirements have complicated storage requirements – requiring storage of trade information in addition to market data

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

application

RMS

Maths

Calc

RMS

Exchange

2

F

I

X

F

I

X

Data

Normalizer

Order

Router

Back

office

record

MktData

Store

Admin

Monitor

Traditional systems → Automated systems → Internal components → External components → QA

Page 56: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

30

System Architecture of an Automated Trading System

• And obviously it should be able to read information from third party vendors as well

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

application

RMS

Maths

Calc

RMS

Exchange

2

F

I

X

F

I

X

Data

Normalizer

Order

Router

Back

office

record

MktData

Store

Data

Vendor

Admin

Monitor

Traditional systems → Automated systems → Internal components → External components → QA

Page 57: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

31

System Architecture of an Automated Trading System

• Moreover, the CEP engine has its own storage requirements of event history to identify future opportunities

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

application

RMS

Maths

Calc

RMS

Exchange

2

F

I

X

F

I

X

Data

Normalizer

Order

Router

Back

office

record

MktData

Store

Event

History

Data

Vendor

Admin

Monitor

Traditional systems → Automated systems → Internal components → External components → QA

Page 58: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

32

System Architecture of an Automated Trading System

• Complex functionality third party applications have to be tightly integrated with all the blocks

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

application

RMS

Maths

Calc

RMS

Exchange

2

F

I

X

F

I

X

Data

Normalizer

Order

Router

Back

office

record

MktData

Store

Event

History

Adaptor for

third party

apps – R,

Matlab, etc

Data

Vendor

Admin

Monitor

Traditional systems → Automated systems → Internal components → External components → QA

Page 59: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

33

System Architecture of an Automated Trading System

• Independent data management tools to verify the sanity of the information have to configured

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

application

RMS

Maths

Calc

RMS

Exchange

2

F

I

X

F

I

X

Data

Normalizer

Order

Router

Back

office

record

MktData

Store

Event

History

Adaptor for

third party

apps – R,

Matlab, etc

Data

Retrieval

Data

Vendor

Admin

Monitor

Traditional systems → Automated systems → Internal components → External components → QA

Page 60: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

34

System Architecture of an Automated Trading System

• To be able to back-test strategies, two components are required: (i) replay of stored data

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

application

RMS

Maths

Calc

RMS

Exchange

2

F

I

X

F

I

X

Data

Normalizer

Order

Router

Back

office

record

MktData

Store

Event

History

Adaptor for

third party

apps – R,

Matlab, etc

Data

Retrieval

Data

Vendor

Replay

of

stored

data

Admin

Monitor

Traditional systems → Automated systems → Internal components → External components → QA

Page 61: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

35

System Architecture of an Automated Trading System

• To be able to back-test strategies, two components are required: (ii) a simulator destination instead of an actual exchange

Application

Order Manager

Market Data

Complex Event Processing

engine

Exchange

1

Storage

Application Server Exchange

Strategy

Settings

UI

State

Mgmt (PnL

+ Position)

Order /

Execution

Monitor

Within

application

RMS

Maths

Calc

RMS

Admin

Monitor

Exchange

2

F

I

X

F

I

X

Data

Normalizer

Order

Router

Back

office

record

MktData

Store

Event

History

Adaptor for

third party

apps – R,

Matlab, etc

Data

Retrieval

Data

Vendor

Replay

of stored

data

Simulator

exchange

Traditional systems → Automated systems → Internal components → External components → QA

Page 62: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

36

Table of Contents • System architecture of a traditional trading

system

• System architecture of an algorithmic trading system

• System architecture of external components

Traditional systems → Automated systems → Internal components → External components → QA

Page 63: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

37

System Architecture – external components

• Standard vs Native – FIX vs Proprietary

Standard APIs Native APIs

Traditional systems → Automated systems → Internal components → External components → QA

Page 64: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

38

Relevant factors for analyzing different markets → Current landscape in different geographies → The future → QA

Technology Protocols globally One of the most popular protocol is FIX

Financial Information eXchange protocol

Data transferred as sequence of tag=value pairs

e.g.: 8=FIX.4.2 | 9=77 | 35=0 | 49=MCXSXTRADE | 56=xxxxx | 34=24

| 43=N | 52=20140607-05:14:05 | 112=DNLDCOMPLETE | 10=127

1 Account

2 AdvId

3 AdvRefID

4 AdvSide

5 AdvTransType

6 AvgPx

7 BeginSeqNo

8 BeginString

9 BodyLength

10 CheckSum

11 ClOrdID

12 Commission

13 CommType

14 CumQty

15 Currency

16 EndSeqNo

17 ExecID

18 ExecInst

19 ExecRefID

20 ExecTransType

21 HandlInst

22 IDSource

23 IOIid

24 IOIOthSvc (no longer used)

25 IOIQltyInd

26 IOIRefID

27 IOIShares

28 IOITransType

29 LastCapacity

30 LastMkt

31 LastPx

32 LastShares

33 LinesOfText

34 MsgSeqNum

35 MsgType

36 NewSeqNo

37 OrderID

38 OrderQty

39 OrdStatus

40 OrdType

41 OrigClOrdID

42 OrigTime

43 PossDupFlag

44 Price

45 RefSeqNum

46 RelatdSym

47 Rule80A(aka OrderCapacity)

48 SecurityID

49 SenderCompID

50 SenderSubID

51 SendingDate (no longer used)

52 SendingTime

53 Shares

54 Side

55 Symbol

56 TargetCompID

57 TargetSubID

Page 65: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

39

System Architecture – external components

Message Rates/ order throttles

1. Enforced using message rate per

second

2. Invitation informing available

message slots

3. Intermediate layer – TAP Server

4. Bandwidth considerations

Traditional systems → Automated systems → Internal components → External components → QA

Page 66: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Technology and Hardware innovations

Options Workshop: Algorithmic & Automated Trading

QuantInsti 7-Oct-2014

Page 67: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

41

Agenda • Understanding Performance factors

• Improving Performance – software

• Improving Performance – hardware

Page 68: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

42

Agenda • Understanding Performance factors

• Improving Performance – software

• Improving Performance – hardware

Page 69: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

43

How critical is performance ?

Hundreds of millions of dollars spent by various people to reduce the

round trip time between Chicago and New York from 13 milliseconds to

around 9 milliseconds

Page 70: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

44

How critical is performance ?

Hundreds of millions of dollars spent by various people to write code in

hardware itself instead of implementing it in software

Page 71: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

45

What is Performance? • Internal to the system

– Lots of data – fast processing

– Fast decision making

– Fast risk management

• External to the system

– Fast transfer of data, both outgoing and incoming

– Fast processing of requests at the destination

Page 72: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

46

Microbursts

Page 73: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

47

Latencies: Exchange to Network

• Typical latencies from exchange to network

Page 74: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

48

Latencies: Within network • Typical latencies within internal network

Page 75: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

49

Agenda • Understanding Performance factors

• Improving Performance – software

• Improving Performance – hardware

Page 76: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

50

Race to 0 latency – Software

• Re-tune TCP Stack. TCP hacks (TCP_NODELAY, sendfile(2))

• Moving the software as close to hardware as possible.

• Move from reusable object oriented code towards extremely efficient code using lower level of programming

• Avoiding disk writes, in memory storage

• Program Runtime – isolcpus, stack bypass

• Lock Free Codes

• Operating System – RT kernels

Page 77: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

51

Agenda • Understanding Performance factors

• Improving Performance – software

• Improving Performance – hardware

Page 78: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

52

Race to 0 latency – Hardware

• Servers – Fastest Cores, Cache, • Fastest Network Infra (Switches, Routers ) • Solid State Drives • Microwave Transmission • FPGA – ASIC implementation • Custom Chips • TCP Offload / Kernel Bypass by hardware DMA • Hardware message filters • Line arbitration

Page 79: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

53

Latency race leading to microwaves

• Chicago to New York – Ordinary Cable round trip time = 14.5 milliseconds – Trading leased lines = 13.1 milliseconds – Oct 2012: Spread Network lays straighter cables resulting

in 12.98 milliseconds • Huge benefits to Spread as lot of players shifted there

– 2013-14: McKay Brothers and Tradeworx offer microwave connection between these cities

(9 & 8.5 milliseconds respectively) • Theoretical limit of physics = 7.5 to 8 milliseconds

Page 80: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

54

Any Questions?

Page 81: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

55

Copyright © 2014 by QuantInsti Quantitative Learning Private Limited.

Although great care has been taken to ensure accuracy of the information

in this presentation – however the author (and QuantInsti) accepts no

liability or warranty for the precision, correctness or completeness of any

statement, estimate or opinion. QuantInsti also accepts no liability for the

consequences of any actions taken on the basis of the information

provided.

The slides of this presentation cannot be taken separately from the whole

set of slides.

Prior approval from QuantInsti is necessary before usage of this

presentation for educational and (or) commercial purposes.

This document provides an outline of a presentation and is incomplete

without the accompanying oral commentary and discussion.

Disclaimer

Page 82: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Risk Management – for HFT systems

Options Workshop: Algorithmic & Automated Trading

Nitesh Khandelwal & Rajib Ranjan Borah

QuantInsti

Bangkok 7-Oct-2014

Page 83: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Table of Contents

• Case studies of major risk incidents globally

• Algorithmic Trading Related Risks

Page 84: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Major algorithmic trading incidents globally - I

• Credit Suisse, Nov 2007 – Incident:

• Hundreds of thousands of cancel orders sent to the exchange

• Orders clogged NYSE and affected trading of over 900 stocks

– Reasons: • Trader implemented code which could change parameters

on clicking on spin button

(without any need for confirmation)

• With each click, orders were cancelled and resent

– Fine/ Losses: • $150,000 fine

Page 85: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Major algorithmic trading incidents globally - II

• Infinium Capital, Feb 2010 – Incident:

• 4612 trades on crude oil futures in 24 seconds

– Reasons: • Strategy was designed to trade energy ETFs on the basis of

crude prices

• Trader configured crude oil futures on the basis of energy ETFs

• Moreover, RMS was designed on the basis of ETF prices, not crude prices

– Fine/ Losses: • $850,000 fine by CME

Page 86: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

• Deutsche Bank, June 2010 – Incident:

• Sent orders for 1.24 million Nikkei 225 Futures & 4.82 million Nikkei 225 mini-futures in first few minutes

• More than 10 times normal volume

• Market dropped 1% on orders

– Reasons: • Pair trade strategy used value of mini-Nikkei to quote

Nikkei. At start of day, there was no liquidity in mini-Nikkei

• Error recognized immediately, 99.7% orders cancelled

– Fine/ Losses: • Forced to close Algorithmic trading desk in Tokyo

Major algorithmic trading incidents globally - III

Page 87: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Major algorithmic trading incidents globally - IV

• Knight Capital, Aug 2012 – Incident:

• Traded 154 stocks at bizarre prices (4 million trades for 397 million shares in 45 minutes): alternately bought at higher prices and sold at lower prices

– Reasons: • Accidentally installed test software which incorporated an old

piece of code designed 9 years ago

• In one out of 8 production servers, new code was not installed by a technician

• No process for second technician to review

– Fine/ Losses: • Trading loss of $460 million in 45 minutes. Fine of $12 million

• Knight Capital had to be rescued by Getco

Page 88: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Major algorithmic trading incidents globally - V

• Goldman Sachs, Aug 2013

– Incident:

• Traded stock options at very erroneous prices at the exchange

– Reasons:

• Indication of interests were sent as actual orders to the exchange

– Fine/ Losses:

• Trading loss of $100 million

Page 89: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Major algorithmic trading incidents globally - VI

• Everbright Securities, Aug 2013 – Incident:

• Rogue algorithm kept buying – index moved up 6% intraday

• Did not inform regulators, shorted the artificial bubble – banned from prop trading forever for insider trading

– Reasons: • Algorithm sent buy orders for ETFs worth 23.4 billion

Yuan (7.27 billion got traded) – no risk check in OMS

– Fine/ Losses: • Banned from prop trading forever for insider trading

Page 90: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Major algorithmic trading incidents globally - VII

• HanMag Securities, Dec 2013 – Incident:

• HanMag exercised wrong call and put options

• 36,100 trades in a few minutes

– Reasons: • Error in automated profit taking trade program

(interchanged puts with calls)

– Fine/ Losses: • Some firms returned money back to HanMag (Optiver

returned $600k trading profits)

• Eventual loss of 57 billion Korean Won

Page 91: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

• United Airlines flash crash

– Incident:

• On Sep. 7, 2008 United Airlines had a downward price spike

– Reasons:

• Google’s news bots picked up an old 2002 story about United Airlines possibly filing for bankruptcy

• News Analytics based automated traders reacted to it

Major algorithmic trading incidents - VIII

Page 92: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

• Dow Jones Flash Crash

– Incident: • On Apr 23, 2013 Markets dropped 0.8% momentarily

– Reasons: • Twitter account of news publisher hacked – false news of White

house explosion

• News Analytics based automated traders reacted to it

Major algorithmic trading incidents - IX

Page 93: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Table of Contents

• Case studies of major risk incidents globally

• Algorithmic Trading Related Risks

Page 94: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Risks related to Algorithmic Trading

• Orders flow without human control – Higher reliance on technology implies increased sys-ops risk – In case of a wrong input, algorithm will execute at a wrong

level – If price feed goes down, algorithm will send orders based on

stale data • price feed could go down because of physical connectivity,

exchange disconnection, software crash, etc

• Before a human can realize (and then respond), tremendous damage would have been done already

• Trades happen at such a fast pace, that positions could reach a dangerous level in no time – Real-time monitor of positions, exposures, regulation checks

Page 95: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

• Risks specific to automated trading can be classified into the following categories: – Access – Consistency – Quality – Algorithm – Technology – Scalability

• These risks have to be handled pre-order – Within the application – Before generating an order in the Order Management

System

• Moreover, it is pertinent that the trader understands the internal working of the black-box

Risks related to Algorithmic Trading

Page 96: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

RISK Handled in

Methodology App OM

Access Connectivity to an exchange goes down

Y Y Heart-beats

Exchange disconnects you Y Y Heart-beats

Network issue Y Hardware, Operating System

Consistency Market Data is stale Y Y Time-stamp

Analytics are running in real-time (huge processing time)

Y Time-stamp

OM adaptor is responding in real time

Y Time-stamp

Quality Market - data is garbled Y Common RMS rule

Loss of liquidity during high-volatility

Y Common RMS rule

Risks related to Algorithmic Trading

Page 97: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

RISK

Risk Handled in Methodology

App OM

Algorithmic Margin breached Y Common RMS rule

Exposure limit set by exchange

Y Common RMS rule

Risk limits exceeded Y

Check for acknowledgements before sending order

Incorrect strategy setting leading to continual mistrades

Y Y PnL fluctuation check

-do- Y Order throttle rate

-do- Y Fat finger settings check

-do- Y Max Value Traded

Incorrect order generation Y Y Price range check

Order throttle Y Exchange reject limit

Risks related to Algorithmic Trading

Page 98: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

RISK

Risk Handled in

Methodology

App OM

Technology Hard disk gets full Independent check

Virus /Trojan Firewall, Anti-virus

System Crash Operating System

Application crash Y

Heart-beat to check application

Protocol Mismatch Third-party software compatibility check

Risks related to Algorithmic Trading

Page 99: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

RISK

Handled in

Methodology App OM

Scalability Number of applications & portfolios that can be handled Y Y

Number of exchanges that can be connected Y

Number of symbols that can be handled Y Y

Order of complexity of computations Y

Risks related to Algorithmic Trading

Page 100: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Risks related to Algorithmic Trading

Knowledge is the Key

Page 101: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

E-PAT

Statistics and Econometrics

Financial Computing & Technology

Algorithmic & Quantitative Trading

QI’s E-PAT course

Page 102: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

E-PAT

Statistics and Econometrics

Financial Computing & Technology

Algorithmic & Quantitative Trading

E-PAT course structure - module I

Basic Statistics

Advanced Statistics

Time Series Analysis

Probability and Distribution Statistical Inference Linear Regression

Correlation vs. Co-integration ARIMA, ARCH-GARCH Models Multiple Regression

Stochastic Math Causality Forecasting

Page 103: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

E-PAT

Statistics and Econometrics

Financial Computing & Technology

Algorithmic & Quantitative Trading

E-PAT course structure - module II

Programming

Technology for Algorithmic Trading

Statistical Tools

Intro to Programming Language(s) Programming on Algorithmic

Trading Platforms

System Architecture Understanding an Algorithmic

Trading Platform Handling HFT Data

Excel & VBA Financial Modeling using R Using R & Excel for Back-testing

Page 104: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

E-PAT

Statistics and Econometrics

Financial Computing & Technology

Algorithmic & Quantitative Trading

E-PAT course structure - module III

Trading Strategies

Derivatives & Market Microstructure

Managing Algo Operations

Statistical Arbitrage Market Making Strategies Execution Strategies Forecasting & AI Based Strategies Pair Trading Strategies Trend following Strategies

Option Pricing Model Dispersion Trading Risk Management using Higher

Order Greeks Option Portfolio Management Order Book Dynamics Market Microstructure

Hardware & Network Regulatory Framework Exchange Infrastructure & Financial

Planning (Costing) Risk Management in Automated

systems Performance Evaluation & Portfolio

Management

Page 105: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

E-PAT

Statistics and Econometrics

Financial Computing & Technology

Algorithmic & Quantitative Trading

Project work

E-PAT course structure - project

Page 106: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Contacts For 4-month Executive Program in Algorithmic Trading:

[email protected]

E-PAT: 4 month weekend online program (3hrs every Sat + Sun)

• Statistics & Econometrics

• Quantitative Trading

• Financial Computing

For algorithmic trading advisory: [email protected]

To reach us directly: [email protected] , [email protected]

Page 107: Options Workshop: Algorithmic & Automated Trading · PDF fileNitesh Khandelwal & Rajib Ranjan Borah QuantInsti Options Workshop: Algorithmic & Automated Trading Introduction to Algorithmic

Copyright © 2014 by QuantInsti Quantitative Learning Private Limited.

Although great care has been taken to ensure accuracy of the information in this presentation – however the author (and QuantInsti) accepts no liability or warranty for the precision, correctness or completeness of any statement, estimate or opinion. QuantInsti also accepts no liability for the consequences of any actions taken on the basis of the information provided.

The slides of this presentation cannot be taken separately from the whole set of slides.

Prior approval from QuantInsti is necessary before usage of this presentation for educational and (or) commercial purposes.

This document provides an outline of a presentation and is incomplete without the accompanying oral commentary and discussion.

Disclaimer