Correction of analyst target data gauge and addition of the 52-Week Range gauge
Ticket #338: Correction of analyst target data gauge and addition of the 52-Week Range gauge
Type: Fix / Business Logic / Test Lockdown
Affected Component: code_source_simule/flask_app.py, templates/titre_detail.html, tests/test_titre_detail.py, docs/tests/stock_detail.md, docs/llm-wiki/01_architecture/key-decisions.md
1. Context and Symptoms
Some data on the stock detail page was problematic: the analyst target gauge reused the 52-week low/high values when the active CSV row did not contain any analyst target data. In plain terms, the screen replaced a missing value with another set of data. The result was misleading for users.
This problem appeared for tickers such as AFLYY and UA, where the CSV contains blank or N/A target values. Instead of an explicit unavailable state, the interface displayed 52-week values from the wrong section.
2. Objective
Keep these two data families separate and clear:
- analyst targets must read only the target columns from the active CSV;
- the 52-Week Range must use its own low/high thresholds over 52 weeks;
- a missing analyst target must remain unavailable and never be replaced by 52-week data;
- the current price remains shared between the two gauges to keep the reading simple and consistent.
3. Implemented Solution
3.1 — Source-driven analyst lookup
The detail route was updated to resolve analyst targets directly from the active CSV path and to ignore an_haut / an_bas for this gauge. The helper returns None if the CSV row is empty or N/A, which respects the product rule for missing data.
3.2 — Dedicated 52-week range gauge
The 52-Week Range block now has its own gauge, in the same visual style as the analyst gauge but with the labels:
- 52-Week Low
- 52-Week High
The comparison continues to use the same current price as the analyst module so the user keeps one consistent reference point.
3.3 — Regression lock with tests
A dedicated test suite was added to lock this business contract:
- ready-state analyst data from the CSV;
- unavailable state when CSV values are blank or
N/A; - clear message when the range is invalid (
low > high); - regression preventing 52-week thresholds from replacing a missing analyst target;
- 52-week gauge using the current price and its own low/high thresholds.
4. Validation
The full project suite was executed after the fix:
- full suite: 268 tests passed;
- warnings: 3 (existing pandas/pyarrow deprecation plus parser warnings on a known corrupted CSV fixture);
- application code coverage (
code_source_simule/*): 79%.
This validation confirms that the business fix is coherent and that the regression suite remains green.
5. Outcome
The user experience is now aligned with the data contract:
- missing analyst targets remain missing;
- 52-week thresholds remain in their own module;
- both gauges remain readable and comparable with the same current price.
6. Token Consumption Summary
During this session of correction and improvement of the analysis gauges, which lasted more than 2 hours, 175.27 Copilot AI credits were consumed, for a gross cost of $1.75; which represents only 0.7% of the total cost of a consultant on such a task.