Git Product home page Git Product logo

ghas-results / predictive-market-using-arria Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ibm/predictive-market-using-arria

0.0 0.0 0.0 12.37 MB

WARNING: This repository is no longer maintained :warning: This repository will not be updated. The repository will be kept available in read-only mode.

Home Page: https://developer.ibm.com/patterns/build-a-stress-test-app-for-financial-portfolios/

JavaScript 65.02% CSS 18.10% HTML 16.88%
ibm

predictive-market-using-arria's Introduction

WARNING: This repository is no longer maintained โš ๏ธ

This repository will not be updated. The repository will be kept available in read-only mode.

Build Status

Predictive Market Using Arria

This code pattern demonstrates how to compute a stress test using the Predictive Market Scenario service and Simulated Instrument Analytics service on a set of investments maintained in the Investment Portfolio service, and then narrate the results using the Arria NLG service.

This code pattern is designed for developers with interest in creating financial applications pertaining to investment portfolios. When the reader has completed this code pattern, they will understand how to:

  • Load and retrieve data from the Investment Portfolio service
  • Use the Predictive Market Scenario service to generate a scenario
  • Send data along with a scenario to the Simulated Instrument Analytics service to retrieve analytics
  • Pipe the results to the Arria NLG service which generates a human-readable interpretation of the results

Architecture flow

Included Components

Offered on IBM Cloud:

NOTE: These services are free for those who have a Lite account.

Automatically Deploying the Application to IBM Cloud

Deploy to IBM Cloud

You will need to create Arria service in IBM Cloud and then bind the Arria NLG service to your application.

Go to your application page in IBM Cloud, under Connections choose Create Connection:

Find your Arria Natural Language Generation service and choose Connect:

Next, load investment portfolio before running the application. First clone the repo and then use the investmentPortfolio.js script to load your portfolio.

Manually Deploying the Application to IBM Cloud

Follow these steps to setup and run this pattern. The steps are described in detail below.

Prerequisites

Steps

  1. Create Arria service
  2. Create IBM Cloud services
  3. Clone the repo
  4. Configure .env file
  5. Load Investment Portfolio
  6. Run Application
  7. Deploy to IBM Cloud

1. Create Arria service

You will need Arria API key. Register for an Arria account here. Click Get Started to sign up for an account.

After you have created your account, then login. Click Your API Key. This will take you to your API key, which will be required in subsequent steps.

Explore Narrative APIs. Here under Portfolio Management, find Predictive Market Stress Testing.

Next, create the Arria service in IBM Cloud.

For the Arria Natural Language Generation API service in IBM Cloud you will need to provide your API Key from Arria.

For the url provide: https://stresstesting-narrativeapi.arria.com/services/rest/fullnarrative. Click Create to create the service in IBM Cloud.

2. Create IBM Cloud services

Create the following services in IBM Cloud for financial services:

For each service, go to service credentials on the left tab. Select New Credentials

Choose a name for your credentials, click Add:

This will add credentials to your service.

3. Clone the repo

Clone the Predict Market Using Arria repo locally. In a terminal, run:

$ git clone https://github.com/IBM/predictive-market-using-arria.git

4. Configure .env file

Create a .env file in the root directory of your clone of the project repository by copying the sample .env.example file using the following command in terminal:

$ cp .env.example .env

NOTE: Most files systems regard files with a "." at the front as hidden files. If you are on a Windows system, you should be able to use either GitBash or Xcopy

You will need to update the credentials with the IBM Cloud credentials for each of the services you created in Step 2.

The .env file will look something like the following:

# Investment Portfolio
CRED_PORTFOLIO_USERID_W=
CRED_PORTFOLIO_PWD_W=
CRED_PORTFOLIO_USERID_R=
CRED_PORTFOLIO_PWD_R=
CRED_PORTFOLIO_URL=https://investment-portfolio.mybluemix.net/

# Predictive Market Scenario
CRED_PREDICTIVE_MARKET_SCENARIO_URL=https://fss-analytics.mybluemix.net/
CRED_PREDICTIVE_MARKET_SCENARIO_ACCESSTOKEN=

# Simulated Instrument Analytics
CRED_SIMULATED_INSTRUMENT_ANALYTICS_URL=https://fss-analytics.mybluemix.net/
CRED_SIMULATED_INSTRUMENT_ANALYTICS_ACCESSTOKEN=

# Arria Natural Language Generation
CRED_ARRIA_NATURAL_LANGUAGE_GENERATION_URL=https://stresstesting-narrativeapi.arria.com/services/rest/fullnarrative
CRED_ARRIA_NATURAL_LANGUAGE_GENERATION_KEY=
CRED_ARRIA_NATURAL_LANGUAGE_GENERATION_FACTORS=factors.csv
CRED_ARRIA_NATURAL_LANGUAGE_GENERATION_VSV=vcv.csv

5. Load Investment Portfolio

You will now need to create a portfolio in your Investment Portfolio service and create holdings for that portfolio. The holdings.sample.json file provides you with sample holdings for a portfolio.

You can use the investmentPortfolio.js script to load portfolio and holdings. The credentials for Investment Portfolio service are retrieved from .env file as per the previous step or can be added directly to the script.

To load a portfolio named MyFixedIncomePortfolio, first install dependencies and use the command-line with the investmentPortfolio.js script to create portfolio. In the project directory, run the following commands in terminal:

$ npm install
$ node investmentPortfolio.js -l MyFixedIncomePortfolio

To load holdings from holdings.sample.json into MyFixedIncomePortfolio, run:

$ node investmentPortfolio.js -l MyFixedIncomePortfolio -h holdings.sample.json

Similarly you can view your portfolios by running:

$ node investmentPortfolio.js -g

and view holdings for portfolio:

$ node investmentPortfolio.js -g MyFixedIncomePortfolio

6. Run Application

In your terminal, cd into this project's root directory

  1. Run npm install to install the app's dependencies
  2. Run npm start
  3. Access the running app locally at http://localhost:8080/

7. Deploy to IBM Cloud

Edit the manifest.yml file in the folder that contains your code and replace with a unique name for your application. The name that you specify determines the application's URL, such as your-application-name.mybluemix.net. Additionally - update the service names so they match what you have in IBM Cloud. The relevant portion of the manifest.yml file looks like the following:

applications:
- path: .
  memory: 256M
  instances: 1
  domain: mybluemix.net
  name: arria-predictive-market
  host: arria-predictive-market
  disk_quota: 256M
  buildpack: sdk-for-nodejs
  services:
  - {Investment-Portfolio service name}
  - {Predictive-Market-Scenarios service name}
  - {Simulated-Instrument-Analytics service name}
  - {Arria-Natural-Language-Generaton service name}

NOTE: Add the name of your Arria NLG service to manifest file. This will deploy the application with the service without having to bind later.

Once the manifest.yml file is configured, you can push to IBM Cloud. From your root directory login into IBM Cloud using CLI:

$ bx login

And push the app to IBM Cloud:

$ bx push

Troubleshooting

  • To troubleshoot your IBM Cloud application, use the logs. To see the logs, run:

    $ bx logs <application-name> --recent
  • If you are running locally, inspect your environment variables closely to confirm they match.

License

This code pattern is licensed under the Apache Software License, Version 2. Separate third party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 (DCO) and the Apache Software License, Version 2.

Apache Software License (ASL) FAQ

predictive-market-using-arria's People

Contributors

raheelzubairy avatar ljbennett62 avatar ash7594 avatar boneskull avatar kant avatar imgbotapp avatar stevemart avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.