feat: сеть (network) для крипто-холдингов

Свободное текстовое поле на холдинге — какой сети принадлежит конкретная
монета (Ethereum, Tron и т.д.), с редактированием прямо в таблице и
разбивкой % по сетям на отдельной вкладке. Помогает увидеть, что часть
стейблкоинов лежит на рискованных сетях и стоит перевести на безопасные.
This commit is contained in:
ZProger
2026-09-09 00:52:11 +03:00
parent 526bfe104d
commit c3047c6d6a
16 changed files with 421 additions and 13 deletions

View File

@@ -76,6 +76,18 @@ class CryptoHoldingCreate(BaseModel):
# services/crypto_service.py) — but user-overridable at add time, since
# not every coin carries the same risk (a large-cap vs. a memecoin).
risk_level: RiskLevel = RiskLevel.HIGH
# Free-form chain name (e.g. "Ethereum", "Tron") — optional, not
# validated against a fixed list (see CryptoHolding.network).
network: str | None = Field(default=None, max_length=50)
class CryptoHoldingUpdate(BaseModel):
"""Holding-only metadata that isn't part of the buy/sell transaction
log — currently just `network`. Quantity/price/date changes go through
the /transactions routes instead (see add_transaction/update_transaction),
same split as risk_level living on the Asset via PATCH /assets/{id}."""
network: str | None = Field(default=None, max_length=50)
class CryptoHoldingRead(BaseModel):
@@ -90,6 +102,8 @@ class CryptoHoldingRead(BaseModel):
# same endpoint every other Asset already uses, no crypto-specific
# update route needed.
risk_level: RiskLevel
# Lives on CryptoHolding itself — editable via PATCH /crypto/holdings/{asset_id}.
network: str | None
# Quantity and avg_buy_price are derived from the transaction log (see
# services/crypto_service.py's _compute_position) — never stored.