-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprice.py
More file actions
23 lines (15 loc) · 695 Bytes
/
Copy pathprice.py
File metadata and controls
23 lines (15 loc) · 695 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from __future__ import annotations
from pydantic import BaseModel, Field, field_validator
class PriceResponse(BaseModel):
asset: str = Field(description="Asset symbol")
price: float = Field(gt=0, description="Current price")
timestamp: int | None = Field(default=None, description="Timestamp")
@field_validator("asset")
@classmethod
def uppercase_asset(cls, v: str) -> str:
return v.upper()
class PriceListResponse(BaseModel):
prices: list[PriceResponse] = Field(description="List of prices")
count: int = Field(description="Number of prices")
class AssetsResponse(BaseModel):
assets: list[str] = Field(description="List of available assets")