Compute the Hedging

To compute the hedging, you use Financial Model Builder. In this section you learn how to do that. However, the script is not provided. To learn more about how to create scripts with Financial Model Builder, see Financial Model Builder Documentation.

Create the Flow

To create the flow in the Flow editor
  1. Open the Flow editor and create a new flow.
  2. Name it ComputeHedge.
  3. From the Flow Menu select Import > Clipboard.
  4. Copy the following code, and paste it into the text area of the Import nodes window.
[
    {
        "id": "6d9d52f0.8a9d1c",
        "type": "mb-http-in",
        "z": "8a1fbe5a.f01d7",
        "name": "hedge",
        "method": "post",
        "url": "/Hedge/input",
        "swaggerDoc": "",
        "x": 90,
        "y": 360,
        "wires": [
            [
                "7bd1d1d1.263ec"
            ]
        ]
    },
    {
        "id": "7bd1d1d1.263ec",
        "type": "function",
        "z": "8a1fbe5a.f01d7",
        "name": "getFormPayload",
        "func": "msg.sensi = msg.payload.value.data[1].value;\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 160,
        "y": 420,
        "wires": [
            [
                "e34a01f2.f6742"
            ]
        ]
    },
    {
        "id": "e34a01f2.f6742",
        "type": "function",
        "z": "8a1fbe5a.f01d7",
        "name": "getAuthorization",
        "func": "msg.headers = {\n\"Authorization\" : \"Bearer \" + msg.req.user.authTokens.master.access_token,\n\"Ocp-Apim-Subscription-Key\": \"<your-API-key>\"\n};\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 210,
        "y": 480,
        "wires": [
            [
                "c4ce2090.36949"
            ]
        ]
    },
    {
        "id": "c4ce2090.36949",
        "type": "template",
        "z": "8a1fbe5a.f01d7",
        "name": "fmb-document-template",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "{\n  \"documents\": [\n    { \"sensitivity\" : {{sensi}}}\n  ],\n  \"pricingData\": {\n     \"dates\": [\n      \"2017-04-13\"\n    ]\n  }\n} \n \n",
        "output": "json",
        "x": 310,
        "y": 540,
        "wires": [
            [
                "462497b.0fad768"
            ]
        ]
    },
    {
        "id": "462497b.0fad768",
        "type": "http request",
        "z": "8a1fbe5a.f01d7",
        "name": "call-fmb",
        "method": "POST",
        "ret": "obj",
        "url": "https://{host}{basePath}/library/FMB/script/ir_hedge/execute",
        "tls": "",
        "x": 400,
        "y": 600,
        "wires": [
            [
                "b40c9f29.7621c"
            ]
        ]
    },
    {
        "id": "b40c9f29.7621c",
        "type": "function",
        "z": "8a1fbe5a.f01d7",
        "name": "formatResult",
        "func": "msg.payload = msg.payload.results[0].values[0];\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "x": 480,
        "y": 660,
        "wires": [
            [
                "8e249fbf.5867e"
            ]
        ]
    },
    {
        "id": "8e249fbf.5867e",
        "type": "mb-http-out",
        "z": "8a1fbe5a.f01d7",
        "name": "price",
        "x": 530,
        "y": 740,
        "wires": []
    }
]
  1. Click Import to import the flow.
  2. Double-click the getAuthorization node, and then replace <your_API_key> with your Financial Model Builder API key.
  3. Double-click the call-fmb node to open the node where you configure the connection to Financial Model Builder to execute the pricing script.
  4. In the URL field, replace {host}{basePath} with the appropriate values from the API definition. To get the API definition, see Get Started with Finastra Open APIs
  5. Click Deploy to deploy the ComputeHedge flow to your application. You can now call it from the Link Editor module.
Fig. 91: The flow to retrieve the computed hedge.

Fig. 91: The flow to retrieve the computed hedge.

To enable the flow, you must create a script, named ir_hedge, in Financial Model Builder and deploy your library. See Financial Model Builder Documentation for more information.

Call the Flow from the UI