mirror of
https://github.com/Zproger/Aurum.git
synced 2026-10-13 02:56:39 +07:00
feat: crypto portfolio analytics (history chart, allocation, P&L, cost basis)
Adds the analytics half of the CoinMarketCap reference: a value-over-time chart (GET /crypto/history, forward-filled from AssetValuation like Net Worth's own series but scoped to crypto assets), an allocation breakdown by coin, and stat tiles for all-time profit, total invested (cost basis), and best/worst performer. Deliberately no "24h" range — history is only as dense as the sync cadence (button or once/day), so a 24h chart would be one or two points, not a smooth intraday line. Cost basis / all-time profit / best-worst performer aren't separate endpoints: they're trivial to derive client-side from fields already in GET /crypto/holdings, so no redundant backend logic. Allocation card follows the dataviz skill's categorical rule: top 7 coins by value get a fixed-order color from the app's already-validated 8-slot ramp, an 8th+ folds into "Other" rather than generating a new hue. 82/82 backend tests passing (3 new for /crypto/history). Verified live against the real CoinGecko API — and caught a real holding the user had already added directly through the UI between messages, which the smoke test correctly left untouched while cleaning up only its own test data. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01855PiW5Wd8n4aRW4n9kByY
This commit is contained in:
@@ -93,3 +93,21 @@ class CryptoSearchResult(BaseModel):
|
||||
symbol: str
|
||||
name: str
|
||||
thumb_url: str | None
|
||||
|
||||
|
||||
class CryptoHistoryPoint(BaseModel):
|
||||
date: date_
|
||||
value: Decimal
|
||||
|
||||
|
||||
class CryptoHistoryResponse(BaseModel):
|
||||
"""Total crypto holdings value over time — same "cumulative point
|
||||
events, forward-filled" shape as NetWorthSummary's own series, but
|
||||
scoped to crypto-class assets only (see services/crypto_service.py's
|
||||
get_crypto_history). Powers the History chart on the Crypto tab."""
|
||||
|
||||
range: str
|
||||
current: Decimal
|
||||
change_amount: Decimal
|
||||
change_percent: float | None
|
||||
series: list[CryptoHistoryPoint]
|
||||
|
||||
Reference in New Issue
Block a user