Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database: Adding wiki sp500 table #170

Merged
merged 1 commit into from
Jul 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions stocklake/stores/db/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,13 @@ class NasdaqApiData(Base):

class PolygonFinancialsData(Base):
__tablename__ = "polygonapi_financials_data"
# financials data
# - balance sheet

id = Column(Integer, primary_key=True)
created_at = Column(DateTime(timezone=True), default=func.now())
updated_at = Column(
DateTime(timezone=True), default=func.now(), onupdate=func.now()
)

equity_attributable_to_noncontrolling_interest = Column(Float, nullable=True)
liabilities = Column(Float, nullable=True)
equity_attributable_to_parent = Column(Float, nullable=True)
Expand Down Expand Up @@ -97,3 +101,19 @@ class PolygonFinancialsData(Base):
fiscal_year = Column(Integer, nullable=True)
source_filing_url = Column(String, nullable=True)
source_filing_file_url = Column(String, nullable=True)


class WikiSP500Data(Base):
__tablename__ = "wiki_sp500"

id = Column(Integer, primary_key=True)
created_at = Column(DateTime(timezone=True), default=func.now())
updated_at = Column(
DateTime(timezone=True), default=func.now(), onupdate=func.now()
)

symbol = Column(String)
company = Column(String)
sector = Column(String, nullable=True)
industry = Column(String, nullable=True)
headquarters = Column(String, nullable=True)
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
"""adding wikisp500 table

Revision ID: c8deb56c7d92
Revises: 84fb754ea7f6
Create Date: 2024-07-07 10:15:09.525907

"""

from typing import Sequence, Union

import sqlalchemy as sa
from alembic import op

# revision identifiers, used by Alembic.
revision: str = "c8deb56c7d92"
down_revision: Union[str, None] = "84fb754ea7f6"
branch_labels: Union[str, Sequence[str], None] = None
depends_on: Union[str, Sequence[str], None] = None


def upgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.create_table(
"wiki_sp500",
sa.Column("id", sa.Integer(), nullable=False),
sa.Column("created_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=True),
sa.Column("symbol", sa.String(), nullable=True),
sa.Column("company", sa.String(), nullable=True),
sa.Column("sector", sa.String(), nullable=True),
sa.Column("industry", sa.String(), nullable=True),
sa.Column("headquarters", sa.String(), nullable=True),
sa.PrimaryKeyConstraint("id"),
)
op.add_column(
"polygonapi_financials_data",
sa.Column("created_at", sa.DateTime(timezone=True), nullable=True),
)
op.add_column(
"polygonapi_financials_data",
sa.Column("updated_at", sa.DateTime(timezone=True), nullable=True),
)
# ### end Alembic commands ###


def downgrade() -> None:
# ### commands auto generated by Alembic - please adjust! ###
op.drop_column("polygonapi_financials_data", "updated_at")
op.drop_column("polygonapi_financials_data", "created_at")
op.drop_table("wiki_sp500")
# ### end Alembic commands ###
Loading