- Update ExchangeConfigResponse schema with direction-specific fields - Remove premium_percentage from PriceResponse (now in config) - Update price endpoint to load pricing config from database - Update frontend to use direction-specific min/max and calculate premium - Update tests to seed pricing config - Add logic to clamp amount when direction changes
50 lines
1.2 KiB
Python
50 lines
1.2 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_buy: int
|
|
eur_max_buy: int
|
|
eur_min_sell: int
|
|
eur_max_sell: int
|
|
eur_increment: int
|
|
premium_buy: int
|
|
premium_sell: int
|
|
small_trade_threshold_eur: int
|
|
small_trade_extra_premium: 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 values.
|
|
Premium calculation: base premium for direction + extra premium if
|
|
trade <= threshold.
|
|
"""
|
|
|
|
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
|