You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.0 KiB

"""
实时数据模型
"""
from datetime import datetime
from sqlalchemy import Column, Integer, String, BigInteger, Numeric, DateTime
from app.db.base import Base
class RealtimeSnapshot(Base):
"""实时快照数据表"""
__tablename__ = "realtime_snapshot"
id = Column(BigInteger, primary_key=True, index=True, autoincrement=True)
code = Column(String(20), nullable=False, index=True)
security_type = Column(String(20), nullable=False) # stock, future, index, etf, kzz, option
trade_time = Column(DateTime, nullable=False, index=True)
# 价格数据
pre_close = Column(Numeric(12, 4))
last = Column(Numeric(12, 4))
open = Column(Numeric(12, 4))
high = Column(Numeric(12, 4))
low = Column(Numeric(12, 4))
close = Column(Numeric(12, 4))
volume = Column(BigInteger)
amount = Column(Numeric(18, 4))
# 盘口数据 - 卖盘
ask_price1 = Column(Numeric(12, 4))
ask_price2 = Column(Numeric(12, 4))
ask_price3 = Column(Numeric(12, 4))
ask_price4 = Column(Numeric(12, 4))
ask_price5 = Column(Numeric(12, 4))
ask_volume1 = Column(Integer)
ask_volume2 = Column(Integer)
ask_volume3 = Column(Integer)
ask_volume4 = Column(Integer)
ask_volume5 = Column(Integer)
# 盘口数据 - 买盘
bid_price1 = Column(Numeric(12, 4))
bid_price2 = Column(Numeric(12, 4))
bid_price3 = Column(Numeric(12, 4))
bid_price4 = Column(Numeric(12, 4))
bid_price5 = Column(Numeric(12, 4))
bid_volume1 = Column(Integer)
bid_volume2 = Column(Integer)
bid_volume3 = Column(Integer)
bid_volume4 = Column(Integer)
bid_volume5 = Column(Integer)
# 期货特有字段
settle = Column(Numeric(12, 4))
open_interest = Column(BigInteger)
pre_settle = Column(Numeric(12, 4))
average_price = Column(Numeric(12, 4))
trading_phase_code = Column(String(10))
created_at = Column(DateTime(timezone=True), default=datetime.utcnow)
expires_at = Column(DateTime(timezone=True), nullable=False, index=True)