data/app/schema.py

37 lines
1003 B
Python
Raw Normal View History

2024-12-30 22:42:53 +00:00
from sqlalchemy import Column, Integer, Float, DateTime
from sqlalchemy.ext.declarative import declared_attr
from .database import Base
class CoinBase(Base):
__abstract__ = True # Klasa abstrakcyjna (nie tworzy tabeli)
id = Column(Integer, primary_key=True, index=True)
timestamp = Column(DateTime, index=True)
open = Column(Float)
high = Column(Float)
low = Column(Float)
close = Column(Float)
volume = Column(Float)
close_time = Column(DateTime)
quote_asset_volume = Column(Float)
number_of_trades = Column(Integer)
taker_buy_base_asset_volume = Column(Float)
taker_buy_quote_asset_volume = Column(Float)
ignore = Column(Float)
@declared_attr
def __tablename__(cls):
"""Automatycznie ustawia nazwę tabeli na podstawie nazwy klasy."""
return cls.__name__.lower()
# Poszczególne pary dziedziczące po CoinBase
class ADAUSDT(CoinBase):
pass
class SHIBUSDT(CoinBase):
pass
class BTCUSDT(CoinBase):
pass