# BPET: A Unified Blockchain-Based Framework for Peer-to-Peer Energy Trading
## 4 System Design
### Energy Trading Models  
In the energy industry, the merit order effect [32] is the most widely adopted trading model in pool markets. It allocates electricity generation sources according to their variable costs, favoring the cheapest and most efficient generators. However, the detailed wholesale market rules may vary significantly in practice. For example, while both the wholesale electricity markets in Australia [33] and Alberta [34] employ the merit order effect to determine pool prices, they do so in distinct ways. Figure 2 shows their different market clearance points on the demand-supply curves based on the same sample bidding data in Table 2.  
Figure 1: BPET architecture. In the Australian electricity pool market, both consumers and producers compete to win the auction. The market clearance price (MCP) is calculated as the intersection point of the supply and demand curves, which present the aggregated supply or demand on the horizontal axis and the price rate at which participants wish to sell or buy on the vertical axis. Individual bids and offers are matched against the MCP to identify the winners, who are those consumers offering a price rate exceeding the MCP and producers with a bidding price below the MCP. The Australian Energy Market Operator (AEMO) employs other markets (i.e., bilateral and balancing markets) to meet the needs of those bidding losers in the pool market. In the Alberta electricity pool market, for each hour, market participants submit supply offers and demand bids for electric energy at day-ahead prices for the following day. These offers and bids are organized in a price ascending list called the merit order. The system controllers in the Alberta Electric System Operator (AESO) use the merit order to balance the electricity supply and find a system marginal price (SMP). In this way, the AESO ensures that Alberta internal load (AIL) is met by the most competitively priced electricity. Typically, the merit order mechanism consists of two steps. The first step is to calculate the aggregated demand-supply curves. Supply offers are sorted by price in ascending order, and demand bids are sorted in descending order. Then, the cumulative summation operation is applied to each list separately to obtain the aggregated supply and demand \begin{table}
\begin{tabular}{c c c c} \hline \hline
**ID** & **User Type** & **Price (5/MWh)** & **Aggregated Amount (MWh)** \\ \hline
1 & Supplier & 20 & 500 \\ \hline
2 & Supplier & 40 & 1100 \\ \hline
3 & Supplier & **70** & **1800** \\ \hline
4 & Supplier & **80** & **3500** \\ \hline
5 & Supplier & 90 & 4500 \\ \hline
10 & Consumer & 100 & 500 \\ \hline
9 & Consumer & 90 & 1000 \\ \hline
8 & Consumer & 70 & **1800** \\ \hline
7 & Consumer & 40 & 2700 \\ \hline
6 & Consumer & 20 & **3500** \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Sample bidding data of merit order effect. Figure 2: Sample demand–supply curves with different market clearance points for Australia and Alberta Canada. amounts in megawatt-hour (MWh). The second step is to determine the pool price and trading volume. These steps differ from each other according to different market price mechanisms. In Australia, the intersection point of the demand and supply curves is determined by matching the price and aggregated energy volume. The pool price MCP and volume of energy to be traded (VET) in a trading interval are defined as:  
\[MCP=\{a|a=b\wedge ESA_{a}=EDA_{b}\} \tag{1}\]  
\[VET=\{ESA_{a}|a=b\wedge ESA_{a}=EDA_{b}\} \tag{2}\]  
where \(ESA_{a}\) is the energy supply aggregate at price \(a\) and \(EDA_{b}\) is the energy demand aggregate at price \(b\). In Alberta, the intersection point is determined by matching the AIL demand and the aggregated supply, which does not consider the bidding price of the buyers.