Shivanshu Pathak / Software Engineer · Trading Systems
I build trading systems where a slow answer and a wrong one cost the same.
I build the parts of a trading stack where correctness and latency both matter: pre-trade risk, order execution, and market-data pipelines that stay ordered, idempotent, and replayable.
- Now
- Software Engineer II, Kryptos
- Before
- Founding Engineer, Baskt · derivatives trading platform
- Building
- Aether, a C++20 matching engine
- Studied
- B.Tech CS (Cyber Security), CGPA 9.3 · M.S. AI, ongoing
- Based
- India · open to relocating
- Contact
- shivanshu814pathak@gmail.com
Measurements
Numbers I can reproduce on demand. Apple M1 Pro · macOS · Apple clang 21 · -O2 · threads unpinned. The source for every figure is linked.
Order book throughput
Flat price levels, intrusive FIFOs and a pooled order store: 1.9× the throughput of std::map on the same 2M-operation stream, with identical fills.
method & source| std::map + list | 7.0 M ops/s |
|---|---|
| flat + pool | 13.2 M ops/s |
Queue round-trip latency
An acquire/release SPSC ring buffer loses to a mutex queue on raw throughput, but wins where trading cares: median round trip 3.7× faster, p99 20× faster.
method & source| mutex queue | 458 ns |
|---|---|
| SPSC ring | 125 ns |
| mutex queue | 20,250 ns |
|---|---|
| SPSC ring | 1,041 ns |
False sharing
Two threads, two counters. Sharing one 128-byte M1 cache line costs ~1.4× per increment (one run: 6×). Padding to the real line size, not x86’s 64 bytes, removes it.
method & source| same cache line | 3.53 ns / increment |
|---|---|
| padded to 128 B | 2.47 ns / increment |
Where these numbers sit on the hardware ladder
Log scale, 1 ns to 1 ms. A whole order-book operation costs less than one trip to DRAM. A contended mutex's tail lands next to an SSD read. That gap is the argument for lock-free hot paths.
| L1 hit | 1 ns | reference |
|---|---|---|
| L2 hit | 4 ns | reference |
| mutex lock/unlock (uncontended) | 25 ns | reference |
| DRAM access | 100 ns | reference |
| context switch | 3 µs | reference |
| SSD random read | 16 µs | reference |
| datacenter round trip | 500 µs | reference |
| flat order book op (avg) | 76 ns | measured |
| SPSC round trip p50 | 125 ns | measured |
| std::map book op (avg) | 142 ns | measured |
| SPSC round trip p99 | 1 µs | measured |
| mutex queue round trip p99 | 20.3 µs | measured |
This page, measured live
Frame-to-frame intervals in the tab you are reading. The median is your display refresh. The amber tail is jitter: GC pauses and main-thread stalls. Scroll hard and watch it grow.
Anatomy of a trade
Scroll through the tick-to-trade path: where the microseconds go, and which ones software can win back.
- 1Wire → user space~1–2 µs
- 2Decode feed~50–200 ns
- 3Update book76 ns avg (measured)
- 4Strategy~100–500 ns
- 5Pre-trade risk~50–200 ns
- 6Encode & send~1 µs
Illustrative orders of magnitude for a software path with kernel bypass, from public talks and vendor figures. The segment is my own measurement.
- 01 · ~1–2 µs
Wire → user space
A UDP multicast packet lands on the NIC. Kernel bypass (ef_vi, DPDK, Onload) DMAs it straight into a ring the application polls, skipping interrupts, syscalls and the socket layer. On a normal kernel path this one stage costs several microseconds.
- 02 · ~50–200 ns
Decode feed
Parse a fixed-layout binary message in place: no allocation, no copies, no JSON. Check the sequence number. A gap means a packet was lost and the book is wrong until recovery.
- 03 · 76 ns avg (measured)
Update book
Apply the add, cancel or execute to the order book. With flat price levels and pooled orders, the touch is one indexed load away. This number is mine: 76 ns per operation on an M1 Pro.
see the benchmark → - 04 · ~100–500 ns
Strategy
Turn the new book state into a decision. The hot path is branch-light and precomputed; anything expensive (fitting, calibration) runs off the critical path and publishes parameters.
- 05 · ~50–200 ns
Pre-trade risk
Position limits, notional caps, price collars and fat-finger checks, applied on every order before it leaves. I built this layer for a derivatives venue. It has to be fast and it must never be wrong.
- 06 · ~1 µs
Encode & send
Serialise the order into the exchange’s binary protocol and push it out through the bypass stack. The edges of the system, I/O in and out, dominate the budget, which is why serious shops move them into FPGAs.
Experience
Trading and financial infrastructure first. Earlier roles condensed.
- Feb 2024 – Sep 2025Remote · Texas, US
Founding Engineer — Baskt
First engineer on a derivatives trading platform.
- –Designed and built the pre-trade risk engine: margin and collateral checks, position limits, and liquidation logic applied before an order is accepted.
- –Built the order execution and settlement path between off-chain services and on-chain programs, with idempotent retries so an order is never filled twice.
- –Built the real-time event-streaming layer feeding pricing, positions, and PnL services from on-chain events.
- –Wrote on-chain programs in Rust (Anchor) that ran on mainnet, where every bug is a financial event.
Rust · TypeScript · Go · Solana / Anchor · PostgreSQL · Redis
- Dec 2023 – PresentRemote · Gothenburg, Sweden
Software Engineer II — Kryptos
Enterprise crypto accounting, tax, and portfolio intelligence for global clients.
- –High-volume, multi-chain transaction ingestion: ordered, idempotent pipelines that can be replayed after a partial failure.
- –Deterministic cost-basis and tax computation over inconsistent exchange and on-chain data, producing reproducible, audit-ready numbers.
- –Event-driven, multi-tenant services and high-throughput APIs with back-pressure handling.
- –OAuth2 / OIDC identity platform: token lifecycle, session security, and multi-tenant SSO.
Go · TypeScript · Python · PostgreSQL · Redis · AWS
- Jan 2023 – Jun 2026Bengaluru, India
Co-Founder & CTO — Touch Computing Technologies
TouchOS: a browser-based cloud operating system.
- –Architected VM orchestration, real-time session services over WebSockets, and multi-tenant SaaS applications.
- –Owned infrastructure, reliability, and the engineering hiring bar.
Go · Node.js · Docker · Kubernetes · AWS
- Aug 2023 – Jul 2024Remote
Software Engineer — Mantle
Blockchain infrastructure engineering.
TypeScript · Solidity
- 2022 – 2024India · Remote
Backend & ML internships — Early career
KliqueStart (Backend Developer), Horse’s Mouth (SDE Intern), Metabees (Technical Lead Intern), Ignitus (ML Intern), Amazon ML Summer School.
The platform
Five C++20 projects, one system: from historical replay to matching. Each ships with tests, benchmarks and a write-up of what failed.
- 01building
AetherUltra-low-latency matching engine
A miniature electronic exchange: price-time priority matching across multiple instruments, with a custom order book, a memory pool, and deterministic event replay.
Limit, market, cancel & modify orders · Price-time priority (FIFO), partial fills · Custom price-level book vs std::map · Memory pool: no heap allocation on the hot path · Deterministic, replayable order processing
measures: Orders/sec · p50 / p99 / p99.9 latency · allocations per order
- 02planned
AtomLock-free concurrency library
Concurrency primitives built from atomics, not std::mutex: SPSC and MPSC queues, explicit memory ordering, and memory reclamation, stress-tested under ThreadSanitizer.
SPSC ring buffer & MPSC queue · acquire / release vs seq_cst ordering · Cache-line padding against false sharing · Thread pinning, contention benchmarks
measures: Throughput & tail latency vs mutex queue, by producer/consumer count
- 03planned
MercuryMarket-data feed handler
Receives a simulated exchange feed over UDP/TCP, parses a binary protocol, and maintains sequence integrity under packet loss, duplicates, reordering, and bursts.
Binary protocol parsing, zero-copy · Gap / duplicate / out-of-order detection · Snapshot recovery · Fault-injecting exchange publisher
measures: Messages/sec · parse latency · recovery correctness under burst
- 04planned
CacheLabCPU & memory performance research
Reproducible experiments showing how hardware shapes software: cache hierarchy, line alignment, false sharing, branch prediction, AoS vs SoA, allocators, and SIMD.
L1 / L2 / L3 latency staircase · False sharing & 64 vs 128-byte lines · AoS vs SoA over millions of orders · Branch prediction & SIMD
measures: ns/op with hardware counters, compiler flags & machine details
- 05planned
ChronosMarket replay & backtesting engine
A deterministic, event-driven simulator that replays historical ticks and models execution realistically: queue position, slippage, spread, and fees.
Timestamp-ordered event replay · Fill simulation with partial fills · Slippage & transaction-cost models · Market-making & momentum test strategies
measures: Replay determinism · events/sec · PnL under cost assumptions
Writing
Long-form notes. Every benchmark comes with its source and its caveats.
- November 17, 2026Your order book should not be a std::mapA flat, price-indexed order book with intrusive FIFO queues and pooled orders against the textbook std::map design: same workload, same fills, 1.9× the throughput. Includes the numbers, the caveats, and where the time actually goes.
- November 16, 2026My lock-free queue lost on throughput. It still won.An SPSC ring buffer with acquire/release ordering and cache-line padding: 1.7× slower than a mutex queue on raw throughput, but a 3.7× faster median round trip and a 20× better p99. Why both results are correct, and what that means for trading systems.
- December 15, 2024Building LiquiDash: A Comprehensive DeFi Protocol with Smart ContractsDeep dive into building LiquiDash - a comprehensive DeFi protocol featuring smart contracts, TypeScript SDK, and developer UI for the Liquity Protocol. Learn about interest-free loans against ETH collateral and the technical challenges faced.
- December 14, 2024TerraZenith: Building Production-Ready AWS ECS Infrastructure with TerraformDeep dive into TerraZenith - a comprehensive Terraform infrastructure for AWS ECS deployment with Fargate, Application Load Balancer, auto-scaling, and CloudWatch monitoring. Learn how to build production-ready infrastructure as code.
Toolbox & open source
- Languages
- C++20, Rust, Go, Python, TypeScript, SQL, Bash
- Systems & performance
- Linux, Memory layout, Cache locality, Multithreading, Atomics / memory model, perf · gdb
- Trading domain
- Pre-trade risk, Order execution, Order books, Derivatives, Market data, PnL & positions
- Distributed systems
- Event-driven design, Idempotency, Exactly-once semantics, Back-pressure, Replayable pipelines
- Networking
- TCP / UDP, Multicast, WebSockets, Binary protocols
- Data & infra
- PostgreSQL, TimescaleDB, Redis, Kafka, AWS, Docker, Kubernetes, Terraform
§7
Hiring for trading systems or low-latency infrastructure? Let's talk.
I reply within a day (IST).