automated trading

24
Automated Trading

Upload: gaurav-chakravorty

Post on 14-Aug-2015

327 views

Category:

Economy & Finance


0 download

TRANSCRIPT

Page 1: Automated Trading

Automated Trading

Page 2: Automated Trading

What IS Trading /what do traders

do

Traders observe market behaviourfor a long time

They detect certain patterns in market data and their mind makes certain prediction models consciously or subconsciously ( intuition )

They try to execute trades as instructed by the abstract model which was learned by their mind

Feed historical data to our system

Make it automatically learn patterns using ML/Statistics/Pattern Recognition and build prediction models

Make it execute trades as instructed by the automated model which was learned by our system

How about building a system that learns patterns in the market automatically?

But, What is the role of computer science in all this?

Page 3: Automated Trading

Advantages of automated trading ✖ Very reactive Quickly Responds to minor changes in the market

✖ Objective in natureNot subject to emotional bias

✖ Capable of handling very high dimensional data

1000’s of features

Page 4: Automated Trading

Prediction Problem

✖ General IdeaPredict future price under given market conditions/ scenario

✖ Challenge1 - High Dimensional data

1000s of variables/features to characterise given market scenario. Question:Why is that a problem ??

Overfitting??What if most the the features are correlated ??

How to avoid that ??Dimensionality Reduction/PCA/subset selection

Page 5: Automated Trading

Prediction Problem - Continued

✖ Challenge2 - Loss function/Objective function

How to evaluate if the learned model/pattern is good enough

Profit??Accuracy rate??Correlation ??

What if an objective function is not analytical.

Other Challenges - Overfitting problems (bias / variance tradeoff), Outlier detection

What if an objective function is not even continuous

Page 6: Automated Trading

Limit Order Book

Best Bid Price Best Ask Price

{ }Passive BuyOrders

Passive SellOrders

Bid Order Count

Bid Size

Bid Price

Ask Price

Ask Size

Ask Order Count

4 18 3061 3062 50 6

5 40 3060 3063 100 8

10 200 3059 3065 140 13

12 190 3058 3066 110 7

…. …. …. …. …. ….

Page 7: Automated Trading

Bid Order Count

Bid Size

Bid Price

Ask Price

Ask Size

Ask Order Count

4 18 3061 3062 50 6

5 40 3060 3063 100 8

10 200 3059 3065 140 13

12 190 3058 3066 110 7

…. …. …. …. …. ….

Place Passive Sell Orders

Cancel Passive Sell Orders

AggressivelySell

AggressivelyBuy

3 7 2 6 18

14

Ask Queue

Place Passive Buy Orders

Cancel Passive Buy Orders

Bid Queue

7 2 6 3

Page 8: Automated Trading

Notion of PRice - Reducing Order

book Dimensionality✖ No concrete fair price defined

✖ Only order book snapshots and trade history

✖ Total dimensionality of order book is high

✖ How to map this higher dimension data to a single number ( A Notion of fair price ) ??

Page 9: Automated Trading

Let’s take an easy problem

Total size at Bid

Number of orders at Bid

Price at highest Bid

Price at lowest Ask

Number of orders at Ask

Total size at Ask

240 25 99 100 40 80

What is your price ?

● Should it be between the bid and the ask ?

o How about the mean of the two ?

o How should sizes affect it?

● Should the inference be different if the market has been

moving a lot and this is just the current snapshot ?

Page 10: Automated Trading

APPLICATION Of Computer

Science in

ALGORITHMIC TRADING

Page 11: Automated Trading

➽ Every microsecond matters !

➽ Need to be Fast, Optimized and Robust.

➽ Several Areas of Computer Science involved.

Infrastructure Challenges

Page 12: Automated Trading

Infrastructure Pipeline

Receiving &

Decoding Market Data

Processing &

Building Book

Strategy Decision

Sending Orders

Receiving Replies

Page 13: Automated Trading

Infrastructure Pipeline

Receiving &

Decoding Market Data

Processing &

Building Book

Strategy Decision

Sending Orders

Receiving Replies

What’s going on in the market right now?

Page 14: Automated Trading

Infrastructure Pipeline

Receiving &

Decoding Market Data

Processing &

Building Book

Strategy Decision

Sending Orders

Receiving Replies

Interpreting market data and effectively keeping a track of bid/ask sides

Page 15: Automated Trading

Infrastructure Pipeline

Receiving &

Decoding Market Data

Processing &

Building Book

Strategy Decision

Sending Orders

Receiving Replies

In which direction is the market going to move?

Page 16: Automated Trading

Infrastructure Pipeline

Receiving &

Decoding Market Data

Processing &

Building Book

Strategy Decision

Sending Orders

Receiving Replies

Sending new orders or cancelling previously placed orders

Page 17: Automated Trading

Infrastructure Pipeline

Receiving &

Decoding Market Data

Processing &

Building Book

Strategy Decision

Sending Orders

Receiving Replies

What happened to my order?Did it get placed successfully, or was there

any error?

Page 18: Automated Trading

➽ Receiving exchange data faster : UDP(Multicast) or TCP ?

➽ Colocation servers, direct lines to exchange.

➽ Data through Microwave.

COMPUTER NETWORKS

Page 19: Automated Trading

➽ Book building requires efficient data structures.

➽ Using the best algorithms, minimizing latency.

➽ Optimizing code for better hardware utilization

Data Structures / Algorithms

Page 20: Automated Trading

➽ Inter Process Communication : Shared Memory or TCP or Multicast ?

➽ Multithreaded Applications: Locks, Mutexes, Semaphores ?

➽ Context Switches ? Affine process to a single core Messaging Accelerators ( eg. VMA ) :

bypass kernel for network input

Operating Systems

Page 21: Automated Trading

➽ Decoding provided data using Hardware (instead of software)?

➽ FPGAs programmed to decode data.

➽ Latency benefits due to parallel processing (at Hardware level)

Digital Hardware Design

Page 22: Automated Trading

➽ Managing large amounts of historical exchanges’ data, and running studies on it.

➽ Amazon EC2 (compute), S3 (backups)

BIG DATA MANAGEME

NT

Page 23: Automated Trading

➽ Large Codebase with common code.

➽ Design Patterns, Object Oriented, Templated Programming.

Design Practices

Page 24: Automated Trading

Thanks!Any questions?

Two Roads Technological Solutions

http://www.tworoads.co.in/[email protected]

08800355641