Skip to content

Enriched demo history and adaptive chart density

Ticket #352: Enriched demo history and adaptive chart density for stock detail pages
Type: Feature / User Experience / Data Visualization
Affected Component: code_source_simule/flask_app.py, code_source_simule/portfolio_metrics.py, tests/test_demo.py, tests/test_portfolio_metrics.py, tests/test_titre_detail.py, docs/tests/demo.md, docs/fr/tests/demo.md, docs/tests/stock_detail.md, docs/fr/tests/stock_detail.md, docs/llm-wiki/01_architecture/key-decisions.md, specs/021-graph-historical-density/


1. Context

Stock detail pages in the public demo (e.g. /demo/titre/JPM) only displayed 2 data points on the chart, tied to the Snapshot History — not enough to show a credible trend to visitors of the commercial showcase.

At the same time, in the secure application, a stock's history goes back to August 1, 2025 with near-daily entries. The chart was plotting one point per raw entry, which becomes unreadable once a stock accumulates more than a year of history.

2. Objective

  • Demo: enrich each stock's Snapshot History to draw a credible price trend, while staying within the existing privacy cap (10 entries max per stock).
  • Secure application: make the chart adapt to how old the data is — the older an entry, the more spaced out the plotted points — without ever touching the "Snapshot History" table, which must keep displaying 100% of raw entries.

3. What was delivered

  • Enriched demo history: every demo stock now shows 10 entries (the 2 existing real entries + 8 new weekly entries), generated through deterministic linear interpolation toward the price already used on June 28, 2026 — no random values, so results stay perfectly reproducible in tests.
  • Adaptive chart density in the secure application, via a new pure function bucket_history_for_chart (code_source_simule/portfolio_metrics.py):
    • entries from a fully completed year → one point per quarter;
    • entries from the current year but a completed quarter → one point per month;
    • entries from the current quarter but a completed week → one point per week;
    • entries from the current week → one point per available day.
  • When a grouped period contains several entries, only the most recent one is kept as the representative point; a period with no entries never produces an invented point.
  • The "Snapshot History" table below the chart stays unchanged in both contexts (demo and secure): it always shows every raw entry, regardless of the chart's density rule.
  • Full Spec Kit process followed end to end: specification, clarification (2 questions resolved, including a scope adjustment from 20 down to 10 demo entries to respect the existing cap), technical plan, tasks, consistency analysis, then test-first implementation.
  • Documentation updated: test report pages (FR/EN) and a new LLM Wiki entry (key-decisions.md).

4. Business Impact

  • More convincing showcase: the public demo now shows a credible price trend for every stock, instead of two isolated points.
  • Long-term readability preserved: in the secure application, a stock tracked for over a year stays readable on its chart, without losing any raw data (the table remains the complete source of truth).

5. Validation and Status

  • Full test suite green: 283/283 tests passing.
  • Application code coverage: 79.42% (code_source_simule/*), up from the previous measurement.
  • Overall quality score recalculated: 90/100.
  • New dedicated test cases: tc-demo15, tc-demo16, tc-demo17 (demo), updated tc-hold03 plus tc-hold03b (secure application), tc-bucket01 through tc-bucket08 (density function, including automatic reclassification at quarter and week boundaries).
  • Regenerated artifacts: coverage.xml, docs/reports/report.xml, docs/reports/report.jsonl, docs/reports/coverage.xml, docs/reports/quality_score.json.
  • Associated traceability ticket: #352.

6. Token Consumption Summary

This complete implementation (specification, clarification, plan, tasks, analysis, test-first implementation, and documentation) consumed 1,623.81 Copilot AI credits, for a cost of $16.24. This cost remains very marginal compared to the cost of this delivery—specification, code, tests, and bilingual documentation—by the smallest IT team (PO, dev, and QA).