{'fraction_non_alphanumeric': 0.028773991141732284, 'fraction_numerical': 0.010780634842519685, 'mean_word_length': 5.13038559441878, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Peer-to-Peer Trading in Electricity Networks: An Overview

Peer-to-peer trading is a next-generation energy management technique that economically benefits proactive consumers (prosumers) transacting their energy as goods and services. At the same time, peer-to-peer energy trading is also expected to help the grid by reducing peak demand, lowering reserve requirements, and curtailing network loss. However, large-scale deployment of peer-to-peer trading in electricity networks poses a number of challenges in modeling transactions in both the virtual and physical layers of the network. As such, this article provides a comprehensive review of the state-of-the-art in research on peer-to-peer energy trading techniques. By doing so, we provide an overview of the key features of peer-to-peer trading and its benefits of relevance to the grid and prosumers. Then, we systematically classify the existing research in terms of the challenges that the studies address in the virtual and the physical layers. We then further identify and discuss those technical approaches that have been extensively used to address the challenges in peer-to-peer transactions. Finally, the paper is concluded with potential future research directions.


I. INTRODUCTION
Over the last few years, there has been an extensive growth in small-scale distributed energy resources, which encompass behind-the-meter generation, energy storage, inverters, electric vehicles, and control loads. At the household level, in particular, the increase in the use of distributed energy resources has been unprecedented. For instance, the global market of rooftop solar photovoltaic (PV) panels is expected to grow by 11% over the next six years, with an additional increase in residential storage systems from 95 MW in 2016 to 3700 MW by 2025 [1]. These small-scale resources can be utilized not only to manage the energy demand more efficiently, but also to enable a significant mix of clean energy into the grid. However, to do so, it is important for the owners of these assets to act as proactive consumers -referred to here as prosumers -and actively participate in the energy market.
Given this context, feed-in-tariff (FiT) has been used extensively to enable prosumers to participate in energy trading [2]. In FiT, prosumers with rooftop solar panels can sell their excess solar energy to the grid and can buy energy again from the grid in case of any energy deficiency [3]. Unfortunately, the benefit to prosumers for participating in recent FiT schemes has been very marginal [4]. As a consequence, FiT schemes have been discontinued in some parts of the world such as the state of Queensland in Australia [5].
As such, peer-to-peer (P2P) trading has emerged as a next generation energy management technique for smart grid that can enable prosumers to actively participate in the energy market either by selling their excess energy [6] or by reducing the demand of energy via Negawatts, i.e., demand reduction or negative Watts [7]. With the prosumers in control of setting the terms of transactions and the delivering of goods and services [8], it is expected that the gain that the prosumers can reap from participating in P2P trading would be substantial [9]. At the same time, the grid -consisting of generators, retailers, and distribution network system provider (DNSPs) -can also obtain significant benefit in terms of reducing peak demand [10], lowering investment and operational costs [11], minimizing reserve requirements [12], and improving power system reliability [8].
However, trading in a P2P network is challenging. This is because, in P2P trading, it is expected that prosumers will trade their energy with one another with a very low (or, not any) influence from a central controller, which makes P2P platforms a trustless system. Hence, it is a challenging task to encourage prosumers to cooperate in such a trustless environment [3]. Further, in an energy system with a large number of users, it is difficult to model the decision making process for various energy trading parameters given their rational choices that can conflict with the interests of other prosumers in the network [13]. Furthermore, electricity exchange is different from any other exchange of goods. This is due to the fact that prosumers are part of an electricity network, which has its own hard technical constraints on energy exchange [14]. Completely decentralized P2P trading could be detrimental in maintaining the technical limit of the network within the safety range [14]. Therefore, how to trade energy in the P2P network without compromising the network's security needs to be addressed. Finally, a number of stakeholders in the grid may request of prosumers P2P services with different objectives in mind. Thus, innovations are needed in the pricing scheme to prioritize these requests in order to deliver a non-congested service throughout the entire network, while keeping the network loss at a minimum [15].
To that end, a large number of interesting results have been reported in the literature recently with the aim to address these challenges. Due to the complex nature of the problem as well as the broad range of techniques that have been used to solve it, to have a grasp of the entire paradigm of current P2P trading research has become a troublesome task. However, an overall understanding of the state-of-the art P2P research is important in order to: 1) initiate new research direction in this field; 2) cater for new challenges that are forthcoming in the energy sector; 3) develop more efficient and cost-effective energy trading mechanisms to deploy in real networks; and 4) design new services via P2P trading. Thus, having clear insight into the current state-of-the-art in P2P energy research could be beneficial for new researchers of power and energy systems. This is particularly true for investigators who want to contribute to developing a sustainable future through distributed energy resources.
Given this context, this paper aims to provide an overview of disruptive innovations in current P2P energy trading research contributing to revolutionizing the future energy sector by making the following contributions: • We provide a background discussion of P2P networks, features of P2P trading, P2P energy markets, and an overview of challenges in P2P trading.
• We determine the core technical approaches that are adopted by current studies to devise various solutions in P2P trading and provide a detailed discussion of each of the techniques. • We provide a number of potential research directions that would be valuable to investigate as extensions of current research practice.
We note that there are other recent review articles that discuss various aspects of P2P trading. For example, in [16], the authors provide an overview of various P2P projects that are currently being implemented in different parts of the world. Extensive overviews of different types of P2P and communitybased market frameworks are described in [17] and [18]. How different blockchain-based distributed ledger technologies can be applied for various applications in energy sector are reviewed in [19] and [20], whereas the challenges and opportunities of these applications are discussed in [12]. Finally, optimization techniques and other technical approaches for energy trading are comprehensively reviewed in [21], and with a particular focus on game-theoretic application in [13].
Indeed, these existing review studies have contributed extensively to the body of energy trading knowledge that can provide researchers with a good understanding of various technical aspects of P2P trading. However, these reviews are suitable mainly for those who have some understanding of energy trading, P2P networks, and demand response management. Our paper, on the contrary, takes a step back and targets an audience with no or little prior knowledge of P2P trading and provides a basic understanding of most of the aspects of P2P trading including the definition, network elements, various layers, and market structure of P2P networks. Then, by introducing the challenges and solution approaches for different layers, this article helps readers to choose research directions in a specific layer and then have an in-depth understanding of the challenges and technical approaches relevant to that layer. Further, this paper is also different from existing studies in terms of organization and focus of discussion, which is mainly the trading approaches for addressing challenges of relevant layers. Note that this paper could also be a useful resource for experienced researchers for revising the understanding of the topic. The rest of the paper is organized as follows. In Section II, we give an overview of the elements of P2P networks followed by a review of P2P market structures in Section III. A detailed overview of state-of-the-art research in P2P trading is provided in Section IV following a systematic classification. Key technical approaches that have been applied for P2P trading are identified and discussed in Section V. Finally, Section VII provides some concluding remarks with a list of potential future research directions.

II. P2P TRADING: OVERVIEW OF NETWORK ELEMENTS
A distributed network architecture can be defined as a P2P network, if the participants of the network share a part of their own resources with one another. These shared resources provide the service and content offered by the network and can be accessed by other peers directly, without the intervention of intermediary entities [22]. In addition, in a P2P network, any entity can be removed or added, if necessary, without the network suffering from any loss of network service. A formal definition of P2P networks can be found in [9].
As shown in Fig. 1, P2P network can be divided into two layers [13]: 1) virtual layer and 2) physical layer. The virtual layer essentially provides a secured connection for participants to decide on their energy trading parameters. It ensures that all participants have equal access to a virtual platform, in which transfer of all kinds of information takes place, buy and sell orders are created, an appropriate market mechanism is used to match the buy and sell orders, and finally, financial transactions are carried out upon successful matching of the orders.
The physical layer, on the other hand, is essentially a physical network that facilitates the transfer of electricity from sellers to buyers once the financial settlements between both parties are completed over the virtual layer platform. This physical network could be the traditional distributed-grid network provided and maintained by the independent system operator or an additional, separate physical microgrid distribution grid, in conjunction with the traditional grid [13]. It has the necessary framework to enable communication between different prosumers and the grid. Here, it is important to note that the financial settlements between different prosumers in the virtual platform does not warrant the physical delivery of electricity; rather, the payment can be thought of as indication from the buyers to their producing prosumers within the P2P network to process the injecting of renewable energy into the distribution grid. Now, to successfully enable energy trading between different prosumers within the P2P network, it should have a number of key elements. A summary of these elements is given below.
A. Elements in the virtual layer 1) Information system: The heart of the P2P energy network is a high-performing and secured information system. The information system needs to be able to: 1) enable all market participants to communicate with one another for participating in energy trading; 2) integrate the participants within a suitable market platform; 3) give the participants equal access to the market; 4) monitor the market operation; and 5) set restrictions on participants' decisions to ensure network security and reliability. Examples of such information systems include blockchainbased smart contracts [23], consortium blockchain [24], [25], and Elecbay [10].
2) Market operation: The information system of a P2P network facilitates the market operation consisting of market allocation, payment rules, and a clearly defined bidding format. The main objective of market operation is to enable the participants to experience an efficient energy trading process by matching the sell and buy orders in near real-time granularity. In market operations, energy generation of each producer influences the thresholds of a maximum and minimum allocation of energy. Different market-time horizons may exist in the market operation that should be able to produce enough allocation of energy at every stage of operation.
3) Pricing mechanism: Pricing mechanisms are designed as parts of market operations and used to efficiently balance between the energy supply and demand. Pricing mechanisms used for P2P trading have a basic difference with that of the traditional electricity markets. For example, in traditional electricity markets, a significant portion of electricity price consists of electricity surcharges and taxes. However, as renewable energies typically have very low marginal costs [11], prosumers can reap more profits by suitably setting prices for their energies. Nonetheless, pricing mechanisms need to reflect the state of energy within the P2P network, that is, a higher surplus of energy within the network should lower the energy price and vice versa. 4) Energy management system: While participating in P2P trading via a particular bidding mechanism, the energy management system (EMS) of a prosumer secures its supply of energy. To that end, an EMS has access to the real-time supply and demand information of the prosumer through the transactive meter based on which it develops the generation and consumption profile of the prosumer and subsequently decides the bidding strategy to participate in the trading on behalf of the prosumer. For example, The EMS of a rational prosumer may always buy energy in the microgrid market when the price per unit of energy falls below its maximum price threshold [13].
B. Elements in the physical layer 1) Grid connection: P2P trading can be done for both gridconnected and islanded microgrid systems. For balancing the energy demand and generation in a grid-connected system, it is important to define the connection points of the main grid. By connecting smart meters at these connection points, it is possible to evaluate the performance of the P2P network, for example, in terms of energy and cost savings [13]. For islanded microgrids, on the other hand, participants should have enough generation capacity to ensure an appropriate level of security and reliability in supplying energy to consumers.
2) Metering: Each prosumer should have appropriate metering infrastructure to be able to participate in P2P trading. In particular, each prosumer should be equipped with a transactive meter [13], in addition to a traditional energy meter. A transactive energy is capable of deciding whether to participate in the P2P market based on the demand and generation data as well as the information available about market conditions (price, total demand, total available generation, and network conditions). It can also communicate with other prosumers in the network by any appropriate communication protocol.
3) Communication infrastructure: In P2P trading, the major requirement of communication is the discovery of prosumers and information exchange within the network. Multiple P2P communication architectures exist in the literature including structured, unstructured, and hybrid architectures [26]. The choice of a communication architecture needs to fulfill the performance requirements recommended by the IEEE 1547.3-2007 for the integration of DER that include latency, throughput, reliability, and security [26].
C. Other elements 1) Market participants: For P2P energy trading, the existence of a sufficient number of market participants within the network is necessary and a subgroup of the participants needs to have the capacity to produce energy. The purpose of P2P energy trading affects the design of pricing schemes and the market mechanism and therefore should be clearly defined. Further, the form of energy (that is, electricity or heat) traded. 2) Regulation: The success of P2P trading in the future electricity market will probably be mostly governed by the regulation and energy policy. That is, governmental rules of a country decide what kind of market design will be allowed, how taxes and fees will be distributed, and how the P2P market will be into the existing energy market and supply systems. Thus, governments can support P2P energy markets to accelerate the efficient utilization of renewable energy resources and decrease environmental degeneration by regulatory changes. On the contrary, they can discourage the implementation of such markets as well if that impacts detrimentally current energy systems. An overview of the elements of P2P network is shown in 2.

III. P2P TRADING: OVERVIEW OF MARKET STRUCTURE
In contrast to the top-down approach of the current energy market, P2P energy trading would require reorganizing electricity markets within decentralized management and collaborative principle that will allow for a bottom-up approach to empower prosumers [17]. Now, to determine how energy trading can be conducted in a P2P network, as shown in Fig. 3, the market structures that have been proposed in the literature can be divided into three types: 1) Full decentralized markets; 2) Communitybased markets; and 3) Composite markets.
1) Fully decentralized market: In a fully decentralized P2P market, participating prosumers can independently and directly negotiate with one another to decide on the energy trading parameters without any centralized supervision. Such decentralization of a P2P market relies on bilateral contracts between individual prosumers as proposed in [27]. Through the designed contract, [27] captures both upstream-downstream energy balance and forward market uncertainty within the model. In [28], the authors propose another fully decentralized market for multi-bilateral economic dispatch, where prosumers with energy demand can choose their preferences for the type of energy source, such as local or green energy, for trading. Other examples of fully decentralized markets can be found in [11] and [29], where in [11], the authors discuss various properties of decentralized markets by referring to a test case of the Brooklyn microgrid. In [29], on the other hand, the authors propose a distributed approach based on the consensus and innovations method to coordinate local generation, flexible load, and storage devices within the microgrid to derive a distributed economic dispatch algorithm.
2) Community-based market: A community-based P2P market can readily be applied to community microgrids [30], [31] and group of neighboring prosumers [32], in which the members of the community share common interests and goals even though they are not at the same location. The members may work either in a collaborative [33] or a competitive manner [32]. In a community-based P2P market, each member generally trades its energy within the community through a community manager. Indeed, a peer may also choose to trade its energy with someone outside the community, in which the community manager has a function associated with the energy exchanged with the outside world. Thus, a community manager manages the trading activities within the community, for example, by mimicking the role of an auctioneer [32], and also acts as an intermediary between the community and rest of the system [17]. Under community-based P2P energy trading, the privacy of preferences and strategic schemes of each participant within the community are preserved [33]. Further, the preferences of different classes of prosumers are reflected in their choice of energy parameters to trade within the community [34]. A demonstration of a community-based market is shown in Fig. 3.
3) Composite market: A composite market is essentially a combination of fully decentralized and community-based markets in which each community and each single prosumer can interact with one another, while maintaining their own market properties. That is, on the one hand, each individual prosumer can engage in P2P trading between themselves, while also interacting with existing markets like fully distributed markets. On the other hand, a community manager can also oversee the trading inside a community. In such a market, prosumers may be nested into each other and form a community for trading within the neighborhood community. Examples of such markets can be found in [35] and [36]. Now, in a grid-connected system, a prosumer may need to deal with both regulated and deregulated P2P markets. Hence, how to integrate both of them in a single paradigm remains a challenge. Nonetheless, existing literature sheds some light on the possible ways for co-existence of such markets. For instance, in [4], the authors propose a three-party energy trading technique in which a community manager primarily participates in community-based P2P trading with the prosumers of its community in order to meet its demand for energy for maintaining different community facilities. However, the participation of the community manager in a regulated market for energy becomes necessary when it is unable to procure all required energy from the prosumers within a community. In that case, the community manager buys energy from a regulated market.
Another interesting discussion of a potential integration scenario is proposed in [6], in which prosumers primarily purchase their energy from a regulated electricity market as traditional customers. Now, when there is an extensive demand for energy from the grid, the grid sends a price signal to its selected prosumers to refrain from buying any energy from it for a specific period of time. Subsequently, prosumers form a fully decentralized P2P market among themselves and meet their demand for energy from their local generation. A graphical presentation of this market mechanism is shown in Fig. 4.

IV. P2P TRADING: OVERVIEW OF EXISTING CHALLENGES
Indeed, by participating in different energy market structures, on the one hand, the ultimate objective of P2P trading participants is to address a number of challenges related to energy trading including reducing the cost of energy usage, increasing and maintaining the sustainable use of renewable energy, and improving social engagement of prosumers. On the other hand, the decision making process of the prosumers to address these challenges are limited by the hard constraints imposed by the power network operators for ensuring the reliable operation of the power system without violating the voltage limit at prosumers' nodes, while keeping the overall network loss within reasonable limits. As such, what follows is an overview of how existing studies have developed P2P trading schemes as viable energy management techniques to solve various significant challenges of future smart grid.

A. P2P Trading Challenges in Virtual Layer
Studies proposed in the existing literature mainly focus on designing P2P energy trading mechanisms based on suitable pricing schemes that can enable participation of an extensive number of prosumers. Financial transactions are required to be securely conducted without involving a third party manager, while, at the same time, the trading should contribute to the achievement of desirable objectives of balancing local supply and demand, reducing prosumers' energy costs, and peak load shaving. As such, based on the focus of the study, the existing literature related to the virtual layer platform can be divided into five general categories as outlined bellow.
1) Reducing cost of energy: First category of studies propose how P2P trading can reduce prosumers cost of energy. Essentially, P2P trading enables small-scale prosumers with distributed energy resources to sell their excess energy, if any, to prosumers with energy deficiency, which has been shown to be very effective in reducing energy cost significantly [37], [38]. Indeed, to facilitate such a trading mechanism, interaction among participating prosumers is the key [30], [40], [39], [41]. The performance of P2P in terms of cost savings can further be improved if the batteries incorporated within the system also participate in the market [42], [43], [44]. It is important to note that P2P trading is effective in reducing prosumers' costs for a number of energy trading scenarios including open market urban and remote systems [45], fully decentralized systems [9], [46], and community-based microgrids [42].
2) Balancing local generation and demand: The reduction in energy cost in P2P trading is due to its ability to enable prosumers with deficiency to meet their demand by buying the required energy from prosumers with energy surplus at a cheaper rate [4], [3] compared to the traditional market. However, such trading in a local environment necessitates the balance of supply and demand of energy within the community, which is the focus of the second category of studies. Now, for balancing the demand and supply, a ledger is necessary that can track all the transactions as well as the available supply from and demand of each participating prosumers. In P2P trading, this is currently achieved by using blockchain based platforms, as shown in [25], [47], [48] and [49]. Under the blockchain platform, prosumers learn the energy usage pattern of different sellers and buyers [50], manage their own energy consumption through residential demand response schemes [51], and then trade with one another, whenever applicable, within the local community [30] to keep the balance between supply and demand. Indeed, if there is still an imbalance between the supply and demand, that can be fulfilled by the grid [3], community storage [52], or diesel generator [80] in expense of higher costs.
3) Incentivizing & engaging prosumers: Clearly, to successfully reap the benefits explaining in the previous two sections, prosumers need to be actively involved in the trading mechanism [53]. This is only possible if prosumers find outcomes of the P2P trading beneficial for them. Hence, the mechanisms need to be prosumer-centric [9] (also, known as consumercentric [81]). The third category of existing literature devote its efforts to determine how to incentivize prosumers to extensively participate in P2P trading. Under this category, a large number of techniques have been proposed to ensure prosumer-centric delivery of outcomes including multi-class energy management [34], motivational psychology [3], bilateral contract theory [27], [54], reinforcement learning [56], [50], game theory [3], predictionintegrated double auction [57], consensus-based approach [28], and aggregated battery control technique [42], [55].
4) Developing pricing mechanism: Extensive prosumers' engagement in P2P trading and the subsequent benefits exclusively depend on the financing transactions among the participating buyers and sellers in the trading. Therefore, there is a need for innovative pricing schemes that are particularly applicable for P2P trading, which is the main aspect of the fourth category of study in the existing literature. For example, in [24], a credit-based pricing scheme is proposed for fast and frequent

Reducing cost of energy
To help reduce prosumers cost of energy by enabling small-scale prosumers with distributed energy resources to sell their excess energy to prosumers with energy deficiency.

Voltage & capacity constraint
To prevent over voltage and reverse power flow issue due to P2P trading.
[72], [15], [73], [34] System strength To understand the impact of increased use of renewable energy resources on the system strength of the power network.
[74], [75], [76], [77], [78], [79] energy trading. Based on different type of prosumer classes, a distributed price-directed optimization scheme is studied in [34]. A discrimination pricing scheme suitable to deploy in P2P network is discusses in [58]. Other example of different pricing schemes can also be found in [59] and [60]. 5) Identifying uncertainty and asynchronicity: While P2P markets have substantial advantages in terms of product differentiation, customer involvement, and low transaction costs, the market outcome could be suboptimal if interaction and negotiation mechanisms are not adequately designed. In particular, when a large number of prosumers engage in P2P transactions, computation and communication complexity issues must be resolved for robust system operation. As such, extensive computational analysis of existing decentralized and distributed algorithms is provided in [61]. It is identified that both computation and communication complexity impact the average time per iteration. Computation delays appear in cases of non-performing hardware and solving complicated optimization sub-problems. Communication delays are caused by bandwidth limits or internet traffic.
Other examples of such studies can be found in [62] and [63].
6) Securing transactions: To seamlessly engage prosumers to perform P2P trading, the financial transactions among themselves need to carry out securely. Further, the buy and sell orders and price information also need to be available over a secured platform for the prosumers to be incentivized and participate in the trading [64]. As such, the fifth and final category of studies, as outlined in this paper, deal with securing P2P transactions over the virtual layer platform. Different types of secured transactions are modeled based on the blockchain platform. For example, consortium blockchains are implemented in [25] and [24] for conducting P2P trading for electric vehicles and Industrial Internet-of-Things respectively. For energy trading in a residential community, some popular examples of secured transaction platform include Hyperledger [48], Elecbay [10], smart contracts [23], [47], Ethereum [65], and multi-signature blockchain [66].
We note that other than the discussed categories, P2P trading is also conducted to achieve peak load shaving [82] and setup virtual power plant [8] to provide ancillary services to the grid. A summary of the existing studies that deal with P2P trading in the virtual layer platform is given in Table I.

B. P2P Trading Challenges in Physical Layer
The state-of-the-research in the virtual layer platform has laid the foundation for performing P2P trading in the energy network by capturing decision making process of prosumers in secured and transparent energy trading platforms as well as devising pricing scheme to ensure their extensive participation. However, once the decision of the energy trading parameters is established at the virtual layer, the actual transfer of an agreed amount of energy is transferred over the physical layer. Now, the power system puts hard constraints on the exchange of energy over its network [14]. As a consequence, if the decision making process in the virtual layer platform does not consider the potential impact of P2P trading of energy on the physical layer platform, the transfer of energy may violate a number of technical constraints. For example, in [68], we discuss the feasibility of P2P trading in a grid-connected power network, in which it is shown that some of the bus voltages may exceed the network imposed voltage limit and compromise the security and reliability of the network if P2P trading is coordinated ignoring the constraints of the network.
Given this context, recently, there has been a growing interest to address challenges that may impede the transfer of energy over the physical layer platform of P2P networks. In particular, three types of network challenges have been being studied in the existing literature: 1) Violation of voltage and capacity constraints, 2) increase in network power loss, and 3) loss of system strength. An overview of these challenges is illustrated in Fig. 5.

1) Violation of voltage & capacity constraints:
Since, residential users who act as prosumers are connected to low voltage distribution systems, their active participation in P2P trading could cause an over voltage issue [68] and reverse power flow [69]. To combat such cases, a novel methodology based on sensitivity analysis to assess the impact of P2P transmission on the network and the subsequent cost with the associate energy exchange is studied in [14]. Now, the inverters installed within the prosumers' premises primarily responsible for pushing power to the network and extensive transaction of energy over the P2P network would obviously increase the load on the inverters. This can be reduced by exploiting grid voltage support algorithms for smart photovoltaic inverters, based on distributed optimization and peer-to-peer communication [70]. Another resulting detrimental impact of pushing power by an extensive number of prosumers in the network could be the operational overhead, which can increase the expense of energy transportation due to the requirement of a long chain maintaining of many blocks [23]. A blockchain-based P2P trading scheme exploiting local energy storage is shown to be effective to avoid such scenarios in [23]. Finally, how large prosumsers like community-microgrids that are operated in multiple voltage levels can participate in energy transfer is discussed in [71].
2) Increase in network power loss: While power exchange between sellers and buyers via P2P trading could increase the node voltages and overload the network capacity, it inevitably incurs losses as well. Consequently, this entails extra energy amounts and costs, above the local net demand, that needs to be produced and recovered by each market entry [72]. To that end, a graph-based loss allocation scheme to harmonize the physical attributes of the low voltage distribution grid is proposed and tested in [72]. Another cost allocation mechanism is proposed in [15], in which costly incentives are used to allocate P2P market related grid costs to the participants by the system operator. In this allocation process, a degree of freedom is given to the system operator to reach cost recovery. Other than cost allocation, another interesting mechanism to reduce the loss during P2P trading could be to choose an optimal power routing strategy [73]. By doing to, as shown in [73], it is possible to optimize power dispatching with the minimum power loss ratio between the power seller and buyer within the P2P network. Finally, energy classes are introduced in [34] to allow energy to be treated as a heterogeneous product and to coordinate P2P energy trading to minimize the cost associated with network losses.
3) Loss of system strength: Synchronous generators make major contributions to re-stabilize power systems following voltage/frequency disturbances by providing system strength and inertia [74]. However, as technologies like P2P trading penetrate the market, the growth of renewable energy sources within the system has been extensive. This necessitates the retirement of a large number of synchronous generators in recent times. As a consequence, maintaining system strength in renewable dominated power networks is becoming more and more challenging [75]. A typical example of system failure due to lack of system inertia can be found in the recent blackout in South Australia [76].
As such, the necessity of investigating the impact of renewable energy sources on the system strength has become very important in the current context. Some example of such studies can be found in [77], [78] and [79]. In [77], a real-time method is designed for solar plants that coordinates photovoltaic inverters and battery storage systems in order to provide voltage regulation. The authors in [78] propose a site-dependent short-circuit ratio to analyze the system strength and voltage variability of renewable dominated power systems. Finally, [79] considers the characteristics of diesel engines such as time-delay management, spinning reserve strategies, and ramp rate to develop an optimal photovoltaic-storage control strategy and capacity in order to combat the variability of photovoltaic output. Now, clearly, implementing P2P trading in power system networks is challenging. As such, to deliver trading schemes that address the challenges of both virtual layer and physical layer platforms simultaneously, a number of technical approaches have been adopted. To this end, what follows in the next section is an overview of technical approaches that have been proven to be effective in modeling P2P trading in the virtual and physical layer platforms.
V. P2P TRADING: OVERVIEW OF TECHNICAL APPROACHES Based on the approaches adopted by recent studies, four general techniques can be identified as the main contributors to the design of existing P2P energy trading schemes. They are 1) game theory, 2) auction theory, 3) constrained optimization, and 4) blockchain. An overview of different technical approaches adopted by existing studies is summarized in Table II. A. Game theory 1) Preliminary: Game theory is a mathematical tool that analyzes the strategic decision making process of a number of players in a competitive situation, in which the decision of action taken by one player depends on and affects the actions of other players [87]. Game theory can generally be divided into two categories: non-cooperative games and cooperative games.
Non-cooperative game: In non-cooperative games, the strategic decision-making process of a number of independent players that have partially or completely conflicting interests are analyzed to determine outcomes that are influenced by their actions. In such games, players take their decisions without communicating with one another. Any cooperation that may arise in a noncooperative game cannot be a result of either communication or coordination of strategic choices among players [88].
In general, two types of non-cooperative games have been used for designing energy trading schemes: static games and dynamic games. In a static game, players take their actions once only, either simultaneously or at different times. In a dynamic game, on the other hand, time plays a central role in the decision making process of each player. Players in a dynamic game act more than once and have inputs regarding the choices of other players.
The most popular solution concept of a non-cooperative game is the Nash equilibrium [89]. Essentially, a Nash equilibrium refers to a stable state of a non-cooperative game in which no player can be better paid off by unilaterally deviating from its action, provided all other players are also taking their Nash equilibrium strategies. For instance, let a static game Γ be defined by Γ = {N , s n , U n }, where N is the set of all players participating in the game, s n is the vector of strategies of player n ∈ N , and U n is the utility function of n that reflects the benefit that the player n can reap by choosing a strategy s n . Now, the Nash equilibrium of Γ can be defined as Here, s * −n is the strategy vector of players in N \ {n}.
A particular non-cooperative game that has extensively been used to design P2P trading in the literature is the Stackelberg game [89]. A Stacklelberg game is essentially a strategic game in which at least one player is defined as the leader who makes its decision first and commit a strategy before other players. Other players, on the other hand, act as the followers in the game, who optimize their strategies in response to the action taken by the leader. The solution concept of a Stackelberg game is the Stackelberg equilibrium, in which followers participate in a non-cooperative Nash game among themselves and reach a Nash equilibrium in response to the Leader's decision. At the Stackelberg equilibrium, neither the leader nor any follower has any incentive to deviate from its chosen strategy [32], [6].
Cooperative game: Cooperative games, also known as coalitional games, deal with incentives that can make independent decision makers to act together as one entity to improve their position in the game. The most common form of coalitional game is the characteristic form [88], where the value of coalition is determined by the members of the coalition irrespective of the structure of the coalition. Now, coalition games can be classified into three types.

a) Canonical coalition game:
In canonical coalition games, forming a grand coalition with all players is never detrimental to any participant of the game. Consequently, the main objectives of such a game is to determine whether or not a grand coalition can be formed, to investigate if the grand coalition is stable, and to formulate a fair revenue distribution scheme for distributing the gains of coalition among the players. The most commonly considered solution concept of a canonical coalition game is the core [88]. Meanwhile, for revenue distribution, the most popular methods include the Shapley value, the Kernel, the nucleolus, and the strong epsilon-core.
b) Coalition formation game: The objective of static coalition formation game is to study the network coalitional structure. In a dynamic coalitional game, on contrary, the game is subject to environmental changes, including a change in the number of players or a variation in network topology. Therefore, the main objective of this type of dynamic game is to study the formation of a coalitional structure through players' interactions and inquire the properties of the structure and its adaptability to environmental variations [13].
c) Coalitional graph game: Coalition graph games deal with the connectivity of communications between players of the game. The main objectives are to derive low complexity distributed algorithms for players who want to build network graphs and to study the properties of the graphs [88].
2) Game theory for P2P trading in the virtual layer: In the virtual layer platform, game theory has been extensively used to obtain different objectives that are outlined in Section V-A2. For example, Stackelberg game has been used to reduce the cost of energy [30], [39], [43] and to design suitable pricing scheme for secured transaction in P2P trading [24]. The application of non-cooperative Nash games in P2P trading can be found for reducing energy cost [46], balancing local generation and demand [47], [10], [49], encouraging prosumers' participation in the trading [27], [83], improving the security of transaction [64] and peak shaving [82]. Finally, the authors in [40], [84], [3], and [9] demonstrate how the framework of a canonical coalition game can be used to obtain reduction in energy cost via balancing local generation and demand, fairness in deciding the trading price, and increased participation of prosumers in P2P trading respectively.
3) Game theory for P2P trading in the physical layer: In the physical layer platform, however, the application of game theory has been limited so far. One application of a multiple-leadermultiple-follower Stackelberg game can be found in [85] with an objective to study the influence level of transmission losses on trading behavior of retailers and consumers. In particular, the authors propose a credit rating based optimal pricing and energy scheduling model by considering retailers as leaders and consumers as followers. It is shown that transmission losses cannot be ignored in energy trading, which, if avoided, could result in a large difference between actual power received by consumers and their demands.

Game theory
To capture the competition and cooperation between different participants of P2P energy trading market to deliver a solution that is stable, sometime optimal, and mutually beneficial for all involved parties Stackelberg game, coalition formation game, canonical coalition game, noncooperative Nash game, generalized Nash game.

Auction theory
To capture the interaction between a number of sellers and buyers of a P2P market so as to enable them to trade their electricity in a step-by-step fashion.

Constrained optimization
To use mathematical programming technique for optimizing the parameters of P2P trading under different hard and soft constraints imposed by the market and power system.
(2) Buyers are arranged in a decreasing order of their reservation bids. (3) Once the sellers and buyers orders are ordered, the aggregated supply and demand curves are generated that meet at a intersection point. (4) The intersection point establishes the auction price and the number of seller and buyers that eventually engage in the market trading process. In the double auction process, the sellers and buyers need to truthfully report their reservation prices and bids for efficient operation of the market. Hence, auction mechanisms need to satisfy the properties of individual rationality and incentive compatibility [32]. Now, a double auction scheme is said to possess the property of individual rationality if the utility that a prosumer receives for participating in the auction mechanism cannot be improved otherwise, provided all other prosumers in the auction are choosing their selected strategies. Meanwhile, a double auction mechanism is called incentive-compatible, if every participant of the auction mechanism can achieve the best outcome to themselves by acting upon their true preference that they revealed during the above mentioned Steps 1 and 2.
2) Double auction for P2P trading in the virtual layer: In the virtual layer platform, double auction technique has been used by [25], [51], [82], [57] to achieve objectives of balancing local generation and demand, shaping the demand at the peak hour, and improving prosumers engagement in the trading. For example, the authors in [25] propose a consortium blockchain enabled double auction mechanism to decide on the electricity price and traded energy amount by the prosumers in order to maintain the balance between the local generation and supply. For a similar purpose, an optimal bidding strategy via a double auction is proposed in [51] for residential houses. In [82] and [57], the authors exploit a Nash bargaining model and data-driven prediction-integration models respectively to design the double auction frameworks with the purpose of reducing peak demand and improving prosumers' engagement in P2P trading.
3) Double auction for P2P trading in the physical layer: The application of double auction to address problems related to physical layer platform is elaborated in [14]. In particular, [14] propose a decentralized P2P architecture that can facilitate local energy trading. In designing the scheme, the authors explicitly take into account the underlying network constraints at the distribution level. The market mechanism is developed using a continuous double auction technique, a simple market format that matches parties interested in trading, rather than holding any of the traded commodity itself. As such, this scheme is very well suited for P2P exchanges. It is further shown in [14] that in continuous double auctions comprising bidders with rational goals (i.e. participants only trade at a profit), trades are always Pareto-improving. Subsequently, the continuous double auction moves towards an allocation that is Pareto efficient with a highly efficient allocation of commodities [92].
C. Constrained optimization 1) Preliminaries: A number of constrained optimization techniques have been used to design P2P energy trading schemes. Examples of some techniques include linear programming (LP), mixed integer linear programming (MILP), alternating direction method of multipliers (ADMM), and nonlinear programming (NLP). a) LP: LP is a mathematical programming technique to achieve the optimal outcome in a mathematical model, in which all requirements are presented by linear forms. Any LP can be expressed in its canonical form as such that Ax ≤ c, and x ≥ 0. Here, x is the vector of variables to be determined, c and b are coefficient vectors, A is a matrix of coefficients, and (·) T is the transpose of (·). The expression in (1) is called the objective function and the inequalities Ax ≤ c and x ≥ 0 are known as the constraints that need to be satisfied. b) MILP: MILP is a special case of integer linear programming, in which only some of the variables are constrained to be integers and, unlike integer linear programming, other variables are allowed to be non-integer. Mathematically, an MILP can be expressed as same as an integer linear programming subject to Ax + s = c, x ≥ 0, s ≥ 0, and x ∈ Z n , where some of the entries are not integer. c) ADMM: ADMM is an algorithm that solves convex optimization problems by breaking them into smaller pieces, each of which are then easier to handle [93]. Essentially, ADMM is a variant of augmented Lagrangian scheme that uses partial updates for the dual variables. This can be mathematically expressed for a maximization problem as subject to Ax + Bz = c, where is z is a vector of second variables. Thus, ADMM can have two objectives with two separate sets of variables. d) NLP: NLP is a mathematical technique that solves an optimization problem, in which the objective function is nonlinear and/or the feasible region is determined by nonlinear constraints. In maximization form, the problem can be expresses as that in (1) with nonlinear objective function and/or nonlinear constraints.
2) Constrained optimization for P2P trading in the virtual layer: Different constrained optimization techniques have been heavily utilized in the literature to design P2P energy trading techniques in the virtual layer platform. For example, in [55], the authors exploit a LP approach to design a novel multienergy management strategy based on the complementarity of multi-energy demand with the purpose to explore optimal energy scheduling problems of prosumers. An MILP technique is used by [44] to optimize the use of energy generated from the rooftop solar with battery for P2P energy trading. A multi-class energy management technique with the purpose of P2P trading is designed in [34] using ADMM optimization technique. The application of NLP in [42] is for designing a P2P energy sharing mechanism in a community through aggregated battery control. Further use of constrained optimization in P2P trading can be found in [37] and [54].
3) Constrained optimization for P2P trading in the physical layer: In the physical layer, the most popular constrained optimization technique has been ADMM as can be seen from its application in [15] and [70]. In [15], authors discusses a decentralized consensus ADMM to develop a cost allocation mechanism that enable prosumers to share the cost of using common infrastructure and services for P2P trading. Meanwhile, ADMM is utilized in [70] to locally optimize reactive power compensation and active power curtailment of each inverter participating in the P2P trading for voltage control purposes. Besides, ADMM, the application of constrained optimization has also been exploited in [73] for addressing network loss issues at the physical layer.
D. Blockchain 1) Preliminaries: Blockchain, which was first introduced in [94], is a distributed data structure that is replicated and shared among the members of a network. With blockchain in place, applications that could previously run only through a trusted intermediary, can now operate in a decentralized fashion, without the need for a central authority, and achieve the same functionality with the same amount of certainty [95]. Thus, given the properties of P2P trading, blockchain has profound applications in the future energy network. This has led to establish a number of blockchain based platforms for P2P energy trading in recent times.
a) Smart contracts: The smart contract is essentially a computerized transaction protocol that executed the terms of a contract [96]. By translating contractual clauses into code and embedding them into property that can enforce them, the need for trusted intermediaries between transacting parties, and the occurance of malicious and accidental exceptions can be minimized [95]. Within the blockchain context, smart contracts are scripts stored on the blockchain with a unique address [86]. A smart contract is triggered by addressing a transaction to it. It then executes independently and automatically in a prescribed manner on every node in the network, according to the data that was included in the triggering transaction.
b) Elecbay: The elecbay is a software platform dedicated to the development of P2P trading within a microgrid. Each order contains the information including the time period for the energy exchange, the amount of energy to be exchanged, the price of the energy to be exchanged and the details about the seller and buyer. After the orders are placed by peers, they are either accepted or rejected by Elecbay, based on the network constraints. After the order acceptance or rejection, each peer generates/consumes the amount of energy as promised in the accepted orders and energy is delivered through the distribution network. Further details of the platform can be found in [10].
c) Consortium blockchain: The consortium blockchain is a specific blockchain with multiple authorized nodes to establish the distributed shared ledger with moderate cost [25]. It is established on authorized nodes to publicly audit and share transaction records without relying on a trusted third party. During P2P trading, energy transaction records among peers are uploaded to the authorized nodes after encryption. The authorized nodes run an algorithm to audit the transactions and record them into the shared ledger. This ledger is publicly accessed by participating peers and authorized nodes connected to the consortium blockchain. d) Hyperledger: The hyperledger is an open source collaborative effort, hosted by the Linux Foundation, to advance cross-industry blockchain technologies [97]. It uses a consensus mechanism to create a transparent and non-tampering distributed ledger. According to [98], the core module of the Hyperledger IBM runs in an open platform called Docker. When a peer within the system wants to trade, it logs into the system through the blockchain system terminal and submits the appropriate transaction. After the transaction is submitted, the transaction information is sent to a power trading unit to analyse and initiate the transaction. The information is mapped in the database in the form of key and value for user query. When mapping is complete, the power trading unit carries out the dispatching to complete the power trading. e) Ethereum: The Ethereum, which was launched in 2015, is a programmable public blockchain with a native cryptocur-rency called Ether [99]. While the structure of Ethereum is very similar to that of bitcoin, a big difference is that in ethereum nodes also store the most recent state of each smart contract, in addition to all other ether transactions. For each ethereum application, the network needs to keep track of the the current information of all of these applications, including each peer's balance, all the smart contract code, and the location where it's all stored. Like bank account funds, ether tokens appear in a wallet, and can be ported to another account.
Besides the outlined classification, other modified versions of blockchain based approaches have also been used for securing energy trading in smart grid. Examples of such modified schemes can be found in [40] and [66].
2) Blockchain for P2P trading in the virtual layer: In the virtual layer, existing studies have exploited a large variation of blockchain based platforms to ensure secure and transparent energy trading. In [40], the authors propose a blockchain based system, which is based on a parallel double-chain combined with a high frequency verification mechanism to enable a trusted and secure settlement of electricity trading transactions. To achieve a similar energy trading performance among plug-in hybrid electric vehicles within an electricity market, [25] and [24] develop trading platforms using consortium blockchain. A multi-signature based blockchain is designed in [66] to provide transaction security in decentralized energy trading in smart grid without reliance on trusted third parties. Using smart contracts, secured P2P trading between energy storage systems and heterogeneous end-users from residential, commercial, and industry sectors are performed in [47] and [49] respectively. In [48], the authors utilize the IBM hyperledger fabric architecture to create an operational model of crowdsourced energy systems in distribution networks considering various types of energy trading transactions and crowdsources. For secured energy trading in microgrids, Elecbay is proposed in [10]. Further application of blockchain based platforms for decentralized energy supply and demand management via P2P trading can be found in [59], [64], [65] and [100].
3) Blockchain for P2P trading in the physical layer: Since the physical layer is mainly responsible for accommodating the transfer of energy from sellers to buyers after the secured transactions, the focus of how the security of such transactions may impact physical layer performance is not necessary and therefore has not been reported to date. Now, while game theory, double auction, constrained optimization, and blockchain have been extensively used in the literature for designing P2P energy trading scheme, a number of new other methods are also becoming popular. Examples of such emerging techniques include graph theory [72], heuristic multi-agent simulation [101], artificial intelligence [56], [50], and activity based models [38].

VI. DISCUSSION ON FUTURE RESEARCH DIRECTION
Note that despite extensive attention in the last couple of years, energy-management research for peer-to-peer networks is relatively new. Hence, much work is yet to be done before the integration of peer-to-peer energy trading into the current energy system. To that end, what follows is a description of a number of challenges that require further investigation as future research topics in the area of P2P trading. An overview of these challenges is also illustrated in Fig. 6. a) Network charge identification: Unlike traditional electricity systems, prosumers do not use the entire energy network for peer-to-peer trading. Therefore, the way they are currently being charged in their electricity bills needs to be researched and revised for billing them under a peer-to-peer trading paradigm. b) Large scale network trading and simulation: Since the flow of electricity cannot be regulated, it is unlikely for a very large network that the intended receiver will receive the actual power that has been pushed to the network by the sender. Hence, the power loss due to peer-to-peer trading would be different, which necessitates further investigation. Further, P2P trading algorithms need to be simulated for large-scale realistic power system model to observe the impact of computational complexity on the conduct of trading in such a large system. c) Benefit to the grid: Consumer-centricity of peer-to-peer trading has been well established in recent literature. However, the benefit of peer-to-peer energy trading to the distribution grid also needs to be demonstrated. Further, the grid should also have the provision to participate in P2P trading either as a generator or service provider, if necessary. This will be particularly important to pave the way for this new approach to be approved as a part of the energy system. d) Ancillary service to the grid: Peer-to-peer trading has demonstrated potential to form coalitions between the prosumsers of the network to achieve a reliable and cost-effective supply of energy. Now, it would be an interesting extension to investigate how such coalitions can help to provide ancillary services to the grid such as with virtual power plants.
e) Multi-level storage management: With P2P trading, it is expected that a community may have different types of storage facilities, including small-scale batteries at the prosumers premises, medium-scale community storage, and large-scale grid storage. Coordination between these storage devices in an economic way and developing suitable pricing mechanisms to conduct inter-storage energy sharing would be a very complicated problem. Therefore, innovative scheduling and optimization techniques need to be developed. f) Prioritizing stakeholders: Clearly, different stakeholders would be interested in exploiting prosumers' batteries to deliver different services to their customers and maintain network security. For example, generators may want to use them for reducing production volatility, Distribution Network Service Providers (DNSP) for demand constraint, and retailers may want to discharge the batteries to combat energy imbalances. Nevertheless, these actions could be conflicting with one another. Hence, P2P trading schemes need to be designed such that they do not affect participants' independence and benefits. g) Injection limit and market mechanism: At present, a cap is being set for each prosumer on the maximum amount of energy its inverter can send to the grid. This limits prosumers capacity to install larger capacity rooftop solar PV and earn more revenue. With P2P trading, prosumers can actively negotiate with one another on the amount of energy they can trade with one another and the pricing. Therefore, the injection limit needs to be flexible to extract the most benefits from such decision making processes. This necessitates the development of novel market mechanisms that will dynamically change the injection limit based on the supply and demand of energy within the network without impacting the network detrimentally. h) Unified model: At present, research are directed either to the virtual layer or to the physical layer. However, for a successful deployment of P2P trading within the network, it is important that requirements of both layers be addressed. Hence, there is a need for a unified model, which could capture this. This is particularly possible as blockchain based information systems make all real-time system information available to both prosumers and system operator. Thus, it could be possible for the system operator to assist the participants to take decisions in the virtual layer that do not contradict with the constraints in the physical layer. Nevertheless, the extent to which a system operator can influence prosumers' behaviors needs to be carefully articulated. Otherwise, the decentricity of P2P trading could be compromised.
i) Enabling data accessibility with privacy: Of significant importance to the performance of the P2P trading, both intra-community and inter-community, is statistically useful, and accurate, energy transaction and usage data being made available across communities, for better prosumers decision making. However, this accessible data needs to also provide privacy to each prosumer. Thus provably-private transformations, of communities? energy trading data, are required to facilitate data accessibility and required sharing, while providing sufficient statistical accuracy for interrogation of the data. This remains a key research challenge, as such deployment is highly dependent on the applied scenarios for the P2P trading, and also on the desired level of utility from the privacy-preserved data.
j) Inter & Intra-community trading: In P2P trading, a prosumer should have enough flexibility to decide whether it wants to trade with peers within its community (intra-community) or with someone external (inter-community). Market mechanisms for P2P trading should have policies and technologies ready to accommodate such flexibility.

VII. CONCLUSION
In this review article, an overview of existing research in peer-to-peer energy trading has been provided. As such, first, the background of peer-to-peer trading in energy networks has been discussed with specific emphasize on features of peer-topeer networks, market structure for peer-to-peer trading, and opportunities and challenges. Second, a systematic classification of peer-to-peer energy has been proposed based on the relevant challenges in both virtual and physical layers that have been addressed by the state-of-the-art research papers. Third, core technical approaches that have been extensively used in the literature have been identified and summarized. In addition, an overview of the application of these identified approaches for peer-to-peer trading in virtual and physical layers has been provided. Finally, this paper have discussed a number of interesting topics for researchers to work on in the future.