Towards Flexibility Trading at TSO-DSO-Customer Levels: A Review

The serious problem of climate change has led the energy sector to modify its generation resources from fuel-based power plants to environmentally friendly renewable resources. However, these green resources are highly intermittent due to weather dependency and they produce increased risks of stability issues in power systems. The deployment of different flexible resources can help the system to become more resilient and secure against uncertainties caused by renewables. Flexible resources can be located at different levels in power systems like, for example, at the transmission-level (TSO), distribution-level (DSO) and customer-level. Each of these levels may have different structures of flexibility trading as well. This paper conducts a comprehensive review from the recent research related to flexible resources at various system levels in smart grids and assesses the trading structures of these resources. Finally, it analyzes the application of a newly emerged ICT technology, blockchain, in the context of flexibility trading.


Introduction
Electricity generation has been one of the largest sectors in producing emissions due to the utilization of fuel-based power plants [1,2]. The recent development in the energy sector has led to the large-scale use of renewable energy sources (RESs) in order to prevent climate change. Also, constant political pressure to decrease the amount of carbon emissions, as well as subsidization of RESs, has led to an increase in using renewable, distributed energy resources in the form of roof-mounted photovoltaic panels or small wind turbines in residential and commercial buildings.
Nevertheless, RESs are extremely volatile due to their dependency on weather conditions [3]. The power produced by renewables is highly variable and challenging to predict [4]. Therefore, the power system balancing between generation and load becomes also more challenging, and the risk of security and stability issues increases due to RESs. Traditionally, balancing issues in power systems have been related to the variability of loads and errors in the load forecasts due to the unpredictable nature of customer demand. The increasing penetration of renewables combined with increasing penetration of electric vehicles (EVs) in distribution systems will result in highly volatile net-load profiles. In other words, the growing penetration of RESs along with the entry of EVs in distribution networks will increase the fluctuations in power systems. Besides, the growing use of renewables instead of conventional generators reduces system inertia due to inverter-based interfaces which in turn deteriorates the system volatility and risk for stability issues [5,6].
In order to tackle the above-mentioned challenges, system operators need to increase the flexibility of the system through flexible resources [7]. There exist several definitions of flexibility in the context of power systems. One quite comprehensive definition describes the flexibility of power systems as the ability to adjust the operating point of the power system continuously and to resist the expected and unexpected changes happening in the operating conditions [8]. Hence, the flexible power system should adapt to the changes in both demand and generation in a timely and harmonized manner. On the other hand, flexibility can be also defined as the adaptability of the generation-or demand-based flexible resources to modify their behavior during operation in order to respond to external signals sending from the grid operators [9]. According to this definition, any resources which are located in the demandor generation-side, and can react to the system changes, can be considered as flexible resources.
Traditionally, large centralized generators were responsible for fulfilling the flexibility requirements of the power system by offering different ancillary services [10]. Quite recently, the possibility to utilize demand-side resources and loads for power-system-balancing-related ancillary services has also been considered more extensively. It means that the demand can follow the generation changes. This is typically considered as demand response (DR) and, for example, reference [11] presents a review from different possible DR classifications and definitions. In the literature also the effect of DR on market prices has been studied. For example, reference [12] presents a comprehensive survey from the potential of smart grids to provide DR-related services as well as from the potential benefits of DR in smart grids. Also, the role of advanced technologies in boosting the efficiency and the coordination of DR were also estimated in [12]. In addition, different advantages and challenges of DR were fully discussed in [13]. Residential DR resources, in particular, were taken into consideration in [14] which also reviewed the latest information and communication technologies supporting the utilization of this type of DR resource.
The most recent research has evaluated the flexibility by considering both generation-and demand-side resources. For example, an index for flexibility of DR units has been introduced and various classifications and forms of flexibility have been presented in [15]. Then, different flexibility products and markets have been classified by also considering their location [16]. However, all different flexible resources and system levels were not thoroughly considered [16]. An in-depth review of flexible ramping products (FRPs), which are mainly intended to the transmission-level networks (TSO), was presented in [17]. Respectively, [18] also reviewed feasible technologies for improving transmission-level flexibility. Thus, the flexibility of distribution networks was not within the scope of these papers. On the contrary, there has been a thorough review of forecasting, controlling and planning of flexibility in active distribution networks, but the TSO level was beyond the scope of the research conducted by [9].
The main aims of the paper can be explained as the following: • Conducting a comprehensive review of conventional as well as new potential flexible resources located at different levels of power systems including transmission-level, distribution-level (DSO) and customer-level. At each level, the system operator has different responsibilities which make them deploy different kinds of flexible resources in order to enhance the flexibility of the power system.

•
Seeking the existing flexibility trading structures of different-level systems proposed by the recent research. The trading structures aim to facilitate injecting flexibility to the DSO-, TSO-, and customer-level networks. • A newly emerged ICT technology, blockchain technology, is analyzed in this paper and its merits and applications in the flexibility trading are discussed as well.
Since market and trading structures at each level can be different depending on the different-sized resources with various behaviors and objectives, the flexible resources and trading structures of each level are evaluated distinctively. To the best of the authors' knowledge, there do not exist any previous studies which introduce different-level flexible resources and the trading structures of these resources, especially in the customer-level context. The rest of the paper is organized as follows. Section 2 reviews flexibility at the transmission system operator (TSO) and network level. Section 3 introduces flexible resources and trading structures at the distribution system operator (DSO) and network level. Customer-level flexibility is discussed in Section 4. Section 5 analyzes the applications of blockchain technology in flexibility trading. Finally, a summary of the paper is done in Section 6.

Flexibility at TSO Level
The main responsibilities of TSOs in power systems are related to generation and demand balancing and transmission-network congestion management. Balancing and congestion management can consist of different issues related to, for example, the hierarchical (primary, secondary, tertiary) frequency and voltage control [19]. The actions associated with congestion management are completely dependent on the states of the system. Flexible ramping products (FRPs) along with ancillary service products help the independent system operator (ISO) or TSO to regulate the network frequency and voltage aiming to maintain the security of the power system.
There should be a distinction between ancillary services and FRPs deployed by the ISO [20]. Although both of these products can be considered as market-based, FRPs are used to address uncertainties of net loads in the future dispatch time slots while ancillary regulation services are utilized to capture uncertainties related to the error of forecast in a matter of seconds. Besides, some ancillary services such as operating reserves are planned to react to a sudden loss of supply, known as contingency reserves. These ancillary service products can only provide the network with upward regulation whereas FRPs are able to present ramping in both directions by flexibility ramp down (FRD) and flexibility ramp up (FRU) products. The optimal FRPs are proposed to be purchased in the existing real-time markets. However, ISOs often provide a separate market for reserves which increases the total costs.
ISOs can combine congestion management with the balancing market or perform them in separate markets [21]. Although the separate markets may lead to higher prices, they will create less confusion over cost management of two different flexibility products. Besides, the separate markets may need less complex governance and implementation considering the management of transmission networks. On the other hand, the combined flexibility markets would enjoy more liquidity as well as lower costs in comparison with the separate ones.
Cooperation among TSOs is also needed in the operation of transmission networks. For instance, it has been proven that optimal cooperation between TSOs would lead to enhanced flexibility in transmission networks and could simultaneously enable higher penetration of renewables into the power system [22]. In addition, the cooperation between 34 European countries has been presented with the aim to increase the security and sustainability of the interconnected European power system as well as to develop the European energy markets [23].
TSOs use different kinds of flexible resources and ancillary/flexibility services in order to increase the flexibility of transmission networks. These resources can be connected to low-voltage (LV), medium-voltage (MV) or high-voltage (HV) networks. In addition to large-scale flexibility providers/aggregators, flexibility provision potential of aggregated small-scale (LV and MV network connected) customers is also increasingly necessary in order to fulfill the future TSO-level flexibility needs. The next section presents the potential flexible resources in the TSO-level power system.

Flexible Resources at TSO Level
TSO-level flexible resources can be categorized into supply-and demand-side resources. The demand-side resources consist of aggregated customers who can adjust their demand to provide the transmission grid with flexibility and aggregated prosumers equipped with a larger flexibility mix consisting of renewable resources, electric vehicles (EVs) and/or storages. Supply-side resources include traditional generators, wind power producers (WPPs), virtual power plants (VPPs) and any large-scale generators which are able to react to the TSO's flexibility needs. Figure 1 illustrates different potential flexible resources in TSO-level networks. Various studies exist related to flexible resource utilization for TSO needs. For example, customers have been proposed to be aggregated and react to the price signals sent by the TSO. The TSO determines the price signals taking into account its estimation about available demand flexibility [24]. In [25], customers were classified according to their elasticity and preferences in order to quantify demand flexibility for balancing purposes in transmission networks. Also, customers' responsiveness to time-varying prices was analyzed to show how much these resources could contribute to ancillary service requirements.
EV's contribution to flexibility services provision has been considered [26]. Two different types of EV participation have been considered [26]. In the first case, aggregated EVs only participated in the ramp markets. In the second case, the focus was on the EV's ability to cooperate with traditional generators in order to improve their ramp rate. The results based on EV contribution to providing flexibility services demonstrate that the system would have a higher probability to respond to the ramp requirements. For instance, it states that the system would be able to deal with more uncertainty and variability within the probability of 99.9%. Driver behavior, along with EV stochastic mobility, were also taken into account to enhance the efficiency of the proposed models. Another study developed a bi-level model in order to investigate the potential of EV aggregators to present FRPs in the spot markets [27]. It concluded that this kind of aggregator would be able to give the power system a considerable economic advantage [27]. quantify demand flexibility for balancing purposes in transmission networks. Also, customers' responsiveness to time-varying prices was analyzed to show how much these resources could contribute to ancillary service requirements. EV's contribution to flexibility services provision has been considered [26]. Two different types of EV participation have been considered [26]. In the first case, aggregated EVs only participated in the ramp markets. In the second case, the focus was on the EV's ability to cooperate with traditional generators in order to improve their ramp rate. The results based on EV contribution to providing flexibility services demonstrate that the system would have a higher probability to respond to the ramp requirements. For instance, it states that the system would be able to deal with more uncertainty and variability within the probability of 99.9%. Driver behavior, along with EV stochastic mobility, were also taken into account to enhance the efficiency of the proposed models. Another study developed a bi-level model in order to investigate the potential of EV aggregators to present FRPs in the spot markets [27]. It concluded that this kind of aggregator would be able to give the power system a considerable economic advantage [27].   Traditional generators have usually had the responsibility of providing flexible ramping services to the TSO-level network by submitting their available ramping capacities as well as operational limits to the TSO or ISO. Afterward, the ISO/TSO jointly clears these capacities with energy and ancillary services markets to overcome uncertainties that jeopardize the system security [28]. Conventional units have been proposed to be utilized for generation ramping reserve and generation capacity reserve [29]. The ramping capability of a generator would be locked when scheduling the security-based economic dispatch. As a result, it forms the generation ramping reserve while the unused capacity of a unit was considered as the capacity reserve.
Wind power producers (WPPs) were also considered as TSO-level flexible resources in the literature. Although the resources' low marginal costs may make them non-beneficial to be used for flexible ramping capacities, reference [30] proved that they would bring benefits for the system by eliminating the commitment of costly fast-start generating units. As the results indicate, introducing a WPP as a flexible resource has reduced the overall cost of the system by 5.5%. Wind power ramping products were also modeled in [31] which studied the impact of different forecasted values on the conditional distribution of WPPs' ramping. Wind power ramping products were also considered in [32] regarding the potential economic benefits of wind-power-based ramping products under various ramping reserve needs.
Storages are also very potential flexibility providers for future TSO needs. References [26,33] stated that the battery energy storage (BES) and plugged-in EVs might be the most suitable options to produce flexible ramping products due to their frequent usage and time-related constraints. Since ramp-based markets are cleared sub-hourly, the time-related limitations of batteries would be relieved. DR was also proposed to be used as a supplementary flexible resource which aim to make customers react to changing market conditions. Reference [20] proposed the aggregator of BES to participate in multi-product markets including FRP, energy and reserve products. The paper stated that it would be profitable for the aggregator to submit a part of its capacities for FRP purposes instead of taking part just in energy and reserve markets. Large bulk energy storages are also very potential flexible resources in future power systems [34] and the deployment of bulk energy storage with transmission-capacity expansion has been compared in the literature from a flexibility provision point of view.
DR has been also regarded as one of the most cost-efficient sources of flexibility [35], because of DR availability and ability to respond rapidly to the system changes. For example, in Singapore's electricity market, customers are allowed to bid their flexible demand to the markets [36]. Also, DR services like load shifting and curtailment have been introduced, which can be aggregated in power systems to help the system respond to real-time electricity prices [37].
In addition to the potential of the above-mentioned energy resources in providing flexibility to the transmission networks, some operational actions as well as technology and devices can be also employed to increase flexibility. For example, power electronics-based solutions like flexible AC transmission systems (FACTS) and high voltage DC (HVDC) are capable of improving the flexibility and controllability of transmission systems [18]. The combination of wide-area monitoring protection and control (WAMPAC) with FACTS devices and HVDC is able to react rapidly to the unexpected changes in active and reactive power flows [18]. Controlling power flows in transmission networks can be also performed through two other technologies like on-load tap changing (OLTC) transformers and phase-shifting transformers (PSTs) [38]. OLTCs are utilized to regulate the magnitude of voltages, leading to the proper control of reactive power flows [38]. These above-mentioned resources can provide flexibility services for the TSO-level networks, but they are not traded in market-based platforms.

Flexibilities Related Trading at TSO Level
The optimal FRPs are often proposed to be co-optimized with the existing energy and ancillary service markets. In the day-ahead market, security-based unit commitment (SCUC) and the real-time security-based economic dispatch (SCED) are employed to schedule the resources. There exist two basic methods in order to provide the TSO-level system with sufficient FRPs. The first method is to set Energies 2020, 13, 165 6 of 19 the system ramping capability related constraints so that the main objective function of the system does not change. The second method adds additional terms to the objective function of SCUC and SCED while setting constraints related to the ramping capabilities [17].
In most of the studies, flexible resources i.e., flexibilities, can voluntarily participate in the market in order to make profits. Moreover, opportunity costs are mainly paid to flexibility providers, i.e., they will receive as much profits as they could have made through providing energy. Accordingly, they do not need to submit separate bids for their offered flexibility capacities. Besides, it has been indicated that allowing flexibility to submit bids may result in false incentives as they prefer to take part in reserve markets with higher prices rather than the flexibility markets [39]. However, it has been proposed that FRPs can be also products with their own pricing which can send clearer signals to the market [40]. When it comes to pricing, the effect of various dynamic tariffs including time-of-use, real-time, critical peak pricing and emergency DR program tariffs on flexible ramp markets has been investigated [41].
In terms of trading timeframes, it would be better for flexibility markets to be settled in spot markets as FRPs are often procured from SCUC and SCED processes. Further, uncertainties coming from forecast errors are well-captured in spot markets. Firstly, the optimal amount of FRPs is obtained from SCUC in a way that it covers 15 min forecast errors [42]. Secondly, the incremental values of FRPs are determined through the real-time dispatch process in order to compensate for the 5 min forecast errors. In MISO (Midcontinent Independent System Operator) and CAISO (California Independent System Operator) markets, FRPs are implemented through both day-ahead and real-time markets so that they have a two-settlement system [17,43]. In MISO, FRPs are obtained from applying single-interval ramp-related constraints while CAISO considers several intervals ahead in order to calculate system ramping capabilities. With regard to ancillary services, there exist various timeframes depending on the type of services. Services that are related to emergency conditions should be provided in real-time or near real-time while the ones operating in steady-state conditions such as power flow optimizations can be used each day, month or even year [22]. The flexible resources associated with resource adequacy and grid developments are usually deployed for mid-and long-term planning which is done for many years ahead. Figure 2 shows the timeframes of flexibility services in TSO-level networks.
Energies 2020, 13, x FOR PEER REVIEW 6 of 19 does not change. The second method adds additional terms to the objective function of SCUC and SCED while setting constraints related to the ramping capabilities [17].
In most of the studies, flexible resources i.e., flexibilities, can voluntarily participate in the market in order to make profits. Moreover, opportunity costs are mainly paid to flexibility providers, i.e., they will receive as much profits as they could have made through providing energy. Accordingly, they do not need to submit separate bids for their offered flexibility capacities. Besides, it has been indicated that allowing flexibility to submit bids may result in false incentives as they prefer to take part in reserve markets with higher prices rather than the flexibility markets [39]. However, it has been proposed that FRPs can be also products with their own pricing which can send clearer signals to the market [40]. When it comes to pricing, the effect of various dynamic tariffs including time-ofuse, real-time, critical peak pricing and emergency DR program tariffs on flexible ramp markets has been investigated [41].
In terms of trading timeframes, it would be better for flexibility markets to be settled in spot markets as FRPs are often procured from SCUC and SCED processes. Further, uncertainties coming from forecast errors are well-captured in spot markets. Firstly, the optimal amount of FRPs is obtained from SCUC in a way that it covers 15 min forecast errors [42]. Secondly, the incremental values of FRPs are determined through the real-time dispatch process in order to compensate for the 5 min forecast errors. In MISO (Midcontinent Independent System Operator) and CAISO (California Independent System Operator) markets, FRPs are implemented through both day-ahead and realtime markets so that they have a two-settlement system [17,43]. In MISO, FRPs are obtained from applying single-interval ramp-related constraints while CAISO considers several intervals ahead in order to calculate system ramping capabilities. With regard to ancillary services, there exist various timeframes depending on the type of services. Services that are related to emergency conditions should be provided in real-time or near real-time while the ones operating in steady-state conditions such as power flow optimizations can be used each day, month or even year [22]. The flexible resources associated with resource adequacy and grid developments are usually deployed for midand long-term planning which is done for many years ahead. Figure 2 shows the timeframes of flexibility services in TSO-level networks.

Flexibility at DSO Level
With the arrival of renewables, smart metering, smart grid technologies, EVs, etc., the role of DSOs is going to change considerably. Traditional DSOs are recently and in the future burdened with various new responsibilities. First, they should, for example, handle the data received from smart meters, and manage and utilize them for the purpose of forecasting, risk management, scheduling and planning of distribution systems [44]. Second, managing local markets in the distribution systems level can be in the future one of the new responsibilities of the DSOs and they should simultaneously ensure that the system constraints are not violated. Feeder congestion management and reactive power (Q)-voltage (U) (i.e., QU-or Volt/Var) management for distribution network voltage control, are regarded as vital responsibilities of DSOs [45]. However, these are becoming more challenging due to increased amount of intermittent renewable-based generation and the growing number of EVs in the distribution system. As a result, DSOs also need more flexibility services in the future, e.g., from customers with production (prosumers), in order to provide infrastructure for EVs [46] and renewables-based distributed generation.

Flexibility at DSO Level
With the arrival of renewables, smart metering, smart grid technologies, EVs, etc., the role of DSOs is going to change considerably. Traditional DSOs are recently and in the future burdened with various new responsibilities. First, they should, for example, handle the data received from smart meters, and manage and utilize them for the purpose of forecasting, risk management, scheduling and planning of distribution systems [44]. Second, managing local markets in the distribution systems level can be in the future one of the new responsibilities of the DSOs and they should simultaneously ensure that the system constraints are not violated. Feeder congestion management and reactive power (Q)-voltage (U) (i.e., QU-or Volt/Var) management for distribution network voltage control, are regarded as vital responsibilities of DSOs [45]. However, these are becoming more challenging due to increased amount of intermittent renewable-based generation and the growing number of EVs in the distribution system. As a result, DSOs also need more flexibility services in the future, e.g., from customers with production (prosumers), in order to provide infrastructure for EVs [46] and renewables-based distributed generation.
There exist different flexibility services and products which can be deployed by DSOs so as to enhance system security. These services can be related to congestion management, voltage control and system maintenance, and be realized by using various information and communication technologies [46]. In order to determine the optimal amount of flexibility, a DSO can utilize, for example, the values from metering devices and use them to calculate the amount of available flexibility. In addition, customers/prosumers with flexibilities should be motivated in order to react to DSO flexibility service needs. In the following section, the main flexible resources at distribution networks (DSO level) are introduced briefly.

Flexible Resources at DSO Level
Traditionally, DSOs invest in upgrading the distribution grids in order to effectively resolve different current or future grid issues [47]. The components such as transformers and cables are upgraded and replaced by the ones with higher capacity limits to avoid congestion in the grid [48]. Besides, capacitor banks or transformers equipped with OLTCs are used for voltage control [47]. Changing topology of the grid known as network reconfiguration is also one potential action used by DSOs to relieve network congestion [49,50]. DSOs may plan the topology reconfiguration for different timeframes like day-ahead, intraday and real-time. As part of distribution network topology changes, circuit-breakers and switches can be controlled together with demand response/shifting in order to solve DSO network congestions [51]. Flexibility can be also obtained from advanced monitoring techniques like dynamic line rating (DLR) [52].
Active management of DSO-network-connected distributed energy resources (DERs) can be seen as very potential future DSO-level flexible resources, reducing the need for grid reinforcement and reconfiguration. DERs can be curtailed dynamically or statically to increase system flexibility [9]. In the static curtailment, there exists a predefined threshold for the injection of active power (P) from renewable DER. In contrast, regarding dynamic curtailment, the injection of active power (P) is only controlled and curtailed if the congestion happens. Capacity-limitation-related flexibility services could be provided to DSOs e.g., by aggregating multiple DERs through a FLECH (flexibility clearing house) service-oriented platform [53]. The encouraging results demonstrated that these resources could meet the DSO requirements in an acceptable manner. For instance, their capacities decreased by 38.5 kW in response to the required 37.8 kW reduction offered by the DSO. Hence, DERs would be utilized as flexible resources in an aggregated manner or through curtailment.
Demand response (DR) resources and microgrids (MGs) are also able to contribute to the provision of flexibility for DSOs' needs. For example, reference [54] investigated the effect of DR resources on mitigating the uncertainties coming from the penetration of intermittent wind power. In [55], responsive loads were proposed to be rescheduled considering DSO preferences and in order to maximize the profits and load leveling. The proposed load scheduling approach was proved to lead to the highest load reduction (26.8%) which had been requested by the DSO. DSOs may also benefit from flexibility services provided by MGs connected to the distribution grids. Reference [56] illustrated how MGs could control their local resources to provide the grid with flexibility/ancillary services. However, the results of [56] advocate that MGs should deviate from their optimal profits in order to provide the distribution grid with the desired ramping needs. This amount was estimated to be $328.7 for 24 h in the literature. Accordingly, the DSO needs to incentivize these resources by paying the aforementioned deviation profits to the MGs. An aggregator of different small-scale flexible resources could provide the flexibility services for DSOs and act as an intermediary between DSOs and the customer-level resources [57]. The proposed decentralized aggregator-based market design was proved to facilitate flexibility integration from prosumers seeking autonomy and privacy. In [58], the aggregator utilized small prosumers' flexibility for participation in energy and tertiary frequency reserve markets. The research adopts the two-stage stochastic programming to exploit the flexibility of prosumers in both generation-side and demand-side.
DSO-level storage-based resources are also naturally have potential to be providers of flexibility for distribution network needs through different active network management (ANM) schemes. For example, reference [59] proposed to coordinate load shedding and EV charging by ANM in future distribution networks. The work in [59] took into account the satisfaction of EV customers along with interruptible load compensation in its optimization problem. The paper concludes that the proposed flexible resources increased the average qualified voltage ratio from 82.7% to 100% while the average ratio of primary line load decreased from 41.57% to 38.32%. Reference [60] suggested that EVs are one of the efficient flexibility providers in terms of issues associated with congestion management and voltage regulation. In addition, a real-time congestion management method, named "swap", was introduced in [61] focusing on flexibility services provided by EVs and heat pumps. Reference [62] discussed that battery energy storage (BES) could provide a wide range of flexibility services including the provision of the spinning and non-spinning reserve, power quality and primary frequency regulation. Following this research, reference [63] assessed the integration of BESs and hybrid photovoltaic (PV) arrays in order to meet short-term flexibility requirements.
The market-or pricing/tariff-based approach is another method implemented by the DSO in order to relieve network congestion in the distribution grids. Reference [64] utilized dynamic tariffs along with power-based network tariffs in order to motivate heat pumps and EVs to react to the changes in the distribution system. In addition, locational marginal pricing was employed by [65] in order to provide flexibility to the distribution network.
Traditional methods like network reconfiguration are also combined with flexibility services/products in the literature in order to operate the distribution grid in a more efficient way. For example, in [66] a DSO-level capacity market was integrated with the network reconfiguration in order to resolve the congestion issues through an iteration process between the DSO and aggregators. According to the paper's simulation results, this combination would be able to enlarge the control space that pricing approach alone cannot reach at some certain times of the day, while guaranteeing minimal investment costs in the grid development. Furthermore, in [51] a combination of price-and incentive-based DR programs was proposed. Table 1 illustrates the potential flexible resources in the distribution networks (DSO-level).

Flexibilities Related Trading at DSO Level
There exist three main methods to implement flexibility services for DSOs' needs. The first method is the rule-or grid-code-based method in which some strict requirements are set to the behavior of DER units in order to support the needs of the distribution networks. In the second method, DSOs execute bilateral contracts to buy flexibility services from the resources [53]. Flexibility services at the DSO-level could be also traded in the market environment which forms the third method of flexibility services trading.
Grid codes can be different for different countries. DER units connected to the grid must follow the strict rules and regulations imposed by the system operator. For example, some grid codes associated with integrating solar power into the DSO-level network have been introduced [68]. However, it should be kept in mind that most DER-related grid codes are traditionally made for emergency situations in order to support the transmission network and whole power system stability during large disturbances. In addition, DER grid codes are under constant development and in the future they will also increasingly take into account the needs of distribution networks and microgrids (intended island operation).
The bilateral contracts can be negotiated between a DSO and a broker aggregating flexible resources (like the aggregator-DSO contract in [69]) or the DSO can carry out contracts for each end-user [70]. Reference [69] defined aggregator-DSO contracts as including the awards which should be given to the aggregator when it reacts to the DSO request. In [57], a DSO buys/sells flexibility contracts from/to aggregators acting as mediators between small-scale flexible resources and the DSO. The DSO will buy flexibility contracts during time intervals in which the demand violates the predefined levels, and sell them when there is no violation. In [70], the traffic light concept presented by [71] was utilized to introduce the system states to the flexible resources before the DSO asks for corrective actions. Figure 3 shows the various flexibility trading structures for DSO-level networks. There exist three main methods to implement flexibility services for DSOs' needs. The first method is the rule-or grid-code-based method in which some strict requirements are set to the behavior of DER units in order to support the needs of the distribution networks. In the second method, DSOs execute bilateral contracts to buy flexibility services from the resources [53]. Flexibility services at the DSO-level could be also traded in the market environment which forms the third method of flexibility services trading.
Grid codes can be different for different countries. DER units connected to the grid must follow the strict rules and regulations imposed by the system operator. For example, some grid codes associated with integrating solar power into the DSO-level network have been introduced [68]. However, it should be kept in mind that most DER-related grid codes are traditionally made for emergency situations in order to support the transmission network and whole power system stability during large disturbances. In addition, DER grid codes are under constant development and in the future they will also increasingly take into account the needs of distribution networks and microgrids (intended island operation).
The bilateral contracts can be negotiated between a DSO and a broker aggregating flexible resources (like the aggregator-DSO contract in [69]) or the DSO can carry out contracts for each enduser [70]. Reference [69] defined aggregator-DSO contracts as including the awards which should be given to the aggregator when it reacts to the DSO request. In [57], a DSO buys/sells flexibility contracts from/to aggregators acting as mediators between small-scale flexible resources and the DSO. The DSO will buy flexibility contracts during time intervals in which the demand violates the predefined levels, and sell them when there is no violation. In [70], the traffic light concept presented by [71] was utilized to introduce the system states to the flexible resources before the DSO asks for corrective actions. Figure 3 shows the various flexibility trading structures for DSO-level networks.  Related to the market-based approach, reference [45] introduced two different frameworks for the interaction between a DSO and aggregators. In the first framework, the DSO first asks for quantities of various kinds of flexibility services. After that, the aggregators submit offers to respond to the request and finally, the DSO selects appropriate flexibility services. In the second framework, aggregators must estimate the required flexibility services and show services at different prices, similar to a supermarket. Reference [66] also proposed a mid-term market in which aggregators build a price/quantity curve to react to the DSO requests for services related to the capacity limitation.

Flexibility at Customer Level
Nowadays, the roles of small customers are undergoing a significant change. Customers have been typically considered as submissive ratepayers who were not subject to variations in the network. However, in the future, customers/prosumers are increasingly going to react to system changes and make profits, for example, by reshaping their demand based on price signals. Prosumers with renewable resources and batteries can also provide an increased amount of competitive flexibility services at local (DSO) and system-wide (TSO) levels [72]. They can also be more and more capable of meeting their own demand, known as self-consumption. In addition, EVs can be considered as one flexible resource of customers, if charging power and time of EVs can be controlled and scheduled.
Automatic home systems (AHSs) equipped with sensors and actuators are utilized to monitor and control the household energy consumption and generation [73]. In general, home energy management systems (HEMSs) are introduced to manage household appliances as well as generate resources in an optimal manner. HEMS can add intelligence as well as comfort to the home environment while aiming to save energy through optimal scheduling of controllable appliances. The last approaches in the field of real-time monitoring and measuring of prosumers' energy include advanced metering infrastructure (AMI) [74], smart sensors [75], home area networks [76] and home energy storage systems [77]. In order to manage power at the customer-level, the existence of these systems is necessary [78].

Flexible Resources at Customer Level
Correspondingly to the potential flexibilities connected at DSO and TSO levels, small-scale customers with flexible resources, like roof-mounted photovoltaics (PV), storages, controllable appliances (loads) and EVs, can be regarded as customer-level flexible resources on the demand-side of the system. Total customer load consists of non-flexible and flexible (controllable/shiftable) loads [79]. On the other hand, energy storage (e.g., batteries and EVs) can be utilized for flexibility provision instead of controlling the customer loads.
Regarding controllable appliances (loads) of households, they can be divided into three types: (1) interruptible appliances such as pool pump and EVs, (2) non-interruptible appliances like washing machines and dishwashers, and (3) thermostatically controlled appliances such as air conditioners and water heaters [80]. The user could define the preferred interval for operating particular appliances. Following the user's preference, the HEMS determines the optimal operation time taking into account the type of appliances. For example, interruptible appliances are allowed to operate at any time during the user's predefined interval whereas the operation of non-interruptible appliances cannot be interrupted while they are working [80].

Flexibilities Related Trading at Customer Level
Flexibility could be traded between customers/prosumers in a peer-to-peer way without any entity to play the role of mediator. For instance, authors in [81] proposed a peer-to-peer market that empowers customers to transact energy directly. In this way, producers and customers with flexible demand trade electricity with each other. The results of the paper verify that the proposed P2P approach can preserve the privacy of players considerably compared to the centralized one while the social welfare of players decreases negligibly from 50.75 to 50.55. In [57], a decentralized flexibility market was designed where all players of the distribution network make decisions autonomously. The proposed market design in [57] consisted of electricity transactions between DSO-to-aggregators, aggregators-to-customers and customers-to-customers. The simulation results state that the peak shaving obtained from the proposed flexibility local market can enhance the minimum voltage magnitude (from 0.93 pu to 0.945 pu).
Prosumers could also trade their flexibility with an upstream entity such as an aggregator. Reference [82] proposed a method to provide flexibility services for aggregators in large-scale energy communities. A bottom-up decentralized approach has been used for trading energy among customers and aggregators in [83][84][85]. In [86,87], an iterative algorithm has been introduced to transact energy flexibility locally from customers to aggregators to DSO. Moreover, authors in [88] presented game-based and monopolistic-based approaches to transactions for the energy flexibility service between customers and aggregators in the distribution network. According to the paper's simulation results, the proposed monopolistic approach can be profitable for aggregators acting as mediators if all end-users would be able to take part as interruptible loads.
Prosumers could also sell flexibility to the local markets. For instance, authors in [89] defined a local market (LM) in which players of the bottom-layer of the power system can participate in the LM with regard to flexibility. Authors in [90] introduced the local market scheme from the EMPOWERproject, which is based on a value-oriented approach. In this way, different services (e.g., flexibility) are provided by contracts among players. In [91], a decision-support tool was presented in which local market players are able to present their flexibility offer to the local markets through the MASCEM simulation platform proposed in [92]. The simulation results verify that the total profits of the end-users coming from the local market trading can be estimated to double in amount compared with the profits stemming from participation in the conventional day-ahead spot markets. In [57], authors designed decentralized local load management with the flexibility provided by prosumers and aggregators. In [93], the flexibility was defined as a load reduction service during peak hours which means that the DSO is able to buy the flexibility service from demand response aggregators based on monthly contracts. Table 2 shows different flexibility-related trading models at the customer level.

Application of Blockchain Technology in Flexibility Trading
In the context of flexibility trading at different levels, all of the players are looking for a digital platform through which flexible resources could offer flexibility services and the operators (like TSOs and DSOs) would be able to send requests for buying flexibility. In other words, the platform is used to facilitate the sharing of information between different players. The platform should contain the functionality to help to aggregate the resources and perform market clearing and settlement. The platform needs to be capable of preserving the privacy of inputs while maintaining security against external signals and cyberattacks. Transparency and immutability are other key features that a suitable platform should retain in order to avoid information asymmetry. For this purpose, blockchain offers a distributed-based trusted platform for storing data in a secure way as well as for simplifying transactions between the actors.
A platform integrated with Blockchain technology mainly consists of a distributed ledger, a decentralized consensus mechanism, along with cryptographic security measures [94]. All users can share information as well as hold the transaction data. In a blockchain-based platform, the confirmation of validity is obtained providing that all of the nodes (users) reach a common consensus [95]. A simple architecture of blockchain technology is presented in Figure 4. Transactions are confirmed using the pre-defined consensus in a shared execution way, named smart contracts. Despite the unrestricted access of users to the transaction data, each user can only access transactions in which it has been involved and no one is allowed to modify them. In order to preserve the privacy of input data, cryptographic hash functions are also employed in the blockchain-based platform. Further, each block containing transactions is linked to the previous block so that the information cannot be tampered with.
Energies 2020, 13, x FOR PEER REVIEW 12 of 19 external signals and cyberattacks. Transparency and immutability are other key features that a suitable platform should retain in order to avoid information asymmetry. For this purpose, blockchain offers a distributed-based trusted platform for storing data in a secure way as well as for simplifying transactions between the actors. A platform integrated with Blockchain technology mainly consists of a distributed ledger, a decentralized consensus mechanism, along with cryptographic security measures [94]. All users can share information as well as hold the transaction data. In a blockchain-based platform, the confirmation of validity is obtained providing that all of the nodes (users) reach a common consensus [95]. A simple architecture of blockchain technology is presented in Figure 4. Transactions are confirmed using the pre-defined consensus in a shared execution way, named smart contracts. Despite the unrestricted access of users to the transaction data, each user can only access transactions in which it has been involved and no one is allowed to modify them. In order to preserve the privacy of input data, cryptographic hash functions are also employed in the blockchain-based platform. Further, each block containing transactions is linked to the previous block so that the information cannot be tampered with.  Recently, the applications of blockchain technology have been extended to the energy field. Some unique features of blockchain technology can help to implement a secure decentralized energy trading environment. In a blockchain-based trading structure, there is no centralized entity to control, monitor, and confirm the legibility of the transactions. As a result, all users of a blockchain-based platform have equal rights, as they can share information such as submitting and accepting bids freely. The personal user information remains secure as they do not need to share it with another entity. Decentralization may decrease the costs typically allocated to the mediator. Besides, transactions recorded in the system are open and transparent and therefore information asymmetry can be avoided [96]. Accordingly, it can ensure that the data entered into the blockchain-based network remains safe and secure. Finally, users of this platform are able to trade together without knowing each other based on another key feature of blockchain technology called anonymity. Recently, the applications of blockchain technology have been extended to the energy field. Some unique features of blockchain technology can help to implement a secure decentralized energy trading environment. In a blockchain-based trading structure, there is no centralized entity to control, monitor, and confirm the legibility of the transactions. As a result, all users of a blockchain-based platform have equal rights, as they can share information such as submitting and accepting bids freely. The personal user information remains secure as they do not need to share it with another entity. Decentralization may decrease the costs typically allocated to the mediator. Besides, transactions recorded in the system are open and transparent and therefore information asymmetry can be avoided [96]. Accordingly, it can ensure that the data entered into the blockchain-based network remains safe and secure. Finally, users of this platform are able to trade together without knowing each other based on another key feature of blockchain technology called anonymity.
Reference [97] denoted that the blockchain-based platform for demand response resources can provide the following benefits for the system: (1) All DR products can be integrated through a single venue, enhancing the liquidity as well as providing a combination of different DR products. (2) It has the ability to allocate the value of flexibility in a fair manner.
(3) It promotes competitive operation and reduces costs by eliminating centralized entities. (4) A blockchain-based platform may incentivize users to innovate and extend functionality as needed. (5) Users can manage their own personal data as there is no need for a centralized entity to take control of their private data.
Blockchain technology provides a trading platform through which flexible resources and operators located at TSO, DSO and customer levels can trade collaboratively without giving power to a single entity. Finally, all market participants can confirm the allocation of value according to the rules of the system.
Authors in [98] proposed adopting the blockchain technology to help customers to provide ancillary services for a microgrid. In the study, for each transaction, energy losses were calculated and after that, the required reactive power and its remuneration at each regulator node was estimated. Then, smart contracts were utilized to define interactions between sellers and buyers and finally the transactions related to active and reactive power were written in the blockchain. These actions were taken in order to monetize voltage regulation as well as the provision of reactive power. Smart contracts, as one of the key features of blockchain technology, were employed in [99] to guarantee the expected flexibility levels along with the balance between generation and demand. Blockchain technology was also proposed to facilitate the validation of DR agreements.
To summarize, blockchain technology can provide a secure transparent platform that does not require any agents to act as a centralized entity. However, the main issue related to the provision of a platform for flexibility trading is related to the required coordination between operators of different network levels. For example, should TSO and DSO interact via their common blockchain-based platform, or should each of them have a separate platform to aggregate their own flexible resources [21]?

Discussion and Conclusions
This paper focuses on the flexible resources, potential services and trading structures at different levels (TSO, DSO, customer) of the power system. Moreover, it discusses the applicability of blockchain technology in providing a suitable platform for trading flexibility.
At first, the flexible resources at TSO level were discussed. Traditional generators have been typically responsible for providing flexibility services in TSO-level networks. However, recent studies proved that large-scale aggregators aggregating EVs, prosumers, DR, storage-based resources as well as WPPs could also provide the needed flexibility at TSO-level. For example, it has been proven proved that the use of EV aggregators as flexible resources would help the system deal with more uncertainty and variability within the probability of 99% [26], and according to results obtained by [30], participation of WPPs as flexible resources can reduce the overall cost of the system by 5.5%. Flexibility products at the TSO level could be divided into FRPs and ancillary services. The trading timeframes are mostly dependent on the types of flexibility services. Services belonging to the contingency situations can be traded in real-time or near real-time while planning-related services could be traded years ahead. FRPs are often proposed to be sold in existing markets, meaning that they do not have a separate market, whereas ancillary services can be traded in a separate market. In this context, there may exist a need for a separate market for ramping products. Flexible resources which are able to provide a faster response could participate in the ramp market in order to enhance the system resiliency and stability at the TSO level.
After the TSO level, potential flexible resources at the DSO level were also reviewed. Apart from conventional control-based methods, DER units connected to distribution networks can also provide the needed flexibility for DSO requirements. Renewable DERs and EVs, which to a large extent created the need for flexibility in distribution networks, are also the most potential providers of the needed flexibility services at the DSO-level. According to [53], the capacities of these resources have the potential to decrease by 38.5 kW in response to the required 37.8 kW reduction offered by the DSO. Also, the combination of conventional and new potential flexible resources can increase the distribution network's controllability and flexibility. Related to trading, DSOs may need to restrict trading in some situations so as to avoid violations of the distribution network limits. They can sign a contract with aggregators or directly with prosumers to procure flexibility services. In addition, the aggregators may provide flexibility for DSOs through market-based approaches.
Furthermore, the customer level flexibility trading was considered. At this level, small household size customers are allowed to provide flexibility and sell to other customers, the aggregator or local markets. Some of the reviewed papers analyzed peer-to-peer models for flexibility trading, but most of the studies considered a local market in which prosumers can sell flexibility and make profits. As mentioned in [91], the total profits of end-users participating in local markets can be estimated to double in amount compared with the profits stemming from participation in the conventional day-ahead spot markets. Besides, with the existence of local markets, prosumers will have more incentive to participate solely in the local markets and compete against other approximately equal-sized competitors. Moreover, in some cases the customer or prosumer itself may also need to buy flexibility in order to compensate for fluctuations of its renewables or in situations in which the prosumer cannot sell the flexibility it had promised.
Finally, an appropriate platform is needed to facilitate flexibility trading while promoting cooperative trading between operators. Blockchain technology can ensure that the data would remain secure, it would not be tampered as well as it is transparent for all of the participants. In addition, the blockchain technology could also potentially eliminate the dependency from the centralized entity (such as an aggregator) as all of the rules and transactions can be determined and confirmed through smart contracts. Funding: This work was done as part of FLEXIMAR-project (Novel marketplace for energy flexibility) which is funded by Business Finland and Finnish companies (https://www.univaasa.fi/en/research/projects/fleximar/).

Conflicts of Interest:
The authors declare no conflict of interest.