aboutsummaryrefslogtreecommitdiff
path: root/server/services/process_bids.py
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2025-04-27 22:41:14 -0600
committerNavan Chauhan <navanchauhan@gmail.com>2025-04-27 22:41:14 -0600
commitf32142947b853076889801913d47b8c2c0f4f456 (patch)
tree20981c0c2b79c2ba9cc58eece69591cfbe5b21ff /server/services/process_bids.py
parentba700c31fceb4554ccbb3181f0e5747fcf5c3259 (diff)
format using black
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()