[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
|
|
Subscribe / Log in / New account

Networking and high-frequency trading

By Jake Edge
November 16, 2022

Netdev

The high-frequency-trading (HFT) industry is rather tight-lipped about what it does and how it does it, but PJ Waskiewicz of Jump Trading came to the Netdev 0x16 conference to try to demystify some of that, especially with respect to its use of networking. He wanted to contrast the needs of HFT with those of the traditional networking as it is used outside of the HFT space. He also has some thoughts on what the Linux kernel could do to help address those needs so that HFT companies could move away from some of the custom code that is currently being developed and maintained by multiple firms in the industry.

Secrets

Waskiewicz began by highlighting the secretive nature of the industry; it is sometimes amusing, but also rather frustrating, how little is known about HFT. For example, there is almost nothing on his company's web site beyond some office-location information; that can make recruiting difficult, for example. It is well-known that HFT companies do trading—stocks, options, securities, etc.—but the "how" is the secretive part; how do the companies decide on the trades to execute and how do they actually get executed? That is the secret sauce that HFT companies do not want to share with anyone—especially their HFT competitors.

He said that a Wikipedia definition describes HFT as "algorithmic-based trading"—data is analyzed in various ways in order to decide whether or not to execute a trade. Those trades are then made in "very very high volumes". While preparing for the talk, he found a study that attributes 60% of all of the trades in all of the exchanges worldwide to HFT firms. All of that volume is coming from algorithmic trading.

The trading strategies that determine what to trade and how to trade it are based on quantitative analysis. So HFT firms have teams of people looking at large amounts of data, extracting signals from the data, and using it to build models. The goal is to predict the future and then to automatically execute trades to take advantage of those predictions. The strategy algorithms can be implemented in either software or hardware; it is no secret, he said, that HFT firms use custom hardware to help accelerate their operations.

HFT firms have massive amounts of data stored that can be used by the teams to create their models. Market data for the last ten years or more amounts to petabytes of storage required. Moving that data around efficiently is important, but the primary concern for HFT networking is to have predictable latency; Waskiewicz had already mentioned that network jitter can cause HFT firms to lose a lot of money and he would return to that idea several times in the talk. Unexpected latency can change the timing of queries and actions so that the strategy is no longer doing what it is trying to accomplish.

The communication between HFT companies and the exchanges is subject to various differences between the exchanges and the protocols that they use. Exchanges, such as Nasdaq, Eurex, and KRX, each publish their own specifications of the protocols that can be used to do electronic trading. The specifications cover packet formats, how to query information, incoming and outgoing packet rates, and so on; each exchanges has its own nuances—and quirks. The exchanges generally run on standard 10Gbps Ethernet; there is no movement toward 100Gbps Ethernet that he knows of, though there is some talk about 25Gbps.

Inside the HFT firm, there is a need for high-performance computing (HPC) facilities to do the quantitative analysis. Those HPC environments require grid networks with lots of distributed CPU horsepower and storage, he said. Remote DMA (RDMA) is used on these internal networks, but predictable latency is still the main concern.

Latency

Out of the box, the kernel networking stack has poor performance with regard to latency, he said, though it can be improved with some tuning. Techniques like pinning workloads to particular CPUs, keeping NUMA locality in mind, and using interrupt affinity are generally well-known for reducing packet jitter. CPU isolation is perhaps a lesser-known feature that the HFT world uses to reduce the jitter even further; CPUs are isolated from the rest of the system and workloads are pinned to them in order to reduce or eliminate the jitter.

He put up some graphs from a simple benchmark that he did to show the effects of these techniques; it used netperf to measure request-response latency on a 10Gbps Ethernet network with a switch. As expected, the numbers generally got better for the minimum and mean latencies as each technique was applied; the values were reported as an average of ten runs of the benchmark. The unoptimized values were a minimum of 51.6µs and a mean of 68.7µs, which he said "wasn't terrible" though the maximum latencies were 250-600µs, thus "a bit of a mess".

He then showed the results for pinning the CPU with no interrupt-affinity change, which showed a small improvement (50.1/67.6). When he added interrupt affinity into the mix, so that the cache locality came into play, there was a more noticeable boost (45.4/53.1); "we're starting to get to this point of less jitter, which is the important part". He expected that isolating the CPU would make things better still, but was surprised to see the numbers get worse (47.8/61.1). He thought about that and realized that the interrupt was interfering, so he ran the benchmark without interrupts by putting the driver into polling mode. That was more in line with expectations with a 41.9µs minimum and a 56.3µs average latency.

But that was "a very synthetic benchmark", where he could mold the system and the application specifically to his needs; it does not really match the real world of traditional networking at all. In that world, there are other workloads that also need to be run so things cannot be statically partitioned as he was doing; but in the HFT networking environment, none of that matters. The synthetic-benchmark environment is what is used; a system where "everything is perfectly lined up is actually how things get deployed" for HFT.

Options

So he wondered if he could use express data path (XDP or, commonly, AF_XDP) as a way to improve things further. "Because if we throw eBPF at any problem that'll just fix it, right?", he said to some scattered laughter. While XDP is "not here yet" for HFT, he thinks it could be the right path someday and has some ideas on how to get there.

XDP allows for kernel bypass without actually bypassing the kernel, Waskiewicz said, which is really compelling. His vision is that the "hot path" data that is extremely latency-sensitive could be identified by the application and those packets would go directly to it, while the other traffic would continue to be handled by the kernel networking stack. "That's like the best of both worlds as far as I am concerned." There are some limitations that need to be dealt with (or worked around). The receive side must be done with polling since interrupts introduce jitter by their very nature. As far as he is aware, transmitting data requires making a system call and the context switches for system calls introduce jitter as well.

CPU isolation works well, he said, until it does not. His firm uses the isolcpus boot parameter to choose the set of isolated CPUs, but there are still some "random" inter-processor interrupts (IPIs) that occur, which are "fairly infuriating". At this year's Linux Plumbers Conference, there was a microconference on CPU isolation where the problems he has been seeing were discussed.

In some configurations, simply connecting to a CPU-isolated system using SSH will cause a cascade of events that eventually result in "TLB [translation lookaside buffer] shootdowns issued to every core on the system". Those IPIs cause jitter, but refilling the TLB causes jitter as well. He is trying to carve out some time to address that problem. Another CPU-isolation problem that he encountered was that an IPI is sent to all processors when someone executed "cat /proc/cpuinfo"; the system does that to get the operating frequency of each core. This was particularly a problem for systems that ran some kind of telemetry application that would check those values frequently. The bug has now been fixed upstream in work that his company did in conjunction with Red Hat, he said.

HPC side

As noted, the connection to the exchanges requires standard Ethernet, but the internal HPC grid, where there can be tens to hundreds of thousands of CPUs, can be (and is) rather more exotic. It turns out that HPC in HFT has been something of a niche market for RDMA. Quantitative analysis requires moving lots of data around and operating on it in parallel throughout the network.

Predictable latency is also important on the analysis side of the network, and RDMA works well for that, but there are some things that he thinks could be done better. For one, io_uring is showing great promise; it has expanded quite a ways from its initial genesis as a replacement for the libaio asynchronous I/O library. It is no longer only for I/O, as Josh Triplett's io_uring_spawn talk at LPC shows, Waskiewicz said. It would be interesting to see if the networking-hardware ring buffers could be used directly as buffers for io_uring operations so that data can get to and from the hardware using that mechanism; that would allow the HPC side to use something "much more kernel-standardized that would be able to replace RDMA".

But, for now at least, RDMA is the king in HPC networks; no mention of RDMA is complete without mention of RDMA over Converged Ethernet (RoCE), though, he said. Infiniband, which is the fabric used for these RDMA networks, is expensive, but that is not necessarily a problem in the HFT world as the industry is willing to spend money that allows it to make more money. Infiniband is something of a niche technology, though, which makes it hard to find technical people that can manage the network and keep it up and running.

RoCE (along with iWARP) allow the use of Ethernet equipment and management skills, but they come with challenges of their own. Converged networks still have jitter problems because they are not a dedicated fabric. That leads to a need for additional equipment and configuration to reduce that.

He said that he already had planned to talk about Homa for HPC before the John Ousterhout's keynote the previous day (which we covered: part 1 and part 2). Waskiewicz sees the remote-procedure-call-based approach of Homa as being similar to the RDMA Verbs API. Having Homa available both in user space and the kernel would allow for more flexibility. Being able to use standard Ethernet equipment throughout the network would be worthwhile from a maintenance and cost standpoint as well.

He wondered if there are other possibilities that the HFT industry should be looking at. If so, they must eliminate jitter, as mentioned multiple times, but they must also be low latency. If the latency is 100µs, even without any jitter, it still cannot be used for HFT because "it will lose every time".

Waskiewicz was running out of time at that point so he quickly reiterated his main points from the talk. Not surprisingly, jitter was the centerpiece; it is important to ensure that the algorithms can get the predictable latency that they need because the exchanges themselves can be damaged "when algorithmic trading goes haywire". It is not hard to find instances where this kind of trading has caused problems that made exchanges hit their circuit-breakers—or worse. He is pleased to see that there are various efforts to attack the jitter problem underway at this point.


Index entries for this article
ConferenceNetdev/2022


to post comments

Networking and high-frequency trading

Posted Nov 16, 2022 22:43 UTC (Wed) by mbligh (subscriber, #7720) [Link] (6 responses)

This doesn't really make sense.
HFT is as much about LOW latency as it as about predictable latency.
To do that, you need specialized hardware (eg Solarflare) that already have their own drivers, and a custom UDP stack.

Fiddling around with the standard kernel stack is not going to cut it, so you'll just waste a lot of effort and disrupt things. Why bother?

Networking and high-frequency trading

Posted Nov 16, 2022 23:34 UTC (Wed) by da4089 (subscriber, #1195) [Link]

Agreed -- maybe it's just Jump putting out some disinfo.

Networking and high-frequency trading

Posted Nov 17, 2022 1:35 UTC (Thu) by jheiss (subscriber, #62556) [Link]

Yeah, Jump's approach as described here is not universal in the HFT or quant industry.

Networking and high-frequency trading

Posted Nov 17, 2022 1:55 UTC (Thu) by xecycle (subscriber, #140261) [Link] (2 responses)

The networking stack is only one part of the problem, as long as we are still using Linux the other parts still come to bite us, e.g. the scheduling part. "isolcpus" is not supported by every part of the kernel, wigeguard being an example; it creates threads that could be scheduled to the isolated cores; cgroup cpuset partitioning doesn't help. These problems are not magically solved by a specialized add-on hardware with its out-of-tree driver, after all it did not replace the kernel, so there are still problems to look at.

Networking and high-frequency trading

Posted Nov 17, 2022 11:08 UTC (Thu) by mbligh (subscriber, #7720) [Link]

Agreed there are still problems to look at.
However, not the ones this guy is going to expend people's time and energy on.

Networking and high-frequency trading

Posted Dec 2, 2022 7:28 UTC (Fri) by jepsis (guest, #130218) [Link]

It's amazing WireGuard still has not been fixed. There was a patch for isolated cpus in April but nothing has happened since then and therefore WireGuard still violates kernel behaviour. At minimum WireGuard should make visible in its documentation and Kconfig that it is not compatible with isolcpus.

Networking and high-frequency trading

Posted Dec 2, 2022 20:32 UTC (Fri) by 22SAS (guest, #151278) [Link]

I work in the industry, at one of the other firms. While this is correct that solutions are mostly using NIC's with vendor supplied kernel bypass libraries, not all system use this solution. Systems that are supposed to be as fast as possible will be using this solution, however, not all applications will require that level of latency. Some applications need to be fast and not that fast, and tuning the kernel's network stack is useful in those cases.

Not all teams will be building sub-microsecond/nanosecond latency systems. The author of that presentation could be on one of those teams.

Networking and high-frequency trading

Posted Nov 17, 2022 7:15 UTC (Thu) by weberm (guest, #131630) [Link]

I always thought those firms would be the perfect consumers for TSN, next to industrial automation (PLC & field-bus developers) companies...

High-frequency trading considered harmful

Posted Nov 17, 2022 9:19 UTC (Thu) by smurf (subscriber, #17840) [Link] (16 responses)

Faster-than-your-neighbor trading is a zero-sum game that's really bad for market stability. The race to be microseconds faster than your opponent burns a lot of money for no gain whatsoever because, surprise, your opponent does the exact same thing.

Tell the exchanges to process trades in fixed timeslots, with no visibilty of the intra-slot order book, and the whole problem goes away.

Worse, one aspect of getting the jitter down which was not mentioned is that you can measure the exchange's response time (and add that to your analysis model). Surprise, some HFT companies really do that. I've seen logs with a high volume of random limit orders that all get cancelled milliseconds later.

High-frequency trading considered harmful

Posted Nov 17, 2022 12:53 UTC (Thu) by esemwy (guest, #83963) [Link]

Thank you. High speed trading is more about market manipulation than actual commerce. A technological pump and dump, if you will.

High-frequency trading considered harmful

Posted Nov 17, 2022 16:54 UTC (Thu) by rgmoore (✭ supporter ✭, #75) [Link] (14 responses)

Another possible solution- one that doesn't require cooperation from the traders or exchanges- is to put a small tax on trades. It would have a minimal effect on people who buy and sell stock because they care about stock as ownership in the company, but it would be a serious deterrent to traders who are just trying to make a profit from market churn.

That said, extreme cases like HFT have often been important test beds for new technologies in Linux. A long time ago, people saw NUMA as an obscure area that was only interesting to people running on exotic big iron. Now NUMA is everywhere, and the effort Linux put into supporting it way back when has paid off. I won't say the stuff people are working on now for HFT is guaranteed to have the same payoff, but it's at least worth paying attention to.

High-frequency trading considered harmful

Posted Nov 17, 2022 17:43 UTC (Thu) by smurf (subscriber, #17840) [Link] (1 responses)

I agree that a tax on trades is a very good idea for multiple reasons, but in order to prevent HFTs you'd need to charge some non-infinitesimal amount for each order, no matter whether it completes or is cancelled.

Also, a tax probably won't address the market instability that's caused by multiple algorithms reacting in microseconds to minimal price changes that humans would simply shrug at.

Also² a tax requires cooperation from politics, which are fed both BS and $$ by the very traders and/or exchanges they're supposed to regulate. The ongoing uphill battles by people who do work towards establishing some sort of transaction tax show that holding your breath until that happens is not a viable survival strategy.

High-frequency trading considered harmful

Posted Nov 17, 2022 20:14 UTC (Thu) by Wol (subscriber, #4433) [Link]

Stagger the tax on how long you hold the stock ... start at 90%, and that drops at 10%/week. And you get charged at the higher rate of trading tax or capital gains tax.

I think UK CGT is about 40%, so trades drop out of the trading tax net at just over a month.

Cheers,
Wol

High-frequency trading considered harmful

Posted Nov 19, 2022 14:32 UTC (Sat) by kleptog (subscriber, #1183) [Link] (1 responses)

Presumably the exchange also wants to be compensated for the trades, so that acts as a de facto tax. You could argue however the exchange isn't charging enough to discourage it (for whatever reason).

High-frequency trading considered harmful

Posted Nov 19, 2022 19:38 UTC (Sat) by Cyberax (✭ supporter ✭, #52523) [Link]

Exchanges don't charge anything for individual trades, though.

High-frequency trading considered harmful

Posted Nov 24, 2022 10:58 UTC (Thu) by ghostbar (guest, #75013) [Link] (9 responses)

There's already a tax on trades, it's called trade fee.

HFT also gives a lot of liquidity to the markets, which is necessary.

High-frequency trading considered harmful

Posted Nov 24, 2022 12:16 UTC (Thu) by smurf (subscriber, #17840) [Link]

Trade fees are ludicrously low. There's no fee or limit on adding nonsense orders to the order books, much less using them to probe what the exchange and/or the other HFTs may or may not be up to.

Also, nobody has yet managed to explain why such liquidity must necessarily occur in microseconds instead of, say, seconds. Or even minutes. "I make money by arbitraging between Frankfurt, London and NYC one millisecond faster than the other guy" (don't see many gals in that space …) is not an endeavor that should be rewarded in a sane economic system IMHO, and I for one won't spend any effort to help those people make even more play money.

Worse: said play money doesn't grow on trees. Ultimately, it's siphoned off from all those who think owning a couple stocks is a good idea but don't have the $$$ to participate in the HFT game. You want to buy for $10 and sell for $20? not if the HFT thing notices. It'll buy for 10.01 and sell for 19.99, leaving $.02 margin for you instead of $10.

Yes I'm exaggerating, and I skipped a couple of levels between the retail stock owner and the HF trader, but WAY not as much as I wish I were.

High-frequency trading considered harmful

Posted Nov 25, 2022 8:20 UTC (Fri) by marcH (subscriber, #57642) [Link] (5 responses)

> HFT also gives a lot of liquidity to the markets, which is necessary.

That's complete BS and you know it. The real economy needs liquidity but not measured in thousands of transactions per second.

HFT is pure speculation siphoning money away from the real economy based on the now universal principle "too rich to pay taxes". Even a minuscule per transaction tax (even much smaller than in the real economy) would put an immediate stop to it. HFT is merely exploiting a tax loophole.

A friend working on HFT once described his job as: "stealing your pension". I'm not making this up.

High-frequency trading considered harmful

Posted Nov 25, 2022 12:23 UTC (Fri) by Wol (subscriber, #4433) [Link]

> A friend working on HFT once described his job as: "stealing your pension". I'm not making this up.

Daytraders - good ones at least - would describe what they do in exactly the same terms.

Let's take an example - Pilkingtons Glass. Was planning to move their listing from London to ?Den Haag. Had they done so, all the big FTSE index linked stocks would have had to dump large holdings, causing the price to seriously implode, and causing lots of damage to the funds. Funds your and my pension is invested in. You make money (short term) in the stock market by predicting what's going to happen, and that was a very easy prediction.

And it's all driven by stupid legislation. A very recent example is the bond market debacle where the Bank Of England was buying bonds like they were going out of fashion. Trying to shore up the price to stop insurance companies (and hence pension funds) going technically bankrupt. If I've promised to give you £1000 in 5 years time, and I have gilts with a face value of £1000 and a redemption date in 5 years time, your money is (barring government default) safe. So why on earth are you worried about ANY gyrations in today's bond values? But because the government says I need £1000 of assets - at today's values! - to cover my 5yr debt, I can be bankrupted today for a debt I can easily repay when it comes due.

Oh - and I nearly lost my pension because of pretty much EXACTLY that silliness ... (and that would have been nearly 20 years ago...)

Cheers,
Wol

High-frequency trading considered harmful

Posted Nov 26, 2022 12:36 UTC (Sat) by Wol (subscriber, #4433) [Link] (3 responses)

> > HFT also gives a lot of liquidity to the markets, which is necessary.

> That's complete BS and you know it. The real economy needs liquidity but not measured in thousands of transactions per second.

Liquidity is only needed if you want to use the markets as a gambling den. I hesitate to use the word "properly", but if you're using the markets to store your savings (like pensions, etc) the LAST thing you want is liquidity, and its friend volatility.

You want stodgy, old-fashioned, income stocks that just generate a steady stream of money, and the value of the stocks themselves be damned.

The problem with liquidity, and all this trading, and all that crap, is that stodgy, old-fashioned income stocks become the target of speculation, get taken over by vultures, stripped and the carcasses are left to collapse. All that survives is the name, which gets bought by a company with a far saner market structure (the Swiss come to mind, as do the Chinese), and all we get left with from what was a fine old Anglo-American company is a bunch of rich oligarchs, a load of pension funds in critical care because the company no longer exists, and a load of ex employees with no job and no pension.

And I hate to say it, but when you look at the news coming out of America with Democrats and Republicans talking past each other without hearing, when you look at what's happening over here with middle-class professions like nurses going on strike because they can't afford to live, I think democracy itself could be in serious trouble in the not-too-distant future if we don't do something fast. And a tipping-point climate shock could very easily bring the western house of cards crashing down. Oh well. I think the world, and humanity in small part, will have no trouble surviving. It's just that if Western Civilisation doesn't, most of us in said "Civilisation", won't survive either ...

Cheers,
Wol

High-frequency trading considered harmful

Posted Dec 16, 2022 7:31 UTC (Fri) by ssmith32 (subscriber, #72404) [Link] (2 responses)

If UBS is anything to go by, the Swiss shouldn't be praised for their regulation of financial markets. And the Chinese market is worth whatever Xi wants it to be: c.f. Ma & Ant. It's only as sane as the paramount leader is on that particular day.

HFT and the US market have major issues, but they certainly shouldn't be looking to the Swiss (bankers for *actual* oligarchs), and definitely not the Chinese market.

And even if it's misdirection, I'll take the fixes to the kernel - as long as they pay to make it happen. Even hedgies need to pay up for someone with actual skills now & again ;)

High-frequency trading considered harmful

Posted Dec 17, 2022 4:11 UTC (Sat) by marcH (subscriber, #57642) [Link] (1 responses)

I recommend "Butler to the World: How Britain Became the Servant of Tycoons, Tax Dodgers, Kleptocrats and Criminals". I didn't read the book, only listened to the author presenting in some podcast and it was enlightening.

The Western world used to colonize the rest of the world by force. Now we got much, much smarter: we let _local_ oligarchs and dictators do the work and then we just take their money because of course they don't trust their own, much more corrupt country to keep it safe. They know it too well.

Business over ideology: isn't that how the Roman Empire lasted 1000 years? Hitler tried to build his empire the other way round and he lasted less than 10 years. Poor thing.

High-frequency trading considered harmful

Posted Dec 17, 2022 11:03 UTC (Sat) by Wol (subscriber, #4433) [Link]

Well, the British Empire was so successful because, again, it was business over ideology. Pretty much all of Imperial Expansion was driven by trade - the Pax Britannica ... and it was ended when we lost WWI which - as a trade war - was won by the US (and started as a trade war between Germany and Britain?)

(And no Germany did not actually start WWI. It was started by Austria, and Germany got dragged in as an unwilling participant.)

Cheers,
Wol

High-frequency trading considered harmful

Posted Nov 25, 2022 10:34 UTC (Fri) by paulj (subscriber, #341) [Link] (1 responses)

How much of HFT is about seeing overlapping bids and asks, and being fast enough to interpose oneself into the trade and buy the ask and sell to the bid before the actual bidder and asker can do so - thereby 'stealing' a little margin that would otherwise have gone to one of the original parties?

How much of this liquidity provision concerns trades that would have happened at the same - or better - price if the markets involved rate-limited or slot-limited trading?

High-frequency trading considered harmful

Posted Nov 25, 2022 12:06 UTC (Fri) by smurf (subscriber, #17840) [Link]

Well, you won't ever see overlapping bid/ask. The exchange never adds an "overlapping" order to the order book – it executes the trade instead.

> How much of this liquidity provision

IMHO there is no proof whatsoever that HFT adds any liquidity to the market in the first place. On the other hand, AFAIK nobody seriously disagrees with the assertion that it does add a fair amount of volatility and instability.

Networking and high-frequency trading

Posted Nov 17, 2022 11:18 UTC (Thu) by korteland (subscriber, #122120) [Link] (2 responses)

I have to agree with the other comments about the first half of Jump's talk seeming like disinformation. Hardware-based autotraders have been a thing for over a decade now, and the state-of-the-art systems are orders of magnitude faster than what's in the article.

As a point of reference, a typical benchmark is what's called "tick to trade". The overall idea here is to send some packet out in response to some incoming data. It's important here to remember that Ethernet is a serial protocol - when you get down to this level, you stop seeing frames, and start seeing bits. Typically 16, 32 or 64 bits per clock cycle, depending on transceiver setup on the hardware you're using.

These benchmarks will include some data at some point in the frame, and importantly for measurement and benchmarking purposes, this can be calculated and cancelled out. The response must be based on the information in the original frame, to stop people sending the response as soon as they see the start of the original frame.

State of the art here is somewhere around 30ns, for purely hardware-based autotraders. Yes, that's nanoseconds - it includes the MAC/PHY, generating the outgoing frame (again, you only need to generate it 16 bits at a time), and parsing the incoming data. And yes, that's nanoseconds - so we're talking literally 1000x faster than what's in the article.

Networking and high-frequency trading

Posted Nov 17, 2022 14:30 UTC (Thu) by ejr (subscriber, #51652) [Link]

The talk's numbers are slow even for plain ol' HPC. Years ago.

And the FPGA-based (now called) smart NICs blow the doors off pretty much everything.

Networking and high-frequency trading

Posted Dec 2, 2022 20:35 UTC (Fri) by 22SAS (guest, #151278) [Link]

Not all systems use FPGA's, and even FPGA's are constrained to doing certain things. A lot of the stuff is still software based.

Networking and high-frequency trading

Posted Nov 17, 2022 20:15 UTC (Thu) by caliloo (subscriber, #50055) [Link] (10 responses)

HFT is not just about speed of reaction, that is a big component sure (as per definition doh) but the cleverness of your reaction counts as well.

The speeds outlined above for specialised hardware imply a few things: if it takes you 30ns to react that means you can execute a few 100 instructions max. I don’t see the trading strat be very sophisticated there. Plus at these scales speed of light matters. If you want time of travel to be comparable to time of calculations, then only tens or hundreds of feet from the exchange are acceptable.

I’d wager there is a whole world of strategies that require a bit more thought , ie thousands or 10 of thousands of cycles that can accommodate reaction times and time of travel in the us range (which is still only a few miles from the exchange at most). IMHO the interplay between time of reaction and decision complexity allows for a rich world where searching for the right optimization in function of your distance to the exchange is the name of the game.

And there is something to be said for intercontinental arb, which probably doesn’t give a shit about Us as long as it’s not Ms .

That being said, beyond the fun intellectual challenge of being the fastest, I’m also of the opinion that the world would be much better of f with fixed time slot trading , like.. once a day or so… that’d free up a lot of brain cycles to solve the bigger problems of this world.

Networking and high-frequency trading

Posted Nov 17, 2022 20:47 UTC (Thu) by smurf (subscriber, #17840) [Link] (1 responses)

> intercontinental arb, which probably doesn’t give a shit about Us as long as it’s not Ms .

You can't get below Ms (as in milliseconds) intercontinentally (OK, so let's ignore Turkey for the moment). Speed of light and all that.

Networking and high-frequency trading

Posted Nov 17, 2022 20:53 UTC (Thu) by caliloo (subscriber, #50055) [Link]

Yes, so microseconds of jitter over a trip that takes tens of ms or more is probably fine is my point. Perhaps entering the realm of milliseconds of jitter for a trip that is tens of millis is not.

Networking and high-frequency trading

Posted Nov 18, 2022 2:57 UTC (Fri) by zerolagtime (guest, #102835) [Link] (7 responses)

Michael Lewis’s exposé on HFT revealed an industry that is all about front running. Go fast so that you can raise the price on another buyer putting in a big order, but force them to split their order because of a misused law. Second half is just a few pennies bigger per share traded. If a previous comment is right, and that 50% or more volume is algorithms, just one day netted the industry $10m USD. ($0.02/trade * 1 billion trades in mid Nov 22 * 50%). That’s probably a major lowball.
I’m honestly surprised that Starlink doesn’t advertise a faster route for traffic than land lines, and make a killing off HFTing.
In short, don’t take any sympathy. There’s little incentive for them to cooperate with the Linux community in the form of upstream patches. Not unless there’s something in it for them.

Networking and high-frequency trading

Posted Nov 18, 2022 3:28 UTC (Fri) by Cyberax (✭ supporter ✭, #52523) [Link] (6 responses)

> I’m honestly surprised that Starlink doesn’t advertise a faster route for traffic than land lines, and make a killing off HFTing.

There are companies that provide microwave links across the US for this very purpose. Microwaves in air propagate faster than light in glass.

Starlink right now is not usable for this, because the current generation of satellites work as a "bent pipe", simply beaming traffic back to the nearest ground station.

Networking and high-frequency trading

Posted Nov 18, 2022 9:19 UTC (Fri) by excors (subscriber, #95769) [Link] (2 responses)

> Starlink right now is not usable for this, because the current generation of satellites work as a "bent pipe", simply beaming traffic back to the nearest ground station.

Even with the inter-satellite laser links and ignoring any processing delays, the satellites are still at 550km altitude (or 340km for future phases if they survive that long), so you're adding ~4 msecs of latency just to go up and down. I suspect that means it'll never be able to compete with ground-based microwave links, when you're willing to spend a lot of money to optimise latency between two fixed endpoints.

Networking and high-frequency trading

Posted Nov 19, 2022 3:22 UTC (Sat) by mtaht (subscriber, #11087) [Link]

London to Tokyo via ISL would be very profitable for a starlink-driven approach to trading.

Networking and high-frequency trading

Posted Nov 20, 2022 2:04 UTC (Sun) by Paf (subscriber, #91811) [Link]

Presumably it would compete on all of the *other* routes, though.

Networking and high-frequency trading

Posted Nov 20, 2022 20:06 UTC (Sun) by caliloo (subscriber, #50055) [Link] (2 responses)

Starlink still has a shot for over the ocean link. As long as the bent pipe is faster than the light in the glass pipe ...

As for advertisement of the possilibity to these guys : I'd think that starlink does not have to do any adverstisement to make a killing. I'm pretty sure the HFT industry is on permanent alert for new ways to communicate fast.

Networking and high-frequency trading

Posted Nov 20, 2022 20:08 UTC (Sun) by caliloo (subscriber, #50055) [Link]

The variability of starlink links delays might be a new challenge to these guys tho.

Networking and high-frequency trading

Posted Nov 21, 2022 10:28 UTC (Mon) by farnz (subscriber, #17727) [Link]

As a bent pipe, it's no good - if you're in London, sending a signal to New York via Starlink, you send the data 550km to a Starlink satellite, which sends it 550km to a ground station near London. It then traverses the fibre route between London and New York, and at the New York end, gets sent 550km into space, then back to the New York station.

This is always going to be slower than cutting out the space hop and using the fibre directly. Where Starlink has the potential to get interesting for latency mavericks is when the inter-satellite links come into use. Then, you'd have the choice between a 5,500 km fibre route at 2/3rd c, or a roughly 7,500 km route via Starlink inter-satellite links at about c; the fibre route is roughly the same as a 8,250 km Starlink route, which gives Starlink an advantage as long as its processing and queueing delays are no worse than 2.5 milliseconds more than the fibre delays.

In practice, the HFT guys will probably pay for low queueing delay, so it all comes down to the processing delays - and I've not seen Starlink publish those details.

Networking and high-frequency trading

Posted Nov 26, 2022 21:40 UTC (Sat) by marcH (subscriber, #57642) [Link] (7 responses)

Predictable latency, jitter and pretty much everything else screams real-time OS yet "real-time" is never mentioned once... how come?

Disclaimer: I could not find the slides and the "video" link seems not active yet:
https://netdevconf.info/0x16/session.html?The-Anatomy-of-...

There's another thing surprisingly missing: DPDK.

> Being able to use standard Ethernet equipment throughout the network would be worthwhile from a maintenance and cost standpoint as well.

Competing standards and unnecessary duplication of efforts have always been harmed customers and profited vendors but there's only so much "convergence" you can get. Sure, much cheaper and common equipment totally not designed for real time and/or latency is... cheaper. What a surprise?

I'm not familiar with them but there are examples of industries re-using the "good parts" of Ethernet (= the parts that are predictable) and replacing the "bad" ones, here's one:
https://en.wikipedia.org/wiki/Avionics_Full-Duplex_Switch...

There's probably one for cars as well.

Networking and high-frequency trading

Posted Nov 26, 2022 21:53 UTC (Sat) by marcH (subscriber, #57642) [Link]

Forgot to share this great paper, sorry for the noise: https://bravenewgeek.com/everything-you-know-about-latenc...

Networking and high-frequency trading

Posted Nov 28, 2022 9:19 UTC (Mon) by jem (subscriber, #24231) [Link] (4 responses)

>Predictable latency, jitter and pretty much everything else screams real-time OS yet "real-time" is never mentioned once... how come?

The term "real-time OS" refers to real-time scheduling, i.e. prioritizing some tasks so that processing is guaranteed to meet some timing constraints. I guess the HFT systems run only one task, so there is no scheduling.

Networking and high-frequency trading

Posted Nov 28, 2022 13:46 UTC (Mon) by mathstuf (subscriber, #69389) [Link]

I don't know that a task defined as "leech money from the system" isn't composed of smaller components that might warrant scheduling against each other.

Networking and high-frequency trading

Posted Nov 29, 2022 15:49 UTC (Tue) by marcH (subscriber, #57642) [Link] (2 responses)

The purpose of "real time" is bounded latency. A scheduler is only one part of the picture.

Networking and high-frequency trading

Posted Nov 30, 2022 0:18 UTC (Wed) by opalmirror (subscriber, #23465) [Link] (1 responses)

Excellent description. In real-time, the attempt to bound latency adds additional record-keeping and accounting overhead at the lowest levels, which comes at the expense of throughput and CPU and memory cycles. HFT sounds like it optimizes certain paths for highest performance (shortest run time), a very different optimization problem than ensuring high-level algorithms have adequate compute and I/O resources they need to complete algorithms before a particular clock deadline.

Networking and high-frequency trading

Posted Dec 1, 2022 1:39 UTC (Thu) by marcH (subscriber, #57642) [Link]

Thanks, I was wondering about exactly that.

So in a nutshell they want to have both their cake: highest average performance as possible and eat it: somewhat bounded/predictable latency like a real-time OS would provide.

The word "greedy" keeps coming to me, not sure why :-)

Networking and high-frequency trading

Posted Dec 2, 2022 20:36 UTC (Fri) by 22SAS (guest, #151278) [Link]

Solarflare is the industry standard. Most firms are using one of ef_vi, TCP Direct, or onload.

Networking and high-frequency trading

Posted Dec 1, 2022 17:57 UTC (Thu) by donbarry (guest, #10485) [Link]

This preposterous way of organizing the world's productive labor really leads to absurdities.

Several companies have been planning undersea cable routes through the Arctic Ocean and the Northwest Passage to connect Asia to Europe, most particularly Japan's stock market with London's. It's not that there's a lack of *bandwidth* that drives these, it's purely latency.

London-Tokyo latency would be reduced by about 60 milliseconds with these cables, if the political knots manage to get untied. The cost? About $1.5 billion.


Copyright © 2022, Eklektix, Inc.
This article may be redistributed under the terms of the Creative Commons CC BY-SA 4.0 license
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds