Create Script and Module Files

In this section you will learn how to create the script and module files. These are similar to those that you used to run the code in the previous section.

Create Script File

To create a script
  1. In Explorer, browse to /fpp-library-fmb/src/main/resources/library/scripts/
  2. Right-click the scripts folder, and then select New > FPP Script File.
  3. Enter the name of the script: SampleScript. The SampleScript.psl file is created.
Fig. 3: Creating a script called SampleScript.

Fig. 3: Creating a script called SampleScript.

  1. Double-click the script file you just created to open it in the Editor.
  2. Copy the following code snippet, and paste it in the file.
/**
* This script is used to demonstrate how a function from a module file 
* is called to calculate a variable
*/

def x = 10
def y = returnsquare(x)
return y

Create Module File

To create a module
  1. In Explorer, browse to /fpp-library-fmb/src/main/resources/library/modules/
  2. Right-click the modules folder , and then select New > FPP Module File.
  3. Enter the name of the module: SampleModule. The SampleModule.module file is created.
Fig. 4: Creating a module called SampleModule.

Fig. 4: Creating a module called SampleModule.

  1. Open the file and enter the following code snippet:
/**
* Returns the square of a number
* @param z
*        Number whose square is to be calculated
*/

@Public
def returnsquare(z){
    return z * z
}

The text in the /** ... */ structure is a Javadoc-style comment and is used to inform future users about the purpose of the code. Javadoc-style comments from modules will be automatically included into the documentation when you deploy your Valuation Library. You can find more details in the Scripting reference and Deploy your library sections.

In the following sections you create the code to call your square function.

Create Document File

The document and pricing data files are at the core of the execution of FPP scripts. They are the input of your scripts and allow you to take maximum advantage of the parallelization potential provided by the FPP Platform.

The document aggregates deal attributes such as dates (schedule dates, maturity), notional amounts, foreign exchange pairs, etc.

To create the document file
  1. In Explorer, browse to /fpp-library-fmb/src/test/resources/documents
  2. Right-click the Documents folder , then select New > FPP Document File
  3. Enter the name of the document file: SampleDeal. The SampleDeal.json file is created.
Fig. 5: Creating a document called SampleDeal.

Fig. 5: Creating a document called SampleDeal.

  1. Open the file and enter a pair of curly brackets: {}

You will not use any document content in this example. However, you are required to create this file to launch a computation, therefore you create an empty json at this step.

Create Pricing Data File

The pricing data includes the calculation dates and scenario data such as spot prices, interest rates and more. The pricing data file conforms to a format that enables you to run computations in parallel. If you do not comply with this format you will get an error when you run your configuration.

To create the pricing data file
  1. In Explorer, browse to /fpp-library-fmb/src/test/resources/pricingData
  2. Right-click the pricingData folder , then select New > FPP PricingData File.
  3. Enter the name of the pricing data file: SamplePricingData. The SamplePricingData.scn pricing data file is created.
Fig. 6: Creating pricing data file called SamplePricingData.

Fig. 6: Creating pricing data file called SamplePricingData.

  1. Open the file and enter the following code snippet:
{ "dates" : [ "2017-04-13" ] }

Unlike the document, this file is not an empty JSON file because the minimal format requires the dates node.

To find more details about the pricing data, go to Pricing data formalism.