aboutsummaryrefslogtreecommitdiff
path: root/server/models/bid.py
blob: c0b788e43597dd4d881f45a0f3c5d187a400b1ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
from sqlalchemy import Column, Integer, Float, String, DateTime, ForeignKey
from sqlalchemy.orm import relationship
from db import Base

class Bid(Base):
    __tablename__ = "bids"

    id = Column(Integer, primary_key=True, index=True)
    timestamp = Column(DateTime, index=True, nullable=False)  # Bid target time
    quantity = Column(Float, nullable=False)  # MWh
    price = Column(Float, nullable=False)     # $/MWh

    status = Column(String, default="Submitted")  # Submitted / Success / Fail
    pnl = Column(Float, nullable=True)  # Profit/loss value, nullable initially

    user_id = Column(Integer, ForeignKey("users.id"))
    user = relationship("User", back_populates="bids")