algorithmic trading and fix protocol

60
Algorithmic Trading and FIX Protocol Sergey Troshin, Ph.D. Director [email protected] Moscow, March 2016 Anton Antonov Head of OPS [email protected] www.exante.eu

Upload: exante

Post on 21-Apr-2017

1.884 views

Category:

Economy & Finance


5 download

TRANSCRIPT

Page 1: Algorithmic Trading and FIX Protocol

Algorithmic TradingandFIX Protocol

Sergey Troshin, [email protected]

Moscow, March 2016

Anton AntonovHead of OPS

[email protected]

Page 2: Algorithmic Trading and FIX Protocol

Содержание

• Алгоритмическая торговля. Классы алгоритмов (10 мин)• Инфраструктура современного брокера (10 мин)• FIX протокол. Основные концепции (40 мин)– Тэги и сообщения– Dictionary файл– Разница между версиями– Как читать FIX спецификацию брокера

• FIX протокол. Пример реализации на С# (20 мин)• Вопросы и ответы (10 мин)

Page 3: Algorithmic Trading and FIX Protocol

Algorithmic Trading

Page 4: Algorithmic Trading and FIX Protocol

Algorithmic trading

Automatic trading

HFT – high frequency trading

Algorithmic Trading

Page 5: Algorithmic Trading and FIX Protocol

How does Execution Works?

Order driven market model

–Market Order– Limit Order

Page 6: Algorithmic Trading and FIX Protocol

Automatic trading

Buy-side Sell-side

Statistical arbitrageVWAPMarket Making / HFT

Trend following

Arbitrage

Smart order routing

Well Known Strategies.

Page 7: Algorithmic Trading and FIX Protocol

Automatic trading

Market Making and Scalping

Page 8: Algorithmic Trading and FIX Protocol

Trend Following

Technical Analysis• SMA / EMA• Moving Average

Convergence/Divergence• Bollinger bands• Stochastic oscillator• Parabolic SAR• Rate of Change (ROC)• Relative Strength Index (RSI)• etc• …

Page 9: Algorithmic Trading and FIX Protocol

Volume Weighted Average Price

Page 10: Algorithmic Trading and FIX Protocol

Volatility and Option Trading

Implied volatility prediction

1. Delta neutral portfolio– Buy option / sell stock on volatility going up– Sell Option / buy stock on volatility going down

2. Various options strategies– Straddle– Strangle– Butterfly– Etc.

Page 11: Algorithmic Trading and FIX Protocol

Arbitrage Strategy Example

GAZPRU(MICEX)

On new tick:

ogzd_rub = convert(ogzd, usd_rub)spread = normalize(ogzd_rub/gazpru)

changedSpread()OGZD(LSE)

USD/RUB(FOREX)

LIMIT (LSE)

London Server

Filled (size)

MARKET (MICEX)

Filled (price)

On change spread:if (spread > threshold) place_limit(OGZD, price, size)

On limit fill:If (limit_is_filled) place_market(GAZPRU, size)

Parameters: threshold

Another example: S&P stocks on NYSE and NASDAQ in NY against Futures on CME in Chicago

Page 12: Algorithmic Trading and FIX Protocol

Pairs Trading and Statistical Arbitrage

Market neutral portfolio– Short one set of stocks– Long another set– Rebalance very often

• Pair Trading– Coca-Cola (KO) and Pepsi (PEP)– Renault (RNO) and PSA Peugeot Citroen (UG)

• Statistical Arbitrage– Up to 1000+ stocks in portfolio– Huge quantitive calculations

Page 13: Algorithmic Trading and FIX Protocol

How to Compare Strategies?

Page 14: Algorithmic Trading and FIX Protocol

Sharp Ratio

Page 15: Algorithmic Trading and FIX Protocol

Which is better?

Strategy Sharp Ratio Calculations HFT / Delay Sensitive?

Trend FollowingMean revision

Bad Easy No

Volatility Trading Bad Hard No

Arbitrage / Pair trading

Good Easy Yes

Statistical Arbitrage

Good Hard Yes

Market Making Good Easy Yes

Page 16: Algorithmic Trading and FIX Protocol

Technology

Market data

Delays

Market Depth Best Bid Offer

Trades

Execution

Delays

Client side / Server side

Pre-trade risks, Software

Connection

Protocol

Virtual Machines

Co-location

Control

Trades Export

Interface

Error handling

Page 17: Algorithmic Trading and FIX Protocol

Technical Broker Infrastructure

Page 18: Algorithmic Trading and FIX Protocol

EXANTE Platform

inin

ATP

out

Customized backoffice reporting

API(FIX)

Platform

Page 19: Algorithmic Trading and FIX Protocol

300 +Servers

Page 20: Algorithmic Trading and FIX Protocol

->What is located on servers?

Page 21: Algorithmic Trading and FIX Protocol

-> Where are other exchanges?

Page 22: Algorithmic Trading and FIX Protocol

-> Where FIX server is located?-> What is algorithm?

Page 23: Algorithmic Trading and FIX Protocol

FIX Server Location

One exchange– Low latency algorithm• Exchange data center

– No special requirements• Back up data center or any random data center

Several exchanges– Arbitrage with low latency algorithm• Exchange data center (exchange depends on algorithm) • Dedicate link to other exchanges

– No special requirements• Any data center (non exchange preferably)• Common Internet link

Page 24: Algorithmic Trading and FIX Protocol

Creating an Algorithm

• Any programming language• 3rd party software• Run algorithm on your server or in

broker’s VM• Control through the trading terminal

Page 25: Algorithmic Trading and FIX Protocol

Trading Terminal

• Market Analysis• Manual trading• FIX orders control• Account control

-> What about other servers?

Page 26: Algorithmic Trading and FIX Protocol

Trading Data and Client Accounts Processing

+ DEMO environment+ Development servers

Page 27: Algorithmic Trading and FIX Protocol

FIX Protocol. Main Concepts

Page 28: Algorithmic Trading and FIX Protocol

Origins

Page 29: Algorithmic Trading and FIX Protocol

Versions

• 4.2

• 4.4

• 5.0

• FIXML• FIX FAST

Page 30: Algorithmic Trading and FIX Protocol

The two parts of FIX

Page 31: Algorithmic Trading and FIX Protocol

Communication partners

• Initiator• Acceptor

Page 32: Algorithmic Trading and FIX Protocol

Why FIX?

Page 33: Algorithmic Trading and FIX Protocol

Structure: Tags

TAG=VALUE[SOH]35=A[SOH]35=A[SOH]34=1[SOH]|35=A|34=1|

Page 34: Algorithmic Trading and FIX Protocol

Structure: Message

8=FIX.4.4|9=125|35=A|34=1|49=EXAMPLE_TRADE_UAT|52=20160318-14:28:55.885|56=EXANTE_TRADE_UAT|98=0|108=30|141=Y|553=User|554=PA55W0RD|10=217|

Page 35: Algorithmic Trading and FIX Protocol

Structure: Message 2

8=FIX.4.4|9=192|35=D|34=241|49=EXAMPLE_TRADE_UAT|52=20160318-16:53:18.655|56=EXANTE_TRADE_UAT|1=TST1111.001|11=20160315152146019575|22=111|38=37|40=1|48=AAPL.NASDAQ|54=2|55=blank|59=3|60=20160318-16:53:18.653|10=225|

Page 36: Algorithmic Trading and FIX Protocol

Structure: Component blocks

146=3

55=SHAREA

207=EXCHANGE

55=SHAREB

207=EXCHANGE

55=SHAREC207=EXCHANGE

Page 37: Algorithmic Trading and FIX Protocol

Message types

Admin:35=0 Heartbeat35=5 Logout35=A Logon

Application:35=D New Order - Single

35=8 Execution Report

35=3 Reject

Page 38: Algorithmic Trading and FIX Protocol

Fix engines

• FIX Antenna C++:• QuickFIX• QuickFIX/J• VersaFix• UL FIX

Page 39: Algorithmic Trading and FIX Protocol

Certification

Page 40: Algorithmic Trading and FIX Protocol

Dictionary files

Page 41: Algorithmic Trading and FIX Protocol

FIX Specification

Page 42: Algorithmic Trading and FIX Protocol

Logging and debugging

Page 43: Algorithmic Trading and FIX Protocol

FIX Protocol. C# Example

Page 44: Algorithmic Trading and FIX Protocol

• EXANTE’s Demo program overview• QuickFix lib and Project dependencies • Configuration files• Application class• Methods to override• Some implement samples:– Market data subscribe and receive– Getting symbols list

Page 45: Algorithmic Trading and FIX Protocol

https://bitbucket.org/SergeyTroshin/exante-fix-sample

Page 46: Algorithmic Trading and FIX Protocol

Project Dependencies

Classes to Implement

QuickFIX minimum

Page 47: Algorithmic Trading and FIX Protocol

QuickFIX. Configuration Files

Page 48: Algorithmic Trading and FIX Protocol

Feeder Application

Page 49: Algorithmic Trading and FIX Protocol

Feeder Application Class. From Server.

Page 50: Algorithmic Trading and FIX Protocol

Feeder Application. Receive Market Data.

Page 51: Algorithmic Trading and FIX Protocol
Page 52: Algorithmic Trading and FIX Protocol

Feeder Application Class. Subscribe for Market Data.

Page 53: Algorithmic Trading and FIX Protocol

Broker Application

Page 54: Algorithmic Trading and FIX Protocol

Broker Application. From Server.

Page 55: Algorithmic Trading and FIX Protocol

Broker Application. Symbol List Request.

Page 56: Algorithmic Trading and FIX Protocol

FIX Specification. Symbol List Response.

Page 57: Algorithmic Trading and FIX Protocol

Broker Application. Symbol List Response.

Page 58: Algorithmic Trading and FIX Protocol

Using EXANTE FIX Wrapper

Page 59: Algorithmic Trading and FIX Protocol

Links

• www.exante.eu• [email protected]• http://elato.se/minifix/• http://www.quickfixengine.org/• http://btobits.com/fixopaedia/fixdic44/index.html• https://bitbucket.org/SergeyTroshin/exante-fix-sample

Page 60: Algorithmic Trading and FIX Protocol

NEXT GENERATIONPRIME BROKER

Questions?

Portomaso Business Tower, Level 7, ST. Julians, [email protected] | [email protected] | www.exante.eu