Price Spike Detection and Analysis

Find and analyze extreme price events for risk assessment

Find and analyze extreme price events for risk assessment.

import pandas as pd

# Find all price spikes above $100/MWh in January 2026
spikes = client.get_dataset(
    "ercot_lmp_by_settlement_point",
    start="2026-01-01",
    end="2026-02-01",
    filter_column="lmp",
    filter_value=100,
    filter_operator=">",
    columns=["interval_start_utc", "location", "lmp"],
)

# Sort by price descending (Python client returns ascending by default)
spikes = spikes.sort_values("lmp", ascending=False)

print(f"=== ERCOT Price Spikes > $100/MWh (Jan 2026) ===")
print(f"Total spike events: {len(spikes)}")

# Group by date to see spike frequency
spikes['date'] = pd.to_datetime(spikes['interval_start_utc']).dt.date
spike_days = spikes.groupby('date').agg({
    'lmp': ['count', 'max'],
    'location': lambda x: x.nunique()
}).round(2)
spike_days.columns = ['num_intervals', 'max_price', 'num_locations']
spike_days = spike_days.sort_values('max_price', ascending=False)

print(f"\nDays with most severe spikes:")
print(spike_days.head(10))

# Which locations had the most spikes?
location_spikes = spikes.groupby('location').size().sort_values(ascending=False)
print(f"\nLocations with most frequent spikes:")
print(location_spikes.head(10))

Last updated

Was this helpful?