Trading Hub Price Analysis

Compare prices across trading hubs to identify arbitrage opportunities and congestion patterns

Compare prices across trading hubs to identify arbitrage opportunities and congestion patterns.

import pandas as pd

# Fetch one week of hourly average prices for major ERCOT hubs
df = client.get_dataset(
    "ercot_lmp_by_settlement_point",
    start="2026-01-01",
    end="2026-01-08",
    filter_column="location",
    filter_value="HB_HOUSTON,HB_NORTH,HB_WEST,HB_SOUTH",
    filter_operator="in",
    columns=["interval_start_utc", "location", "lmp"],
    resample="1 hour",
    resample_function="mean"
)

# Pivot to get locations as columns
df_pivot = df.pivot(index='interval_start_utc', columns='location', values='lmp')

# Calculate price spreads
df_pivot['Houston_North'] = df_pivot['HB_HOUSTON'] - df_pivot['HB_NORTH']
df_pivot['Houston_West'] = df_pivot['HB_HOUSTON'] - df_pivot['HB_WEST']

# Summary statistics
print("=== Hub Price Spread Analysis ===")
print(f"\nHouston-North Spread:")
print(f"  Mean: ${df_pivot['Houston_North'].mean():.2f}/MWh")
print(f"  Max: ${df_pivot['Houston_North'].max():.2f}/MWh")
print(f"  Min: ${df_pivot['Houston_North'].min():.2f}/MWh")
print(f"  Std Dev: ${df_pivot['Houston_North'].std():.2f}/MWh")

print(f"\nHouston-West Spread:")
print(f"  Mean: ${df_pivot['Houston_West'].mean():.2f}/MWh")
print(f"  Max: ${df_pivot['Houston_West'].max():.2f}/MWh")

# Find hours with largest spreads (potential congestion)
print(f"\n=== Top 5 Hours with Largest Houston-North Spread ===")
top_spreads = df_pivot.nlargest(5, 'Houston_North')[['HB_HOUSTON', 'HB_NORTH', 'Houston_North']]
print(top_spreads)

Last updated

Was this helpful?