# Swing Option: Linear vs. Dynamic Programming II

In order to get an improved impression on the differences between Monte-Carlo/linear programming and  finite difference methods/dynamic programming  a more realistic swing option with hourly payoff profile is evaluated based on a German hourly forward curve. The forward curve is taken from the Kyos example download page. The parameterization of the Kluge model is outlined in [1].

With maturity of twelve weeks the example swing option provides $12*7*24=2016$ exercise opportunities. The number of overall exercised swing opportunities is constraint by

$100 \le \sum_{i=1}^{2016} \beta_i \le 500$.

The size of two dimensions of the finite difference method (dynamic programming) is therefore already been given. 2016 steps are needed in time direction and 500 steps are needed in the “consumed exercises” direction. Together with the two other directions – one for the power price and one dimension for the jump process – and without further simplidsfications this forms a pretty large finite difference problem. The Monte-Carlo based linear programming approach reduces the computational burden but will lead to an upper bound of the swing option price. The diagram below shows the corresponding results.

The code is available here. It depends on the GNU Linear Programming Kit, the Boost Thread library for parallelization and at the time of writing on the latest QuantLib version from the SVN trunk. If you want to generate the plot directly out of the C++ program you also need R, RCPP and RInside. To utilize all CPU cores please use the -DNTHREADS=(number of CPU cores)  compiler switch. In addition to run the program you have to download the forward curve German power from the Kyos web page and convert it into a text file EEX_2010-2013.txt of the folliwing format

4-Oct-2010 36.73 32.09 27.32 23.22 25.71 35.60 47.32 …

5-Oct-2010 38.12 31.12 22.76 25.65 27.87 34.60 50.01 …

## 4 thoughts on “Swing Option: Linear vs. Dynamic Programming II”

1. Dennis Zhang says:

How long does this code run? I finally make the code running but I cannot tell if the code is making any progress facing the black cmd window …

• Depends on how many threads you are using. But you need a powerful machine and even then it can take hours because the number of Monte-Carlo scenarios and the grid for FDM are chosen to be pretty large to get very accurate results. If you want to increase the speed it up please change nrTrails in line 147 to 250 and line 229ff towards
boost::shared_ptr swingEngine(
new FdSimpleExtOUJumpSwingEngine(jumpProcess, rTS, 1, 25, 10, shape_));

2. Dennis Zhang says:

Thanks and I got the following results. Can you help confirm the option value for strike of 70 and 80?
For strike of 70: -91.903115 1030.508428 43.331651
For strike of 80: -1091.903115 -273.818882 34.896562

3. No, unfortunately not, I’m getting
Strike 70: 2085.482875 5341.918128 505.220760
Strike 80: 676.994699 3024.298155 420.527542
I guess we are using different market data. My power prices are starting with
28-Sep-2010 43.58 37.99 33.41 29.20 31.99 39.87 48.83 57.79 61.48 63.68 65.88 71.82 66.85 63.83 61.15 57.75 54.89 54.85 56.53 58.21 59.40 58.70 56.67 48.92
29-Sep-2010 31.99 27.89 24.53 21.43 23.49 29.27 38.26 46.21 56.98 60.35 64.15 69.93 65.09 62.16 59.55 56.24 53.44 53.41 54.38 54.13 45.90 43.09 41.60 35.91
3