Algorithmic TradingandFIX Protocol
Sergey Troshin, [email protected]
Moscow, March 2016
Anton AntonovHead of OPS
Содержание
• Алгоритмическая торговля. Классы алгоритмов (10 мин)• Инфраструктура современного брокера (10 мин)• FIX протокол. Основные концепции (40 мин)– Тэги и сообщения– Dictionary файл– Разница между версиями– Как читать FIX спецификацию брокера
• FIX протокол. Пример реализации на С# (20 мин)• Вопросы и ответы (10 мин)
Algorithmic Trading
Algorithmic trading
Automatic trading
HFT – high frequency trading
Algorithmic Trading
How does Execution Works?
Order driven market model
–Market Order– Limit Order
Automatic trading
Buy-side Sell-side
Statistical arbitrageVWAPMarket Making / HFT
Trend following
Arbitrage
Smart order routing
Well Known Strategies.
Automatic trading
Market Making and Scalping
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• …
Volume Weighted Average Price
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.
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
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
How to Compare Strategies?
Sharp Ratio
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
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
Technical Broker Infrastructure
EXANTE Platform
inin
ATP
out
Customized backoffice reporting
API(FIX)
Platform
300 +Servers
->What is located on servers?
-> Where are other exchanges?
-> Where FIX server is located?-> What is algorithm?
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
Creating an Algorithm
• Any programming language• 3rd party software• Run algorithm on your server or in
broker’s VM• Control through the trading terminal
Trading Terminal
• Market Analysis• Manual trading• FIX orders control• Account control
-> What about other servers?
Trading Data and Client Accounts Processing
+ DEMO environment+ Development servers
FIX Protocol. Main Concepts
Origins
Versions
• 4.2
• 4.4
• 5.0
• FIXML• FIX FAST
The two parts of FIX
Communication partners
• Initiator• Acceptor
Why FIX?
Structure: Tags
TAG=VALUE[SOH]35=A[SOH]35=A[SOH]34=1[SOH]|35=A|34=1|
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|
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|
Structure: Component blocks
146=3
55=SHAREA
207=EXCHANGE
55=SHAREB
207=EXCHANGE
55=SHAREC207=EXCHANGE
Message types
Admin:35=0 Heartbeat35=5 Logout35=A Logon
Application:35=D New Order - Single
35=8 Execution Report
35=3 Reject
Fix engines
• FIX Antenna C++:• QuickFIX• QuickFIX/J• VersaFix• UL FIX
Certification
Dictionary files
FIX Specification
Logging and debugging
FIX Protocol. C# Example
• 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
https://bitbucket.org/SergeyTroshin/exante-fix-sample
Project Dependencies
Classes to Implement
QuickFIX minimum
QuickFIX. Configuration Files
Feeder Application
Feeder Application Class. From Server.
Feeder Application. Receive Market Data.
Feeder Application Class. Subscribe for Market Data.
Broker Application
Broker Application. From Server.
Broker Application. Symbol List Request.
FIX Specification. Symbol List Response.
Broker Application. Symbol List Response.
Using EXANTE FIX Wrapper
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
NEXT GENERATIONPRIME BROKER
Questions?
Portomaso Business Tower, Level 7, ST. Julians, [email protected] | [email protected] | www.exante.eu