1 Commits
Author SHA1 Message Date
cnmcdee 11493b5f22 Stock charts: CSV data loading (load_csv/set_series/clear/populate)
Every chart widget rendered only the baked-in 250-bar demo series:
no set_series existed in Python despite the docstring naming it, so
there was no way to plot real data at all. Now StockWidget holds up
to three series slots (primary + two extra for the multi-symbol
charts) via set_series (the C API), get_series, add_point, clear /
populate, item_count, and load_csv; all 37 draw paths read the
widget series through _bars(widget) instead of module DEMO_SERIES,
so derived series (Heikin-Ashi, Renko, VWAP, OBV, ...) rebuild from
the loaded data and the drawing tools inherit it as background.

load_csv reads date,open,high,low,close,volume with the stdlib csv
module: header optional (matched by name, any order, extra columns
ignored), dates YYYY-MM-DD / YYYY/MM/DD / DD-MM-YYYY / ISO datetime
/ epoch seconds (validated, not stored -- the x-axis is bar index),
ValueError naming the row on bad data. A cleared series draws a
no-data placeholder; a one-bar series draws (Price: flat change).

Tests: tests/test_stock_csv.py, 27 tests (parsing, API, headless
renders of all 24 chart kinds incl. CSV-vs-template pixel diff).
Fixture tests/data/ohlcv_30.csv (30 weekday bars). Full suite 311
tests pass; visreg 24/24 stock charts pixel-identical to template
goldens. Docs: docs/stock-charts-data.md. Screenshots:
tools/stock_csv_shots.py (Xvfb, RMSE 9-35% vs template goldens).
2026-12-02 09:55:14 +00:00