Trading systems

Python or C++ for a Trading Bot? We Timed Hyperliquid's API From 4 Cities

We sent the same order book request to Hyperliquid 1,000 times per client from Tokyo, Singapore, Mumbai and New York, in Python and in C++. The two languages were within 2.2 ms of each other in every city. The cities were up to 155 ms apart. The script to time it from your own machine is included.

By

A Python trader asked r/IndiaAlgoTrading which language is best for algo trading. People keep telling them C++ is the fastest. Many replies said the language won’t matter for a retail bot. Nobody posted a measurement.

So we measured one. We sent the same read-only request, Hyperliquid’s BTC order book, from servers in 4 cities. Each server ran a Python client and a C++ client, taking turns, and timed every request from send to a parsed book.

Key findings

From all 4 cities on 17 November 2026, Python and C++ fetched Hyperliquid’s BTC order book within 2.2 ms of each other at the median, while Tokyo and New York were 154.82 ms apart.

What we timed

Each city got a fresh 1 vCPU Vultr server. Both clients call the same public endpoint, https://api.hyperliquid.xyz/info, with {"type": "l2Book", "coin": "BTC"}. No login and no orders.

Setting Value
Cities Tokyo, Singapore, Mumbai, New York
Python client Python 3.13.5, one requests.Session kept open
C++ client g++ 14.2.0 at -O2, libcurl with one kept-open connection, nlohmann json
Rounds 20 per city, each 51 Python requests then 51 C++ requests, 150 ms apart
Timed requests 1,000 per client per city (the first request of each turn also opens the connection, so it is left out)
Errors 0
When 17 November 2026, 10:16 to 10:29 UTC

Taking turns means both clients saw the same minutes of market and network. Each timing is split in two parts. Network is from sending the request to having the whole response. Parse is turning the JSON into bid and ask levels and reading the best prices.

The results

Median milliseconds per request, and the slowest 1% (p99):

City Python median C++ median Gap Python p99 C++ p99
Tokyo 5.92 4.39 1.53 143.00 123.43
Singapore 75.52 73.35 2.17 241.23 245.27
Mumbai 156.52 154.65 1.87 306.95 360.04
New York 160.74 159.86 0.88 358.35 408.91

The gap between the languages never passed 2.2 ms. The gap between Tokyo and New York was about 155 ms for both.

Parse time, the only part where the language does the work:

City Python parse C++ parse
Tokyo 0.091 0.097
Singapore 0.129 0.139
Mumbai 0.072 0.078
New York 0.141 0.161

So the small gap at the median sits in how each HTTP library sends and reads, not in the parsing. Python’s json module does its work in C, and the book is small, about 20 levels a side.

Where the time goes

Every server connected to an Amazon CloudFront address in its own city. The reverse DNS names end in nrt12, sin3, bom78 and jfk50. So the TLS connection ends close to each server. Even so, only Tokyo answered in single digit milliseconds. Our numbers point to the book being served from near Tokyo, and the request travelling there and back from every other city.

The tail tells the same story. The slowest 1% was 120 to 410 ms everywhere, and C++ was slower there in Singapore, Mumbai and New York. That is network jitter. A faster language does not shorten a slow packet.

If you trade on Hyperliquid from India, this is the part to look at. From Mumbai, a request took about 156 ms. From Tokyo it took under 6 ms. Moving the server saves you far more than rewriting the bot.

We covered the same idea from the other side in Is Python Too Slow for Crypto Trading?, which compares Python’s compute time to block times. For cloud to cloud times between regions, see Colocation and Latency for Crypto Trading. For how Hyperliquid’s order books work, see the Hyperliquid protocol page.

Check it yourself

You need Python 3 and the requests library. The script times the same request and prints the medians.

pip install requests

Save this as time_book.py:

import json
import statistics
import sys
import time

import requests

coin = sys.argv[1] if len(sys.argv) > 1 else "BTC"
n = int(sys.argv[2]) if len(sys.argv) > 2 else 51
session = requests.Session()
network, parse = [], []

for i in range(n):
    t0 = time.perf_counter()
    r = session.post("https://api.hyperliquid.xyz/info", json={"type": "l2Book", "coin": coin})
    raw = r.content
    t1 = time.perf_counter()
    book = json.loads(raw)
    best_bid = float(book["levels"][0][0]["px"])
    best_ask = float(book["levels"][1][0]["px"])
    t2 = time.perf_counter()
    if i > 0:  # the first request also opens the connection, so leave it out
        network.append((t1 - t0) * 1000)
        parse.append((t2 - t1) * 1000)
    time.sleep(0.15)

print(f"{coin}: best bid {best_bid}, best ask {best_ask}")
print(f"network median {statistics.median(network):.2f} ms")
print(f"parse median   {statistics.median(parse):.3f} ms")

Run it:

python3 time_book.py BTC

We ran it from a laptop on home internet in Bengaluru at 11:16 UTC on 17 November 2026. Your numbers will differ with your city and your line:

BTC: best bid 64340.0, best ask 64341.0
network median 144.44 ms
parse median   0.089 ms

The same endpoint serves Hyperliquid’s spot books. Spot pairs go by an index, not a ticker. NVDAX, the xStocks token for NVIDIA, is pair 702:

python3 time_book.py @702
@702: best bid 156.48, best ask 156.58
network median 142.02 ms
parse median   0.079 ms

The C++ client, the runner that takes turns between the two clients, and the raw timings for all 4 cities are in the latency folder of our cpp-trading repo. On a Debian server:

apt install g++ libcurl4-openssl-dev nlohmann-json3-dev python3-requests
sh run_latency.sh nrt
python3 summarize.py

When C++ does matter

C++ pays off when your bot does a lot of work between requests. If it keeps its own order book and replays a million updates, the code is the slow part, and the build flags alone can change the speed by several times. We built one in Building an Order Book in C++. For a bot that reads a book, decides and sends an order, the work inside is a fraction of a millisecond. The trip to the exchange is the rest.

Buy the same stocks on Hyperliquid from your own wallet

The request you just timed also reads the xStocks spot books, and that is where chaotic.markets buys. Open the Hyperliquid page, connect, pick the Index basket (SPYX and QQQX) or the Memory chips basket (NVDAX, SKHYX and MUX), and enter the amount.

You pay with USDC in your own Hyperliquid account, and the tokens settle there. chaotic.markets never holds them. chaotic.markets adds no fee. You still pay Hyperliquid’s spot trading fee, and Hyperliquid rejects any single order under 10 USDC.

This is a speed test, not investment advice. We measured how long a request takes, not what to buy.

Newsletter

Get chaotic.markets updates and new data articles by email.

You confirm by email, and you can unsubscribe from any message. The list is kept by Kit.