Battery arbitrage backtest on day-ahead prices

Household mode: the battery charges from the grid on a dynamic tariff and discharges only into your own consumption, with no export. Wholesale mode buys and sells at spot. Each mode compares the daily 13:00 rolling plan (rest of today plus tomorrow), a 24-hour plan made at midnight, and perfect foresight. Every plan is a linear program solved with HiGHS in your browser.

Use case

Prices

Drop a file here or
energy-charts JSON · SMARD, ENTSO-E or OKTE CSV

Get real prices from energy-charts

Open this API link, save the page as a .json file, then drop it above. Data: Bundesnetzagentur | SMARD.de via energy-charts.info, CC BY 4.0. For Slovakia, export from OKTE or ENTSO-E.

Consumption

Consumption per month, kWh (× = kWh a day vs. the yearly average)

Edit hourly shapes

24 values each, hour 0 first. They're relative: only the shape counts, because each month is scaled to its kWh.

3501 kWh a year ≈ 9.6 kWh a day on average; winter/summer ratio 1.40.

Weekday Saturday Sunday Average month, kW per hour

Shifted consumption comes off the day's peaks and runs as one block in the cheapest stretch of the same day, e.g. a dishwasher, washing machine or car charging you can time.

Tariff

Retail price per quarter-hour = (spot + fees) × (1 + VAT).

Details

Default 13.67 = grid fee 7.0 (estimate for Saxony) + 2026 levies and electricity tax 6.67; take the exact grid fee from your network operator. It hardly moves the savings, because you pay it on charging and save it on discharging; only the losses carry it.

Prices paid and received

Grid fees, levies and supplier margin go into the buy adder. Zero for both is the pure wholesale case.

Battery

Plan

Use another history file

Energy-charts JSON or a CSV. Its days within the value period above are used.

Rolling 13:00 plan, net profit
–
–
Share of perfect foresight–
Perfect foresight (upper bound)–
24-hour plan made at midnight–
Full cycles, rolling plan–
Consumption supplied by the battery–
Bill without → with battery–

Cumulative bill savings

By month

One day in detail

Price, €/MWh (left) SoC rolling, % (right) SoC perfect foresight

Why it charges or discharges

Same day as above. Each plan puts a value on stored energy, and that sets two price thresholds: it charges when the price is below the grey band and discharges when the price is above it. Inside the band it holds.

Details

The band is wider than the price gap alone because of round-trip losses and wear. The price axis stretches to show both edges, up to one price range beyond the day's prices; an edge further out is not drawn, which means that side never triggers that day. Hover a step for the numbers. Steps re-solved as a MILP have no band. Above the band the plan discharges as much as it can in that step: up to the battery's power (in household mode never more than the household uses), and not when the battery is empty.

Spot price, €/MWhDischarge aboveHold bandCharge belowCharging (bars up)Discharging (bars down)

Method

  • Rolling plan: day 1 is planned at 00:00 for day 1 only. After that, each day at the decision time the plan covers the rest of that day plus all of the next day, using the prices known by then, and runs until the next decision. The 24-hour plan re-solves at 00:00 for that day only. Perfect foresight is one LP over the whole period, the upper bound.
  • Value of leftover energy: for each month, the extra savings over the next two days from ending a plan with more energy stored, averaged over historical days of that month. It is scaled down by the factor α that earns most on that history, because the fit sees two days ahead.
  • The assumed profile scales the weekday, Saturday and Sunday shapes so that each month adds up to its kWh (on the 2026 calendar). Public holidays count as weekdays. The default shapes are an approximation in the spirit of the BDEW H0 standard profile, not the official table.
  • Load shifting (optional): the chosen share of each day's consumption comes off its peaks and runs as one block in that day's cheapest stretch, at most the given extra power, before the battery plans. Shifted load already sits in cheap hours, so it leaves the battery less to gain.
  • Times are Europe/Berlin. Partial first and last days are dropped.

Methodology: full model, equations and limitations.