Intraday re-trading (DE-LU): day-ahead + continuous intraday¶
This module adds a second trading stage to the German day-ahead workflow: after the day-ahead auction a battery
keeps re-trading its position in the continuous intraday market until shortly before delivery. Results on real data
are in reports/intraday.md, regenerated by scripts/research/intraday_backtest.py.
- Data layer:
euroflex_bess_lab.public_data.intraday(download, normalisation, loader). - Strategy and backtest:
euroflex_bess_lab.markets.intraday(LPs, forecasts, walk-forward backtest, audit). - Research script:
scripts/research/intraday_backtest.py(report, figures, ledgers).
Intraday price data¶
Continuous-intraday order books and trades of EPEX SPOT are licensed market data, so this repository uses a public index instead: the ID AEP (Index Ausgleichsenergiepreis) of the four German TSOs, published per quarter-hour on netztransparenz.de.
| Item | Value |
|---|---|
| Definition | Volume-weighted average price of the most recent continuous exchange intraday trades (German market area) of each quarter-hour product, covering 500 MW; topped up with the hourly product when the quarter-hour product traded less; undefined if both together traded less than 500 MW. The TSOs use it to couple the German imbalance price (reBAP) to the intraday market. |
| Coverage used | 2024-01-01 onwards (quarter-hourly, UTC grid; 92 / 100 quarter-hours on DST days) |
| Access | The page's public "CSV Download" (no account, no token). The registered netztransparenz Web API is not used. |
| Terms | The netztransparenz.de imprint ("Nutzung der Internetseiten") protects the site content by copyright; reproduction requires the German TSOs' prior written consent unless permitted by law. |
| Consequence | Not redistributed. Raw CSVs and the normalized table live in data/raw/intraday/ (gitignored); data/public/intraday/id_aep_DE-LU.meta.json is a sidecar stub with redistributed: false. Reports publish only results derived from the data (simulated P&L, aggregate statistics) and ledgers are daily so the index cannot be reconstructed from them. |
Build and load the local table:
python -m euroflex_bess_lab.public_data.intraday fetch --start 2024-01-01 # one request per month, polite pause
from euroflex_bess_lab.public_data.intraday import load_intraday_index
frame = load_intraday_index("2026-03-01", "2026-04-01") # timestamp_utc, resolution_minutes, id_aep_eur_mwh
How the download works: the browser button sends a GET to /DesktopModules/LotesCharts/CsvDownloadHandler.ashx
with a base64-encoded JSON request (local delivery dates LocalFrom / LocalTo exclusive, result time zone, and
the chart settings embedded in the page). netztransparenz.py sends the same request with ResultTimeZone=utc,
validates the CSV header, parses German number formats, and keeps a provenance record (.source.json) per
monthly chunk. Incomplete trailing days are dropped; missing quarter-hours are kept as NaN on a complete grid.
Other public quarter-hourly intraday sources checked (October 2026):
| Source | Finding |
|---|---|
Energy-Charts API (api.energy-charts.info) |
Day-ahead prices only (CC BY 4.0 for DE-LU and other SMARD zones); no intraday endpoint. |
| SMARD (Bundesnetzagentur) | Day-ahead wholesale prices only. |
| ENTSO-E Transparency Platform | Requires a registered account / security token; not used. |
| EPEX SPOT indices (ID1, ID3, IDFull) and trade data | Licensed market data (EPEX market-data agreement); can be plugged in, see below. |
Market model and timing¶
| Step | Assumption (default) |
|---|---|
| Day-ahead decision | D-1 12:00 Europe/Berlin (SDAC gate closure); quantity schedule from the persistence forecast (previous local day by clock time, the semantics of PersistenceForecastProvider). |
| Day-ahead products | Hourly until delivery day 2025-09-30 (one position per hour), 15-minute from 2025-10-01. |
| Day-ahead results | Known from 13:00 on D-1 and used by every intraday decision for day D. |
| Intraday gate closure | The quantity of quarter-hour k is frozen 30 minutes before delivery (cross-zonal target of the EU market-design reform). German market-area trading on EPEX runs until 5 minutes before delivery, so 30 minutes is conservative for the information set. Sensitivity: 5 and 60 minutes. |
| Execution | At the ID AEP of the product: a VWAP-execution proxy for trading in the final phase of the product, plus slippage (default 1 EUR/MWh) and an exchange + clearing fee (default 0.15 EUR/MWh; day-ahead 0.10 EUR/MWh). EPEX prices access through member packages, so these per-MWh costs are assumptions; the report shows sensitivities. If the index is undefined, the trade settles at the day-ahead price. |
| Information | Trade-feed model (default): the closing price of product j is usable from the end of its delivery (an exchange member sees the trades; the published index appears on netztransparenz.de the next day). With the 30-minute gate closure product k sees products up to k-3. Published-index model: only whole days up to D-2. |
| Battery | 1 MW / 2 MWh, SOC 5-95 %, 50 % at the start and end of each delivery day, efficiency 0.95 / 0.95, 8 EUR/MWh discharged. |
Only the German market area (DE-LU) is covered: the ID AEP is a German index.
Strategies¶
All strategies share the persistence day-ahead position x of the day; intraday trades z = zs - zb change the
physical schedule to x + z.
| Name | Decision rule |
|---|---|
da_only |
Follow the day-ahead schedule. |
da_id_reopt_da |
One re-optimisation after the day-ahead results; forecast of every intraday price = its day-ahead price. |
da_id_reopt_profile |
Same, forecast = day-ahead + trailing intraday spread profile (days up to D-2, published index only). |
da_id_rolling (main) |
Before each gate closure re-optimise the rest of the day with forecast = day-ahead + profile + decaying live residual, commit product k. |
oracle_id, oracle_da, oracle_da_id |
Perfect foresight of the intraday index, of day-ahead prices, or of both (upper bounds, not tradable). |
LPs (HiGHS via highspy, warm-started): variables per quarter-hour are discharge d, charge c, SOC, intraday sell
zs and buy zb; d - c = x + zs - zb; d + c <= P is the convex hull of "charge or discharge" and is realisable by
switching mode inside the quarter-hour (settlement is on quarter-hour energy). The day-ahead leg of oracle_da_id
must itself be a feasible battery schedule. The terminal SOC equality keeps the next day's day-ahead schedule valid.
Intraday forecast (forecast.py), all inputs visible before the decision:
- profile: mean intraday-minus-day-ahead spread per local quarter-hour of the day over 56 days (D-57 .. D-2), soft-thresholded at 2 standard errors so statistically weak slots shrink to zero; it captures the stable ramp pattern inside hourly day-ahead products;
- live residual: mean of the 2 latest visible residuals, carried forward with direct per-lead regression slopes (clipped to [0, 1], set to zero below t = 2), estimated on the same window;
- spreads are winsorised at +-300 EUR/MWh for estimation; execution always uses the raw index.
The forecast settings were chosen on forecast error (not on backtest revenue); the report lists the error of each information set.
Causality¶
Decisions only read arrays below the visible index. audit_causality checks it empirically: intraday prices from a
cut onwards and all later days are replaced by noise and the day is re-run; decisions for products that could not
see a perturbed price must not change (rolling: k < cut + visible_offset; day-ahead and static strategies: the whole
day). The oracles fail this test by design. The report runs the audit on 30 random real days; the unit tests run it on
synthetic data (tests/test_intraday_backtest.py).
Plugging in licensed intraday data¶
Any quarter-hourly price series can replace the ID AEP, e.g. EPEX ID1 / ID3 indices or a VWAP computed from licensed trade data. Keep such data out of the repository unless its licence allows redistribution.
from datetime import date
import pandas as pd
from euroflex_bess_lab.markets.intraday import FrameIntradaySource, IntradayConfig, IntradayMarket, run_parallel
licensed = pd.read_parquet("my_licensed/epex_id1_de.parquet") # timestamp_utc (quarter-hour start), id1_eur_mwh
source = FrameIntradaySource(licensed, price_column="id1_eur_mwh", name="epex_id1")
market = IntradayMarket.from_public("2026-01-01", "2026-06-30", source=source) # adds 35 history days
days = [d for d in market.days if d >= date(2026, 1, 1)]
daily = run_parallel(market, IntradayConfig(), days, workers=8)
A custom class works too: implement the IntradayPriceSource protocol (name, execution_label,
redistributable, load(start_utc, end_utc) -> pd.Series). SyntheticIntradaySource / synthetic_market generate
synthetic prices for tests and demos only.
Reproduce¶
python -m euroflex_bess_lab.public_data.intraday fetch --start 2024-01-01
.venv/bin/python scripts/research/intraday_backtest.py # about 2-3 minutes with 10 worker processes
.venv/bin/python -m pytest tests/test_intraday_*.py # fast, synthetic
EUROFLEX_RUN_SLOW=1 .venv/bin/python -m pytest tests/test_intraday_realdata.py # needs the local ID AEP table
Scope¶
Simulated revenue of one price-taking battery; no orders are sent. Execution at an index is a proxy for continuous trading (no order book, queue position or partial fills); the slippage parameter covers the gap to achievable prices. Intraday auctions (IDA1-3), reserve markets and imbalance positions are not part of this study.