Andrew Dorokhov

Crypto trading · Own product

A crypto arbitrage engine that reprices every opportunity the moment a price changes

A scanner that streams a crypto exchange's quotes and order books, reprices every trading route a price change touches and paper-trades the opportunities it finds.

crypto exchanges supported
50+
math operations per second
~80M
average pricing time per batch of price updates
< 0.5 ms

The challenge

What the client needed

Triangular arbitrage looks simple: trade BTC for ETH, ETH for USDT and USDT back to BTC, and end up with more BTC than you started with. On a large exchange there are thousands of markets and an enormous number of such routes, prices change several times a second, and a gap rarely lasts longer than a moment.

Best bid and ask prices are not enough either. A route that looks profitable at the top of the book can lose money once fees are paid and the order book is too thin for the amount you want to trade. Every opportunity has to be checked against real depth, and fast.

I wanted a tool that shows which opportunities are real, not just which ones look good on paper, and that tests a strategy against live data before any money is at risk.

The approach

How I solved it

01

Shared memory instead of a message bus

Each exchange runs in its own worker thread and writes quotes and order books into tables in SharedArrayBuffer, guarded by a seqlock. The pricing code reads them straight from memory, so a quote reaches the arbitrage math without being serialized, sent over a socket and parsed back.

02

Repricing on every update, with depth

There is no evaluation timer: every batch of changed quotes reprices the routes that trade through those markets. Routes that pay at the top of the book are then priced layer by layer against live order books, net of taker fees, so the scanner reports the profit a real trade would get.

03

One socket, nothing sent unasked

The dashboard and the bot share one WebSocket server that sends only what a client subscribed to. Order books are pulled from the exchange only while someone is watching them, and opportunity frames are coalesced so the socket never becomes the bottleneck.

04

Paper trading before real money

A separate bot listens to the opportunity feed and trades on paper: every hop waits out a simulated API delay and then fills against the order book as it is at that moment. Comparing expected and actual profit shows how much of an opportunity survives real latency.

In motion

Highlights

01

Opportunities ranked as the books move

Thousands of candidate chains are re-ranked by the profit the live order books can deliver right now. Rows rise, fall and refresh as quotes arrive, without reloading the page or polling the server.

Maker-entry opportunities table updating live: chains of currencies with profit, volume and top-of-book percentage refresh every second.
02

The whole exchange as one graph

Every market that can take part in an arbitrage route is an edge between two currencies. Switching between spot and perpetual swaps rebuilds the graph and shows which currencies hold the routes together.

Currency graph of Bybit markets on arbitrage routes, switching between all markets, spot and swap.
03

An engine you can watch

Live telemetry shows what the engine costs: memory, CPU, event-loop lag, how long each quote batch takes to price, and the traffic and health of every exchange connection.

System page with live sparklines for memory, CPU, event loop lag and pricing time per batch, and the Bybit connection stats.

See it in action

The product

Engine telemetry: pricing time per batch, main-thread load and every exchange connection.
The paper-trading bot: expected profit at signal time next to what the books gave after the delay.

The outcome

What the client got

  • Every route a price change touches is repriced in under a millisecond on average, with no polling interval.
  • Opportunities are ranked by the profit the live order books can actually deliver, not by top-of-book prices.
  • A live System page shows memory, CPU, event-loop lag, pricing time and the health of every exchange connection.
  • The paper-trading bot has run thousands of simulated trades, with expected and actual profit side by side.
  • One exchange adapter runs the engine on any of 50+ exchanges; quirks that fail silently, like oversized subscriptions or rejected book depths, are handled per exchange in configuration.

Need something similar built?

Send a short brief about your project. Within 24 hours you get an estimate or a clear next step, even if we don't work together.