feat: add fundamentals DB model and cached provider
This commit is contained in:
parent
6c909d12c3
commit
0530f496ca
5 changed files with 217 additions and 0 deletions
|
|
@ -15,6 +15,7 @@ from shared.models.news import Article, ArticleSentiment
|
|||
from shared.models.learning import LearningAdjustment, TradeOutcome
|
||||
from shared.models.auth import User, UserCredential
|
||||
from shared.models.timeseries import MarketData, PortfolioSnapshot, StrategyMetric
|
||||
from shared.models.fundamentals import Fundamentals
|
||||
|
||||
__all__ = [
|
||||
"Base",
|
||||
|
|
@ -41,4 +42,6 @@ __all__ = [
|
|||
"MarketData",
|
||||
"PortfolioSnapshot",
|
||||
"StrategyMetric",
|
||||
# Fundamentals
|
||||
"Fundamentals",
|
||||
]
|
||||
|
|
|
|||
27
shared/models/fundamentals.py
Normal file
27
shared/models/fundamentals.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
"""Fundamentals database model for caching fundamental data."""
|
||||
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import Float, String, DateTime
|
||||
from sqlalchemy.dialects.postgresql import UUID
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from shared.models.base import Base, TimestampMixin
|
||||
|
||||
|
||||
class Fundamentals(TimestampMixin, Base):
|
||||
__tablename__ = "fundamentals"
|
||||
|
||||
id: Mapped[uuid.UUID] = mapped_column(
|
||||
UUID(as_uuid=True), primary_key=True, default=uuid.uuid4
|
||||
)
|
||||
ticker: Mapped[str] = mapped_column(String(20), unique=True, nullable=False, index=True)
|
||||
eps_ttm: Mapped[float | None] = mapped_column(Float, nullable=True)
|
||||
pe_ratio: Mapped[float | None] = mapped_column(Float, nullable=True)
|
||||
peg_ratio: Mapped[float | None] = mapped_column(Float, nullable=True)
|
||||
revenue_growth_yoy: Mapped[float | None] = mapped_column(Float, nullable=True)
|
||||
profit_margin: Mapped[float | None] = mapped_column(Float, nullable=True)
|
||||
debt_to_equity: Mapped[float | None] = mapped_column(Float, nullable=True)
|
||||
market_cap: Mapped[float | None] = mapped_column(Float, nullable=True)
|
||||
fetched_at: Mapped[datetime] = mapped_column(DateTime(timezone=True), nullable=False)
|
||||
Loading…
Add table
Add a link
Reference in a new issue