Skip to content

Added my management rules indicators

Ticket #272: Adding indicators for my portfolio management rules
Type: Feature / Decision Support / Business Analysis
Affected Component: code_source_simule/flask_app.py, code_source_simule/portfolio_metrics.py, templates/dashboard.html, templates/index.html, tests/test_portfolio_metrics.py, tests/test_dashboard.py, specs/015-refonte-indicateurs-portefeuille/


1. Context

This report starts with a short context reminder. I built this application with a dual objective: to have a personal decision-support tool for buying and selling stock holdings, and to build an AI experimentation lab applied to software engineering (see my Project Vision).

My buy and sell decisions follow a specific investment strategy documented here. Until now, the dashboard did not surface the information needed to properly execute this strategy, which slowed down my analyses and did not adequately prepare the ground for the upcoming advisory AI.

2. Objective

Make the two most important decision signals in my strategy visible in the right place, and establish a contextual information base that the upcoming AI can use.

Concretely, the goal was to:

  • synthesize decision-relevant information into two clear indicators: titles where gains should be secured, and titles to reinforce or liquidate;
  • add the "distance to next milestone" reading at the individual stock level, where the decision is actually made;
  • ensure these signals become explicit reference points so the AI can advise me in line with my strategy.

3. What was delivered

  • Two new indicators on the dashboard:
    • Gains to secure: all titles with gain change at or above +80%, sorted from highest to lowest.
    • Titles to reinforce or liquidate: all titles with gain change at or below -20%, sorted from lowest to highest.
  • A clear and disciplined presentation:
    • one line per stock, even when a stock appears on multiple data rows;
    • percentages displayed with one decimal and the % symbol;
    • no top-10 cap: all eligible titles are visible.
  • One gauge per stock on the "Portfolio stocks" page, scaled from -100 to +100 with a white neutral zone in the center, a red loss-side gradient and a green gain-side gradient, and a single global % symbol.
  • A deliberately autonomous computation scope: indicators rely strictly on current file data, without transaction history or external market sources, using the existing Price and Purchase Price values directly.

4. Business impact

  • Faster decisions: titles to secure and titles to arbitrate are visible at a glance, without mental calculation.
  • Fuel for upcoming AI: these indicators formalize what matters most to me and become explicit context for the future advisory AI.
  • Right-level reading: the per-stock gauge places information exactly where decisions are made.
  • Information reliability: an autonomous calculation scope, without external dependencies, reduces incoherence risk at decision time.

5. Validation and status

  • Full test suite green: 185 passed.
  • Key behaviors covered by dedicated tests: +80% and -20% thresholds, severity-based sorting, per-stock uniqueness, percentage formatting, and gauge normalization within [-100, +100].
  • Coverage recalculated after the changes: portfolio_metrics.py at 98%, flask_app.py at 94%.
  • Related traceability issue: #272.

6. Lessons learned

  1. Translating a personal strategy into simple indicators is already, by itself, direct preparation for AI-assisted advisory.
  2. A well-bounded, autonomous calculation scope is more robust and easier to explain to a future AI than a stack of mixed sources.
  3. Token-cost visibility is now part of my delivery discipline: for this full session scope (feature implementation, associated documentation, and Chapter 4), the recorded gross cost reached $16.47, with a total AI credit of $1,640.19. Making this cost explicit helps me evaluate value-for-money and guide future optimization choices.