arbret/backend/schemas/price.py
2025-12-26 20:04:46 +01:00

44 lines
1 KiB
Python

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: int
eur_max: int
eur_increment: int
premium_percentage: int
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_percentage.
"""
market_price: float # Raw price from exchange
premium_percentage: int
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