top | item 34274510

How to Build an Exchange (2017)

219 points| mksherif | 3 years ago |janestreet.com

122 comments

order

hardwaregeek|3 years ago

I've always been curious whether someone will succeed in using the same development strategy as Jane Street, namely using a non-C++ language as their primary language. I suspect OCaml may have been a very good choice back in the early 2000's simply because C++ was a much different language and there weren't many options for other languages. Building up an ecosystem was not a bad plan because most languages did not have much of an ecosystem anyways. Nowadays ecosystems are a lot more developed. But on the flip side, that could mean you could stand to use a language like Rust that has an ecosystem and interoperability with C++. I know Tsuru Capital uses Rust but I'm not familiar with any other firms.

It also could be that Jane Street succeeded regardless or even despite OCaml. At the end of the day OCaml isn't going to ensure that your trading strategies work. It's not going to suddenly create alpha. But I do suspect they've gotten serious hiring and marketing returns by using OCaml. And benefited the OCaml ecosystem as a byproduct, which is a pretty solid side-effect, even if side effects are not very functional :D

signify1121|3 years ago

I have worked for a big (probably more successful) competitor to Jane Street, that uses in its different offices C#, C++, possibly some Java that I'm unaware of, and for non-production systems a very large mix of everything under the sun (Python, R, etc.)

The idea that the language is part of their success is simply absurd. If anything having to have to develop and maintain an entire ecosystem probably slowed them down more than anything.

codetrotter|3 years ago

> whether someone will succeed in using the same development strategy as Jane Street, namely using a non-C++ language as their primary language

It’s gonna happen and it’s gonna be Rust

> you could stand to use a language like Rust that has an ecosystem and interoperability with C++.

Indeed :)

hot_gril|3 years ago

I once wrote one mostly in SQL with a Postgres database. It behaved pretty predictably with concurrent usage. I wonder how many trades per second it could do. Postgres itself can handle a lot of the difficult details, but reinventing those wheels for trading in particular can probably get you something faster.

pclmulqdq|3 years ago

There is a little bit of survivorship bias here: in the 2000's, the two main languages of HFT were C++ and Java. By 2015, all the Java shops (and many of the C++ shops too) had failed. Lots of companies tried to do something other than C++, but most of them chose wrong.

noloblo|3 years ago

anyone use haskell?

Zaheer|3 years ago

Fun fact: Jane Street, Citadel and other HFT firms pay exorbitantly. You can see the base salary ($200-300k) posted public here: https://www.janestreet.com/join-jane-street/position/4274288...

Even interns make $120/hr: https://www.levels.fyi/internships/

paxys|3 years ago

They do pay extremely well, but are also very selective. The kind of talent they are looking for can earn similar salaries at large tech companies like Google ($400K-500K TC is pretty common at staff+ levels).

kennend3|3 years ago

Have family working there. You can get past 300K fairly easily once you factor in signing bonus, annual bonus, and "extras".

They pay VERY VERY well indeed.

rr888|3 years ago

Its kinda sad though being a great company and the only thing people know you for is high salaries. Anything else good about the company?

selectodude|3 years ago

Those are low numbers compared to the smaller prop shops that routinely pay 1MM+.

Gotta have a PhD in pure math though. That shit is bananas.

laidoffamazon|3 years ago

I’m more surprised people don’t know this. It’s the primary cause for my depression.

delta_p_delta_x|3 years ago

I'm quite salty about HFTs. I'm a final-year undergraduate with a bunch of close friends who all love C++ (yes, we're masochistic that way). They're all really smart, too (me, not so much—my GPA is 3.00/5). However, after a while, it got really dull and frankly, a bit exasperating when all the rest of them could discuss were HFTs, their ridiculous, outrageous salaries, matching engines, order books, and low-latency trading. Heck, one of our assignments last year was to write such an engine in C++. It seems C++ developers are particularly in demand at most HFTs.

Some of these companies I have never even heard of before having entered CS—Jane Street, Citadel, HRT, DRW, Ansatz, Two Sigma... Their names and websites are cryptic, and their job position listings are even more so, unless one knows that they're mostly proprietary traders—in other words, making money for money's own sake.

It feels dirty and excessively capitalist—these companies don't even have products to show for all their effort. Any clients they do have probably already make millions to billions, too.

My friends defend themselves by saying 'HFTs make money by keeping the market liquid', 'there's nothing wrong with arbitrage', etc. That's fair, but I still feel that's just sugar-coating what I said.

At the same time, I don't really say anything in person to my friends, because, well, they're friends, and secondly, my lousy grades make me feel thoroughly unqualified to make any sort of criticism.

I personally would rather do embedded, automotive, avionics, or game engine development. I just wish I had someone to discuss this with. Hardly anyone I know wants to do these instead, because the salary is lousy to above average, the hours are as bad, and especially game development is considered a mostly rubbish job to have. It really sucks, because I've gamed all my life and always found video games pretty damn amazing, both technically and just in general. It was a pretty bad bubble-bursting moment when I discovered just how bad the game dev situation was—overwork, crunch, sexual abuse and sexism, bean-counter-led design and marketing decisions.

I'm not looking for 100% job satisfaction (I accept even the most exciting work will have its dull periods), but it would be nice if the thing I spent 8-10 hours a day doing for a salary was something that remotely excited me and others, instead of just mindlessly piping money from X to Y and back just because it paid half a million a year.

paulpauper|3 years ago

In 2017 we extended our trading experience, infrastructure, and technology to digital assets, and we’re now trading crypto 24/7 around the world. We price all the most actively traded spot tokens such as Bitcoin and Ethereum in addition to derivatives like futures and ETPs, and we trade on almost all major global market centers, including crypto exchanges and traditional venues. We’re also a major OTC crypto liquidity provider, and our JCX single-dealer platform provides reliable, integratable liquidity in digital assets. Our institutional-grade crypto offering is a natural extension of our deep cross-asset expertise and our experience trading complex, difficult-to-price securities.

Interesting. Crypto has much less liquidly overnight compared to other markets, no? How would this work? Coinbase?

mianos|3 years ago

Most other markets actually have periods when they don't have a matching engine running because the instrument or settlement is country specific. Crypto has 24 hour liquidity. There are periods that are quieter but it is 24/7 unlike, for example, a typical equities exchange.

(How I know, 25 years writing exchanges).

bob1029|3 years ago

Related: https://lmax-exchange.github.io/disruptor/

I've been using the .NET port of Disruptor to good success. Once you understand the underlying pattern, you can apply it everywhere without pulling in a dependency.

You would be astonished at what will actually fit on 1 x86 thread in 2023. Instruction-level parallelism can give you unbelievable throughput, assuming your batches are reasonably-sized and everything fits neatly into the various caches.

Other related links:

https://martinfowler.com/articles/lmax.html

https://www.youtube.com/watch?v=qDhTjE0XmkE [Evolution of Financial Exchange Architectures]

rusebor|3 years ago

have been wondering for a while why HFTs exist when exchanges have holidays and trading hours [1]?

doesn't the sub-milisecond speed contradict to the several hours pause in trading?

wouldn't be possible to impose some kind of a delay (say an hour) on all participants?

[1] https://www.nyse.com/markets/hours-calendars

matheist|3 years ago

Anyone know of any open-source exchanges at the level of sophistication described here?

shakezula|3 years ago

I wrote an open source one in Go that I'm still working on. It's never meant for production. The code is at github.com/dylanlott/orderbook and there's an accompanying write up on it at dylanlott.com/orderbook if you're interested.

jjoe|3 years ago

Are there any technical books or reading material about matching engines out there?

nullhash|3 years ago

How exactly would would this design keep track of how many funds a client has in order to fulfill an order? How does NASDAQ keep track of client's total funds?

iav|3 years ago

They don't. Remember that NASDAQ's clients are Jane Street, Goldman Sachs, i.e. not you or me. They don't onboard a client with doing due diligence. Then there is a clearing and settlement system called DTCC that requires every firm to post collateral equal to their trading volume. This system's primary job is to make sure everyone has enough funds to pay for their trades across all exchanges, not just NASDAQ.

samwillis|3 years ago

The context here is that Sam Bankman-Fried of FTX and a number of the other executives (Caroline Ellison and Brett Harrison) were previously traders at Jane Street. This video is from 2017, a couple of years prior to the FTX launch. It makes you wander if any of them were in attendance.

jasonzemos|3 years ago

While I wouldn't be surprised to see some proactive PR from the company in the wake of recent events, perhaps including the post on the zkSNARK competition last month; which was in my humble opinion one of the few submissions that has truly moved me since the late 2000's on this site:

I feel obliged to attest that the people I knew working at Jane Street at that time were some of the straightest shooters one could know. My anecdote is that SBF's toxicity didn't originate in their culture. Perhaps it was a counteraction to it, if anything.

NkVczPkybiXICG|3 years ago

FTX didn’t make any of the architectural decisions presented in this talk.

ackbar03|3 years ago

Sbf was playing LoL at the same time

bcjordan|3 years ago

@dang could we get a (2017) added to this? Changes the context quite a bit given FTX folks worked at Jane Street previously and a modern version of this talk would have a much different context.

ctvo|3 years ago

I don't think the context changes at all. This talk is about high performing systems (millions of requests per second) written in OCalm. There is nothing here related to the criminality of FTX or what its non-technical founder decided to do with customer funds as a business decision. It matters very little that one or more of them used to work as an analyst at Jane Street.

1vuio0pswjnm7|3 years ago

FTX's Gary Wang worked at Google.

https://www.forbes.com/profile/gary-wang-1/

It's intriguing how Forbes 400 list includes criminals. If someone tricks people into "investing" with them and they accumulate enough billions of US dollars, and it takes a few years for the authorities to act, then do they get a spot on the Forbes 400. What are the rules.

gjvc|3 years ago

> a modern version of this talk would have a much different context

Everything would be in a different context, yes. But how would the content be different?

gjvc|3 years ago

> a modern version of this talk would have a much different context

How?

unknown|3 years ago

[deleted]

ttobbaybbob|3 years ago

2023 version would have more than one mention of {compliance, regulat*, accounting}

ketralnis|3 years ago

Would it? 2017 is well post 2008 crisis, SOX, all of the big changes in this area