Every round each household computes its net power: solar generation minus consumption. Houses with a surplus post a sell order just below the utility's wholesale buy-back price; houses with a deficit post a buy order just below the utility's retail price. A double-auction engine sorts asks ascending and bids descending, then walks down both queues matching a buyer to a seller whenever the bid still meets or beats the ask — the trade settles at the midpoint of the two prices, exactly as a smart contract would record it on a shared ledger. Every unmatched surplus is exported to the grid at the low wholesale price; every unmatched deficit is imported at the high retail price, so the sliders let you watch trading volume and household savings collapse as clouds roll in or demand spikes past what neighbours can supply.
net_i = solar_i − demand_i
ask_i = gridSell·(1 − spread), bid_i = gridBuy·(1 + spread)
match while max(bids) ≥ min(asks):
price = (bid + ask) / 2 // recorded in the next block
qty = min(seller_left, buyer_left)
- Households — how many prosumer nodes sit on the local market; more neighbours means more chances a surplus finds a matching deficit.
- Cloud cover — cuts solar generation across the board, shrinking the seller side of the order book.
- Demand level — scales everyone's consumption, shrinking the seller side and growing the buyer side.
- Order price spread — how much sellers undercut, and buyers underbid, the utility's own buy/sell prices; a wider spread clears more volume but at a less favourable price for both sides.
Real-world relevance: this is the core mechanism behind transactive/peer-to-peer energy markets (e.g. Brooklyn Microgrid, Power Ledger) — a local double auction settled by smart contracts, falling back to the regulated grid only for the imbalance the neighbourhood can't cover itself.