Metadata-Version: 2.4
Name: omie-market-data
Version: 0.1.0
Summary: Python library to fetch electricity market data from OMIE
Home-page: https://github.com/valterjpcaldeira/omie-data
Author: Valter Caldeira
Author-email: valterjpcaldeira.developer@gmail.com
License: MIT
Project-URL: Source, https://github.com/valterjpcaldeira/omie-data
Project-URL: Issues, https://github.com/valterjpcaldeira/omie-data/issues
Keywords: omie,electricity,market,spain,iberian,energy
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: pandas>=1.3.0
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: keywords
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# omie-data

Python library to fetch electricity market data from OMIE (Operador del Mercado Ibérico de Energía).

## Installation

```bash
pip install omie-market-data
```

Or install from source:

```bash
git clone https://github.com/yourusername/omie-data.git
cd omie-data
pip install -e .
```

## Usage

```python
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)
```

## Data format

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.

## API

- **`get_omie_data(date: datetime) -> Optional[pd.DataFrame]`**  
  Fetches data for the given date. Returns `None` if 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).

## Examples

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  

## Requirements

- Python 3.7+
- pandas

## For maintainers: publishing to PyPI

See [PUBLISHING.md](PUBLISHING.md) for step-by-step instructions to publish the package to PyPI so anyone can run `pip install omie-market-data`.

## License

MIT License
