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
43
alembic/versions/b2c3d4e5f6a7_add_fundamentals_table.py
Normal file
43
alembic/versions/b2c3d4e5f6a7_add_fundamentals_table.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
"""add fundamentals table
|
||||
|
||||
Revision ID: b2c3d4e5f6a7
|
||||
Revises: a1b2c3d4e5f6
|
||||
Create Date: 2026-02-23 10:00:00.000000
|
||||
|
||||
"""
|
||||
from typing import Sequence, Union
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
from sqlalchemy.dialects import postgresql
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "b2c3d4e5f6a7"
|
||||
down_revision: Union[str, Sequence[str], None] = "a1b2c3d4e5f6"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Create the fundamentals table for caching fundamental data."""
|
||||
|
||||
op.create_table(
|
||||
"fundamentals",
|
||||
sa.Column("id", postgresql.UUID(as_uuid=True), primary_key=True),
|
||||
sa.Column("ticker", sa.String(20), unique=True, nullable=False, index=True),
|
||||
sa.Column("eps_ttm", sa.Float, nullable=True),
|
||||
sa.Column("pe_ratio", sa.Float, nullable=True),
|
||||
sa.Column("peg_ratio", sa.Float, nullable=True),
|
||||
sa.Column("revenue_growth_yoy", sa.Float, nullable=True),
|
||||
sa.Column("profit_margin", sa.Float, nullable=True),
|
||||
sa.Column("debt_to_equity", sa.Float, nullable=True),
|
||||
sa.Column("market_cap", sa.Float, nullable=True),
|
||||
sa.Column("fetched_at", sa.DateTime(timezone=True), nullable=False),
|
||||
sa.Column("created_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
|
||||
sa.Column("updated_at", sa.DateTime(timezone=True), server_default=sa.func.now()),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Drop the fundamentals table."""
|
||||
op.drop_table("fundamentals")
|
||||
Loading…
Add table
Add a link
Reference in a new issue