eptr2-market-operations
This skill helps you query electricity market trading data from Turkey's EPIAS Transparency Platform, covering the Day-Ahead Market (GÖP), Intraday Market (GİP), Bilateral Contracts (İA), and Balancin
SKILL.md.claude/skills/eptr2-market-operations
GitHubMarket operations data
Choose the market and measurement before aggregating:
| Market | Starting calls |
|---|---|
| Day-ahead / GÖP | dam-clearing, dam-volume, dam-bid, dam-offer |
| Intraday / GİP | idm-qty, idm-volume, idm-log, wap |
| Bilateral / İA | bi-long, bi-short |
| Balancing / DGP | bpm-up, bpm-down, bpm-orders-w-avg |
These expose published data, not permissions or tools for submitting/canceling orders. Use eptr2 describe <key> to discover accepted parameters; do not assume similarly named transaction/contract-list endpoints exist.
from eptr2 import EPTR2
eptr = EPTR2(use_dotenv=True, recycle_tgt=True, strict_params=True)
clearing = eptr.call("dam-clearing", start_date="2026-07-01", end_date="2026-07-01")
print(clearing.columns.tolist())
print(clearing.head())
A trade value in TL is not a matched quantity in MWh. Do not sum every numeric column: timestamps, IDs, bid/ask sides, prices, and totals can coexist. Avoid adding both sides of the same matched trade. Verify transaction quantity units before converting lots to MWh.
For organization-specific analyses, resolve the organization and pass its ID only to endpoints that accept it. Gate-closure and publication schedules can change; verify them for the requested period instead of treating this skill as a market-rule source.
An organization's positions (GÖP + İA + GİP)
eptr2.composite.get_dabi_idm_data(start_date, end_date, eptr=eptr, org_id=...) returns them per hour in one frame:
da_long/da_short (GÖP purchases/sales), bi_long/bi_short (bilateral), idm_long/idm_short (GİP), the nets
dabi_net, idm_net, dabi_idm_net (long minus short = net purchases) and net_sales (positive = net seller).
Trap: EPİAŞ swaps bid/ask on the GİP matching quantity endpoint. The raw idm-qty response labels the
organization's purchases (Alış) clearingQuantityAsk and its sales (Satış) clearingQuantityBid, the opposite of the
platform page. From eptr2 1.4.1 the idm-qty DataFrame (eptr.call("idm-qty", ...), get_idm_qty) corrects them:
clearingQuantityBid = bought, clearingQuantityAsk = sold. postprocess=False returns the raw, still swapped response,
and eptr2 1.4.0 and earlier return the swapped labels in the DataFrame too; check eptr2.__version__ before reusing
older code or data. get_dabi_idm_data (idm_long / idm_short) is correct in every version. Check against the
platform's "GİP Eşleşme Miktarı" page (Eşleşen Alış / Satış Miktarı) when in doubt.
dam-clearing per organization is not swapped (matchedBids = purchases, matchedOffers = sales).
For an organization's estimated trading activity, use eptr2.composite.get_org_estimated_activity(start_date, end_date, org_id=..., eptr=eptr): per hourly contract it splits day-ahead (GÖP + İA) open / intraday close (dabi_idm_close), intraday day trade (min(idm_long, idm_short)), the day-ahead (GÖP + İA) net position dabi_net and the total net dabi_idm_net to be consumed (+) or generated (−), using only the organization's GÖP, İA and GİP matchings (fast). include_pnl=True adds a fictitious PnL of day-ahead open / intraday close trades (dabi_idm_pnl) from MCP and the published WAP. include_tad=True adds the MAD (idm_mad, mean absolute deviation in TL/MWh: quantity-weighted mean of |price − WAP|) of each contract from the market-wide idm-log and day_trade_tad = day_trade × idm_mad, the TAD (total absolute deviation, TL) of the day-trade volume; these are volatility metrics, not PnL, and need no include_pnl. The log is much slower (roughly 30–70 s per week, depending on EPİAŞ). verbose=True shows progress. By default (export_to_csv=True, check_existing=True) it writes the raw data (positions, MCP, WAP, trade log, per-contract WAP/MAD) and the result as CSV to export_dir ("data") and reads files of the same period instead of fetching; pass export_to_csv=False to write nothing, so the market-wide data is recycled across organizations. end_date must be before today (Europe/Istanbul), otherwise it raises ValueError. For market-wide price dispersion per contract use eptr2.composite.get_idm_contract_stats(start_date, end_date, eptr=eptr): idm_wap, idm_mad (MAD, TL/MWh), idm_tad (TAD, TL = idm_mad × idm_volume_mwh), trade count and volume. It writes the trade log and the statistics to CSV in export_dir and reads them back before fetching (both on by default); get_org_estimated_activity shares these files. idm-log quantities are lots of 0.1 MWh. The PnL is an estimate, not the organization's realized result: its own trade prices are not public.
Read examples.md for discovery and a bounded raw-response query.