提交
This commit is contained in:
@@ -362,6 +362,44 @@ class ScreenerQuery(Base):
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=_utcnow, index=True)
|
||||
|
||||
|
||||
class SignalPlan(Base):
|
||||
"""买卖点实验室方案(一股一方案:手动标注/条件扫描的买卖点集合与指标条件)。
|
||||
|
||||
conditions_json 存 IndicatorCondition[].model_dump_json()(结构化条件可直接
|
||||
推送到 /api/backtest/event 做全市场事件回测);点集在 signal_points 子表。
|
||||
"""
|
||||
__tablename__ = "signal_plans"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
user_id: Mapped[int] = mapped_column(BigInteger, ForeignKey("users.id", ondelete="CASCADE"), index=True)
|
||||
ts_code: Mapped[str] = mapped_column(String(12), index=True)
|
||||
name: Mapped[str] = mapped_column(String(64))
|
||||
note: Mapped[str | None] = mapped_column(Text)
|
||||
conditions_json: Mapped[str | None] = mapped_column(Text)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=_utcnow)
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, default=_utcnow, onupdate=_utcnow)
|
||||
|
||||
__table_args__ = (
|
||||
Index("ix_signal_plans_user_code", "user_id", "ts_code"),
|
||||
)
|
||||
|
||||
|
||||
class SignalPoint(Base):
|
||||
"""方案内的买卖点(manual=K线图手动点击标注;scan=条件扫描命中后勾选保留)。"""
|
||||
__tablename__ = "signal_points"
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
|
||||
plan_id: Mapped[int] = mapped_column(Integer, ForeignKey("signal_plans.id", ondelete="CASCADE"), index=True)
|
||||
kind: Mapped[str] = mapped_column(String(4)) # buy | sell
|
||||
trade_date: Mapped[date] = mapped_column(Date)
|
||||
source: Mapped[str] = mapped_column(String(6)) # manual | scan
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=_utcnow)
|
||||
|
||||
__table_args__ = (
|
||||
UniqueConstraint("plan_id", "kind", "trade_date", name="uq_signal_point_plan_kind_date"),
|
||||
)
|
||||
|
||||
|
||||
class TradeCalendar(Base):
|
||||
"""交易日历缓存(trade_cal 拉取一次宽范围后本地维护,低积分 token 限频 1 次/小时)。"""
|
||||
__tablename__ = "trade_calendar"
|
||||
|
||||
Reference in New Issue
Block a user