aboutsummaryrefslogtreecommitdiff
path: root/server/models/bid.py
blob: 121020d2f2d8f65fc9cfd7aad30c3d7a824cdf11 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
    market = Column(String, nullable=False)  # Market name: ISONE / MISO / NYISO for now

    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")