新增仓位管理功能,支持按轮跟踪锁仓状态
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
+34
-1
@@ -86,4 +86,37 @@ class User(Base):
|
||||
dk = hashlib.pbkdf2_hmac("sha256", password.encode(), salt, 100000)
|
||||
return dk.hex() == dk_hex
|
||||
except (ValueError, AttributeError):
|
||||
return False
|
||||
return False
|
||||
|
||||
|
||||
class Round(Base):
|
||||
__tablename__ = "rounds"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
contract_code: Mapped[str] = mapped_column(String(10), index=True)
|
||||
daily_hands: Mapped[int] = mapped_column(Integer, default=1)
|
||||
status: Mapped[str] = mapped_column(String(20), default="active")
|
||||
started_at: Mapped[date] = mapped_column(Date)
|
||||
|
||||
positions: Mapped[list["Position"]] = relationship(
|
||||
back_populates="round", cascade="all, delete-orphan"
|
||||
)
|
||||
|
||||
@property
|
||||
def total_locks(self) -> int:
|
||||
return sum(p.locked_count for p in self.positions)
|
||||
|
||||
|
||||
class Position(Base):
|
||||
__tablename__ = "positions"
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
round_id: Mapped[int] = mapped_column(ForeignKey("rounds.id"), index=True)
|
||||
open_price: Mapped[int] = mapped_column(Integer)
|
||||
amp_threshold: Mapped[int] = mapped_column(Integer)
|
||||
lock_price: Mapped[int] = mapped_column(Integer)
|
||||
hands: Mapped[int] = mapped_column(Integer, default=1)
|
||||
locked_count: Mapped[int] = mapped_column(Integer, default=0)
|
||||
opened_at: Mapped[date] = mapped_column(Date)
|
||||
|
||||
round: Mapped["Round"] = relationship(back_populates="positions")
|
||||
Reference in New Issue
Block a user