arbret/backend/schemas/price.py

51 lines
1.2 KiB
Python
Raw Normal View History

2025-12-26 20:04:46 +01:00
from datetime import datetime
from pydantic import BaseModel
class PriceHistoryResponse(BaseModel):
"""Response model for a price history record."""
id: int
source: str
pair: str
price: float
timestamp: datetime
created_at: datetime
class ExchangeConfigResponse(BaseModel):
"""Exchange configuration for the frontend."""
eur_min_buy: int
eur_max_buy: int
eur_min_sell: int
eur_max_sell: int
2025-12-26 20:04:46 +01:00
eur_increment: int
premium_buy: int
premium_sell: int
small_trade_threshold_eur: int
small_trade_extra_premium: int
2025-12-26 20:04:46 +01:00
class PriceResponse(BaseModel):
"""Current BTC/EUR price for trading.
Note: The actual agreed price depends on trade direction (buy/sell)
and is calculated by the frontend using market_price and premium values.
Premium calculation: base premium for direction + extra premium if
trade <= threshold.
2025-12-26 20:04:46 +01:00
"""
market_price: float # Raw price from exchange
timestamp: datetime
is_stale: bool
class ExchangePriceResponse(BaseModel):
"""Combined price and configuration response."""
price: PriceResponse | None # None if price fetch failed
config: ExchangeConfigResponse
error: str | None = None