aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2025-04-27 20:14:56 -0600
committerNavan Chauhan <navanchauhan@gmail.com>2025-04-27 20:14:56 -0600
commit5507ee2434a37261fbdc2defb7844631dba0923b (patch)
tree26f18b19797841f3a30971e3aacfce3c6efb1c29
parent2d3ba49b4ee3930b855a8d9b8f9df92057251712 (diff)
add bid model
-rw-r--r--server/models/bid.py25
1 files changed, 17 insertions, 8 deletions
diff --git a/server/models/bid.py b/server/models/bid.py
index 1b2eb0d..c0b788e 100644
--- a/server/models/bid.py
+++ b/server/models/bid.py
@@ -1,8 +1,17 @@
-from pydantic import BaseModel
-
-class Bid(BaseModel):
- id: int
- timestamp: str
- quantity: float
- price: float
- type: str # Could be a boolean value to represent whether the bid is a buy or sell order
+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")