Stock chart widgets — Massive.com flat files (CSV / CSV.GZ)
Load real market data into every Stock* chart widget straight from Massive.com flat files — one file per trading day, no API client, no S3 downloader, no keys in the widget. The loader lives in the shared module, lightgui/xframe/stock.py, next to the generic CSV loader, and the one StockWidget class (parameterised by kind) gains it for all 23 charting kinds at once. See stock-charts-data.md for the generic date,open,high,low,close,volume format.
Where the files come from
Massive flat files need a paid Massive plan. The files are fetched from the Massive dashboard / S3 — endpoint https://files.massive.com, bucket flatfiles, path s3://flatfiles/{asset_class}/{data_type}/{yyyy}/{mm}/{yyyy-mm-dd}.csv.gz. One trading day per file, available around 11:00 AM ET the next day. The widget never fetches anything: you download the file (or point the loader at a file you already have) and hand the path to the widget. There is no network code, no API client, and no credential handling in LightGUI.
The three schemas (exact columns)
Columns are matched by header name, never by position, so a file with extra columns or a different column order still loads. All timestamps are integers, Unix nanoseconds, UTC.
day_aggs_v1 / minute_aggs_v1 — 8 columns
ticker,volume,open,close,high,low,window_start,transactions
SPY,45879.010360,645.12,647.85,648.30,644.90,1789689600000000000,1234
| Column | Meaning |
|---|---|
ticker |
Symbol, or an OCC option ticker (see below) |
volume |
A number that can be fractional (e.g. 45879.010360) — parsed as float, not int |
open, close, high, low |
Bar OHLC |
window_start |
Start of the bar, Unix nanoseconds |
transactions |
Trade count in the bar (kept, not plotted) |
Day and minute aggregates have identical columns; the bar length is a property of the file, not the header. Stocks flat files are unadjusted (no split/dividend adjustment); options bars are not rescaled for splits.
quotes_v1 — 14 columns (NBBO)
ticker,ask_exchange,ask_price,ask_size,bid_exchange,bid_price,bid_size,conditions,indicators,participant_timestamp,sequence_number,sip_timestamp,tape,trf_timestamp
SPY,2,647.86,15,3,647.84,22,"12,37",,1789738200123456000,901000,1789738200123457000,3,1789738200123459000
ask_size/bid_size are shares for stocks (in shares, not round lots, for files dated on/after Nov 3, 2025, per the SEC MDI change) and contracts for options. conditions/indicators are integer lists, quoted with commas when there are several ("12,37"). tape: 1 = A (NYSE), 2 = B (ARCA/American), 3 = C (NASDAQ).
trades_v1 — 13 columns
ticker,conditions,correction,exchange,id,participant_timestamp,price,sequence_number,sip_timestamp,size,tape,trf_id,trf_timestamp
SPY,"12,37",0,3,T001000,1789738200123456000,647.85,902000,1789738200123457000,100,3,,1789738200123459000
id is the trade ID (unique per ticker + exchange + TRF). All three timestamps are Unix nanoseconds, UTC.
Options tickers (OCC format)
Options tickers look like O:SPY260918C00650000 — O: + underlying + YYMMDD expiry + C/P + strike × 1000 as 8 digits. The example is a SPY call expiring 2026-09-18, strike 650.00. parse_option_ticker splits one into underlying, expiry, call/put, and strike.
One file holds every ticker — filter by ticker
A real Massive flat file holds every ticker for the day. Every loader takes an optional ticker filter ("SPY", or an OCC ticker such as "O:SPY260918C00650000"). With no filter, every row is aggregated in file order. Pass the filter whenever you plot one symbol.
Quotes and trades become bars
Aggregates load as bars directly. Quotes and trades are tick streams, so the loader aggregates them into 60-second bars by default (quotes_to_bars / trades_to_bars take an optional bucket width):
- Quotes → bars: OHLC of the mid-price
(ask + bid) / 2, bucketed onsip_timestamp. Volume is the summed quoted ask + bid size — that is quoted size, not traded volume; say so in any label or article that shows it. - Trades → bars: OHLC of traded prices, volume is the summed traded size.
How to code it
One call per widget
load_massive_csv takes a file path or a file-like object, and accepts .csv or .csv.gz (gzip via the standard library). It stores per-bar epoch-second timestamps, readable with bar_times().
from lightgui.xframe.stock import StockWidget
chart = StockWidget("CandlestickChart")
chart.set_bounds(20, 20, 760, 540)
# An options minute-aggregate file: 30 one-minute bars of the
# SPY 2026-09-18 650 call. Ticker filter is required — the file
# holds every ticker for the day.
n = chart.load_massive_csv("spy260918c-minute-aggs.csv",
ticker="O:SPY260918C00650000")
print(n, "bars plotted") # 30
print(chart.bar_times()[:1]) # [1789738200] — epoch seconds
# A quote file becomes mid-price bars (60-second buckets):
quotes = StockWidget("LineChart")
quotes.load_massive_csv("spy-quotes.csv", ticker="SPY")
# Two symbols on one comparison chart: which=1 is the first slot,
# which=2 the second.
cmp = StockWidget("CorrelationView")
cmp.load_massive_csv("spy-day-aggs.csv", which=1, ticker="SPY")
cmp.load_massive_csv("spy260918c-minute-aggs.csv", which=2,
ticker="O:SPY260918C00650000")
The shared loader, for code that is not a widget
from lightgui.xframe import stock
kind = stock.detect_massive_kind(header_line) # "aggs" | "quotes" | "trades"
opt = stock.parse_option_ticker("O:SPY260918C00650000")
# opt == {"underlying": "SPY", "expiry": "260918",
# "is_call": True, "strike": 650.0}
bars, times = stock.load_massive_file("spy-quotes.csv", ticker="SPY")
# bars: [(open, high, low, close, volume), ...]
# times: [epoch seconds, ...]
| Function | Returns |
|---|---|
load_massive_file(path, ticker=None) |
(bars, times) from any of the three kinds |
parse_massive_file(path, ticker=None) |
Same, path or file-like |
load_massive_text(text, ticker=None) |
(bars, times) from file text |
parse_massive_text(text, ticker=None) |
Same, from text |
quotes_to_bars(quotes, bucket_seconds=60) |
(bars, times) of mid-price bars |
trades_to_bars(trades, bucket_seconds=60) |
(bars, times) of traded-price bars |
parse_massive_aggs/quotes/trades_text(text) |
Row dicts with raw nanosecond timestamps |
detect_massive_kind(header_line) |
"aggs" / "quotes" / "trades" / None |
parse_option_ticker(ticker) |
Dict, or None |
mid_price(quote) / spread(quote) |
float |
StockWidget.load_massive_csv(source, which=1, ticker=None) |
Bar count, on the widget |
StockWidget.bar_times(which=1) |
[epoch seconds, ...] |
Error handling (Python)
Python fails fast: a bad row is an error naming its line and the whole load fails. (C skips malformed rows and counts them; Rust fails fast like Python. See the C and Rust pages for their exact behaviour.)
Zoom and pan
All 23 charting kinds zoom and pan. Zoom and pan only change the visible window — the underlying data never changes, and reset_view() restores the full series.
Mouse gestures
| Gesture | Effect |
|---|---|
| Mouse wheel up (button 4) | Zoom in toward the cursor position |
| Mouse wheel down (button 5) | Zoom out from the cursor position |
| Drag with left button held | Pan left / right through the series |
| Left / Right arrow keys | Pan 10% of the visible window |
| + / = | Zoom in (centred) |
| − | Zoom out (centred) |
| Home / R | Reset to the full series |
Wire the GTK events to the widget — the demo in examples/stockcandlestickchart.py shows the pattern: connect scroll-event to on_button_press(x, y, 4 or 5), button-press-event / motion-notify-event / button-release-event to the matching on_* methods, and key-press-event to on_key(Gdk.keyval_name(...)). The same gestures work in C and Rust — same wheel, same drag, same keys.
Programmatic zoom
chart.zoom_at(0.8, 0.5) # zoom in 20%, centred (frac_x 0..1)
chart.zoom_at(1.25, 0.5) # zoom out
chart.pan_by(10) # pan right 10 bars
chart.reset_view() # full series again
print(chart.get_view_first(), chart.get_view_count())
Which widgets
All 23 charting kinds: AccumulationDistribution, AreaChart, BaselineChart, CandlestickChart, CorrelationView, HeikinAshi, HollowCandles, IndexedComparison, LineChart, MoneyFlowChart, MultiSymbolChart, OBVChart, OHLCBarChart, OverlayChart, RatioChart, RelativePerformance, Renko, SectorComparison, SpreadChart, VWAP, VolumeBars, VolumeCandles, VolumeProfile. (Plus StockPriceLabel, which loads data but has no view window, so no zoom/pan.)
The 13 other drawing / annotation tools (Trendline, FibRetracement, FibExtension, Pitchfork, ParallelChannel, Rectangle, Ellipse, Arrow, Brush, HorizontalLine, VerticalLine, MeasureTool, TextAnnotation) take coordinates, not a data series, so they have no Massive loader and no zoom/pan — they draw over a chart that does.
Tests
tests/test_stock_massive.py (18 tests) covers all three schemas, OCC parsing, quote/trade aggregation, ticker filtering, .csv.gz, and zoom/pan on a chart loaded from Massive data. Fixtures live in tests/data/massive/ (spy-day-aggs.csv, spy260918c-minute-aggs.csv, spy-quotes.csv, spy-trades.csv, each also as .csv.gz).