Initial commit: stock market platform
This commit is contained in:
91
backend/app/schemas/stock.py
Normal file
91
backend/app/schemas/stock.py
Normal file
@@ -0,0 +1,91 @@
|
||||
from pydantic import BaseModel
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class StockQuote(BaseModel):
|
||||
symbol: str
|
||||
name: str
|
||||
price: float
|
||||
change: float
|
||||
change_pct: float
|
||||
open: float
|
||||
high: float
|
||||
low: float
|
||||
prev_close: float
|
||||
volume: float
|
||||
amount: float
|
||||
market_cap: Optional[float] = None
|
||||
pe_ratio: Optional[float] = None
|
||||
sector: Optional[str] = None
|
||||
|
||||
|
||||
class StockSearchResult(BaseModel):
|
||||
symbol: str
|
||||
name: str
|
||||
market: str
|
||||
|
||||
|
||||
class KLineBar(BaseModel):
|
||||
date: str
|
||||
open: float
|
||||
high: float
|
||||
low: float
|
||||
close: float
|
||||
volume: float
|
||||
amount: Optional[float] = None
|
||||
change_pct: Optional[float] = None
|
||||
|
||||
|
||||
class IntraDayBar(BaseModel):
|
||||
time: str
|
||||
price: float
|
||||
volume: float
|
||||
amount: Optional[float] = None
|
||||
avg_price: Optional[float] = None
|
||||
|
||||
|
||||
class MarketOverview(BaseModel):
|
||||
index_code: str
|
||||
index_name: str
|
||||
current: float
|
||||
change: float
|
||||
change_pct: float
|
||||
|
||||
|
||||
class SectorData(BaseModel):
|
||||
sector: str
|
||||
change_pct: float
|
||||
stocks: list[StockQuote] = []
|
||||
|
||||
|
||||
class WatchlistItem(BaseModel):
|
||||
id: int
|
||||
symbol: str
|
||||
name: str
|
||||
sort_order: int
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
|
||||
|
||||
class WatchlistAddRequest(BaseModel):
|
||||
symbol: str
|
||||
name: str
|
||||
|
||||
|
||||
class AlertCreate(BaseModel):
|
||||
symbol: str
|
||||
name: str
|
||||
alert_type: str
|
||||
threshold: float
|
||||
|
||||
|
||||
class AlertOut(BaseModel):
|
||||
id: int
|
||||
symbol: str
|
||||
name: str
|
||||
alert_type: str
|
||||
threshold: float
|
||||
is_active: bool
|
||||
triggered: bool
|
||||
|
||||
model_config = {"from_attributes": True}
|
||||
Reference in New Issue
Block a user