Python library to fetch electricity market data from OMIE (Operador del Mercado Ibérico de Energía).
pip install omie-market-dataOr install from source:
git clone https://github.com/yourusername/omie-data.git
cd omie-data
pip install -e .from datetime import datetime
from omie_data import get_omie_data, get_omie_url
# Fetch data for a specific date
date = datetime(2025, 10, 1)
df = get_omie_data(date)
if df is not None:
print(df.head())
# Columns: start_period, end_period, plus one column per metric (prices, power, etc.)
else:
print("Data not available for this date")
# Get the URL used for a date (useful for debugging)
url = get_omie_url(date)
print(url)The returned DataFrame is period-based (one row per 15-minute interval):
| Column | Description |
|---|---|
start_period |
Start of the 15-min interval (datetime) |
end_period |
End of the 15-min interval (datetime) |
| metric columns | One column per metric (e.g. marginal price Spanish/Portuguese, total power buy/sell, etc.) |
- 96 rows per day (24 hours × 4 quarters).
- Intervals follow OMIE quarters: H1Q1 = 00:00–00:15, H1Q2 = 00:15–00:30, …, H24Q4 = 23:45–24:00.
-
get_omie_data(date: datetime) -> Optional[pd.DataFrame]
Fetches data for the given date. ReturnsNoneif the file is not available (e.g. 404). -
get_omie_url(date: datetime) -> str
Returns the OMIE URL used for that date (for debugging or manual download).
See test_omie_data.ipynb for a full Jupyter notebook with:
- Fetching and exploring the period-based DataFrame
- Plotting prices and other metrics
- Converting to hourly averages
- Exporting to CSV/Excel
- Python 3.7+
- pandas
See PUBLISHING.md for step-by-step instructions to publish the package to PyPI so anyone can run pip install omie-market-data.
MIT License