"""退出预测模型。""" import uuid from datetime import datetime, timezone from sqlalchemy import DateTime, Float, ForeignKey, String, Text from sqlalchemy.orm import Mapped, mapped_column from app.core.database import Base from app.core.types import JSONBType class ExitPrediction(Base): """退出时机预测。""" __tablename__ = "exit_predictions" id: Mapped[str] = mapped_column(String(36), primary_key=True, default=lambda: str(uuid.uuid4())) company_id: Mapped[str] = mapped_column(String(36), ForeignKey("companies.id"), nullable=False, index=True) exit_path: Mapped[str | None] = mapped_column(String(50), nullable=True, comment="ipo/acquisition/secondary/merger") timing_window: Mapped[dict | None] = mapped_column(JSONBType, nullable=True, comment="时机窗口 — 起止时间") expected_return: Mapped[float | None] = mapped_column(Float, nullable=True, comment="期望收益率") hold_return: Mapped[float | None] = mapped_column(Float, nullable=True, comment="继续持有预期收益率") confidence: Mapped[float | None] = mapped_column(Float, nullable=True, comment="置信度") signals: Mapped[dict | None] = mapped_column(JSONBType, nullable=True, comment="退出信号") recommendation: Mapped[str | None] = mapped_column(Text, nullable=True, comment="退出建议") created_at: Mapped[datetime] = mapped_column( DateTime(timezone=True), default=lambda: datetime.now(timezone.utc) )