aboutsummaryrefslogtreecommitdiff
path: root/server/services/process_bids.py
diff options
context:
space:
mode:
Diffstat (limited to 'server/services/process_bids.py')
-rw-r--r--server/services/process_bids.py13
1 files changed, 11 insertions, 2 deletions
diff --git a/server/services/process_bids.py b/server/services/process_bids.py
index 4ecbef9..a600128 100644
--- a/server/services/process_bids.py
+++ b/server/services/process_bids.py
@@ -18,18 +18,25 @@ MARKET_TIMEZONES = {
"MISO": ZoneInfo("America/Chicago"),
}
+
def get_day_ahead_price(market: str, target_time: datetime) -> float:
"""Fetch the Day Ahead clearing price for the hour of target_time."""
iso = MARKET_ISOS[market]
- df = iso.get_lmp(date=target_time.date(), market="DAY_AHEAD_HOURLY", locations="ALL")
+ df = iso.get_lmp(
+ date=target_time.date(), market="DAY_AHEAD_HOURLY", locations="ALL"
+ )
df = df.groupby("Interval Start")["LMP"].mean().reset_index()
for _, row in df.iterrows():
- if abs(row["Interval Start"] - target_time.replace(minute=0, second=0, microsecond=0)) < timedelta(minutes=30):
+ if abs(
+ row["Interval Start"]
+ - target_time.replace(minute=0, second=0, microsecond=0)
+ ) < timedelta(minutes=30):
return row["LMP"]
raise ValueError(f"No day ahead price found for {target_time} in {market}")
+
def get_real_time_prices(market: str, target_time: datetime) -> list[float]:
"""Fetch the Real Time 5-min prices during the hour of target_time."""
iso = MARKET_ISOS[market]
@@ -47,6 +54,7 @@ def get_real_time_prices(market: str, target_time: datetime) -> list[float]:
return prices
+
def process_bids():
db: Session = SessionLocal()
@@ -121,5 +129,6 @@ def process_bids():
db.close()
+
if __name__ == "__main__":
process_bids()