29 lines
896 B
Python
29 lines
896 B
Python
|
|
"""Price data model (시계열 가격)."""
|
||
|
|
from sqlalchemy import Column, String, Numeric, BigInteger, DateTime, PrimaryKeyConstraint
|
||
|
|
|
||
|
|
try:
|
||
|
|
from app.database import Base
|
||
|
|
except ModuleNotFoundError:
|
||
|
|
from backend.app.database import Base
|
||
|
|
|
||
|
|
|
||
|
|
class PriceData(Base):
|
||
|
|
"""Price data model (kor_price → price_data, TimescaleDB hypertable)."""
|
||
|
|
|
||
|
|
__tablename__ = "price_data"
|
||
|
|
|
||
|
|
ticker = Column(String(20), nullable=False, index=True)
|
||
|
|
timestamp = Column(DateTime, nullable=False, index=True)
|
||
|
|
open = Column(Numeric(15, 2))
|
||
|
|
high = Column(Numeric(15, 2))
|
||
|
|
low = Column(Numeric(15, 2))
|
||
|
|
close = Column(Numeric(15, 2), nullable=False)
|
||
|
|
volume = Column(BigInteger)
|
||
|
|
|
||
|
|
__table_args__ = (
|
||
|
|
PrimaryKeyConstraint('ticker', 'timestamp'),
|
||
|
|
)
|
||
|
|
|
||
|
|
def __repr__(self):
|
||
|
|
return f"<PriceData(ticker={self.ticker}, timestamp={self.timestamp}, close={self.close})>"
|