hft: futures and arbitrage · the importance of latency if you are “sniping”, you want to be...

34
HFT: Futures and Arbitrage Greg Graham Senior Developer, Geneva Trading [email protected]

Upload: others

Post on 20-Jul-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

HFT: Futures and Arbitrage

Greg GrahamSenior Developer, Geneva Trading

[email protected]

Page 2: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Part 1

Futures and Arbitrage Basics

Page 3: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Styles and Flavors of Trading● Categories as varied as branches of physics or

mathematics – Instruments: Equities, Commodities, Bonds, FX

● Derivatives on these: Futures, Options, Swaps– Markets: Energy, Ags, Metals, Currency, Interest

Rates– Tactics: Going long, going short, being flat– Strategy: Speculative, Risk Averse, “Risk Free”

● Arbitrage, Statistical Arbitrage, Algo trading– Methods: Open Outcry, Electronic, Day trading,

"point and click”, HFT

Page 4: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Futures and Options● A futures contract obligates the exchange of a

specified quantity of a commodity at a specified date and price.– Physically versus financially settled

● An options contract gives the buyer the option to buy/sell a specified quantity of a commodity at a specified date and price.– Both types of derivatives are useful for “hedgers” to minimize

risk.– Speculators provide liquidity and a smaller bid-ask spread.– Risk may be unlimited, depends on your objectives.

Page 5: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Aside on MF Global● Because of the unlimited risk, margin is

required for all futures (and options) traders. – Margin is cash held by a broker or a clearing house

to cover deteriorating positions. ● MF Global “blew up” and took > $109 customer

money with them.– That was customers' margin money!!!– Futures volumes are still down 40% as a result

● Coincidentally, MF Global went bankrupt when they couldn't meet a margin call.

Page 6: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Aside on MF Global● Because of the unlimited risk, margin is

required for all futures (and options) traders. – Margin is cash held by a broker or a clearing house

to cover deteriorating positions. ● MF Global “blew up” and took > $109 customer

money with them.– That was customers' margin money!!!– Futures volumes are still down 40% as a result

● Coincidentally, MF Global went bankrupt when they couldn't meet a margin call.

Page 7: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Synth Arb: Payoff of a futures contract

● (Source: Wikipedia)

Page 8: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Options: Puts versus Calls● A Call is an option that gives the buyer the

option to buy a commodity at a specified price ● A Put is an option that gives the buyer the

option to sell a commodity at a specified price ● Synthetic Futures (see next slide)

– Long Call + Short Put =~ Long Future– Short Call + Long Put =~ Short Future

● Arbitrage opportunity!– Buy the synthetic and sell the actual, or vice versa.– This is known as conversion/reversal.

Page 9: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Synth Arb: Payoff of an Options Contract

● (Source: Wikipedia)

Page 10: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Arbitrage For Pedestrians● In general, you traverse a cycle of financial instruments by

buying and selling and ending up “truly” flat.– If your gross exceeds your fees, you win!

● Conceptually, it really is that simple.● In practice, the field of arbitrage is very rich owing to the

sheer number of commodities and derivatives and the way they can be combined.

● If you are not flat throughout the day (especially at the end of the day), it is not true arbitrage.– Being “truly” flat leads to small, risk free profits. – In the conversion/reversal example, you are truly flat

only when you “leg out of/unwind” the position. Until then you are carrying risk.

Page 11: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Arbitrage For Pedestrians● Simple arbitrage

– Cross exchange, big versus mini contracts, Intercommodities, calendar spreads

● Synthetics– Conversions, reversals

● Statistical– Pairs trading, correlation hunting

● Sniping vs. Market Making– Sniping: Identifying price discrepancies and hitting all instruments at the

same time.– Market Making: Quoting prices in one market based on prices in other

markets (“the lean”) such that if someone hits your quote, you can immediately hit the leans and make a profit.

Page 12: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Another Fun Example: Futures Calendar Spreading

● Exchanges define “spread” instruments that represent the cost of buying a commodity in one month and selling it forward in another month.

● A popular (and obvious!) arbitrage strategy is to pick N months and look for pricing differences in the spreads. – Eg- Buy “Sep-Dec”, Sell “Sep-Nov”, Sell “Nov-Dec”– Lots of interesting graph theory involved in enumerating

possibilities.– Lots of interesting engineering involved in identifying and

evaluating opportunities.– Very competitive strategy. You MUST be very fast to make

money here.

Page 13: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Part II

Electronic Trading

Page 14: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Brief History● Electronic trading has been evolving since the mid 1980's. It

has really taken off since the current millennium began.● The CME (Chicago Mercantile Exchange) Globex system was

one of the earliest and is still today one of the most popular platforms. (www.cmegroup.com)

Page 15: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Nuts and Bolts: Market Data and Order Systems

● Connections to exchanges typically involve provisioning for receiving market data and for order systems.– Market data comprises moment to moment price data and

trade data, is high bandwidth, and is typically distributed over UDP multicast

– An order system comprises a protocol running over TCP that allows the firm to enter new orders, change existing orders, cancel orders, and receive fill reports.

– Other systems include disaster recovery portals, continuous “drop copy” of all orders executed, etc.

Page 16: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Abstraction: Market Book

Commodity X Quantity PriceAsk 52 99Ask 63 98Ask 32 97Ask 15 96Ask 5 95Bid 8 92Bid 22 91Bid 42 90Bid 101 89Bid 87 88

● An abstraction that accumulates working orders in an “open” market

● Updates streamed over UDP Multicast● Difference between an open market and a “dark pool”: dark

pools have no market books. (Request for Quote instead.)

Page 17: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Order Protocols● FIX (Financial Information eXchange) is a

common protocol– Open source FIX engine: QuickFIX.– ASCII “35=D 40=99 11=12345 ...” strings over TCP.

● A “standard”, but everybody has to agree on the meaning of the tags.

● Exchanges compete with each other, so these all get stuffed with special proprietary features anyway.

● Proprietary structured data protocols are also becoming more popular.– Better latency characteristics

Page 18: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Simple Diagram of a Trading Platform

App 1

App 2

App 3

Session 1

Session 2

Session 3

Match Engine

Exchange Traders

Order Flow->New Order Requests->Change Requests->Cancel Requests<-Acknowledgements<-Reject Responses<-Order Fills

TCP SessionOrder Flow

TCP SessionOrder Flow

TCP SessionOrder Flow

UDP Multicast Market Data->Aggregated information about all orders ->Notifications about consummated trades-> Market state information

Trading apps make decisions about where to place ordersbased on aggregated order information (eg- how many orders are there at a given price, also known as a “market book”).

Page 19: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Inside the HFT Trading App

Market Book

Market Book

Market Book

AlgoList of Prices,

Quantities

Order 1

Order 3

Order 2

Market Data Flowing In(possibly multiple sources)

Order Flow (Maintain order state with exchange)

Engineering problem: Efficiently present multiple streams of market data to an algo.Maintain slate of orders algo wants with exchange.

Page 20: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

The Importance of Latency● If you are “sniping”, you want to be the first to decode the

market data and get your orders in.– In software, a good multi-threaded architecture is critical.

● If you are “market making”, you want to be the first to decode market data and get your quotes out of the way if a “lean” disappears.– Also if you get filled on a quote, you want to be the first to hit the lean.

● If you are trading speculatively, latency is not so important.– Contrary to what you may hear ,HFT does not keep grandma and

grandpa from trading their retirement portfolios.

Page 21: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

The Race to Zero● Fast multi-core servers

– Must be able to decode multiple UDP multicast streams at once

● Fast NICs● Fast networks and routers● Colocation services

– Exchanges often run a side business of hosting servers with shorter cable runs to their match engines.

● $$$

Page 22: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Part III

Technology

Page 23: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Platforms● Linux/C++ is probably the most popular.● Microsoft/.Net technologies are also well

represented.– Thread scheduling tweaks: advantage Linux– Time to develop: advantage Microsoft

● Servers: Top of the line, replaced frequently.● It's hard to say what others may/may not be

using.– Nobody talks about it!

Page 24: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Networking● Gigabit ethernet on fiber is probably the most

standard.– 10 Gig is becoming more popular.– Typically, market data bandwidth still fits inside a

1 Gig pipe ● Typically, the low latency links are very

important at the colocation facilities and between colocation facilities.– Better than 1 mSec between server and exchange – Not so important between the office and the colo.

● Costs: ~ $10k/month/rack

Page 25: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Software● Independent Software Vendors

– Closed trading systems with varying degrees of customization

– Trading Technologies, CQG, Reuters– Colocated servers and gateways

● Proprietary Software– Faster, more targeted, only includes important

features (to us!)

Page 26: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Next Gen Technologies● Software: Fiber mode scheduling

– Scheduling tasks within a running thread● FPGA technology

– Trade on a chip, takes the OS networking stack out of the equation

– Coprocessors and ASICs● CUDA

– Massively parallel operations on graphics cards– Probably not suitable for the latency “hot path”

Page 27: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Next Gen Technologies● Shorter fiber runs

– Spread networks (Under 15 mSec, $5k/month)● Microwave links

– McKay bros. Beats fiber from Chicago to NY (Under 10 msec, $15k/month)

– Tradeworkx. (Beats McKay bros. $250k/month!!!)–

– (Source: wired.com)

Page 28: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Monitoring● Low latency is expensive, so we are serious

about monitoring.● We use packet-packet correlation engines to

measure time differences of packets entering/leaving our network– Sensitive under 100 nSec– Network taps on fiber – the measurement does not

add latency.– Can very accurately measure both external

exchange latency and internal algo latency.

Page 29: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Part IV

Career

Page 30: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Career Path● PhD, U of Chicago, 1999 (KteV)● Postdoc, U of Maryland, 1999-2001 (DZero) ● FNAL Computing Division, 2001-2005 (CMS) ● Orbitz, LLC, 2005-2006● American Chartered Bank, 2006-2009● Mecury Holdings/Geneva Trading, 2009-Now●

● Experience is important – but you can be incremental.

Page 31: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Resume/Interview Tips● Always strive to learn new things at every job.

– Never be complacent on this point!● Make sure your resume is up to date

– Make sure you are up to date w.r.t the resume ;-) ● Practice interviewing

– Apply for some jobs just to practice the interview!– Learn something from every interview

Page 32: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

So You Want a Finance Job...● Know what kind of position you are interviewing

for, and tailor your pitch.– IT developer: Expect to be tested on multi-threaded design

and coding gotchas. Expect the f2f to focus on some OO design problem.

– Analyst/Quant: Expect to be tested on basic finance, pricing theory. Expect the f2f to include some goofy brain teasers.

● Some companies give the brain teasers to developers too– There are also niche positions: FPGA (VHDL/Verilog) is

becoming more popular.● Non disclosure/Non competes are standard.

– Be ready to have an attorney look it over.– These are often negotiable.

Page 33: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Geneva Trading● Offices in Chicago, New York, Dublin

– Http://www.geneva-trading.com● We have diverse trading styles

– HFT trading on proprietary platform– ISV “point and click” trading– Algo trading – Primarily futures, some options

● Starting to dip toes in equities● We have no customers● Looking for junior devs now, probably senior

dev after Jan 1.

Page 34: HFT: Futures and Arbitrage · The Importance of Latency If you are “sniping”, you want to be the first to decode the market data and get your orders in. – In software, a good

Conclusion● HFT is a very challenging, fast paced, and rich

environment.● Latency is the overriding concern. It definitely

costs $$$ to play the game.● We're always looking for new technologies (or

new applications of old technologies) to achieve latency goals.

● Always be learning new things, and you will never get bored.