0.0.2 • Published 2 years ago

@rhoova/node-client v0.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

This is a client project for Rhoova app.


Installation

Make sure you have Node.js installed

# Use npm install to install required packages
npm install
#To run Project
node test.js

Usage

You can use the application with the client

const app = require("@rhoova/node-client");

let client = new app.RhoovaClient({apiKey : #YOUR_API_KEY, apiSecret : #YOUR_API_SECRET});

Client Methods

  • loadData:

It allows you to create a data source. It takes 3 values, file, name and type.

file: Represents your data. Must be of json data type.

name: Represents the name of data. Must be of string data type.

type: Represents the data types YIELD_CURVE, YIELD_DATA, FIXED_RATE_BOND_DEFINITION ... that you will use over app.DataType.

//Example Usage

client.loadData({file: {
       "settlementDays": 2,
        "intpMethod": "linear",
        "currency": "TRY",
        "calendar": "TARGET",
        "dayCounter": "Actual360"}, name: "myData-7", type: app.DataType.YIELD_DATA}).then((result) => {
    console.log(result);
}).catch(error => {
     console.log(error)
});
  • getData:

It allows you to access your data with the id of the data you have created. It takes one value, id.

id: Represents your data id. Must be of string data type.

//Example Usage

client.getData({id: "86c2f69e-dae1-423a-8783-493530bb1253" }).then((result) => {
     console.log(result);
}).catch(error => {
     console.log(error)
});
  • createTask:

Allows you to create calculations. It takes 3 values, data, calculationType and waitResult(optional).

data: Represents your json data. Must be of json data type.

calculationType: Represents the calculation type you can use through app.CalculationType.

waitResult(optional): May take true or false values. If false only the taskId of the calculation is returned. You can print the result part directly. If true, it returns the result of the calculation performed. You can see your calculation result with console.log(result.result).

//Example Usage

let calculationData = {
    "valuationDate": "2021-03-17",
    "settlementDate": "2021-03-17",
    "maturityDate": "2021-06-17",
    "notional": 1000000,
    "optionDefinition": {
        "underlying": "USD",
        "currency": "TRY",
        "callPut": "Call",
        "exerciseType": "European",
        "buySell": "Buy",
        "strike": 7.81,
        "underlyingPrice": 7.5109,
        "volatility": 0.19473,
        "interestRate": 0.16732,
        "riskFreeRate": 0.0028,
        "processType": "BSMerton",
        "method": "Analytic",
        "calendar": "Turkey",
        "businessDayConvention": "ModifiedFollowing",
        "dayCounter": "Actual360",
        "optionStartDate": "2021-03-17",
        "optionEndDate": "2021-06-17",
        "timeSteps": 800,
        "timeGrid": 801
    }
};

client.createTask({data: calculationData, calculationType: app.CalculationType.VANILLA_OPTION, waitResult: true}).then((result) => {
    console.log(JSON.stringify(JSON.parse(result.result), null, 6))
}).catch(error => {
    console.log(error)
});
  • getTaskResult:

You can give the id of the calculation you have done before as taskId and see the result. It takes one value, taskId.

taskId: Represents your calculation id. Must be of string data type.

//Example Usage

client.getTaskResult({taskId: "77931e4e-5f56-4ba1-90eb-6f6326e75161"}).then(result=>{ console.log(JSON.stringify(JSON.parse(result.result), null, 6)) });

 
0.0.2

2 years ago

0.0.1

2 years ago