Sambath S

My Order Flow Project Took Forever — I'd Use opencode Now

Disclaimer: I’m still learning this stuff. Some details below might be wrong. Corrections welcome — I’ll update the post.

A while back, I got obsessed with order flow trading.

The idea is simple: instead of watching price candles, watch the individual trades that make them up. Every market is just a stream of people buying and selling — if you can parse that stream, you can see things candles hide. Delta, cumulative delta, imbalances. The microstructure.

I wanted this for the Indian market. Turns out Fyers offers exactly the data you need — if you’re willing to wrestle with it.

The Fyers Real-Time Feed

Fyers provides a real-time market data feed via WebSocket, encoded in Protobuf. It’s not just trades — it’s full 50-level depth, quotes, OI, volume, and a continuous stream of updates. Up to 1000+ ticks per second during active hours, with sub-10ms latency from the exchange.

The feed sends an initial snapshot when you subscribe, then differential updates after that.

One important caveat: this feed is available for F&O instruments only i guess.

Getting access was straightforward. Sign up, get your api key, connect via WebSocket.

Parsing the stream was the actual work.

Building the Order Flow Engine

AI coding tools existed when I built this — Cursor was around, Claude was around. I just didn’t lean on them enough. In hindsight, I should have. A lot of the grinding I did could have been a conversation.

The feedback loop was the painful part:

  • Did I miscompute delta because of a timestamp issue, or because I’m reading the trade direction wrong?
  • Why does cumulative delta spike here — real buying pressure, or a data artifact?
  • Is this a feed gap, or a real flat period?

I’d stare at a plot, form a hypothesis, hack up a fix, rerun the pipeline, wait for regeneration, check again. One cycle could take 30 minutes. Cursor would have cut that to two.

What I Actually Built

An order flow pipeline for F&O symbols that:

  1. Connects to the Fyers WebSocket feed and subscribes to symbols
  2. Decodes Protobuf messages, extracts ticks and depth data
  3. Computes delta from buy/sell flags, aggregates into bars
  4. Spits out plots — cumulative delta, imbalances, the usual suspects

Nothing fancy.

What Changed

Now we have Cursor, Claude Code, opencode — all better than what was available when I started.

If I redid this today, I’d describe the pipeline in plain English and have a working prototype in an hour. The tooling handles the plumbing: WebSocket reconnection, Protobuf decoding, edge case handling, basic visualization. I’d iterate on the analysis, not on debugging byte buffers.

I’ve used opencode on other projects since. The gap is staggering. What took me a full day of debugging now takes one prompt and a few corrections.

I wish I’d used Cursor more back then. But at least I know better now.

The Catch

Faster builds don’t mean faster understanding.

You can generate a perfect order flow dashboard in 10 minutes. You’ll still need weeks to understand what it’s telling you. The AI can write the parser, but it can’t tell you whether a delta divergence is meaningful in Nifty weekly options or just noise.

The bottleneck shifts from “can I build this” to “do I know what this means.” And that’s actually fine. It means you spend your time where it matters.


Turns out I’m better at parsing tick data than predicting the next tick. So I built the parser.

Related Posts