mirror of
https://github.com/Zproger/Aurum.git
synced 2026-10-13 02:56:39 +07:00
Replaces the plain quantity field with a CryptoTransaction log (same
"record events, derive the total" shape as Goal/GoalContribution): quantity
and average buy price are now computed via weighted-average cost — a buy
blends into the running average, a sell reduces quantity but leaves the
average cost of what's still held unchanged.
Switches price fetching from /simple/price to CoinGecko's /coins/markets
(still one batched call for every coin), which also returns 1h/24h/7d %
change in the same request. Old PATCH /crypto/holdings/{id} is replaced by
POST .../transactions (buy/sell, rejects selling more than held), GET
.../transactions (history), and DELETE /crypto/transactions/{id}.
Frontend: CryptoHoldingsTable replaces the simple list with a real table
(Name/Price/1h%/24h%/7d%/Holdings/Avg Buy Price/Profit-Loss/Actions),
horizontally scrollable on mobile rather than dropping columns. New
CryptoTransactionModal (buy/sell) and CryptoTransactionHistoryModal.
Backend: 79/79 tests passing (13 in test_crypto.py, up from 9). Also
verified live end-to-end against the real CoinGecko API with the user's own
key — create, buy, sell, oversell rejection, history, manual refresh, all
against real BTC/ETH prices in EUR — test data cleaned up after.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01855PiW5Wd8n4aRW4n9kByY
69 lines
1.9 KiB
Python
69 lines
1.9 KiB
Python
"""Shared enum types used by the ORM models and API schemas."""
|
|
import enum
|
|
|
|
|
|
class AccountType(str, enum.Enum):
|
|
CHECKING = "checking"
|
|
SAVINGS = "savings"
|
|
CREDIT_CARD = "credit_card"
|
|
CASH = "cash"
|
|
INVESTMENT = "investment"
|
|
OTHER = "other"
|
|
|
|
|
|
class CategoryKind(str, enum.Enum):
|
|
INCOME = "income"
|
|
EXPENSE = "expense"
|
|
|
|
|
|
class TransactionType(str, enum.Enum):
|
|
INCOME = "income"
|
|
EXPENSE = "expense"
|
|
TRANSFER = "transfer"
|
|
|
|
|
|
class AssetClass(str, enum.Enum):
|
|
"""Net-worth categories tracked manually (Cash is derived from Account
|
|
balances instead — see services/net_worth_service.py)."""
|
|
|
|
INVESTMENTS = "investments"
|
|
CRYPTO = "crypto"
|
|
REAL_ESTATE = "real_estate"
|
|
VEHICLES = "vehicles"
|
|
PRECIOUS_METALS = "precious_metals"
|
|
OTHER = "other"
|
|
|
|
|
|
class CapitalRole(str, enum.Enum):
|
|
"""How an asset behaves month to month — set by the user, not inferred:
|
|
the same laptop can be a productive work tool (NEUTRAL) or dead weight
|
|
(DRAIN) depending on how it's actually used, which isn't derivable from
|
|
any stored data."""
|
|
|
|
INCOME = "income" # e.g. a rented-out apartment
|
|
NEUTRAL = "neutral" # e.g. a laptop used for work, furniture
|
|
DRAIN = "drain" # e.g. a personal car, an idle depreciating gadget
|
|
|
|
|
|
class RecurringFrequency(str, enum.Enum):
|
|
WEEKLY = "weekly"
|
|
MONTHLY = "monthly"
|
|
YEARLY = "yearly"
|
|
|
|
|
|
class CryptoTransactionType(str, enum.Enum):
|
|
BUY = "buy"
|
|
SELL = "sell"
|
|
|
|
|
|
class RiskLevel(str, enum.Enum):
|
|
"""Risk of loss, not asset class — set by the user, not inferred: real
|
|
estate can be a paid-off primary home (LOW) or a leveraged rental
|
|
(HIGH), the same asset_class doesn't determine which. Cash is always
|
|
LOW (see services/net_worth_service.py) — it's the zero-risk anchor an
|
|
80/20-style allocation rule is measured against."""
|
|
|
|
LOW = "low"
|
|
MEDIUM = "medium"
|
|
HIGH = "high"
|