|
| 1 | +from pydantic import BaseModel, Field |
| 2 | +from typing import Optional, List |
| 3 | + |
| 4 | + |
| 5 | +class FinancialData(BaseModel): |
| 6 | + revenue: float |
| 7 | + net_income: float |
| 8 | + free_cash_flow: float |
| 9 | + dividends_paid: float |
| 10 | + date: str |
| 11 | + |
| 12 | + |
| 13 | +class GrowthRates(BaseModel): |
| 14 | + revenue: dict[str, float] |
| 15 | + net_income: dict[str, float] |
| 16 | + free_cash_flow: dict[str, float] |
| 17 | + dividends_paid: dict[str, float] |
| 18 | + |
| 19 | + |
| 20 | +class StockValuation(BaseModel): |
| 21 | + symbol: str |
| 22 | + current_price: float |
| 23 | + pe_ratio: float |
| 24 | + dividend_yield: Optional[float] = None |
| 25 | + growth_rates: GrowthRates |
| 26 | + is_quality_dividend_growth_stock: bool |
| 27 | + is_undervalued: bool |
| 28 | + |
| 29 | + |
| 30 | +class Stock(BaseModel): |
| 31 | + symbol: str |
| 32 | + company_name: str |
| 33 | + sector: Optional[str] = None |
| 34 | + industry: Optional[str] = None |
| 35 | + financial_data: List[FinancialData] |
| 36 | + valuation: Optional[StockValuation] = None |
| 37 | + |
| 38 | + class Config: |
| 39 | + schema_extra = { |
| 40 | + "example": { |
| 41 | + "symbol": "AAPL", |
| 42 | + "company_name": "Apple Inc.", |
| 43 | + "sector": "Technology", |
| 44 | + "industry": "Consumer Electronics", |
| 45 | + "financial_data": [ |
| 46 | + { |
| 47 | + "revenue": 365817000000, |
| 48 | + "net_income": 94680000000, |
| 49 | + "free_cash_flow": 90215000000, |
| 50 | + "dividends_paid": 14467000000, |
| 51 | + "date": "2022-09-30", |
| 52 | + } |
| 53 | + ], |
| 54 | + } |
| 55 | + } |
0 commit comments