Added analyst signals indicators
Ticket #273: Added Analyst's signals for my portfolio decisions
Type: Feature / Decision Support / Business Analysis
Affected Component: code_source_simule/portfolio_metrics.py, code_source_simule/flask_app.py, templates/dashboard.html, templates/titre_detail.html, tests/test_portfolio_metrics.py, tests/test_dashboard.py, tests/test_titre_detail.py, specs/016-dashboard-analyst-signals/
1. Context
This report is a direct continuation of my previous work on adding portfolio management-rule indicators. Even though the indicators here are new, they serve exactly the same vision: making my dashboard a true decision-support tool, and preparing a clear information foundation for the future advisory AI (see my Project Vision).
The logic remains the same as in the previous ticket: translate my investment strategy into simple, readable, and reliable signals displayed in the right place. This time, I focused on what analysts anticipate for each stock.
2. Objective
Make it immediately visible which stocks deviate strongly from analyst expectations, and provide on each stock detail page a visual reading of where the current price sits within the target range.
Concretely, the goal was to:
- highlight stocks clearly above and clearly below the average analyst target;
- isolate counter-intuitive cases, meaning stocks that are rising sharply despite negative market sentiment;
- add an "Analyst Targets" gauge on the stock detail page, where I review a position in depth.
3. What was delivered
- Three new indicators on the dashboard:
- Near analyst high target: stocks whose price reaches or exceeds the highest analyst price target, sorted from the most extreme to the least extreme case.
- Near analyst low target: stocks whose price is at or below the lowest analyst price target, with the same priority sort.
- Contrary to expectations: stocks with negative or very negative sentiment that still show a gain increase above 50%.
- One "Analyst Targets" gauge on each stock detail page: low target on the left, high target on the right, and the current price positioned between them for immediate reading.
- A readable and disciplined presentation:
- a clear display format for each line (price compared with actual target bounds);
- an explicit empty state when no stock matches, to avoid ambiguity;
- an "unavailable" or "invalid data" state on the gauge when targets cannot be used.
- A deliberately autonomous computation scope: signals rely strictly on current CSV data, with target ranges defined directly by the individual analyst-published lowest and highest price targets.
4. Business impact
- More focused decisions: I can spot at a glance the stocks that deviate most from market expectations, in either direction.
- Right-level reading: the gauge on the stock detail page places valuation information exactly where I analyze a position.
- Watch signal: the "Contrary to expectations" indicator draws attention to divergences that deserve investigation.
- Vision continuity: these indicators extend the previous ticket and enrich the context that the future advisory AI will be able to use.
5. Validation and status
- Full test suite green:
43 passed. - Key behaviors covered by dedicated tests: direct price-to-target comparison for high target (price >= highest_price_target), direct price-to-target comparison for low target (price <= lowest_price_target), strict rule of negative sentiment combined with gain increase above 50%, sorting from most extreme to least extreme, and gauge states (ready, unavailable, invalid range).
- Coverage recalculated after the changes:
portfolio_metrics.pyat 96%,flask_app.pyat 94`. - Related traceability ticket: #273.
6. Lessons learned
- A signal has value only if it remains reliable when data is incomplete; explicitly handling empty and invalid cases protects trust in the tool.
- Token usage summary: for this addition of analyst-signal indicators, the recorded gross token cost was $9.43 for 935.8 Copilot AI credits. Compared with a recent similar implementation, #272, this implementation therefore cost about 42.95% less, which is a remarkable improvement.
PS: Token usage update: after commit, following a technical issue (resolved by Github Copilot) during deployment, the token cost increased to $11.18 for 1099.1 credits used, which is 32.12% less than the previous implementation. This defect therefore cost me less than $2 to resolve, but saved me at least an hour of investigation and troubleshooting. Considering that an independent AI consultant's hourly rate can exceed $100, this additional token cost is ultimately a significant benefit.