Name: Portfolio-compute
Owner: International Business Machines
Description: Analyze an existing Investment Portfolio using IBM Cloud services
Created: 2017-11-08 17:35:59.0
Updated: 2018-05-02 22:14:07.0
Pushed: 2018-05-17 21:22:10.0
Homepage: https://developer.ibm.com/code/patterns/compute-analytics-on-an-investment-portfolio
Size: 815
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
This journey leverages two services:
This code pattern is designed for developers with interest in creating financial applications pertaining to investment portfolios. When the reader has completed this journey, they will understand how to:
Note: these services are free for those who have a Lite account
Use the Deploy to IBM Cloud
button OR create the services and run Run Locally
.
Create an IBM Cloud account and directly deploy the application using the button below.
Follow these steps to setup and run this developer journey. The steps are described in detail below.
Clone the Portfolio Analytics Computation code
locally. In a terminal, run:
$ git clone https://github.com/IBM/Portfolio-compute.git
Create the following services in IBM Cloud. These services are part of either Free
or Experimental
plan.
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
Instrument-Analytics:
label: fss-instrument-analytics-service
plan: fss-instrument-analytics-service-free-plan
plications:
path: .
memory: 128M
instances: 1
name: Portfolio-Compute
disk_quota: 1024M
domain: mybluemix.net
services:
- Investment-Portfolio
- Instrument-Analytics
buildpack: python_buildpack
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:
.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=
strument Analytics
ri=https://fss-analytics.mybluemix.net/
ccess_token=
In your terminal, cd into this project's root directory
pip install -r requirements.txt
to install the app's dependenciespython run.py
You can push the app to IBM Cloud using IBM Cloud CLI. This will use the services and application name in the manifest.yml
file. From your root directory login into IBM Cloud using CLI:
ogin
And push the app to IBM Cloud:
ush
Once the application is running, the first step is to upload a file that will be used to create a portfolio or a series of portfolios in the Investment Portfolio service. We use the file format of the Algorithmics Risk Service (ARS) import file as many production clients are already used to that format. You can find an example file in this repo labelled “Blue Chip Portfolio”. Alternatively, the file ICFS_SAMPLE_POSITIONS.csv
contains the superset of instruments that the Instrument Analytics service supports.
The code will create a portfolio for each unique element found in the “PORTFOLIO” column. Future releases of this code will take into account a portfolio hierarchy, but currently each portfolio is entirely independent of each other.
Some notes:
Note: You can navigate to /api/unit_test_delete to delete all portfolios that have been loaded into the service using this application. Specifically, it looks for portfolios with “type = unit test portfolio”. You can always start over this way, but be careful to not access this if you've done considerable work.
Once the portfolio have been loaded, a second API call can be made. This was parsed out as two separate calls as uploading the portfolio may not need to occur frequently, whereas the computations may.
The next step is to use the application to call the /api/unit_test endpoint. This will perform the following:
Some notes:
ogs <application-name> --recent
on InvestmentPortfolio.py
on InstrumentAnalytics.py