MATLAB Examples

# Natural Gas Storage Valuation: 4. Rolling Intrinsic Valuation

This is the fourth script of 4 in the Natural Gas Storage Valuation case study. In this script, we value the storage facility using the rolling intrinsic optimization method. To do so, we simulate the monthlyPCA forward curve model (calibrated in script script3_ModelCalibration) for the period between the valuation date and the contract end date and compute a rolling optimization for each path. For more information on this method, please see the Readme document.

## Setup Storage Parameters

Define the storage problem parameters. These are parameters that define the storage facility, its constraints and costs. These are defined in "defineStorageParameters.m"

```type defineStorageParameters defineStorageParameters [facility.injMax, facility.witMax, facility.injCoef, facility.witCoef] = ... generateIWLimitArrays(facility,'linear',6,1000); addpath Utilities ```
```%% Define Storage Facility, Contract & Valuation Parameters % These are parameters that define the storage facility, its constraints % and costs. % Copyright 2014 The MathWorks, Inc. %% Facility Parameters facility.vMax = 1e6; % MMBtu (Maximum gas volume for facility) facility.vMin = 0; % MMBtu (Minimum gas volume for facility) facility.cI = .01; % \$/MMBtu (cost of injection) facility.cW = .01; % \$/MMBtu (cost of withdrawal) % Ratchet Constraints facility.iMax = [ 0 8197; facility.vMax*.8 8197; facility.vMax*.9 6000; facility.vMax 0]; % MMBtu/day (max injection rate) facility.wMax = [ 0 6000; facility.vMax*.2 14000; facility.vMax*.4 16393; facility.vMax 16393]; % MMBtu/day (max withdrawal rate) %% Contract parameters contract.startDate = '1 Jun 2014'; contract.endDate = '1 Jun 2015'; contract.startVolume = 0; % Contract initial volume contract.endVolume = 0; % Contract terminal volume %% Valuation Parameters valuation.valDate = datenum('15 May 2014');% Valuation date valuation.discRate = .03; % Valuation discount rate valuation.liquiditySpread = .02; % Liquidity spread (Bid - Ask) valuation.minLotSize = 1; valuation.nTrials = 100; % Number of Monte Carlo trials % Add initial forward Curve to valuation parameters load Data\FwdCurveHistory ind1 = datenum(valuation.valDate) == obsDate; ind2 = expDate >= datenum(contract.startDate) & ... expDate < datenum(contract.endDate); valuation.startCurve = fwdPrice(ind1, ind2); valuation.expDates = expDate(ind2); % Expiration dates clear ind1 ind2 expDate obsDate fwdPrice ```

## Simulate Forward Curve

Select forward curve model and generate simulations of future forward curves

```model = load('Models/FwdModel_MonthlyPCA'); valuation.nTrials = 100; [paths, obsDates] = simulateFwdModel(model.mu, model.sigma, datemnth(contract.endDate,-1),... valuation.nTrials, valuation.startCurve, valuation.expDates, datenum(valuation.valDate), 'riskNeutral'); ```

## Visualize Simulated Paths.

Change the pathNum parameter with the cell mode incrementors (right-click on "1" and select "Increment value...") to see different forward curve paths.

```pathNum = 1; plotForwardSeries(obsDates, valuation.expDates, ... paths{pathNum}(:,1:length(valuation.expDates))); ```

## Perform rolling intrinsic valuation.

This involves the iterative optimization of positions as the forward curve evolves over each Monte Carlo path to lock in additional storage value. This section includes a flag "recomputeSolution" which provides control over whether the solution is recomputed or loaded from a previous run.

```% Select rebalance dates N = length(valuation.expDates); lastDecDay = find(~isnan(paths{1}(:,N-1)),1,'last'); % Rebalance every 5 days, and on the first and last decision days rebalIdx = union(1:5:lastDecDay, [1 lastDecDay]); recomputeSolution = true; if recomputeSolution rollPos = cell(1, valuation.nTrials); rollValue = cell(1, valuation.nTrials); tic for i = 1:valuation.nTrials fprintf('Performing rolling intrinsic valuation path ] of ]\n', i, valuation.nTrials); bid = paths{i}(1:lastDecDay,1:length(valuation.expDates)) - valuation.liquiditySpread/2; ask = paths{i}(1:lastDecDay,1:length(valuation.expDates)) + valuation.liquiditySpread/2; [rollPos{i}, rollValue{i}] = optimizeRollingStorage(facility, bid,... ask, contract, valuation, rebalIdx); end toc rollValue = [rollValue{:}]; facility = rmfield(facility,{'injMax','witMax'}); save Models/RollingSolution facility contract valuation paths rollPos rollValue obsDates rebalIdx else load Models/RollingSolution end ```
```Performing rolling intrinsic valuation path 1 of 100 Performing rolling intrinsic valuation path 2 of 100 Performing rolling intrinsic valuation path 3 of 100 Performing rolling intrinsic valuation path 4 of 100 Performing rolling intrinsic valuation path 5 of 100 Performing rolling intrinsic valuation path 6 of 100 Performing rolling intrinsic valuation path 7 of 100 Performing rolling intrinsic valuation path 8 of 100 Performing rolling intrinsic valuation path 9 of 100 Performing rolling intrinsic valuation path 10 of 100 Performing rolling intrinsic valuation path 11 of 100 Performing rolling intrinsic valuation path 12 of 100 Performing rolling intrinsic valuation path 13 of 100 Performing rolling intrinsic valuation path 14 of 100 Performing rolling intrinsic valuation path 15 of 100 Performing rolling intrinsic valuation path 16 of 100 Performing rolling intrinsic valuation path 17 of 100 Performing rolling intrinsic valuation path 18 of 100 Performing rolling intrinsic valuation path 19 of 100 Performing rolling intrinsic valuation path 20 of 100 Performing rolling intrinsic valuation path 21 of 100 Performing rolling intrinsic valuation path 22 of 100 Performing rolling intrinsic valuation path 23 of 100 Performing rolling intrinsic valuation path 24 of 100 Performing rolling intrinsic valuation path 25 of 100 Performing rolling intrinsic valuation path 26 of 100 Performing rolling intrinsic valuation path 27 of 100 Performing rolling intrinsic valuation path 28 of 100 Performing rolling intrinsic valuation path 29 of 100 Performing rolling intrinsic valuation path 30 of 100 Performing rolling intrinsic valuation path 31 of 100 Performing rolling intrinsic valuation path 32 of 100 Performing rolling intrinsic valuation path 33 of 100 Performing rolling intrinsic valuation path 34 of 100 Performing rolling intrinsic valuation path 35 of 100 Performing rolling intrinsic valuation path 36 of 100 Performing rolling intrinsic valuation path 37 of 100 Performing rolling intrinsic valuation path 38 of 100 Performing rolling intrinsic valuation path 39 of 100 Performing rolling intrinsic valuation path 40 of 100 Performing rolling intrinsic valuation path 41 of 100 Performing rolling intrinsic valuation path 42 of 100 Performing rolling intrinsic valuation path 43 of 100 Performing rolling intrinsic valuation path 44 of 100 Performing rolling intrinsic valuation path 45 of 100 Performing rolling intrinsic valuation path 46 of 100 Performing rolling intrinsic valuation path 47 of 100 Performing rolling intrinsic valuation path 48 of 100 Performing rolling intrinsic valuation path 49 of 100 Performing rolling intrinsic valuation path 50 of 100 Performing rolling intrinsic valuation path 51 of 100 Performing rolling intrinsic valuation path 52 of 100 Performing rolling intrinsic valuation path 53 of 100 Performing rolling intrinsic valuation path 54 of 100 Performing rolling intrinsic valuation path 55 of 100 Performing rolling intrinsic valuation path 56 of 100 Performing rolling intrinsic valuation path 57 of 100 Performing rolling intrinsic valuation path 58 of 100 Performing rolling intrinsic valuation path 59 of 100 Performing rolling intrinsic valuation path 60 of 100 Performing rolling intrinsic valuation path 61 of 100 Performing rolling intrinsic valuation path 62 of 100 Performing rolling intrinsic valuation path 63 of 100 Performing rolling intrinsic valuation path 64 of 100 Performing rolling intrinsic valuation path 65 of 100 Performing rolling intrinsic valuation path 66 of 100 Performing rolling intrinsic valuation path 67 of 100 Performing rolling intrinsic valuation path 68 of 100 Performing rolling intrinsic valuation path 69 of 100 Performing rolling intrinsic valuation path 70 of 100 Performing rolling intrinsic valuation path 71 of 100 Performing rolling intrinsic valuation path 72 of 100 Performing rolling intrinsic valuation path 73 of 100 Performing rolling intrinsic valuation path 74 of 100 Performing rolling intrinsic valuation path 75 of 100 Performing rolling intrinsic valuation path 76 of 100 Performing rolling intrinsic valuation path 77 of 100 Performing rolling intrinsic valuation path 78 of 100 Performing rolling intrinsic valuation path 79 of 100 Performing rolling intrinsic valuation path 80 of 100 Performing rolling intrinsic valuation path 81 of 100 Performing rolling intrinsic valuation path 82 of 100 Performing rolling intrinsic valuation path 83 of 100 Performing rolling intrinsic valuation path 84 of 100 Performing rolling intrinsic valuation path 85 of 100 Performing rolling intrinsic valuation path 86 of 100 Performing rolling intrinsic valuation path 87 of 100 Performing rolling intrinsic valuation path 88 of 100 Performing rolling intrinsic valuation path 89 of 100 Performing rolling intrinsic valuation path 90 of 100 Performing rolling intrinsic valuation path 91 of 100 Performing rolling intrinsic valuation path 92 of 100 Performing rolling intrinsic valuation path 93 of 100 Performing rolling intrinsic valuation path 94 of 100 Performing rolling intrinsic valuation path 95 of 100 Performing rolling intrinsic valuation path 96 of 100 Performing rolling intrinsic valuation path 97 of 100 Performing rolling intrinsic valuation path 98 of 100 Performing rolling intrinsic valuation path 99 of 100 Performing rolling intrinsic valuation path 100 of 100 Elapsed time is 36.700119 seconds. ```

## Analyze Rolling Intrinsic Solution

Visualize the rolling intrinsic storage value distribution

```clf plotRollingValue(obsDates, rollValue) fprintf('Monte Carlo Rolling Storage Value: \$%0.2fk\n\n', mean(rollValue(end,:))/1e3); ```
```Monte Carlo Rolling Storage Value: \$249.29k ```

## Rolling Position Viewer

Analyze the rolling intrinsic solution through a custom viewer. The viewer allows you to select the path, the day (step) and look at consecutive forward curves and the optimal solution on those consecutive days (steps). Only 200 trials are selected to manage data size.

```nPaths = min(200, length(paths)); storageSolutionViewer(obsDates, paths(1:nPaths), rollValue(:,1:nPaths),... rollPos(1:nPaths), valuation.expDates, facility, contract, rebalIdx); ```

## Solution Summary

Intrinsic and Rolling Intrinsic valuation results

```fprintf('Storage Valuation Results:\n') fprintf('Intrinsic Value: \$%0.2fk\n', rollValue(1,1)/1e3); fprintf('Mean Rolling Intrinsic Value: \$%0.2fk\n', mean(rollValue(end,:))/1e3); extrinsic = mean(rollValue(end,:)) - rollValue(1,1); fprintf('Additional Exstrinsic Value of Rolling Strategy: \$%0.2fk (%0.2f%%)\n\n', extrinsic/1e3, extrinsic/rollValue(1,1)*100); fprintf('Statistics of Storage Value Distribution:\n') fprintf('Standard Deviation of Rolling Intrinsic Value: \$%0.2fk\n', std(rollValue(end,:))/1e3); fprintf('99%% & 95%% Lower Tail: \$%0.2fk & \$%0.2fk\n', prctile(rollValue(end,:), [1 5])/1e3); %#ok<*UNRCH> ```
```Storage Valuation Results: Intrinsic Value: \$96.59k Mean Rolling Intrinsic Value: \$249.29k Additional Exstrinsic Value of Rolling Strategy: \$152.70k (158.10%) Statistics of Storage Value Distribution: Standard Deviation of Rolling Intrinsic Value: \$103.47k 99% & 95% Lower Tail: \$111.87k & \$123.38k ```