Building a Bookmap-Style CVD Indicator with Claude Code and Python
I had a conversation recently with prahko from SMB Capital about building order flow visualization tools. He built a Cumulative Volume Delta (CVD) widget using the IBKR TWS Gateway, and it got me thinking: why am I paying for Bookmap when I could build exactly the indicator I need, tuned to my trading style, using tools I already have?
What CVD Actually Is
Cumulative Volume Delta is one of the clearest windows into market microstructure. The concept is simple: for every trade that executes, classify it as buying pressure (executed at the ask) or selling pressure (executed at the bid). Accumulate the difference over time.
CVD = cumulative_sum(buy_volume - sell_volume)
When CVD trends up, aggressive buyers are in control. When it trends down, sellers are dominant. The divergences between CVD and price are where the real edge lives — price making new highs while CVD makes lower highs signals exhaustion. That is the kind of systematic, quantifiable signal that appeals to me as a trader moving toward algorithmic execution.
The Data Pipeline
I already have the pieces. My Falcon trading platform includes a headless Interactive Brokers gateway, and the IBKR TWS API provides tick-by-tick trade data with aggressor side classification. The architecture would be:
IBKR TWS Gateway
|
v
Python (ib_async) — reqTickByTickData("AllLast")
| classify: executed at ask = buy, at bid = sell
| compute: CVD = cumsum(buy_vol - sell_vol)
v
FastAPI + WebSocket (/ws/cvd)
|
v
Browser widget (compact, embeddable)
The Python layer handles the computation. A lightweight WebSocket endpoint pushes updates to a browser-based chart. The question is what to render with.
Choosing a Visualization Library
I researched several options for rendering compact, real-time financial charts. Here is what I found.
D3.js — Maximum Flexibility, Maximum Effort
D3 is the Swiss army knife of data visualization. You can build literally anything. The problem is you have to build literally everything. For a single-purpose CVD widget, D3 is the wrong tool — its learning curve and manual update management are not justified when purpose-built financial charting libraries exist. The d3fc financial components library helps, but it is still fundamentally a general-purpose framework.
Verdict: Skip for this use case.
Lightweight Charts (TradingView) — The Sweet Spot
TradingView open-sourced their charting library under Apache 2.0. It is purpose-built for compact financial chart embeds at under 50KB gzipped. The API is familiar to anyone who has used TradingView, and it includes a Custom Series plugin API that supports building a CVD renderer with custom Canvas drawing.
The update() method handles real-time data pushes efficiently, and the look and feel is professional out of the box. For a CVD line chart alongside price, this is the natural choice.
Verdict: Production widget. Best balance of capability, size, and polish.
Plotly and Dash — Python-Native Prototyping
Dash lets you build the entire visualization in Python without touching JavaScript. Use dcc.Graph with dcc.Interval for periodic refresh. This is the fastest path to validating the indicator logic and data pipeline from IBKR.
The limitation is performance — Dash callbacks add latency, and Plotly.js weighs about 3MB. It will not handle sub-second updates smoothly. But for proving the concept in an afternoon, nothing is faster.
Verdict: Prototype only. Validate the math, then move to Lightweight Charts.
uPlot — Raw Performance
At 45KB, uPlot is the smallest and fastest open-source charting option. It handles 60fps streaming at 10 percent CPU. If Lightweight Charts cannot keep up with 1000+ ticks per second rendering, uPlot is the fallback. The tradeoff is a more utilitarian look and sparser documentation.
Verdict: Performance fallback if needed.
SciChart.js — Enterprise Grade
SciChart uses WebGL and WebAssembly to render 40 million data points per second. This is what you would use if building a full Bookmap-style Level 2 heatmap alongside CVD. For just a CVD line, it is overkill — and the commercial license starts at $500 per year.
Verdict: Only if building the full heatmap.
What Makes Bookmap Special
Bookmap itself is a Java and OpenGL application rendering at 40 FPS. Its technical moat is not the CVD indicator — that is a simple cumulative sum. The moat is the full Level 2 order book heatmap with historical replay, which requires ingesting and rendering millions of price-level updates per second. Color intensity maps to limit order depth: red and orange for high liquidity, blue and green for low.
For a standalone CVD widget, I do not need anywhere near that complexity. A cumulative line chart with divergence markers against price is sufficient to capture the signal I am looking for.
Where Claude Fits In
This is the kind of project where having an AI development partner changes the economics. Claude Code is effective at iterating on Lightweight Charts plugins because the API surface is small enough to fit in context, the Custom Series interface is a well-defined contract, and you can test changes by refreshing a single HTML file.
The pattern I have been using: describe the visual I want, let Claude generate the plugin class and HTML harness, then iterate on rendering details. The feedback loop is minutes, not hours. For a systematic trader who wants custom indicators without becoming a full-time frontend developer, this is the right approach.
Next Steps
- Prototype — Python CVD computation from IBKR tick data using Plotly and Dash. Validate the math against known CVD implementations.
- Widget — Lightweight Charts Custom Series plugin for the CVD line. Compact, embeddable, real-time via WebSocket.
- Integration — Wire into the Falcon platform alongside the morning game plan pipeline and trading log.
The goal is not to rebuild Bookmap. It is to build the specific order flow indicator I need, own the data pipeline end to end, and have a tool that evolves with my trading — because I built it.
David Duncan is a momentum trader, Fedora Cloud SIG contributor, and builder of AI-assisted trading infrastructure at davidduncan.org.