feat: add Analysis tab with position intelligence engine
Phase 1 of the position-tracker → analysis port:
Backend:
- src/ai/types.ts — shared types (AnalysisInput, ClassifiedPosition, AnalysisResult, etc.)
- src/ai/greeks.ts — added calcTheoreticalPrice() export for scenario analysis
- src/ai/classifier.ts — pure-function position classifier (DEAD_WEIGHT/WORKING/UNDER_PRESSURE/HEDGE/DANGER_SHORT) with module-level hysteresis Map
- src/ai/portfolio-greeks.ts — aggregates per-unit Greeks × quantity into portfolio totals
- src/ai/risk-assessor.ts — naked short detection, concentration, side imbalance, Greeks breach checks
- src/ai/scenario.ts — P&L grid at ±100..±1000 spot moves per underlying
- src/ai/analyze.ts — orchestrator: maps Position[] → AnalysisInput[], reads spot from market_cache, stores JSON in analysis_snapshots
- src/db/client.ts — analysis_snapshots table + index
- src/tracker/poll.ts — runAnalysis() called after every pollTick + forcePoll
- src/api/server.ts — GET /api/analysis endpoint
Frontend (public/index.html):
- Multi-page nav with Dashboard | Analysis tabs (showView())
- Analysis view: summary cards (delta/theta/vega/risk level), action list (urgent positions sorted by urgency score), classification table with urgency bars, risk assessment details, scenario P&L grid per underlying
- loadAnalysis() + renderAnalysis() wired to tab switch
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>