Optimizing Trading P&L with Energy API: Implementing Real-Time Spread and Basis Analysis across Multiple ISOs

Optimizing Trading P&L with Energy API: Implementing Real-Time Spread and Basis Analysis across Multiple ISOs

Energy markets move in milliseconds, but most trading and risk systems are still stitched together with CSV exports, one-off scrapers, and brittle spreadsheets. If you are trying to optimize trading P&L using real-time spread and basis analysis across multiple ISOs, you need intraday electricity curves, corresponding gas and carbon prices, and a normalized way to compare day-ahead auctions across borders—all delivered reliably and consistently. That is exactly the problem this article tackles.

In finance, spreads and basis trades compress disparate signals into tradable edges: Spain vs. Germany day-ahead, NSW vs. EU carbon-adjusted spark, Brent vs. WTI, or TTF vs. Henry Hub. But acquiring those inputs from OMIE, ENTSO-E, ESIOS, EIA/FRED, and other sources creates a cascade of integration work: different time zones, granularities, auction calendars, symbol naming, and currencies. Each mismatch adds latency and operational risk to your P&L workflow.

This post shows how to implement real-time cross-ISO spread and basis analytics using the unified JSON interface exposed by Energy API. You will learn how to assemble intraday electricity curves, normalize currencies, compute spark and clean-spark spreads, compare day-ahead auctions across regions, and monitor provider health—so you can ship robust trader-facing features quickly and with confidence.

Why Energy API

When your job is finance, “time to signal” matters. Energy API collapses weeks of ETL into a few HTTP calls by normalizing wholesale energy market data from OMIE, ENTSO-E, EIA/FRED, ESIOS, and others under one REST surface. Below are the differentiators that directly translate to developer velocity and improved P&L tooling.

  • One schema across commodities and providers: Gas (e.g., TTF_GAS, HENRY_HUB), electricity (OMIE_ES_DA, EPEX_DE_DA, AEMO_NSW1), oil (BRENT_CRUDE, WTI_CRUDE), coal, carbon allowances (EUA_CO2), and carbon intensity all share a consistent JSON format. That means the same parsing, validation, and visualization code powers your cross-commodity dashboards and spread engines.
  • Normalized symbol catalog: Discover and consume 39+ symbols across six categories without memorizing provider-specific codes. The /symbols endpoint yields canonical names, currencies, and frequencies so you can programmatically route analytics by asset class and region.
  • Intraday electricity curves where sources publish them: Build real-time spread and basis models with full hourly or 15-minute intraday curves for auction-sourced electricity symbols. Compute rolling spreads (e.g., OMIE vs. EPEX) directly off these arrays with timestamp alignment.
  • Production reliability and observability: A consistent error model, provider health status via /status, and deterministic /forecast for auction-based symbols let you deploy resilient pipelines with clear backstops. You can implement retry, backoff, and circuit-breakers in minutes using the status signals and error codes provided by the API.

In short, you get the fastest route from idea to production-grade energy analytics: roll out cross-ISO spread monitors, spark/clean-spark calculations, basis risk attribution, and P&L explain views in hours rather than weeks.

Quick Start

Base URL:

https://energy-api.com/api/v1

All endpoints accept an api_key query parameter. Below is a one-liner to fetch the latest price for multiple commodities in one call—perfect for initializing a cross-asset P&L dashboard.

curl -G https://energy-api.com/api/v1/latest \
--data-urlencode "symbols=BRENT_CRUDE,TTF_GAS,EUA_CO2,OMIE_ES_DA,EPEX_DE_DA" \
--data-urlencode "api_key=YOUR_API_KEY"

Example JSON response:

{
"success": true,
"date": "2026-06-11",
"base": "MIXED",
"rates": {
"BRENT_CRUDE": 74.82,
"TTF_GAS": 38.15,
"EUA_CO2": 67.40,
"OMIE_ES_DA": 86.73,
"EPEX_DE_DA": 79.55
},
"dates": {
"BRENT_CRUDE": "2026-06-11",
"TTF_GAS": "2026-06-11",
"EUA_CO2": "2026-06-11",
"OMIE_ES_DA": "2026-06-11",
"EPEX_DE_DA": "2026-06-11"
},
"currencies": {
"BRENT_CRUDE": "USD",
"TTF_GAS": "EUR",
"EUA_CO2": "EUR",
"OMIE_ES_DA": "EUR",
"EPEX_DE_DA": "EUR"
}
}

Key fields:

  • success: Boolean; always check before processing.
  • date: The API-level timestamp for the snapshot; use symbol-specific dates for per-asset freshness.
  • rates: Map of symbol to last value. Note the mixed currencies—normalize in your application if you need base-consistent P&L.
  • dates: Symbol-specific publish dates; essential for recency checks and alignment.
  • currencies: The currency for each symbol; crucial for cross-market spreads and basis calculations.

Core Endpoints for Spread and Basis Analysis

Spread and basis analysis relies on timely last-trade values, intraday curves, historical series, and event-aware forecasts for auction markets. Below are the core endpoints you will combine for robust, multi-ISO analytics. For completeness and operational robustness, we also include discovery and health endpoints you will want in production.

1) Discover tradable symbols: GET /symbols

Purpose: Enumerate all active symbols with metadata so you can programmatically configure dashboards, instruments, and routing logic without hardcoding codes or currencies.

Key params:

  • category (optional): gas | electricity | oil | coal | carbon_intensity | carbon
  • provider (optional): fred | omie | eex | entsoe | esios (where applicable)
  • base (optional): currency filter
curl -G https://energy-api.com/api/v1/symbols \
--data-urlencode "category=electricity" \
--data-urlencode "api_key=YOUR_API_KEY"

Example response:

{
"success": true,
"count": 4,
"symbols": [
{
"symbol": "OMIE_ES_DA",
"name": "OMIE Spain Day-Ahead Electricity",
"category": "electricity",
"country_code": "ES",
"currency_code": "EUR",
"frequency": "daily",
"description": "OMIE day-ahead auction price."
},
{
"symbol": "EPEX_DE_DA",
"name": "EPEX Germany Day-Ahead Electricity",
"category": "electricity",
"country_code": "DE",
"currency_code": "EUR",
"frequency": "daily",
"description": "EPEX DE day-ahead auction price."
},
{
"symbol": "PVPC_ES_2TD",
"name": "Spain PVPC Retail Reference (2TD)",
"category": "electricity",
"country_code": "ES",
"currency_code": "EUR",
"frequency": "hourly",
"description": "Spanish PVPC retail hourly reference."
},
{
"symbol": "AEMO_NSW1",
"name": "AEMO NSW1 Electricity",
"category": "electricity",
"country_code": "AU",
"currency_code": "AUD",
"frequency": "hourly",
"description": "AEMO New South Wales pricing."
}
]
}

Field notes:

  • symbol and currency_code: Use these to enforce currency conversions early in your pipeline.
  • frequency: Decide your resampling or aggregation behavior (e.g., daily for auction day-ahead vs. hourly).
  • country_code: Useful for grouping, reporting, and governance.

2) Multi-asset snapshot: GET /latest

Purpose: Seed a trader’s dashboard with current values for electricity, gas, and carbon in a single request—ideal for spark and clean-spark calculations.

  • symbols (required): comma-separated
  • base (optional): currency normalization request
curl -G https://energy-api.com/api/v1/latest \
--data-urlencode "symbols=OMIE_ES_DA,EPEX_DE_DA,TTF_GAS,EUA_CO2" \
--data-urlencode "api_key=YOUR_API_KEY"

Example response (abbreviated):

{
"success": true,
"date": "2026-06-11",
"base": "MIXED",
"rates": {
"OMIE_ES_DA": 86.73,
"EPEX_DE_DA": 79.55,
"TTF_GAS": 38.15,
"EUA_CO2": 67.40
},
"dates": { ... },
"currencies": {
"OMIE_ES_DA": "EUR",
"EPEX_DE_DA": "EUR",
"TTF_GAS": "EUR",
"EUA_CO2": "EUR"
}
}

Practical use: compute cross-ISO day-ahead spread S_ES-DE = OMIE_ES_DA - EPEX_DE_DA; compute spark spread and clean spark for ES or DE using TTF_GAS and EUA_CO2 with your plant efficiency and emissions factors.

3) Historical series for charting/spread backtests: GET /timeseries

Purpose: Pull date-keyed series for multiple symbols over any window to backtest spreads, run volatility models, or compute rolling correlations for risk overlays.

  • start, end (required): YYYY-MM-DD
  • symbols (required)
  • base (optional)
curl -G https://energy-api.com/api/v1/timeseries \
--data-urlencode "start=2025-01-01" \
--data-urlencode "end=2025-03-31" \
--data-urlencode "symbols=OMIE_ES_DA,EPEX_DE_DA,TTF_GAS,EUA_CO2" \
--data-urlencode "api_key=YOUR_API_KEY"

Example response:

{
"success": true,
"base": "MIXED",
"start_date": "2025-01-01",
"end_date": "2025-03-31",
"rates": {
"OMIE_ES_DA": {
"2025-01-02": 92.10,
"2025-01-03": 88.75
},
"EPEX_DE_DA": {
"2025-01-02": 85.60,
"2025-01-03": 83.90
},
"TTF_GAS": {
"2025-01-02": 46.80,
"2025-01-03": 47.10
},
"EUA_CO2": {
"2025-01-02": 73.25,
"2025-01-03": 72.90
}
},
"frequencies": {
"OMIE_ES_DA": "daily",
"EPEX_DE_DA": "daily",
"TTF_GAS": "daily",
"EUA_CO2": "daily"
},
"currencies": {
"OMIE_ES_DA": "EUR",
"EPEX_DE_DA": "EUR",
"TTF_GAS": "EUR",
"EUA_CO2": "EUR"
}
}

Interpretation:

  • rates: Nested map keyed by symbol and ISO date → numeric price. Construct spreads (e.g., ES-DE) per date, then compute rolling metrics (mean reversion, Bollinger bands, VaR).
  • frequencies: Ensures you do not attempt to blend daily with intraday without an explicit resample policy.
  • currencies: Confidence check for cross-asset math; currency conversions should precede aggregation.

4) Intraday curves for electricity: GET /electricity/hourly

Purpose: Basis and spread decisions often hinge on the hourly shape, not just the day-ahead average. Use this endpoint to retrieve a full hourly (or 15-min) curve for a given symbol and date, enabling hour-by-hour spread analytics and P&L sensitivity.

  • symbol (required): e.g., OMIE_ES_DA
  • date (required): YYYY-MM-DD (auction date or delivery date depending on source convention)
curl -G https://energy-api.com/api/v1/electricity/hourly \
--data-urlencode "symbol=OMIE_ES_DA" \
--data-urlencode "date=2026-06-12" \
--data-urlencode "api_key=YOUR_API_KEY"

Example response:

{
"success": true,
"symbol": "OMIE_ES_DA",
"date": "2026-06-12",
"currency": "EUR",
"granularity": "hourly",
"curve": [
{ "timestamp": "2026-06-12T00:00:00Z", "price": 78.10 },
{ "timestamp": "2026-06-12T01:00:00Z", "price": 74.95 },
{ "timestamp": "2026-06-12T02:00:00Z", "price": 73.02 },
{ "timestamp": "2026-06-12T03:00:00Z", "price": 72.80 },
{ "timestamp": "2026-06-12T04:00:00Z", "price": 74.10 }
// ... hours 05–23 omitted for brevity
]
}

Usage tips:

  • Align curves between markets (e.g., OMIE_ES_DA vs. EPEX_DE_DA) on UTC timestamps to compute hourly spread vectors. Then compute P&L by multiplying by your hedge volumes.
  • Use the shape to size trades: if midday hours widen relative to nights, rebalance your hourly profile to maximize expected spread capture.

5) Auction-aware next-day price: GET /forecast

Purpose: For auction-sourced electricity symbols, retrieve the next published day-ahead price that has already been determined by the market’s official auction. This is not a predictive model; it’s a deterministic lookup of the next available published value—critical for pre-market P&L previews and operations.

  • symbol (required)
curl -G https://energy-api.com/api/v1/forecast \
--data-urlencode "symbol=EPEX_DE_DA" \
--data-urlencode "api_key=YOUR_API_KEY"

Example response:

{
"success": true,
"symbol": "EPEX_DE_DA",
"currency": "EUR",
"publish_time": "2026-06-11T13:15:00Z",
"for_date": "2026-06-12",
"value": 81.20,
"note": "Published auction result. Deterministic lookup."
}

How to use:

  • Generate “tomorrow’s” P&L preview and compare to internal forecasts. Differences can trigger early hedging or spread rebalancing.
  • Coordinate cross-ISO reactions—if ES is published earlier than DE (or vice versa), anticipate basis moves.

6) Gas and carbon snapshots for spark/clean-spark: GET /gas/latest and GET /emissions/latest

Purpose: Spark spread (electricity vs. gas, adjusted by efficiency) and clean spark (subtracting carbon cost) are foundational to margin and dispatch analysis.

curl -G https://energy-api.com/api/v1/gas/latest \
--data-urlencode "api_key=YOUR_API_KEY"

curl -G https://energy-api.com/api/v1/emissions/latest \
--data-urlencode "api_key=YOUR_API_KEY"

Example combined snapshots:

{
"gas": {
"success": true,
"date": "2026-06-11",
"base": "EUR",
"rates": {
"TTF_GAS": 38.15,
"HENRY_HUB": 2.74
},
"currencies": {
"TTF_GAS": "EUR",
"HENRY_HUB": "USD"
}
},
"emissions": {
"success": true,
"date": "2026-06-11",
"base": "EUR",
"rates": {
"EUA_CO2": 67.40
},
"currencies": {
"EUA_CO2": "EUR"
}
}
}

Tip: Convert gas units if needed (e.g., EUR/MWh vs. USD/MMBtu) according to your plant’s basis and thermodynamic conversions. Keep all inputs in a consistent currency and energy unit before computing spreads.

7) Change analytics in one call: GET /fluctuation

Purpose: Express spread P&L attribution over a window using start/end, absolute change, and pct change for all relevant symbols at once.

curl -G https://energy-api.com/api/v1/fluctuation \
--data-urlencode "start=2026-05-15" \
--data-urlencode "end=2026-06-11" \
--data-urlencode "symbols=OMIE_ES_DA,EPEX_DE_DA,TTF_GAS,EUA_CO2,BRENT_CRUDE,WTI_CRUDE" \
--data-urlencode "api_key=YOUR_API_KEY"

Example response:

{
"success": true,
"base": "MIXED",
"start_date": "2026-05-15",
"end_date": "2026-06-11",
"fluctuations": {
"OMIE_ES_DA": {
"start_value": 82.10,
"end_value": 86.73,
"change": 4.63,
"change_pct": 5.64
},
"EPEX_DE_DA": {
"start_value": 77.90,
"end_value": 79.55,
"change": 1.65,
"change_pct": 2.12
},
"TTF_GAS": {
"start_value": 41.80,
"end_value": 38.15,
"change": -3.65,
"change_pct": -8.73
},
"EUA_CO2": {
"start_value": 64.50,
"end_value": 67.40,
"change": 2.90,
"change_pct": 4.50
},
"BRENT_CRUDE": {
"start_value": 77.95,
"end_value": 74.82,
"change": -3.13,
"change_pct": -4.01
},
"WTI_CRUDE": {
"start_value": 74.90,
"end_value": 71.60,
"change": -3.30,
"change_pct": -4.41
}
}
}

Use this to quantify how much of your P&L move was caused by the power leg vs. the gas leg vs. the carbon leg. Because the endpoint returns all legs in one normalized shape, attribution logic becomes straightforward.

8) Provider health checks: GET /status

Purpose: Production-grade trading systems need transparent health signals. Use /status to inform retry/backoff logic and to degrade gracefully if a specific provider lags.

curl -G https://energy-api.com/api/v1/status \
--data-urlencode "api_key=YOUR_API_KEY"

Example response:

{
"success": true,
"providers": [
{
"name": "OMIE",
"last_fetch": "2026-06-11T12:05:02Z",
"status": "ok",
"note": "On schedule"
},
{
"name": "ENTSO-E",
"last_fetch": "2026-06-11T12:03:10Z",
"status": "ok",
"note": "On schedule"
},
{
"name": "EIA/FRED",
"last_fetch": "2026-06-11T11:58:45Z",
"status": "ok",
"note": "On schedule"
}
]
}

Recommendation: Implement a lightweight circuit breaker that defers updates for a given leg if status != "ok", while keeping prior validated values. Log and alert based on provider-level lag thresholds to protect trading UIs from noisy blinking.

From Data to Trading Insight: Spread, Basis, Spark, and Clean-Spark

Below is a practical blueprint to compute cross-ISO spreads and basis, then extend to spark and clean-spark spreads. We show currency and timestamp alignment, along with code examples in Python and JavaScript that hit the endpoints shown earlier.

Aligning currencies and timestamps

  • Currencies: Rates are returned in their native currencies. Electricity in EUR, TTF in EUR, EUA_CO2 in EUR; oil and Henry Hub may differ (USD). Before computing cross-asset spreads, normalize to a base currency with your own FX rate or accounting policy.
  • Time alignment: For intraday curves, align on UTC timestamps. For daily auction values, ensure you understand whether the price corresponds to delivery date (D) or auction publish date (D-1) for your system’s P&L attribution.

Python example: Cross-ISO day-ahead spread and clean spark

import requests
from datetime import date

BASE = "https://energy-api.com/api/v1"
API_KEY = "YOUR_API_KEY"

def latest(symbols):
r = requests.get(f"{BASE}/latest", params={
"symbols": ",".join(symbols),
"api_key": API_KEY
}, timeout=15)
r.raise_for_status()
data = r.json()
if not data.get("success"):
raise RuntimeError(data.get("error", "Unknown API error"))
return data

# 1) Cross-ISO spread ES-DE
symbols = ["OMIE_ES_DA", "EPEX_DE_DA", "TTF_GAS", "EUA_CO2"]
snap = latest(symbols)

es = snap["rates"]["OMIE_ES_DA"] # EUR/MWh
de = snap["rates"]["EPEX_DE_DA"] # EUR/MWh
ttf = snap["rates"]["TTF_GAS"] # EUR/MWh
eua = snap["rates"]["EUA_CO2"] # EUR/tonne CO2

spread_es_de = es - de

# 2) Clean spark for ES with assumed efficiency and emissions factor
# Example assumptions: CCGT efficiency = 50% => 2.0 MWh gas per 1 MWh power
# Emissions factor ~0.35 tCO2/MWh_el (varies by plant)
efficiency = 0.50
gas_per_mwh_power = 1.0 / efficiency # 2.0
emissions_factor = 0.35 # tCO2 per MWh power

spark_es = es - ttf * gas_per_mwh_power
clean_spark_es = spark_es - (eua * emissions_factor)

print({
"spread_es_de": round(spread_es_de, 2),
"spark_es": round(spark_es, 2),
"clean_spark_es": round(clean_spark_es, 2)
})

Notes:

  • Raise on errors, then also check "success". For trading apps, pair with exponential backoff and consult /status if a specific provider lags.
  • Parameterize efficiency and emissions factors per plant; store this in your portfolio metadata to compute unit-specific P&L.

JavaScript example: Hourly spread curve between OMIE and EPEX

async function fetchHourly(symbol, forDate) {
const url = new URL("https://energy-api.com/api/v1/electricity/hourly");
url.searchParams.set("symbol", symbol);
url.searchParams.set("date", forDate);
url.searchParams.set("api_key", "YOUR_API_KEY");

const res = await fetch(url.toString(), { method: "GET" });
const data = await res.json();
if (!data.success) throw new Error(data.error || "API error");
return data.curve; // [{timestamp, price}, ...]
}

(async () => {
const date = "2026-06-12";
const [esCurve, deCurve] = await Promise.all([
fetchHourly("OMIE_ES_DA", date),
fetchHourly("EPEX_DE_DA", date),
]);

// Map by timestamp for alignment
const deByTs = new Map(deCurve.map(pt => [pt.timestamp, pt.price]));
const spreadCurve = [];

for (const pt of esCurve) {
const dePrice = deByTs.get(pt.timestamp);
if (dePrice != null) {
spreadCurve.push({
timestamp: pt.timestamp,
spread: pt.price - dePrice
});
}
}

console.log(spreadCurve.slice(0, 3));
})();

This results in a time-stamped spread array, perfect for plotting and for computing expected P&L based on your hourly hedged volumes.

All Available Endpoints and How They Help Finance Teams

For completeness, here is a concise overview of all endpoints with their finance-focused value. You will likely use a subset in your trading stack, but knowing what’s available helps reduce bespoke ETL.

  • GET /symbols: Discover tradable instruments with metadata; auto-generate watchlists and validation rules.
  • GET /latest: Single-shot multi-asset snapshot; seed dashboards and compute on-the-fly spreads.
  • GET /historical: Point-in-time pricing; backfill missing days for reconciliations.
  • GET /timeseries: Backtest spreads, correlations, and seasonality.
  • GET /fluctuation: P&L attribution over a period with change and change_pct per leg.
  • GET /ohlc: Weekly/monthly/quarterly candles; volatility regimes and technical overlays for macro hedges.
  • GET /electricity/latest: Enumerate current prices across electricity symbols; quick market scan.
  • GET /electricity/hourly: Build intraday spread and basis curves; shape-driven trading.
  • GET /electricity/pvpc: Retail reference prices for Spain; risk transfer to end-customer tariffs.
  • GET /gas/latest: TTF and Henry Hub together; spark calculations and cross-Atlantic basis views.
  • GET /emissions/latest: EUA_CO2; clean-spark and carbon-adjusted profitability.
  • GET /coal/latest: Coal benchmarks (API2, Newcastle); cross-fuel switching analysis.
  • GET /carbon-intensity: Grid gCO2eq/kWh; carbon-sensitive P&L explain and ESG overlays.
  • GET /forecast: Deterministic next day-ahead auction values; pre-market P&L preview.
  • POST /cost-estimate: Wholesale cost estimate for retail-like kWh loads; scenario planning.
  • GET /status: Provider health; production-grade resilience and alerting.

Error Handling, Reliability Patterns, and Best Practices

Robust finance systems anticipate failure modes. Energy API standardizes errors so you can implement predictable logic:

  • 401: Missing or invalid api_key. Validate configuration and avoid repeated retries.
  • 404: No data for symbols/date. Common with non-publishing days; handle by falling back to nearest prior value if that matches your policy.
  • 422: Validation error. Check required params or symbol typos; sanitize inputs upstream.
  • 429: Rate limit exceeded. Implement exponential backoff plus jitter; optionally cache stable series (e.g., historical windows) to reduce repeated hits.

Example defensive wrapper in Python:

import time
import requests

def get_with_backoff(url, params, tries=5, base_delay=0.5):
for i in range(tries):
r = requests.get(url, params=params, timeout=15)
if r.status_code == 429 and i < tries - 1:
time.sleep(base_delay * (2 ** i))
continue
r.raise_for_status()
data = r.json()
if not data.get("success"):
raise RuntimeError(data.get("error", "Unknown API error"))
return data
raise RuntimeError("Exhausted retries")

Operational guidance:

  • Use GET /status to drive fallback chains. If a provider is temporarily unhealthy, pause refresh for that leg and show a banner on the UI indicating data freshness.
  • Cache slowly-changing data (e.g., monthly OHLC, long historical windows) aggressively. Reserve fresh calls for intraday curves and latest snapshots.
  • Normalize currencies and units at ingestion. For example, convert all EUR/MWh and USD/MMBtu into a common currency+unit before calculating spreads to avoid silent P&L skew.
  • Audit logs: Record the symbol, date, value, and currency per data point you consume to support T+1 reconciliations and model backtesting.

Worked Examples: End-to-End Calls with JSON You Can Drop Into Code

Example A: Build a cross-ISO spread monitor (OMIE vs. EPEX) with day-ahead and hourly shape

1) Seed the dashboard with day-ahead snapshot:

curl -G https://energy-api.com/api/v1/latest \
--data-urlencode "symbols=OMIE_ES_DA,EPEX_DE_DA" \
--data-urlencode "api_key=YOUR_API_KEY"

2) Retrieve hourly curves for D:

curl -G https://energy-api.com/api/v1/electricity/hourly \
--data-urlencode "symbol=OMIE_ES_DA" \
--data-urlencode "date=2026-06-12" \
--data-urlencode "api_key=YOUR_API_KEY"

curl -G https://energy-api.com/api/v1/electricity/hourly \
--data-urlencode "symbol=EPEX_DE_DA" \
--data-urlencode "date=2026-06-12" \
--data-urlencode "api_key=YOUR_API_KEY"

3) Align timestamps, compute hourly spread array, and overlay your hourly hedge volumes to derive expected spread P&L by hour, then aggregate to daily totals. Persist the result with the symbol-level dates to ensure auditability.

Example B: Clean-spark watch for ES

Fetch electricity, gas, and EUA in one go:

curl -G https://energy-api.com/api/v1/latest \
--data-urlencode "symbols=OMIE_ES_DA,TTF_GAS,EUA_CO2" \
--data-urlencode "api_key=YOUR_API_KEY"

Then compute:

  • spark = Power - Gas * (1/efficiency)
  • clean_spark = spark - EUA_CO2 * emissions_factor

Because the JSON format is unified, your clean-spark function can be reused for multiple geographies with different plant parameters.

Example C: Backtest a Spain-Germany basis strategy

Use /timeseries to get a 2-year window, compute ES-DE spread per day, then apply a simple mean-reversion rule:

curl -G https://energy-api.com/api/v1/timeseries \
--data-urlencode "start=2024-06-01" \
--data-urlencode "end=2026-06-11" \
--data-urlencode "symbols=OMIE_ES_DA,EPEX_DE_DA" \
--data-urlencode "api_key=YOUR_API_KEY"

Now compute rolling z-scores and evaluate entry/exit. Use /fluctuation to summarize out-of-sample performance windows with change_pct. Augment with /ohlc monthly to detect volatility regime shifts.

OHLC and Volatility Overlays for Macro Hedging

While spread and basis trading is local to electricity and gas, macro hedges (oil, coal) matter for risk budgeting. The /ohlc endpoint provides weekly, monthly, or quarterly candles suitable for technical overlays that inform hedge sizing.

curl -G https://energy-api.com/api/v1/ohlc \
--data-urlencode "symbols=BRENT_CRUDE,WTI_CRUDE" \
--data-urlencode "period=monthly" \
--data-urlencode "start=2024-01-01" \
--data-urlencode "end=2026-06-01" \
--data-urlencode "api_key=YOUR_API_KEY"

Example response:

{
"success": true,
"symbols": {
"BRENT_CRUDE": [
{ "period": "2024-01", "open": 77.10, "high": 83.50, "low": 75.90, "close": 81.25, "data_points": 22 },
{ "period": "2024-02", "open": 81.25, "high": 85.40, "low": 80.10, "close": 84.35, "data_points": 20 }
],
"WTI_CRUDE": [
{ "period": "2024-01", "open": 71.80, "high": 79.20, "low": 70.60, "close": 77.45, "data_points": 22 },
{ "period": "2024-02", "open": 77.45, "high": 81.00, "low": 75.20, "close": 79.10, "data_points": 20 }
]
}
}

Field use:

  • period: YYYY-MM or YYYY-Www; index your candles for charting and volatility regime detection.
  • open/high/low/close: Drive ATR, Bollinger, or simple variance rules for hedge scaling.
  • data_points: Sanity check completeness when markets had holidays.

Carbon Intensity and ESG Overlays for Finance Use Cases

P&L explain increasingly includes carbon context. The /carbon-intensity endpoint yields gCO2eq/kWh by country, which you can overlay on revenue or margin to produce carbon-adjusted profitability. This matters for investor reporting and for trading policy decisions that incorporate carbon pricing paths.

curl -G https://energy-api.com/api/v1/carbon-intensity \
--data-urlencode "country=DE" \
--data-urlencode "api_key=YOUR_API_KEY"

Example response:

{
"success": true,
"country": "DE",
"unit": "gCO2eq/kWh",
"date": "2026-06-11",
"value": 356
}

Tie this metric to your positions to report a “carbon intensity weighted margin” or to allocate internal carbon costs distinct from EUA_CO2, highlighting grid mix effects independent of allowance prices.

Performance, Governance, and Observability Patterns for Finance Teams

When deploying market data into trading and risk systems, success comes from more than accurate numbers; it requires routing choices, retries, and strong governance signals.

  • Routing and overrides: Because all commodities share one REST surface, route requests per asset class through shared client code and centralize currency normalization, timestamp conversion, and audit logging.
  • Streaming and batching: While the API is request/response, you can simulate “streaming” updates by polling /electricity/latest and /latest on a tight cadence and batching processing to amortize costs in your compute layer.
  • Retries/backoff: Respect 429 responses with exponential backoff. Combine with /status to short-circuit retries if a provider is temporarily degraded.
  • Observability: Log success flags, symbol-level publish dates, and provider status snapshots. Build dashboards that display age-of-data by symbol and raise alerts when thresholds are exceeded.
  • Governance: Segment applications by internal roles (e.g., trading UI, risk calc, backtesting job) and maintain per-app usage telemetry and audit logs. Data locality and access reviews are simplified because you have one normalized ingress.

Real-World Use Cases

Cross-ISO Spread Monitor with Hourly Shape

Developers assemble a real-time spread monitor comparing OMIE_ES_DA and EPEX_DE_DA using GET /latest for the day-ahead anchor and GET /electricity/hourly for the intraday shape. The app aligns hour stamps and computes an hourly spread curve, then multiplies by hedged volumes to show expected P&L per hour and in aggregate.

Clean-Spark Margin Tracker for Gas-Fired Fleet

Risk teams compute plant-level clean-spark margins by combining GET /latest for OMIE_ES_DA (or EPEX_DE_DA), GET /gas/latest for TTF_GAS, and GET /emissions/latest for EUA_CO2. Each plant carries a stored efficiency and emissions factor, yielding a portfolio view of carbon-adjusted margins with alerts when thresholds breach.

ESG-Adjusted P&L Dashboard

Sustainability teams augment revenue and margin with GET /carbon-intensity to produce a “carbon-adjusted P&L,” attributing changes to price vs. carbon intensity. For customer-facing fintech, this becomes a differentiator: explain energy cost exposures alongside environmental footprint using the same normalized JSON model.

FAQ

How often does the TTF gas price update?

TTF_GAS is published at a daily frequency and provided as the most recent available value. Use GET /latest for snapshots and GET /timeseries for historical sequences. If a given day is a non-publishing day, GET /historical returns the most recent value before it.

Can I get historical energy prices going back 5 years?

Yes. Use GET /timeseries with a start and end window covering your desired range. Electricity, gas, oil, and carbon series share the same response shape, simplifying long-horizon backtests across commodities.

Does the API support multiple commodities in a single call?

Yes. A key advantage is querying electricity, gas, oil, coal, and carbon in the same GET /latest or GET /timeseries request. This reduces request overhead and lets you compute cross-asset spreads without juggling multiple client libraries.

How should I handle non-publishing days for auction markets?

Use GET /historical to request a specific date; if it is a non-publishing day, you receive the most recent value before it. For the next day-ahead auction value that has already been published, use GET /forecast, which is deterministic and not a predictive model.

What is the recommended approach for error handling and retries?

Check the standard error codes and implement exponential backoff on 429, validate required params to avoid 422, and consult GET /status to adjust retry logic when a provider is temporarily degraded. Always inspect the "success" field in responses before use.

Conclusion + CTA

Optimizing trading P&L across multiple ISOs hinges on rapid, reliable access to normalized data. With the unified JSON interface from Energy API, you can stand up cross-ISO spread monitors, basis risk attributions, spark and clean-spark calculators, and ESG overlays without wrestling heterogeneous data portals or inconsistent formats. Instead of maintaining brittle ingestion code, you focus on the financial logic that drives your desk’s performance.

This post showed how to combine GET /latest, GET /timeseries, GET /electricity/hourly, GET /forecast, GET /gas/latest, GET /emissions/latest, and supporting endpoints to deliver production-grade analytics. By aligning currencies and timestamps and layering robust error handling with /status, your systems become both faster and more resilient—two attributes that directly improve your “time to signal” and, ultimately, your P&L.

Build your next trading feature on a normalized, reliable foundation. Explore the endpoints today and put real-time, cross-commodity insights in front of traders and risk teams. Try Energy API for free.

Ready to get started?

Get your API key and start querying energy commodity prices in minutes.

Get API Key

Related posts