Parallelization using the Valuation Editor

Scenario Parallelization - European Options

The Template Configuration

Run a configuration with the following details:

  • Configuration name: tutorial_EUMultiple
  • Library:fpp-library
  • Script file: tutorial_EUadvanced
  • Pricing data file: tutorial_EU_10Scenarios
  • Document file: tutorial_EUadvanced

Results are displayed in the result tab. They were obtained by scenario parallelization.

Fig. 22: The resulting option net present values in the result file.

Fig. 22: The resulting option net present values in the result file.

In the following sections you will learn to do scenario parallelization.

Files Required by Scenario Parallelization

Consider that instead of pricing your option for a single value of the underlying, you want to price it for several values. What is then the most efficient way to access data from you pricing data .scn file?

Suppose that you have an equity option on company ABC and that you want to evaluate certain aspects of your option for prices of the underlying ranging from $50 to $300 in increments of $50. This can be done as follows:

{
  //...
  "scenarioData": [{
      "id": {"type": "EQUITY",
          "parameters": ["ABC"]},
      "points": {   
          "2017-04-13" : [{
              "values": [50, 100, 150, 200, 250, 300]
              }]
          //...
          }
  }]
  //...
}
To prepare the files for scenario parallelization
  1. Use the same script and document that you created in the European Options - Advanced Tutorial:
    • Script file: tutorial_EUadvanced.psl
    • Document file: tutorial_EUadvanced.json
  2. Create a new pricing data – EU_10Scenarios.scn, and enter the following below.
    • Note that the values field has multiple spot prices for stock COCA_COLA, all separated by comma. When these values are processed, each will be handled by a separate computational thread, in parallel.
{
  "dates": [
    "2017-04-13"
  ],
  "scenarioData": [
    {
      "id": {
        "parameters": [
          "COCA_COLA"
        ],
        "type": "Volatility"
      },
      "metaData": {},
      "points": {
        "2017-04-13": [
          {
            "values": [
              0.0221,
              0.0221,
              0.0221,
              0.0221,
              0.0221,
              0.0221,
              0.0221,
              0.0221,
              0.0221,
              0.0221
            ]
          }
        ]
      }
    },
    {
      "id": {
        "parameters": [
          "COCA_COLA",
          "CONTINUOUS"
        ],
        "type": "DIVIDEND"
      },
      "metaData": {},
      "points": {
        "2017-04-13": [
          {
            "values": [
              0.01,
              0.01,
              0.01,
              0.01,
              0.01,
              0.01,
              0.01,
              0.01,
              0.01,
              0.01
            ]
          }
        ]
      }
    },
    {
      "id": {
        "parameters": [
          "COCA_COLA"
        ],
        "type": "EQUITY"
      },
      "points": {
        "2017-04-13": [
          {
            "values": [
              46,
              47,
              48,
              49,
              50,
              51,
              52,
              53,
              54,
              55
            ]
          }
        ]
      }
    },
    {
      "id": {
        "parameters": [
          "projection_Libor_3M",
          "discountFactor"
        ],
        "type": "YIELD_CURVE"
      },
      "metaData": {
        "currency": "USD",
        "interpolationMethods": [
          "flat"
        ],
        "interpolationVariables": [
          "discountFactor"
        ],
        "switchDates": [],
        "zeroCouponBasis": "ACT/365.FIXED",
        "zeroCouponFormula": "exponential"
      },
      "points": {
        "2017-04-13": [
          {
            "values": [
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1,
              1
            ],
            "x": 17269
          },
          {
            "values": [
              0.99943,
              0.99943,
              0.99943,
              0.99943,
              0.99943,
              0.99943,
              0.99943,
              0.99943,
              0.99943,
              0.99943
            ],
            "x": 17294
          },
          {
            "values": [
              0.99886,
              0.99886,
              0.99886,
              0.99886,
              0.99886,
              0.99886,
              0.99886,
              0.99886,
              0.99886,
              0.99886
            ],
            "x": 17319
          },
          {
            "values": [
              0.99829,
              0.99829,
              0.99829,
              0.99829,
              0.99829,
              0.99829,
              0.99829,
              0.99829,
              0.99829,
              0.99829
            ],
            "x": 17344
          },
          {
            "values": [
              0.99772,
              0.99772,
              0.99772,
              0.99772,
              0.99772,
              0.99772,
              0.99772,
              0.99772,
              0.99772,
              0.99772
            ],
            "x": 17369
          },
          {
            "values": [
              0.99715,
              0.99715,
              0.99715,
              0.99715,
              0.99715,
              0.99715,
              0.99715,
              0.99715,
              0.99715,
              0.99715
            ],
            "x": 17394
          },
          {
            "values": [
              0.99658,
              0.99658,
              0.99658,
              0.99658,
              0.99658,
              0.99658,
              0.99658,
              0.99658,
              0.99658,
              0.99658
            ],
            "x": 17419
          },
          {
            "values": [
              0.99629,
              0.99629,
              0.99629,
              0.99629,
              0.99629,
              0.99629,
              0.99629,
              0.99629,
              0.99629,
              0.99629
            ],
            "x": 17444
          },
          {
            "values": [
              0.99601,
              0.99601,
              0.99601,
              0.99601,
              0.99601,
              0.99601,
              0.99601,
              0.99601,
              0.99601,
              0.99601
            ],
            "x": 17469
          },
          {
            "values": [
              0.99572,
              0.99572,
              0.99572,
              0.99572,
              0.99572,
              0.99572,
              0.99572,
              0.99572,
              0.99572,
              0.99572
            ],
            "x": 17494
          },
          {
            "values": [
              0.99544,
              0.99544,
              0.99544,
              0.99544,
              0.99544,
              0.99544,
              0.99544,
              0.99544,
              0.99544,
              0.99544
            ],
            "x": 17519
          },
          {
            "values": [
              0.99515,
              0.99515,
              0.99515,
              0.99515,
              0.99515,
              0.99515,
              0.99515,
              0.99515,
              0.99515,
              0.99515
            ],
            "x": 17544
          },
          {
            "values": [
              0.99486,
              0.99486,
              0.99486,
              0.99486,
              0.99486,
              0.99486,
              0.99486,
              0.99486,
              0.99486,
              0.99486
            ],
            "x": 17569
          },
          {
            "values": [
              0.99458,
              0.99458,
              0.99458,
              0.99458,
              0.99458,
              0.99458,
              0.99458,
              0.99458,
              0.99458,
              0.99458
            ],
            "x": 17594
          },
          {
            "values": [
              0.99403,
              0.99403,
              0.99403,
              0.99403,
              0.99403,
              0.99403,
              0.99403,
              0.99403,
              0.99403,
              0.99403
            ],
            "x": 17619
          },
          {
            "values": [
              0.99347,
              0.99347,
              0.99347,
              0.99347,
              0.99347,
              0.99347,
              0.99347,
              0.99347,
              0.99347,
              0.99347
            ],
            "x": 17644
          },
          {
            "values": [
              0.99292,
              0.99292,
              0.99292,
              0.99292,
              0.99292,
              0.99292,
              0.99292,
              0.99292,
              0.99292,
              0.99292
            ],
            "x": 17669
          },
          {
            "values": [
              0.99236,
              0.99236,
              0.99236,
              0.99236,
              0.99236,
              0.99236,
              0.99236,
              0.99236,
              0.99236,
              0.99236
            ],
            "x": 17694
          },
          {
            "values": [
              0.99181,
              0.99181,
              0.99181,
              0.99181,
              0.99181,
              0.99181,
              0.99181,
              0.99181,
              0.99181,
              0.99181
            ],
            "x": 17719
          },
          {
            "values": [
              0.99125,
              0.99125,
              0.99125,
              0.99125,
              0.99125,
              0.99125,
              0.99125,
              0.99125,
              0.99125,
              0.99125
            ],
            "x": 17787
          }
        ]
      }
    }
  ]
}

Run the Code

Create a new configuration with the following details, and then run it:

  • Configuration name: EUMultiple
  • Library: fpp-library
  • Script file: tutorial_EUadvanced
  • Pricing data file: EU_10Scenarios
  • Document file: tutorial_EUadvanced

You get the following results:

Fig. 23: The resulting option net present values of your configuration.

Fig. 23: The resulting option net present values of your configuration.

You obtained the same results shown at the beginning of this section, in fig. 22.

The most significant aspect of these results is that they were calculated in parallel, without requiring you to modify the script or to have any knowledge on parallelization.

Parallelization on Dates - Interest Rate Swaps

The Template Configurations

In the previous section you used the parallelization on the scenario axis. However, it is possible to do much more, with parallelization on dates.

To learn how to do that, run first these three configurations:

  • tutorial_IRS_1Date_5Scenarios, modelling 1 date and 5 scenarios:
Fig. 24: Results for 1 date and 5 scenarios.

Fig. 24: Results for 1 date and 5 scenarios.

  • tutorial_IRS_2Dates_1Scenario, modelling 2 dates and 1 scenario:
Fig. 25: Results for 2 dates and 1 scenario.

Fig. 25: Results for 2 dates and 1 scenario.

  • tutorial_IRS_2Dates_5Scenarios, modelling 2 dates and 5 scenarios:
Fig. 26: Results for 2 dates and 5 scenarios.

Fig. 26: Results for 2 dates and 5 scenarios.

In the sections you apply parallelization on dates.

Files Required by Parallelization on Dates

To prepare the files for parallelization on dates
  1. Use the same script and document that you created in the Interest Rate Swap Tutorial.
    • Script file: tutorial_IRS.psl.
    • Document file: tutorial_IRS.json
  2. Create a new pricing data – IRS_2Dates_1Scenario.scn and enter the following code:
{
  "dates": [
    "2017-04-13",
    "2017-10-13"
  ],
  "scenarioData": [
    {
      "id": {
        "parameters": [
          "discount_Libor_3M",
          "discountFactor"
        ],
        "type": "YIELD_CURVE"
      },
      "metaData": {
        "currency": "USD",
        "curveDate": "2017-04-13",
        "interpolationMethods": [
          "flat"
        ],
        "interpolationVariables": [
          "discountFactor"
        ],
        "switchDates": [
        ],
        "zeroCouponBasis": "ACT/365.FIXED",
        "zeroCouponFormula": "exponential"
      },
      "points": {
        "2017-04-13": [
          {
            "values": [
              1
            ],
            "x": 17269
          },
          {
            "values": [
              0.99976
            ],
            "x": 17294
          },
          {
            "values": [
              0.99952
            ],
            "x": 17319
          },
          {
            "values": [
              0.99928
            ],
            "x": 17344
          },
          {
            "values": [
              0.99904
            ],
            "x": 17369
          },
          {
            "values": [
              0.9988
            ],
            "x": 17394
          },
          {
            "values": [
              0.99856
            ],
            "x": 17419
          },
          {
            "values": [
              0.99799
            ],
            "x": 17444
          },
          {
            "values": [
              0.99742
            ],
            "x": 17469
          },
          {
            "values": [
              0.99685
            ],
            "x": 17494
          },
          {
            "values": [
              0.99628
            ],
            "x": 17519
          },
          {
            "values": [
              0.99572
            ],
            "x": 17544
          },
          {
            "values": [
              0.99515
            ],
            "x": 17569
          },
          {
            "values": [
              0.99458
            ],
            "x": 17594
          },
          {
            "values": [
              0.99424
            ],
            "x": 17619
          },
          {
            "values": [
              0.99391
            ],
            "x": 17644
          },
          {
            "values": [
              0.99357
            ],
            "x": 17669
          },
          {
            "values": [
              0.99323
            ],
            "x": 17694
          },
          {
            "values": [
              0.9929
            ],
            "x": 17719
          },
          {
            "values": [
              0.99256
            ],
            "x": 17787
          }
        ],
        "2017-10-13": [
          {
            "values": [
              0.99765
            ],
            "x": 17452
          },
          {
            "values": [
              0.99658
            ],
            "x": 17479
          },
          {
            "values": [
              0.99552
            ],
            "x": 17506
          },
          {
            "values": [
              0.99445
            ],
            "x": 17533
          },
          {
            "values": [
              0.99338
            ],
            "x": 17560
          },
          {
            "values": [
              0.99232
            ],
            "x": 17587
          },
          {
            "values": [
              0.99125
            ],
            "x": 17614
          },
          {
            "values": [
              0.99097
            ],
            "x": 17641
          },
          {
            "values": [
              0.99069
            ],
            "x": 17668
          },
          {
            "values": [
              0.99041
            ],
            "x": 17695
          },
          {
            "values": [
              0.99012
            ],
            "x": 17722
          },
          {
            "values": [
              0.98984
            ],
            "x": 17749
          },
          {
            "values": [
              0.98956
            ],
            "x": 17776
          },
          {
            "values": [
              0.98798
            ],
            "x": 17803
          },
          {
            "values": [
              0.98641
            ],
            "x": 17830
          },
          {
            "values": [
              0.98483
            ],
            "x": 17857
          },
          {
            "values": [
              0.98326
            ],
            "x": 17884
          },
          {
            "values": [
              0.98168
            ],
            "x": 17911
          },
          {
            "values": [
              0.98011
            ],
            "x": 17938
          },
          {
            "values": [
              0.97853
            ],
            "x": 17968
          }
        ]
      }
    },
    {
      "id": {
        "parameters": [
          "projection_Libor_3M",
          "discountFactor"
        ],
        "type": "YIELD_CURVE"
      },
      "metaData": {
        "currency": "USD",
        "curveDate": "2017-04-13",
        "interpolationMethods": [
          "flat"
        ],
        "interpolationVariables": [
          "discountFactor"
        ],
        "switchDates": [
        ],
        "zeroCouponBasis": "ACT/365.FIXED",
        "zeroCouponFormula": "exponential"
      },
      "points": {
        "2017-04-13": [
          {
            "values": [
              1
            ],
            "x": 17269
          },
          {
            "values": [
              0.99943
            ],
            "x": 17294
          },
          {
            "values": [
              0.99886
            ],
            "x": 17319
          },
          {
            "values": [
              0.99829
            ],
            "x": 17344
          },
          {
            "values": [
              0.99772
            ],
            "x": 17369
          },
          {
            "values": [
              0.99715
            ],
            "x": 17394
          },
          {
            "values": [
              0.99658
            ],
            "x": 17419
          },
          {
            "values": [
              0.99629
            ],
            "x": 17444
          },
          {
            "values": [
              0.99601
            ],
            "x": 17469
          },
          {
            "values": [
              0.99572
            ],
            "x": 17494
          },
          {
            "values": [
              0.99544
            ],
            "x": 17519
          },
          {
            "values": [
              0.99515
            ],
            "x": 17544
          },
          {
            "values": [
              0.99486
            ],
            "x": 17569
          },
          {
            "values": [
              0.99458
            ],
            "x": 17594
          },
          {
            "values": [
              0.99403
            ],
            "x": 17619
          },
          {
            "values": [
              0.99347
            ],
            "x": 17644
          },
          {
            "values": [
              0.99292
            ],
            "x": 17669
          },
          {
            "values": [
              0.99236
            ],
            "x": 17694
          },
          {
            "values": [
              0.99181
            ],
            "x": 17719
          },
          {
            "values": [
              0.99125
            ],
            "x": 17787
          }
        ],
        "2017-10-13": [
          {
            "values": [
              0.99765
            ],
            "x": 17452
          },
          {
            "values": [
              0.99682
            ],
            "x": 17479
          },
          {
            "values": [
              0.99598
            ],
            "x": 17506
          },
          {
            "values": [
              0.99515
            ],
            "x": 17533
          },
          {
            "values": [
              0.99432
            ],
            "x": 17560
          },
          {
            "values": [
              0.99348
            ],
            "x": 17587
          },
          {
            "values": [
              0.99265
            ],
            "x": 17614
          },
          {
            "values": [
              0.99218
            ],
            "x": 17641
          },
          {
            "values": [
              0.99172
            ],
            "x": 17668
          },
          {
            "values": [
              0.99125
            ],
            "x": 17695
          },
          {
            "values": [
              0.99078
            ],
            "x": 17722
          },
          {
            "values": [
              0.99032
            ],
            "x": 17749
          },
          {
            "values": [
              0.98985
            ],
            "x": 17776
          },
          {
            "values": [
              0.98938
            ],
            "x": 17803
          },
          {
            "values": [
              0.98892
            ],
            "x": 17830
          },
          {
            "values": [
              0.98845
            ],
            "x": 17857
          },
          {
            "values": [
              0.98799
            ],
            "x": 17884
          },
          {
            "values": [
              0.98752
            ],
            "x": 17911
          },
          {
            "values": [
              0.98706
            ],
            "x": 17938
          },
          {
            "values": [
              0.98659
            ],
            "x": 17968
          }
        ]
      }
    }
  ]
}

Run the Code

Create a new configuration with the following details, and then run it:

  • Configuration name: IRS_2Dates_1Scenario
  • Library: fpp-library
  • Script file: tutorial_IRS
  • Pricing data file: IRS_2Dates_1Scenario
  • Document file: tutorial_IRS

You get the following results:

Fig. 27: Interest rate swap values with multiple dates and one scenario.

Fig. 27: Interest rate swap values with multiple dates and one scenario.

The values for the two dates were computed in parallel, without requiring you to modify the script or to have any knowledge on parallelization.

Parallelization on Scenarios and Dates - Interest Rate Swaps

In this section you learn how to parallelize on scenarios and dates simultaneously.

Files Required by Parallelization on Scenarios and Dates

To prepare the files for parallelization on scenario and dates
  1. Use the same script and document that you created in the Interest Rate Swap Tutorial.
    • Script file: tutorial_IRS.psl.
    • Document file: tutorial_IRS.json
  2. Create a new pricing data – IRS_2Dates_5Scenarios.scn and copy the following block of code:
{
  "dates": [
    "2017-04-13",
    "2017-10-13"
  ],
  "scenarioData": [
    {
      "id": {
        "parameters": [
          "discount_Libor_3M",
          "discountFactor"
        ],
        "type": "YIELD_CURVE"
      },
      "metaData": {
        "currency": "USD",
        "curveDate": "2017-04-13",
        "interpolationMethods": [
          "flat"
        ],
        "interpolationVariables": [
          "discountFactor"
        ],
        "switchDates": [],
        "zeroCouponBasis": "ACT/365.FIXED",
        "zeroCouponFormula": "exponential"
      },
      "points": {
        "2017-04-13": [
          {
            "values": [
              1,
              1,
              1,
              1,
              1
            ],
            "x": 17269
          },
          {
            "values": [
              0.99976,
              0.99924,
              0.99979,
              0.99909,
              0.99854
            ],
            "x": 17294
          },
          {
            "values": [
              0.99952,
              0.99847,
              0.99958,
              0.99818,
              0.99708
            ],
            "x": 17319
          },
          {
            "values": [
              0.99928,
              0.99771,
              0.99937,
              0.99728,
              0.99563
            ],
            "x": 17344
          },
          {
            "values": [
              0.99904,
              0.99695,
              0.99916,
              0.99637,
              0.99417
            ],
            "x": 17369
          },
          {
            "values": [
              0.9988,
              0.99618,
              0.99895,
              0.99546,
              0.99271
            ],
            "x": 17394
          },
          {
            "values": [
              0.99856,
              0.99542,
              0.99874,
              0.99455,
              0.99125
            ],
            "x": 17419
          },
          {
            "values": [
              0.99799,
              0.99463,
              0.99684,
              0.99424,
              0.99058
            ],
            "x": 17444
          },
          {
            "values": [
              0.99742,
              0.99383,
              0.99493,
              0.99392,
              0.98992
            ],
            "x": 17469
          },
          {
            "values": [
              0.99685,
              0.99304,
              0.99303,
              0.99361,
              0.98925
            ],
            "x": 17494
          },
          {
            "values": [
              0.99628,
              0.99225,
              0.99113,
              0.9933,
              0.98859
            ],
            "x": 17519
          },
          {
            "values": [
              0.99572,
              0.99146,
              0.98923,
              0.99299,
              0.98792
            ],
            "x": 17544
          },
          {
            "values": [
              0.99515,
              0.99066,
              0.98732,
              0.99267,
              0.98726
            ],
            "x": 17569
          },
          {
            "values": [
              0.99458,
              0.98987,
              0.98542,
              0.99236,
              0.98659
            ],
            "x": 17594
          },
          {
            "values": [
              0.99424,
              0.98843,
              0.98449,
              0.99069,
              0.98589
            ],
            "x": 17619
          },
          {
            "values": [
              0.99391,
              0.987,
              0.98356,
              0.98903,
              0.98518
            ],
            "x": 17644
          },
          {
            "values": [
              0.99357,
              0.98556,
              0.98264,
              0.98736,
              0.98448
            ],
            "x": 17669
          },
          {
            "values": [
              0.99323,
              0.98412,
              0.98171,
              0.98569,
              0.98377
            ],
            "x": 17694
          },
          {
            "values": [
              0.9929,
              0.98269,
              0.98078,
              0.98403,
              0.98307
            ],
            "x": 17719
          },
          {
            "values": [
              0.99256,
              0.98125,
              0.97985,
              0.98236,
              0.98236
            ],
            "x": 17787
          }
        ],
        "2017-10-13": [
          {
            "values": [
              0.99765,
              0.99325,
              0.98988,
              0.99632,
              0.99563
            ],
            "x": 17452
          },
          {
            "values": [
              0.99658,
              0.99268,
              0.98914,
              0.99547,
              0.99509
            ],
            "x": 17479
          },
          {
            "values": [
              0.99552,
              0.99212,
              0.98839,
              0.99462,
              0.99454
            ],
            "x": 17506
          },
          {
            "values": [
              0.99445,
              0.99155,
              0.98765,
              0.99378,
              0.994
            ],
            "x": 17533
          },
          {
            "values": [
              0.99338,
              0.99098,
              0.9869,
              0.99293,
              0.99345
            ],
            "x": 17560
          },
          {
            "values": [
              0.99232,
              0.99042,
              0.98616,
              0.99208,
              0.99291
            ],
            "x": 17587
          },
          {
            "values": [
              0.99125,
              0.98985,
              0.98541,
              0.99123,
              0.99236
            ],
            "x": 17614
          },
          {
            "values": [
              0.99097,
              0.98874,
              0.98471,
              0.991,
              0.99179
            ],
            "x": 17641
          },
          {
            "values": [
              0.99069,
              0.98764,
              0.98402,
              0.99078,
              0.99121
            ],
            "x": 17668
          },
          {
            "values": [
              0.99041,
              0.98653,
              0.98332,
              0.99055,
              0.99064
            ],
            "x": 17695
          },
          {
            "values": [
              0.99012,
              0.98542,
              0.98262,
              0.99032,
              0.99006
            ],
            "x": 17722
          },
          {
            "values": [
              0.98984,
              0.98432,
              0.98193,
              0.9901,
              0.98949
            ],
            "x": 17749
          },
          {
            "values": [
              0.98956,
              0.98321,
              0.98123,
              0.98987,
              0.98891
            ],
            "x": 17776
          },
          {
            "values": [
              0.98798,
              0.98255,
              0.98103,
              0.98926,
              0.98799
            ],
            "x": 17803
          },
          {
            "values": [
              0.98641,
              0.98188,
              0.98084,
              0.98866,
              0.98708
            ],
            "x": 17830
          },
          {
            "values": [
              0.98483,
              0.98122,
              0.98064,
              0.98805,
              0.98616
            ],
            "x": 17857
          },
          {
            "values": [
              0.98326,
              0.98055,
              0.98044,
              0.98744,
              0.98525
            ],
            "x": 17884
          },
          {
            "values": [
              0.98168,
              0.97989,
              0.98024,
              0.98683,
              0.98433
            ],
            "x": 17911
          },
          {
            "values": [
              0.98011,
              0.97922,
              0.98005,
              0.98623,
              0.98342
            ],
            "x": 17938
          },
          {
            "values": [
              0.97853,
              0.97856,
              0.97985,
              0.98562,
              0.9825
            ],
            "x": 17968
          }
        ]
      }
    },
    {
      "id": {
        "parameters": [
          "projection_Libor_3M",
          "discountFactor"
        ],
        "type": "YIELD_CURVE"
      },
      "metaData": {
        "currency": "USD",
        "curveDate": "2017-04-13",
        "interpolationMethods": [
          "flat"
        ],
        "interpolationVariables": [
          "discountFactor"
        ],
        "switchDates": [],
        "zeroCouponBasis": "ACT/365.FIXED",
        "zeroCouponFormula": "exponential"
      },
      "points": {
        "2017-04-13": [
          {
            "values": [
              1,
              1,
              1,
              1,
              1
            ],
            "x": 17269
          },
          {
            "values": [
              0.99943,
              0.99943,
              0.99854,
              0.99927,
              0.99998
            ],
            "x": 17294
          },
          {
            "values": [
              0.99886,
              0.99886,
              0.99708,
              0.99854,
              0.99996
            ],
            "x": 17319
          },
          {
            "values": [
              0.99829,
              0.99829,
              0.99563,
              0.99781,
              0.99994
            ],
            "x": 17344
          },
          {
            "values": [
              0.99772,
              0.99772,
              0.99417,
              0.99708,
              0.99991
            ],
            "x": 17369
          },
          {
            "values": [
              0.99715,
              0.99715,
              0.99271,
              0.99635,
              0.99989
            ],
            "x": 17394
          },
          {
            "values": [
              0.99658,
              0.99658,
              0.99125,
              0.99562,
              0.99987
            ],
            "x": 17419
          },
          {
            "values": [
              0.99629,
              0.99641,
              0.99011,
              0.99532,
              0.99922
            ],
            "x": 17444
          },
          {
            "values": [
              0.99601,
              0.99625,
              0.98897,
              0.99503,
              0.99857
            ],
            "x": 17469
          },
          {
            "values": [
              0.99572,
              0.99608,
              0.98783,
              0.99473,
              0.99792
            ],
            "x": 17494
          },
          {
            "values": [
              0.99544,
              0.99592,
              0.98668,
              0.99444,
              0.99726
            ],
            "x": 17519
          },
          {
            "values": [
              0.99515,
              0.99575,
              0.98554,
              0.99414,
              0.99661
            ],
            "x": 17544
          },
          {
            "values": [
              0.99486,
              0.99559,
              0.9844,
              0.99385,
              0.99596
            ],
            "x": 17569
          },
          {
            "values": [
              0.99458,
              0.99542,
              0.98326,
              0.99355,
              0.99531
            ],
            "x": 17594
          },
          {
            "values": [
              0.99403,
              0.99491,
              0.98243,
              0.99322,
              0.99436
            ],
            "x": 17619
          },
          {
            "values": [
              0.99347,
              0.9944,
              0.98159,
              0.99289,
              0.99341
            ],
            "x": 17644
          },
          {
            "values": [
              0.99292,
              0.99389,
              0.98076,
              0.99257,
              0.99247
            ],
            "x": 17669
          },
          {
            "values": [
              0.99236,
              0.99337,
              0.97992,
              0.99224,
              0.99152
            ],
            "x": 17694
          },
          {
            "values": [
              0.99181,
              0.99286,
              0.97909,
              0.99191,
              0.99057
            ],
            "x": 17719
          },
          {
            "values": [
              0.99125,
              0.99235,
              0.97825,
              0.99158,
              0.98962
            ],
            "x": 17787
          }
        ],
        "2017-10-13": [
          {
            "values": [
              0.99765,
              0.99265,
              0.99874,
              0.99658,
              0.99335
            ],
            "x": 17452
          },
          {
            "values": [
              0.99682,
              0.99241,
              0.99749,
              0.99569,
              0.993
            ],
            "x": 17479
          },
          {
            "values": [
              0.99598,
              0.99218,
              0.99624,
              0.9948,
              0.99264
            ],
            "x": 17506
          },
          {
            "values": [
              0.99515,
              0.99194,
              0.995,
              0.99391,
              0.99229
            ],
            "x": 17533
          },
          {
            "values": [
              0.99432,
              0.9917,
              0.99375,
              0.99301,
              0.99194
            ],
            "x": 17560
          },
          {
            "values": [
              0.99348,
              0.99147,
              0.9925,
              0.99212,
              0.99158
            ],
            "x": 17587
          },
          {
            "values": [
              0.99265,
              0.99123,
              0.99125,
              0.99123,
              0.99123
            ],
            "x": 17614
          },
          {
            "values": [
              0.99218,
              0.99045,
              0.98992,
              0.99108,
              0.991
            ],
            "x": 17641
          },
          {
            "values": [
              0.99172,
              0.98968,
              0.98858,
              0.99094,
              0.99076
            ],
            "x": 17668
          },
          {
            "values": [
              0.99125,
              0.9889,
              0.98725,
              0.99079,
              0.99053
            ],
            "x": 17695
          },
          {
            "values": [
              0.99078,
              0.98812,
              0.98592,
              0.99064,
              0.99029
            ],
            "x": 17722
          },
          {
            "values": [
              0.99032,
              0.98735,
              0.98458,
              0.9905,
              0.99006
            ],
            "x": 17749
          },
          {
            "values": [
              0.98985,
              0.98657,
              0.98325,
              0.99035,
              0.98982
            ],
            "x": 17776
          },
          {
            "values": [
              0.98938,
              0.98656,
              0.98276,
              0.99027,
              0.98935
            ],
            "x": 17803
          },
          {
            "values": [
              0.98892,
              0.98656,
              0.98228,
              0.9902,
              0.98888
            ],
            "x": 17830
          },
          {
            "values": [
              0.98845,
              0.98655,
              0.98179,
              0.99012,
              0.98841
            ],
            "x": 17857
          },
          {
            "values": [
              0.98799,
              0.98654,
              0.98131,
              0.99005,
              0.98793
            ],
            "x": 17884
          },
          {
            "values": [
              0.98752,
              0.98653,
              0.98082,
              0.98997,
              0.98746
            ],
            "x": 17911
          },
          {
            "values": [
              0.98706,
              0.98653,
              0.98034,
              0.9899,
              0.98699
            ],
            "x": 17938
          },
          {
            "values": [
              0.98659,
              0.98652,
              0.97985,
              0.98982,
              0.98652
            ],
            "x": 17968
          }
        ]
      }
    }
  ]
}

Run the Code

Create a new configuration with the following details, and then run it:

  • Configuration name: IRS_2Dates_5Scenarios
  • Library: fpp-library
  • Script file: tutorial_IRS
  • Pricing data file: IRS_2Dates_5Scenarios
  • Document file: tutorial_IRS

You get the following results:

Fig. 28: Interest rate swap values with multiple scenarios and dates.

Fig. 28: Interest rate swap values with multiple scenarios and dates.

The values for the two dates and five scenarios were computed in parallel without requiring you to modify the script or to have any knowledge on parallelization.

Final Remark

A final discussion is about how the number of input arguments affects the number of output.

In this section you have defined two dates in your pricing data file and for each there are five scenarios attached. Thus, you obtained a two-by-five matrix of results.

The number of scenarios and the number of dates are independent of each other. However, for each date there must be the same number of scenarios.

Therefore, the number of results per document is:

\[\begin{equation} {\left\vert{values}\right\vert = \left\vert{dates}\right\vert \times \left\vert{scenarios}\right\vert} \end{equation}\]

In the next section you will learn how to apply the parallelization using the Valuation Plugin.