IBM/Portfolio-Optimize

Name: Portfolio-Optimize

Owner: International Business Machines

Description: Learn how to build a socially responsible portfolio

Created: 2017-10-16 18:16:46.0

Updated: 2018-04-27 18:54:54.0

Pushed: 2018-05-17 21:27:32.0

Homepage: https://developer.ibm.com/code/patterns/construct-a-socially-responsible-investment-portfolio/

Size: 1058

Language: Python

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Skill Level: Beginner
N.B: All services used in this repo are Lite plans.

Build Status

Socially Responsible Investment Portfolio Construction

In this developer journey, we will demonstrate how to collect information from a user to build a socially responsible portfolio that maintains the same risk and return profile of a standardized portfolio.

This journey leverages two services:

When the reader has completed this journey, they will understand how to:

Included Components
Steps

Use the Deploy to IBM Cloud button OR create the services and run Run Locally.

Deploy to IBM Cloud

Deploy to IBM Cloud

Note: The code automatically prepopulates the Investment Portfolio service before running the front end. This is done without use the typical raw curl command. See Step 6: Initialize Investment Portfolio for more details.

Running the Application Locally

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

Prerequisites
Steps to run locally
  1. Clone the repo
  2. Create IBM Cloud services
  3. Configure Manifest file
  4. Configure .env file
  5. Run Application
  6. Initialize Investment Portfolio
1. Clone the repo

Clone the Build-an-optimal-investment-portfolio code locally. In a terminal, run:

$ git clone https://github.com/IBM/Build-an-optimal-investment-portfolio.git

2. Create IBM Cloud services

Create the following services: You need to click on each link listed below, give it a name and create the service.

3. Configure Manifest file

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 the IBM Cloud. The relevant portion of the manifest.yml file looks like the following:

clared-services:
Investment-Portfolio:
  label: fss-portfolio-service
  plan: fss-portfolio-service-free-plan
Portfolio-Optimization:
  label: fss-financial-optimization-service
  plan: fss-financial-optimization-service-free-plan
plications:
path: .
memory: 128M
instances: 1
name: Socially-Responsible-Investment-Portfolio-Construction
disk_quota: 1024M
domain: mybluemix.net
services:
- Investment-Portfolio
- Portfolio-Optimization
buildpack: python_buildpack
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:

 .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:

vestment Portfolio
_PORTFOLIO_USERID_W=
_PORTFOLIO_PWD_W=
_PORTFOLIO_USERID_R=
_PORTFOLIO_PWD_R=

rtfolio Optimizer
_OPTIMIZER_uri=https://fss-analytics.mybluemix.net/
_OPTIMIZER_accessToken=
5. Run Application

cd into this project's root directory

6. Initalize the Investment Portfolio Service

The application relies on a few elements pre-populated in the Investment Portfolio service. The user interface will read from this service in order to retrieve the properties and selections that a user can interact with.

Once the application is running, we can initialize the service by populating the Investment Portfolio service with the information it needs.

Some points to note:

You have the ability to initalize the application by accessing the initialize endpoint in your browser by navigating to http://0.0.0.0:8080/api/init.

Find more information on Investment Portfolio api calls here.

Note that accessing the /api/reset endpoint will delete all of the portfolios in the service that the /api/init endpoint created. You can always start over this way, but be careful to not access this if you've done considerable work.

7. Learn More

Big Data and Analytics Hub Data & Analytics Architecture

Troubleshooting

pp logs <application-name> --recent
on InvestmentPortfolio.py
on PortfolioOptimization.py
Privacy Notice

This web application includes code to track deployments to IBM Cloud runtimes and services. The following information is sent to a Metrics Tracker service on each deployment:

This data is collected from the VCAP_APPLICATION and VCAP_SERVICES environment variables in IBM Cloud. This data is used by IBM to track metrics around deployments of sample applications to IBM Cloud to measure the usefulness of our examples, so that we can continuously improve the content we offer to you. Only deployments of sample applications that include code to ping the Deployment Tracker service will be tracked.

Learn more

License

Apache 2.0


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.