Skip to content

Commit

Permalink
Merge pull request #170 from tsugumi-sys/feature/adding-wiki-sp500-table
Browse files Browse the repository at this point in the history
Database: Adding wiki sp500 table
  • Loading branch information
tsugumi-sys authored Jul 7, 2024
2 parents 66f1fe6 + e7fdc6b commit 47282d0
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 2 deletions.
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 ###

0 comments on commit 47282d0

Please sign in to comment.