from sqlalchemy import Column, Integer, String, Float from sqlalchemy.orm import declarative_base def get_stock_daily_freq(table_name): class StockDailyFreq(declarative_base()): __tablename__ = table_name id = Column(Integer, primary_key=True) trade_date = Column(String) # 交易日期 time = Column(String) # 时间 open = Column(Float) # 开盘价 close = Column(Float) # 收盘价 high = Column(Float) # 最高价 low = Column(Float) # 最低价 vol = Column(Float) # 成交量(注意单位:手) amount = Column(Float) # 成交额 def __init__(self, **kwargs): self.__dict__.update(kwargs) def to_dict(self): return {"trade_date": self.trade_date, "time": self.time, "close": self.close} return StockDailyFreq