Part 4: Move next to the exchange
Same bot, same code. Moving it off my laptop to a $0.10/hour server in Tokyo took end-to-end latency from 211ms to 27ms.
That's almost 90% gone without touching the code. Part 3 was Amdahl's law: the code takes microseconds, the network takes tens of milliseconds. You can't optimise the speed of light, so you move closer. Easiest win in the whole series.
Pick the zone by measuring
Binance's matching engine lives in AWS Tokyo, which has several zones, basically separate data centres. AWS shuffles zone names per account, so use zone IDs.
Our probe (code linked below) spins up a tiny server in each zone, times 100 handshakes to Binance and deletes itself. A few cents.
apne1-az4: 0.5ms
apne1-az1 and az2: ~2ms
4x closer just by picking the right building.
Don't use a burstable box
Lightsail and EC2's `t` instances only guarantee you a slice of a CPU on the sizes a bot would use, 20% on Lightsail's $12 and $24 plans. Go over and you burn credits, run out and you get throttled. A quoting bot is always on and busiest when the market moves, which is the worst time to get throttled. Remember, we care a lot about low jitter during volatility (will be in the weeds optimisations on this in future tweets).
Lightsail is great for a website. For this you want EC2: a c8g.large, where the CPU is yours.
Do it in code, not clicks
The whole setup is Terraform. Server, zone, firewall and permissions all live in a template. Using the AWS UI is terrible and annoying, and the sooner you switch to IaC (infra-as-code) the better, trust me. One command up, one command down, so no forgotten box on next month's bill. Same build every time, in any zone or account.
Also recommend setting up ssh keys to access your box (or use SSM) and use a static IP (called EIP in AWS) so that you can get your IP ranges whitelisted on exchanges you trade on, and they don't change if you replace the box.
Two freebies
The clock syncs to Amazon's time service inside the data centre. My laptop was 288ms off in part 3, now it's microseconds, so the network numbers are finally useful and accurate.
The bot key never touches disk. It sits encrypted in AWS Parameter Store and gets pulled into memory at startup. Always use delegate/scoped API keys not root access private keys, and never store them anywhere on your infra in plaintext.
Scoreboard, p50
End-to-end: 211ms to 27ms
Binance to us: ~40ms to 1.6ms π₯
Order to live on Bullet: 24.6ms (to be addressed next)
What's left is mostly order to live, because the bot cancels, waits, then places. Part 5 fixes the sockets, part 6 stops the blocking calls.
The @CFTC approved the first exchange and clearinghouse applications for a firm utilizing blockchain-based architecture for the execution and settlement of derivatives.
These approvals demonstrate that there is a regulated pathway for a new generation of market infrastructure built using blockchain technology and reinforce that the United States is open for business to innovators.
Backpack is coming home to the USA. πΊπΈ
Weβve received landmark CFTC approval to establish the first-ever derivatives exchange powered by one order book with unified global liquidity.
Leveraged perpetuals. Crypto collateral. Cross-margin. 24/7 trading.
Join the waitlist: https://t.co/xnByot5jxX
LFG π
How I made $6K PnL in 30 days on $10K principal market making perps ($158m+ volume).
The strat was entirely built by me and my quant, Claude (he won a national math competition in China).
Last night I asked if you'd want a guide. Hundreds of you said yes, so here it is: HFT for Dummies.
The honest timeline when I did it:
- Days for basic harness and venue integrations.
- Weeks to get it semi-competitive.
- Months to really tune and get it properly profitable.
This series can hopefully shortcut the learning curve for you.
I've been writing trading bots since 2017. It's how I got into crypto (free market data!), and how I met my co-founder.
Back then the barrier was high. You had to know how to code, to study data to find alpha, and to grind devops to have systems not blow up in production. Thankfully I taught myself Python and later Rust, but not everyone has a CS degree.
Nowadays with LLMs, anyone can have a skilled quant in their pocket. I use it for data analysis, strategy tuning, research and alpha generation and infra optimisation. It's a ridiculous time saver.
I'm extremely bullish on one-person quant shops. I think this will be a huge trend this next decade as finance comes on chain and market data and connectivity are accessible to anyone. I've already met many hobbyists who've made a living trading on e.g. Hyperliquid, enough so to quit their day jobs.
What we'll be building
A delta-neutral, reference-price market maker.
Binance is where most price discovery happens. We stream its market data, use it as a reference price, and quote a bid and an ask around it on another venue. I'm using @Bulletxyz because it's the one I know best.
Market making is the business of picking up pennies. Mine are under half a basis point per dollar. Enough pennies add up at the scale of millions of volume.
The catch is speed. If the market moves and you're slow to update, someone lifts your stale quote and you're the exit liquidity. It's a fun game of algorithmic cat and mouse.
On Bullet, takers get a 100ms speed bump. Why? It gives soon-to-be market makers like you a safety buffer so you don't get steamrolled by billion dollar firms with microwave towers.
The goal
The goal: tick to order sent in under 10ms. Stretch goal: under 1ms, which is very achievable if you're determined. We'll also focus on minimising jitter (randomness) because your slowest orders are the ones that will lose you the most pnl.
Agenda:
I'll aim to post one topic a day, going from easy wins, and getting progressively more deep in the weeds. If you work at any HFT firm this will all be elementary stuff, but hopefully it's helpful for newcomers.
Saving seconds
1. Basic intro to algo-trading (this post)
2. Running a simple market maker from your laptop
3. Measure once, cut twice: telemetry and Amdahl's law
4. AWS: Infra and colocation
Saving millis
5. Stop polling: websockets are your friend
6. Optimising order execution
7. How to not get rekt by API rate limits
8. Linux tuning: CPU pinning, IRQs and other nerd stuff
Saving micros (diminishing returns, but fun)
9. Optimising the hot path with CPU profiling in Rust
10. AWS: the last mile
11. Bonus: nonces (and other DeFi quirks)
I'll try share some open source code along with it. Don't expect to be beating Jump in the orderbooks just yet. It should be a good baseline that you can extend and take it as far as you want (you can take it pretty far!).
Tomorrow: setting up a basic MM in Rust, the architecture of which will roughly follow the diagram attached below.
When Solana gets faster, Bullet gets faster.ποΈ
The Alpenglow consensus upgrade has reduced the Bullet desposit time to under a second.
Fast speeds. $0 fees to trade.
Bullet mentioned. π
You ready to compete? BULLET ROYALE drops tomorrow with ZERO Trading Fees.
No trading fees means more of every winning trade stays yours. The trader with the highest PNL takes the top prize, with rewards for the top 20 traders.
Trade hard. Pay zero fees. Keep the upside.
September was an absolute blur, looking back on it we actually shipped a bunch of cool updates, and finally cracked a few big milestones (10m volume, 2m OI) π’
Bullet Liquidity Provider (BLP) was finally opened to public deposits, and the $300k cap filled the same day. We've extensively tested the strategy for 3 months and it's been overall profitable, with a 2.37 Sharpe and ~100% APY on the last 30 days annualised. Deposit caps will be opening up again this week, keep notis on π
Speed. We benchmarked end-to-end execution against other perp venues. Bullet came in at ~8ms, ahead of Lighter and HL (Nado just recently improved their p50 a lot to ~7ms, congrats to them, we will get you back xd). Our matching engine runs at ~250Β΅s, and most of the remaining time goes to the network, and there's a lot we have flagged to improve still. Thankfully still have the lowest p999 (tail latency) of any DEX by a factor of 4x.
Collateral. You can now post SOL and jitoSOL as margin, meaning no hassle to sell your beloved bags to stables. We built the jitoSOL integration with @jito_sol, so your collateral keeps earning staking yield while you trade.
New Markets. We listed RAY, BNC, UNI and NEAR, and PUMP and DOGE go live tomorrow. We also automated most of our listing pipeline, so a new market now takes us about 15 minutes end to end. Expect a lot more of them, and quickly. People under-appreciate the operational burden of exchange listings, and we've spent a bunch of time seeing how it can largely be automated. We're aiming to list 2 new markets every week.
Liquidity. Most majors (BTC/ETH/SOL) are now consistently 0.1-0.5bps wide at the top of the book (!!), which is testament to why we've been hell bent on building the fastest execution stack on the market. @AphelionTrading is now providing very competitive liquidity on Bullet. They were the highest-volume onchain market maker on Solana from last cycle, and true friends and legends that I am grateful to be working with again.
Fees. We cut trading fees across every tier, and volume picked in accordance. We are going to continue experimenting with fee structures that reduce friction to onboarding for new traders evaluating our product, our goal being to provide the best cost for the average perps consumer (spread + fees).
Affiliates. More than 100 affiliates have signed up since we launched the program. Form linked below.
Product. We shipped subaccounts, isolated margin, and vault infrastructure that lets anyone launch and run their own vault.
Bullet Liquidity Provider (BLP) is Bullet's automated market-making vault.
The Vault quotes both sides of every perp market, layered from tight to wide around reference prices from centralized venues, and earns the spread plus a maker rebate when its orders fill.
The strategy is designed to be beta neutral. As inventory builds, it skews quotes toward flat, both per market and across beta-weighted exposure in crypto, stocks and commodities. Its taking logic adapts to its risk position, actively working down beta exposure as it builds. Hard position limits apply per market, and there is no external hedge.
Deposits are pooled as margin for those quotes, and depositors share the PnL pro rata:
β’ Users can deposit USDC and share in the vaultβs overall PnL
β’ No management fees or profit-sharing deductions
β’ Deposits have a 24-hour lock-up period
β’ Withdrawals take 24 hours to process
β’ Depositors share the downside if extreme volatility or market manipulation creates losses
Until now, deposits into the BLP was a Team-only perk.
Today, we are sharing it with all our users:
β 1,000 USDC max per wallet
β 300,000 USDC total capacity
β First come, first served