Skip to content
Electricity is a physical commodity, not another kind of stock

Electricity is a physical commodity, not another kind of stock

The first time I saw negative electricity prices, I assumed the data source was broken. The price field had a minus sign, and my cleaning script promptly discarded it as an outlier. Only later, when I went back to the pricing rules, did I understand that it wasn’t dirty data: the grid genuinely wanted someone to consume more power during that hour.

After this, I changed my cleaning rules and began to reunderstand this market. On the surface it has prices, curves, and volatility like stocks, but underneath it’s something else entirely: electricity must be consumed the moment it’s generated, transmission lines have physical capacity, and supply-demand imbalances don’t stop at the quote—they turn directly into equipment failures.

Things that can’t be stored have a different price shape

The most fundamental difference between stocks and energy isn’t volatility—it’s storability. You can hold a stock indefinitely at almost no cost beyond capital tie-up. Electricity can’t do that; production and consumption must happen simultaneously. Storage technology is improving, but it remains small relative to total demand, and pumped hydro is still limited by terrain.

Oil and gas can be stored, but storage incurs rent, insurance, and losses, and these costs ultimately become the price spreads between different delivery months. Apply the same logic to electricity and it breaks down, because the storage link doesn’t exist—arbitrage across the time dimension is physically severed.

Mean reversion is therefore not a statistical phenomenon but something squeezed out by physical arbitrage. When prices rise above marginal cost, idle units start up; when they fall below fuel cost, units shut down. On both ends, real money pushes prices back, making reversion far more robust than for financial assets.

I initially understood “mean reversion” as prices returning to a historical center, and that understanding was wrong. The center itself moves—it follows fuel costs. Using a historical mean as an anchor will lose badly in a year of violent fuel price swings. A more robust approach treats the long-term mean as a variable that needs separate modeling, rather than estimating it directly from the price series.

The supply curve deserves separate attention. Units are stacked from low to high marginal cost, and the price is set by the last unit dispatched. When demand crosses a threshold slightly, the price jumps a notch. This jump is step-shaped, and fitting it with a continuous model will be persistently biased near the inflection points.

Weather is the most important exogenous variable for this curve, and also the hardest to use. Numerical forecasts have ensemble members, and the disagreement among members is actually a good uncertainty indicator—more useful than a single-point forecast. I’ve seen people feed it directly into models as a feature with mediocre results; using it to adjust position limits is more reasonable.

The price series contains less information than you’d think. The real independent variables lie outside the series: temperature, wind speed, unit maintenance schedules, pipeline gas throughput. These don’t update at market frequency, but they determine where the market will stop.

Negative prices and nodal prices: how physical constraints become prices

Negative prices have two common sources. One is must-run units: nuclear and large coal plants have extremely high startup-shutdown costs, and stopping and restarting can take days, so they’d rather pay people to consume power than shut down. The other is subsidies: some renewables still receive per-kWh subsidies in negative price ranges, and as long as the subsidy exceeds the loss, continuing to generate is rational.

The common logic behind both sources is the same sentence: shutting down is more expensive than losing money. This explains many seemingly perverse quotes.

The spatial version is nodal pricing. A transmission line has a thermal limit; if power is cheap at location A but can’t be sent out, location B must start its own expensive units. The market is sliced into nodes, and the price difference is the price of congestion. For someone writing code, grid topology and line capacity are hard constraints on the model, not optional features.

This also explains why inter-regional arbitrage looks simple but is hard in practice. Most of the time when a spread exists, it’s not that nobody noticed—it’s that the power can’t be delivered. When it genuinely can be delivered, the spread has usually already been compressed to almost nothing.

The modeling headache with nodal prices is that there are too many nodes. Node-by-node modeling isn’t realistic; you typically cluster nodes with similar behavior into groups. The clustering method directly affects backtest results and is very hard to validate—I still don’t have a solid answer on this.

The spread between fuel and electricity is another type of play. A gas plant’s gross margin is roughly the electricity price minus the fuel price times the heat rate; a lower heat rate means higher unit efficiency. Understanding this formula as a call option makes the logic click: generate when the spread is positive, shut down when negative, with losses capped at fixed costs. The strategy isn’t trading the direction of electricity prices—it’s trading whether this spread will continue to widen.

Replacing “forecasting” with “pricing” is the most practical aspect of this perspective. Forecasting electricity price direction is hard; judging a unit’s startup-shutdown boundary is relatively easy, because it’s determined by cost structure, not sentiment.

The cost is that unit startup and shutdown aren’t free. Frequent cycling accelerates equipment aging, and there’s an implicit startup cost in real decisions. Ignore it, and the model will generate overly frequent startup-shutdown signals that look profitable but are actually burning equipment.

The most expensive thing in data is time

Energy data differs from other domains in two ways.

One is look-ahead bias. Weather is the primary input for load and renewable output, and using historical actuals instead of the forecasts available at the time during backtesting makes the model look unrealistically good. This error is insidious because actuals data is often revised after the fact, precisely smoothing away the uncertainty that existed at the time. Sampling by publication time rather than effective time is the only solution I know of, at the cost of more complex storage and querying—and many historical data sources don’t retain published versions at all.

The other is time itself. Electricity is delivered hourly or in fifteen-minute intervals, and various regions have daylight saving time, with one day of twenty-three hours and one of twenty-five hours each year. Duplicate time indices cause errors or silent overwrites, and forward-filling creates hours that don’t exist. These problems won’t crash your program—they’ll just slowly bias your backtest results, and they’re extremely hard to locate.

Granularity alignment is equally annoying. Electricity prices are hourly, load might be fifteen-minute, weather is hourly but different models’ timestamps mean different things. Merging directly amounts to unintentionally introducing future information, especially when forward-filling coarse-grained data onto fine-grained data. This kind of error is invisible in code and only shows up in the gap between live trading and backtesting.

Data sources themselves are unstable. Different grids have different publication formats, field naming, and even timezone labeling, and API changes usually come without notice. My current approach is to write separate parsing and validation for each source—I’d rather write a few hundred extra lines than build a universal parser, because the universal one needs changing every time, and when you change it you don’t know who it will affect.

Cleaning rules also need to change accordingly. Negative prices are legitimate values, spikes may be real congestion signals rather than outliers, and wind output exceeding installed capacity is the real dirty data. Generic standard-deviation filtering on this kind of data will delete the most interesting segment.

Now I clean by scenario first: price series are only validated against upper/lower bounds and physical capacity, without smoothing; load and output series get anomaly detection. This division is clumsy, but more reliable than one set of rules for everything.

The system’s focus isn’t speed—it’s predictability

On the futures and derivatives side, the architecture is close to financial high-frequency trading, competing on latency from market data to order submission—kernel bypass, colocation, and hardware acceleration all matter.

Electricity spot and intraday are different. Here “high frequency” means many decisions, not nanosecond-level order racing. The system must handle constraints: unit output limits, ramp rates, bid deadlines, imbalance penalties. Speed matters, of course, but the cost of one calculation error can be orders of magnitude larger than being a hundred milliseconds slower.

Bidding has no counterpart in stock systems. Many electricity trades require submitting physical schedules to the grid operator; a failed or late submission can invalidate the trade entirely and may incur penalties. So connectivity isn’t just “can connect to the exchange”—it means handling several heterogeneous interfaces, each with its own deadlines and retry rules.

A power plant trip is a typical scenario. Once the signal comes in, sequence matters more than speed: first freeze the relevant sell orders, then buy hedges in the intraday market, and only then notify people. Put notification first, and before anyone has reacted, the exposure has already grown.

For this kind of system I lean toward a modular monolith rather than microservices. Remote calls are fast in normal times, but in extreme markets they time out, they retry, and they amplify a single failure into a cascade. With the core path running in the same memory space, the failure modes are at least countable. This judgment runs counter to the internet industry’s default practice, but on a trading path, predictability is worth more than elasticity.

The data ingestion layer is the exception; that part should be isolated. Exchange interfaces, grid reporting interfaces, weather data sources—their protocols all differ and change frequently, so it is worth putting an adapter layer in front of them. The core engine should not know which exchange it is facing.

Backtest-to-live deviation is especially large in this kind of system because there are too many constraints. In backtests, units can start and stop instantly; in live trading, they must ramp. In backtests, declarations can be changed at any time; in live trading, there are deadlines. These differences do not show up in returns; they show up on the days when you need the money most.

Another often-overlooked difference is data latency. Market prices are instant on the exchange, while grid metering data often lags by minutes or more. Backtests assume you get the price in the same second; in live trading you get the state from several minutes ago. This lag likewise does not show up in the strategy logic; it shows up only in those few minutes when you most need to react.

Beyond the system there is another layer I have never done well: risk. Value at risk is a beautiful number under the normal assumption, but the tails of energy prices are far fatter than normal, and extreme weather and pipeline accidents are not in the historical sample.

My current approach is clumsier: set hard stop-losses, set circuit breakers, and write “what the model does not know” into the documentation. Admitting this is not dignified, but it is better than hunting for answers in real time during an extreme market. Circuit breakers matter especially: they do not solve the problem, they just limit the loss to a range you can negotiate.

Liquidity is the same story. Backtests assume you can close a position at any time; in live trading, far-month contracts may have no counterparty at all. This difference is invisible in calm times and exposed all at once when you need to reduce positions.

My stress testing is not systematic either. Rather than testing, it is more like listing: which assumptions, once they fail, will send the entire position in the same direction at the same time. This list is currently only half a page, and still being added to.

I increasingly believe that the core capability in this market is not prediction but making feasible decisions under constraints. If prediction is wrong, constraints can still catch you; if the constraints are misunderstood, even the most accurate prediction is useless.

About this Post

This post is written by Lu's Blog, licensed under CC BY-NC 4.0.

#Data Quality #Energy Trading #Quantization

Comments