Lab note #1

stock-tui: building a stock market heatmap for the terminal

A mouse-first Rust TUI inspired by StockTouch, shaped through 66 rounds of prompts, screenshots, tests, and small corrections with Codex.

View on GitHub Watch the build video
A 14.6-second walkthrough from the nine-sector market overview to sector and ticker views in v0.3.0.

The seed was simple: what if the old StockTouch market map lived inside a terminal? Not a trading app, and not a spreadsheet with ANSI colors – a dense, mouse-friendly view you could scan, open, and explore without leaving the shell.

The idea

A favorite old interface, moved sideways

StockTouch arranged the market as a wall of red and green tiles. stock-tui keeps that visual model but changes the medium: a 3×3 overview of nine economic sectors, up to 100 companies inside each sector, then a ticker screen with price, volume, statistics, and news.

“Represent stocks as color-coded rectangles, moving from bright red through dark red and neutral gray to dark green and bright green.”

From the first prompt to Codex

The opening prompt was broad, but it was not vague. It named the interaction model, screen hierarchy, visual scale, cache, likely data provider, mouse support, and the shape of a future backend. That gave Codex room to make implementation choices without asking it to invent the product.

The build loop

The first prompt made a program. Feedback made the product.

The first commit already contained the end-to-end skeleton. The useful work happened afterward: run it, notice something odd, describe the evidence, let the agent inspect it, and keep the correction small enough to verify. The repository now records 66 prompt notes through the v0.3.0 release and the follow-up dependency and animated-cover update.

  1. 1

    Choose the medium

    A follow-up challenged the initial language choice: Rust or Go instead of Python? Rust won because Ratatui offered precise cell and canvas rendering, Tokio handled background sync, and bundled SQLite kept distribution to one native binary.

  2. 2

    Replace obvious fakes

    The first demo exposed synthetic ticker IDs and suspicious alternating gains and losses. The next pass kept simulated values but paired them with real SEC-catalog issuer identities and independent seeded returns. Demo data became useful without pretending to be live.

  3. 3

    Debug the terminal, not an abstraction

    Mouse reports, Braille chart guides, font fallback, and delayed input all behaved differently inside a browser terminal. Screenshots and exact symptoms led to SGR mouse support, terminal-stable guide glyphs, contrast tests, and a shutdown sequence that drains input before returning to the shell.

  4. 4

    Let constraints change the architecture

    A shared no-key market-data proxy sounded convenient. Provider terms made public redistribution unsafe, so the live path stayed bring-your-own Alpaca credentials. Cloudflare R2 serves only the independently derived SEC issuer catalog; prices and news stay behind the user's chosen provider.

Under the hood

One native client, several deliberately narrow boundaries

Interface

  • Rust 2024 for the client
  • Ratatui for layout and cell rendering
  • Crossterm for mouse, keyboard, resize, and terminal cleanup

Runtime & storage

  • Tokio for background provider work
  • SQLite via bundled rusqlite
  • Reqwest + rustls for provider and catalog requests

Data & delivery

  • Alpaca for BYO-key prices, bars, assets, and news
  • SEC JSON/XBRL for issuer, classification, and share-estimate data
  • Wikidata for conservatively matched CC0 company context
  • Cloudflare R2 for the small public catalog
  • GitHub Actions for five release targets
Working with Codex

Specific observations beat impressive prompts

The sessions ran through chatcode.dev, but the platform was mostly the workbench: a persistent browser terminal where Codex could inspect the repository, run tests, and continue after the laptop closed. More interestingly, that environment surfaced real xterm and browser-font behavior that a local mock would have missed.

  • Point at evidence. “The cursor drifts farther to the right” was more actionable than “the chart looks wrong.”
  • Ask for the trade-off. The Rust-or-Go question produced a decision the repository could explain, not just a language switch.
  • Keep judgment human. Licensing, visual taste, security boundaries, and what counts as honest demo data still needed explicit choices.
  • Turn a fix into a guardrail. Rendering bugs became tests; ambiguous SEC share structures became fail-closed catalog rules.

You do not need to arrive with a perfect specification. A concrete first picture and the confidence to say “that is not what I meant” are enough to start. The project became precise one observation at a time.

Try the experiment

The demo needs no account and no market-data key

Clone the project and run its deterministic offline demo. It generates simulated prices for 900 real SEC-catalog issuer identities, keeps demo and live databases separate, and labels the screen SIMULATED.

shell
git clone https://github.com/chatcode-lab/stock-tui.git
cd stock-tui
cargo run --release -- --demo

Prebuilt binaries for Linux, macOS, and Windows are also attached to the GitHub releases. This is early, pre-1.0 software and not investment advice.

A closer look

The same idea at two depths

See it in motion

Watch the stock-tui build session

The recorded session follows Codex from the first StockTouch-inspired prompt through implementation, visual review, and the finished terminal app.

Source, releases, documentation, and the full prompt-to-commit history are in github.com/chatcode-lab/stock-tui.

Share this note