Metadata-Version: 2.4
Name: iberian-day-ahead-market-simulator
Version: 0.1.0
Summary: Iberian day-ahead electricity market clearing simulator
Author-email: Eloy Insunza <einsunza@comillas.edu>
License-Expression: MIT
Project-URL: Homepage, https://github.com/EloyID/iberian-day-ahead-market-simulator
Project-URL: Repository, https://github.com/EloyID/iberian-day-ahead-market-simulator
Project-URL: Bug Tracker, https://github.com/EloyID/iberian-day-ahead-market-simulator/issues
Keywords: electricity-market,MIBEL,OMIE,Euphemia,day-ahead market,market-clearing,energy,optimization
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy
Requires-Dist: pandas
Requires-Dist: pandera
Requires-Dist: pyomo
Requires-Dist: matplotlib
Provides-Extra: solver
Requires-Dist: gurobipy; extra == "solver"
Requires-Dist: highspy; extra == "solver"
Provides-Extra: dev
Requires-Dist: pytest>=7.0; extra == "dev"
Requires-Dist: pytest-cov; extra == "dev"
Requires-Dist: wandb; extra == "dev"
Requires-Dist: pandas-stubs; extra == "dev"
Dynamic: license-file

# iberian-day-ahead-market-simulator

A Python simulator for the **MIBEL** (Mercado Ibérico de Electricidad) Iberian day-ahead electricity market clearing process.

The package replicates the OMIE/MIBEL market-clearing algorithm, including:
- Simple and complex bid orders
- Paradoxical order inclusion and removal
- Spain–Portugal interconnection capacity constraints
- France exchange integration

## Requirements

### Solver support

The simulator uses Pyomo `SolverFactory`, so you can choose the solver with `solver_factory_type`.

- Recommended/default: **Gurobi** (`solver_factory_type="gurobi"`)
- Also possible: **HiGHS** (`solver_factory_type="highs"`), or any solver plugin available in your Pyomo environment

> Note: model performance and feasibility behavior can vary by solver. Gurobi is the most tested option in this project.

If you use Gurobi, install `gurobipy` and configure your licence:
```bash
pip install gurobipy
```

If you use HiGHS, install `highspy`:
```bash
pip install highspy
```

If you use other solvers, install the corresponding solver binaries in your system and use the appropriate `solver_factory_type`.

## Installation

```bash
pip install iberian-day-ahead-market-simulator
```

Or install from source:
```bash
git clone https://github.com/EloyID/iberian-day-ahead-market-simulator.git
cd iberian-day-ahead-market-simulator
pip install -e .
```

## Quick Start

```python
from iberian_day_ahead_market_simulator.clearing_process import run_iberian_day_ahead_market_simulator
from iberian_day_ahead_market_simulator.plot_helpers import (
    plot_clearing_prices,
    plot_spain_portugal_transmissions,
)

# These files are available in OMIE
det_date = "path/to/det_file.1"
cab_date = "path/to/cab_file.1"
capacidad_inter_date = "path/to/capacidad_inter_file.1"

# Data available in ENTSO-E Transparency Platform
# The df must have date_sesion, int_periodo and 
# float_price_fr columns
price_france_date = "path/to/price_france_file.parquet"

results = run_iberian_day_ahead_market_simulator(
    det_date=det_date,
    cab_date=cab_date,
    capacidad_inter_date=capacidad_inter_date,
    price_france_date=price_france_date,
    n_jobs=10, # Number of parallel processes for scenario analysis
    solver_factory_type="gurobi", # "gurobi" or "highs"
)

# Now you can analyze the results, for example:
plot_clearing_prices(results["clearing_prices"])
plot_spain_portugal_transmissions(
    results["spain_portugal_transmissions"]
)
```

## Usage examples

Some examples can be found in the [examples/](https://github.com/EloyID/iberian-day-ahead-market-simulator/tree/main/examples) directory:

- [application_examples.ipynb](https://github.com/EloyID/iberian-day-ahead-market-simulator/tree/main/examples/application_examples.ipynb): Example of how to run the simulator and analyze results
- [paper_replication.ipynb](https://github.com/EloyID/iberian-day-ahead-market-simulator/tree/main/examples/paper_replication.ipynb): Replication of the results from the paper "iberian-day-ahead-market-simulator: A Python Package to Simulate the MIBEL Day-Ahead Market Clearing"
- [download_omie_data.ipynb](https://github.com/EloyID/iberian-day-ahead-market-simulator/tree/main/examples/download_omie_data.ipynb): Example of how to download OMIE data files

## Data sources

OMIE files used by this project are:

- [Cabecera de las ofertas](https://www.omie.es/en/file-access-list?parents=/Day-ahead%20Market/4.%20Bids&dir=Header%20of%20bids%20for%20Day-ahead%20Market&realdir=cab) (Header of bids for Day-ahead Market, CAB files). Contains one entry per bidding unit (e.g., unit identifier, buy/sell flag, and fixed-cost parameter)
- [Detalle de las ofertas](https://www.omie.es/en/file-access-list?parents=/Day-ahead%20Market/4.%20Bids&dir=Day-ahead%20market%20bids%20detail&realdir=det) (Day-ahead market bid details, DET files). Contains the detailed bid curves and non-convex information, with one entry per bid element (period, price, quantity, block identifier, exclusive-group identifier, and additional SCO parameters when applicable).
- [Capacidad y ocupación de las interconexiones tras la casación del mercado diario](https://www.omie.es/en/file-access-list?parents=/Day-ahead%20Market/6.%20Capacities&dir=%20Capacity%20and%20occupation%20of%20the%20interconnectors%20after%20Day-ahead%20matching%20process&realdir=capacidad_inter_pbc) (Capacity and occupation of the interconnectors after Day-ahead matching process, capacidad_inter files). Contains the information about the interconnection flows and available capacities.

French day-ahead prices can be obtained from the [ENTSO-E Transparency Platform](https://transparency.entsoe.eu/).


## Project Structure

```
src/iberian_day_ahead_market_simulator/
├── clearing_process.py        # Main iterative clearing loop
├── make_model.py              # Pyomo MILP model builder
├── run_model.py               # Pyomo solver wrapper (configurable solver)
├── data_preprocessor.py       # Input data processing
├── parse_omie_files.py        # OMIE flat-file parsers
├── paradoxal_orders_tools.py  # Paradoxical order utilities
├── residual_demand_curve.py   # RDC computation & interpolation
├── schemas/                   # Pandera data-validation schemas
└── data/                      # Bundled reference data
```

## Data Documentation

For a complete data dictionary of inputs, transformed datasets, outputs, enums, and validation rules, see [docs/data_book.md](https://github.com/EloyID/iberian-day-ahead-market-simulator/tree/main/docs/data_book.md).

## Licence

[MIT](LICENSE)
