**4.1. Problem formulation**

Let consider a small generation portfolio running in an electricity market. The power company owning the generation portfolio wants to determine the best-selling strategy of the energy production, which would maximize the expected profit while financial risk is constrained. Any trading strategy *x* is defined by the amount of energy to be sold in each different available selling instrument *i* in the electricity market, for example, the spot market, day-ahead obliga‐ tions, annual forward contracts, etc.

It is important to notice that the trading strategy sets the amounts of energy committed in every forward instrument, but only estimates the amount of energy to be actually sold in the spot market. Indeed, actual energy production is stochastic and depends on technical availability of generating units and the spread between spot and fuel prices. Suppose that whatever trading strategy is decided now, it could be changed in future decision stages in order to rebalance the portfolio. Composition of the portfolio can be rebalanced only at a cost however, i.e. the transaction costs. The process is then a sequence of balancing decisions determined by the trading strategy, each followed by a stochastic reward according to the position taken in the market. The process is over after a number of periods *n*.

The optimization of the trading strategy can mathematically be formulated as a stochastic nonlinear problem involving the maximization of the expected profit accrued by the generation portfolio across all instruments *i* and time intervals *t*:

$$\max\_{\mathbf{x}} \left[ \mathbb{E} \left[ \sum\_{t} \left[ \sum\_{i} I^{W} \left( \mathbf{x}\_{i,t} \right) - \sum\_{i} T^{W} \left( \mathbf{x}\_{i,t}, \mathbf{x}\_{i,t-1} \right) - C\_{t}^{W} \right] \right] \right] \tag{56}$$

subject to the following constraints:

15

Figure 5. Probability density function of operating profits for a forward contract The expected profit can be computed as the expected value of the contract under the hypothesis of

( ) *p f p MC <sup>S</sup>* ( ) ⋅ < *pfp p F S* ⋅ -

*p MC <sup>F</sup>* -

*Fb*

( ) *<sup>F</sup> f b*

From the profit pdf of the forward contract *f* (*bF* ), the downside risk metrics, namely the value at risk (VaR) and the conditional value at risk (CVaR) for a *δ* confidence level can respectively

*F F SS F S SS b q p MC f p dp p p f p dp* 

As for modern units *q* 1 , the change in the expected profit due to unit unavailability is typically

Assuming statistical independence between the unit´s failure and the level of spot prices, the

VaR


0

*F S SS F*

*L p p f p dp b*

VaR CVaR ( ) d


[ ] ( ) ( )

*MC*

Pr( VaR ) ( ) d

CVaR VaR*d*

0

(51)

d

<-= <sup>=</sup> ò *<sup>F</sup> F F <sup>b</sup> f b db* (54)

*f p*( ) *<sup>S</sup>* A

*pS* =E[ ] *MC p p F S*

<sup>B</sup> ( ) *<sup>F</sup> f b* ( )*<sup>S</sup> f b*

> ( ) *<sup>S</sup> f p MC* < *max F F b p* =

Pr( ) *p MC <sup>S</sup>* >

*Fb p MC <sup>F</sup>* -

Pr( ) *<sup>S</sup> q p MC* >

( ) *<sup>S</sup> q f p MC* ⋅ < *Fb*

*max F F b p* = C

*Fb*

*Fb*

Pr( 0) Pr( ) *F SF b pp p* (52)

<sup>=</sup> ò *FFF b f b db* (55)

(53)

*MC*

fully reliable unit times the probability of being available:

108 Dynamic Programming and Bayesian Inference, Concepts and Applications

**Figure 5.** Probability density function of operating profits for a forward contract

Pr( 0) *Fb* <

negligible. However, downside risk increases substantially.

and the conditional expectation on the value of losses can be written as:

*F*

*p*

probability of incurring in losses is given by:

be computed as:

$$\sum\_{i,i \neq spot} \mathbf{x}\_{i,h} + \mathbf{x}\_{spot,h}^{\mathcal{W}} = E\_h^{\mathcal{W}} \quad , \; \forall h \tag{57}$$

$$\sum\_{i \neq \text{spot}} x\_{i,t} \le E\_{\text{max},t} \quad \forall t \tag{58}$$

$$
\infty\_{i,t} \ge 0, \ \forall t, \ i \ne \text{spot} \tag{59}
$$

$$Risk\_W\left[\sum\_i I\left(\mathbf{x}\_{i,t}\right) - \sum\_i T\left(\mathbf{x}\_{i,t}, \mathbf{x}\_{i,t-1}\right) - C\_t^{\
u}\right] \le Risk\_{\max,t}, \ \forall t \tag{60}$$

where:

E: Expected value operator

*w*: Monte Carlo sample path


*xspot*,*<sup>h</sup> <sup>w</sup>* : Energy sold in spot market in hour *h* and Monte Carlo sample *w*

*Eh <sup>w</sup>*: Energy generated in hour *h* and Monte Carlo sample *w*

*Emax*,*t*: Maximal energy that can be generated in period *t*

*xi*,*t*: Energy to be sold by instrument *i* in period *t*

*<sup>I</sup> <sup>w</sup>*(*xi*,*<sup>t</sup>*): Revenue due to energy the sold by instrument *i* in period *t* and Monte Carlo sample *w*

$$I^{w}\left(\mathbf{x}\_{i,t}\right) = \begin{cases} \mathbf{x}\_{i,t} \cdot p\_{Fi,t} \stackrel{\text{w}}{}{\cdot}, i = \text{forward} \\ \sum\_{h \in t} \mathbf{x}\_{i,h} \cdot p\_{Sh} \stackrel{\text{w}}{}{}, \quad i = \text{spot} \end{cases} \tag{61}$$

The constraint (57) represents the hourly energy balance for all Monte Carlo samples and forces the generator to settle in the spot market differences between the energy sold in forward markets and actual production. Constraints (58) and (59) are introduced to avoid financial positions without physical counterpart, i.e. avoid the generator to take speculative positions by selling in forward markets more energy that the generation portfolio can produce. These constraints may be replaced by capital restrictions as regulations often allow financial trading without physical position. Finally, constraint (60) represents the limit to the financial risk associated to the selling strategy within each period *t*. In order to limit risk over the horizon time, the selected risk metric must be coherent [9] ensuring subadditivity. There are several downside risk measures that fulfill this requirement among which the Conditional Value at

Risk-Constrained Forward Trading Optimization by Stochastic Approximate Dynamic Programming

http://dx.doi.org/10.5772/57466

111

The equation (61) represents the revenue generated by each forward contract and the revenue (or cost) due to selling (or buying) differences between energy sold in futures and the real generation in the spot market forced by restriction (57). The equation (62) represents the costs of the operating policy, which is independent of the forward obligation for a price taker as demonstrated in Section 3. Therefore, the three equations (57), (61) and (62) calculated for the whole Monte Carlo set represent then the profit calculated by equation (49) of Section 3. Finally the transaction costs in equation (63) are assumed to be the 3% of the total transacted value

The problem formulation relies on Monte Carlo simulations to represent uncertainty on the future development of key variables. In addition, stochastic simulations are used to confront the algorithm with mapping scenarios for approximating both, the Value and the Risk

A synthetic ensemble of 2000 annual realizations of hourly power prices in the spot market were generated by means of spectral representation techniques [10]. Forward prices and spot prices are not statistically independent. The forward prices corresponding to each spot price sample are calculated considering both, the expected value of the spot price and the mean value of each spot price time series. To simulate the changes in the forward prices accounting

Under perfect competition and rationality on the expectation formation, the price of a forward product should converge to the mean expected spot prices for the delivery period. This is relatively easy to calculate for the first hour of the simulated time. Assuming that the whole Monte Carlo set of spot prices was simulated taking the same price forecast as the market, the

( ( )) ( ( )) , ,

*w h j w j <sup>i</sup> d d FA <sup>S</sup> <sup>S</sup> i i j h i i j h w*

= = é ù ë û - - <sup>å</sup> - - å å *i i*

1 1 = = <sup>=</sup>

*d d i i*

*h*

*H*

*H H W*

1

E (64)

*p*

for the correlation to each sample of the spot prices a simple model is introduced.

price of any forward should be the mean spot prices for the delivery period:

*H h W*

1 1

*p*

Risk (CVaR) is the most widely used (cf. equation 55).

only for forward contracts, and not existent for the spot market.

**4.2. Modeling stochastic spot and forward electricity prices**

functions.

*p*

*pF <sup>i</sup>*,*<sup>t</sup> w* : Effective future price of instrument *i* in period *t* and Monte Carlo sample *w*

*pS h w*: Spot price in hour *h* and Monte Carlo sample *w*

*Ct w*: Costs of energy in period *t* and Monte Carlo sample *w*

$$C\_t^{\prime\prime} = MC \cdot \sum\_{h \neq t} E\_h^{\prime\prime} \tag{62}$$

*MC*: Constant marginal cost of generation.

*<sup>T</sup> <sup>w</sup>*(*xi*,*t*, *xi*,*t*−1): Transaction costs due to the change in the amount of instrument *<sup>i</sup>* held in the portfolio after the rebalancing decision at the beginning of period *t*

$$T^{w}\left(\mathbf{x}\_{i,t},\mathbf{x}\_{i,t-1}\right) = \begin{cases} \mathfrak{P}\emptyset \mathbf{\hat{o}} \cdot p\_{Fi} \, ^{w,h0\_t} \cdot \left(\mathbf{x}\_{i,t} - \mathbf{x}\_{i,t-1}\right), i = forward\\ 0 & \text{, } i = spot \end{cases} \tag{63}$$

*pF i <sup>w</sup>*,*<sup>h</sup>* <sup>0</sup>*t*: Forward price of instrument *i* and Monte Carlo sample *w* at the beginning of period *t*. The constraint (57) represents the hourly energy balance for all Monte Carlo samples and forces the generator to settle in the spot market differences between the energy sold in forward markets and actual production. Constraints (58) and (59) are introduced to avoid financial positions without physical counterpart, i.e. avoid the generator to take speculative positions by selling in forward markets more energy that the generation portfolio can produce. These constraints may be replaced by capital restrictions as regulations often allow financial trading without physical position. Finally, constraint (60) represents the limit to the financial risk associated to the selling strategy within each period *t*. In order to limit risk over the horizon time, the selected risk metric must be coherent [9] ensuring subadditivity. There are several downside risk measures that fulfill this requirement among which the Conditional Value at Risk (CVaR) is the most widely used (cf. equation 55).

The equation (61) represents the revenue generated by each forward contract and the revenue (or cost) due to selling (or buying) differences between energy sold in futures and the real generation in the spot market forced by restriction (57). The equation (62) represents the costs of the operating policy, which is independent of the forward obligation for a price taker as demonstrated in Section 3. Therefore, the three equations (57), (61) and (62) calculated for the whole Monte Carlo set represent then the profit calculated by equation (49) of Section 3. Finally the transaction costs in equation (63) are assumed to be the 3% of the total transacted value only for forward contracts, and not existent for the spot market.
