P
Prism
← Back to app

How Prism Works

An AI-powered portfolio analysis engine built for Canadian self-directed investors. Deterministic math first, AI narration second.

Design Principles

🧮

Deterministic First

The math engine computes every metric before AI touches anything. Portfolio value, allocation drift, concentration risk, tax-loss candidates — all calculated with pure arithmetic.

🧠

AI Explains, Never Invents

GPT-4o-mini receives pre-calculated numbers and writes a narrative. It cannot invent statistics. If no API key exists, a deterministic fallback generates the explanation.

🎯

One Clear Recommendation

Instead of overwhelming you with options, the engine scores 7 possible actions and surfaces the single highest-value move. This prevents decision paralysis.

🍁

Canadian-Specific

TFSA and RRSP contribution room scoring, Canadian marginal tax rates for tax-loss harvesting, and Canadian ETF return assumptions are baked into every calculation.

The Engine Pipeline

Three pure functions process your portfolio data in sequence.

1

computeMetrics()

Calculates total value, cost basis, unrealized G/L, asset-class breakdown, allocation drift, weighted annual return, concentration risk, positions in loss, savings rate, and emergency fund coverage.

2

scoreActions()

Evaluates 7 possible actions (Deploy Cash, TFSA Optimize, RRSP Optimize, Rebalance, Tax-Loss Harvest, Reduce Concentration, Add to Position) and scores each 0–100 based on expected financial impact and time-sensitivity.

3

projectScenarios()

Projects portfolio growth over your goal timeline under Base, Recession, and Bull market conditions. Each scenario outputs a goal probability and year-by-year portfolio values.

Form InputcomputeMetrics()scoreActions()projectScenarios()AI NarrativeDashboard

Action Scoring

Seven possible actions are evaluated every analysis.

ActionTriggerUrgency
Deploy CashExcess cash above target allocationHigh if >10% excess
TFSA OptimizeUnused TFSA room > $1KHigh if >$20K room
RRSP OptimizeUnused RRSP room > $5KMedium
RebalanceAllocation drift > 5%High if drift >15%
Tax-Loss HarvestPosition down > 8%High if savings >$2K
Reduce ConcentrationHolding > 25% of portfolioHigh if >40%
Add to PositionGain >15%, weight <15%, above-avg returnLow

The AI Layer

GPT-4o-mini receives the pre-calculated outputs from the engine and generates:

  • A punchy headline
  • 2–3 paragraph explanation
  • 3 key numbers from the action details
  • A confidence score (constrained to ± a small range of the engine score)

Strict rules: The AI cannot invent numbers, must stay within confidence bounds, and always includes a disclaimer.

If no OpenAI API key is configured, a deterministic mock generates the narrative using the same data.

Tech Stack

Next.js 14

App Router, server-side API routes

TypeScript

End-to-end type safety

React 18

Client-side interactivity

Tailwind CSS

Utility-first styling

GPT-4o-mini

AI narrative generation

Vercel

Edge deployment, zero config

What's Next

Future development roadmap

PDF / CSV export

Client-side PDF and CSV report generation

Custom scenarios

User-defined return and shock parameters

Holdings breakdown

Sortable per-holding gain/loss and weight table

What-If Explorer

Real-time parameter tweaking with delta comparison

Monte Carlo analysis

500-run fan chart with percentile bands

Rebalancing worksheet

Concrete buy/sell trade list for target allocation

Contribution gap calculator

Monthly shortfall/surplus to reach goal

Real-time pricing

Market data API integration (Alpha Vantage, etc.)

Portfolio persistence

Database + auth (Postgres / Supabase)

Brokerage account import

Open Banking API integration

Backtesting

Historical return data integration