Estimated Release Date

Publicly Available

Licence

Apache License 2.0
This is a supervised financial asset recommender service. It takes as input historical asset pricing data (weekly market closing prices) and for an asset and it predicts the annualized return on investment (i.e. profit %) for that asset. This is a publicly available containerized service. This components comes in two main flavors, namely: 1) a python jupyter notebook tutorial and 2) a containerized microservice with Rest API that can host a previously trained recommendation model. Typically new users should start with the python jupyter notebook tutorial as this will guide you through the process of training a recommendation model based on past data, and evaluating its performance. Users with already trained models can then try the microservice container for hosting the models that they have trained.

Category

Recommender

Type

Asset

Field of use

Financial Services

Resources

Visit here
Visit here
Visit here

Deploy in Tutorial Notebook Mode

The easiest way to get started with this service is to work through the python notebook tutorial included with the service. You can either work through the tutorial using a local Python Jupyter Server or Docker Compose, upload it to Google Colabratory, or run it on your Kubernetes compute cluster, as described below:

Deploy Locally via Jupyter Notebook

To run the tutorial on your local machine, you will need to have a Python Jupyter server running locally. You can download and install Jupyter from here

Once running, you can download the stand-alone notebook version of the Financial Asset Recommender FinancialAssetProfitabilityPrediction.ipynb and save it on your computer (right-click on the file and select ‘Save Link As..’), then open it with your Jupyter server. You should make sure to save the notebook in a directory that the Jupyter server can access.

Deploy Locally via Docker Compose

If you have a local installation of Docker (and Docker compose, typically installed with Docker) then you can also run the tutorial notebook using a pre-built Docker container with the notebook server and iPython notebook. In this case, download the docker-compose.yml file from this folder (right-click on the file and select ‘Save Link As..’). Then in a terminal (e.g. Bash for Linux, Terminal for MacOS or PowerShell for Windows) navigate to the folder that you downloaded the file to and run the following command:

docker-compose up

You should then copy the link that will appear in the terminal (the one starting with http://127.0.0.1:8888…) and paste it into your browser URL bar to navigate to the Jupyter Server UI, and open the tutorial notebook (FinancialAssetProfitabilityPrediction.ipynb) from there.

Deploy via Google Colabratory

If you don’t have Jupyter or Docker installed locally, or are using an old machine, then you can also run the notebook remotely via Google’s free Colaboratory Service. Colaboratory is simply a series of Jupyter servers running in Google’s cloud infrastructure, which they make available for reasearch and learning. You will first need to download a copy of the Financial Asset Recommender tutorial notebook and save it locally. You can get the notebook from here and save it on your computer (right-click on FinancialAssetProfitabilityPrediction.ipynb and select ‘Save Link As..’). Once that is done, open Colaboratory in your browser, login with your Google account if you have not already done so, and you will reach a screen like this:

Click on the ‘Upload’ tab, click ‘Browse…’ and select FinancialAssetProfitabilityPrediction.ipynb that you downloaded earlier. This should open the notebook in your browser ready for you to work through it, where execution is performed on Google’s remote servers.

Deploy via Google Colabratory

Deploying the tutorial notebook server on an existing Kubernetes cluster is facilitated via a Helm Chart. This is a specification of the different Kubernetes objects that need to be created on the cluster for the service to function. You will first need to have Helm installed on the machine that you use to communicate with the Kubernetes cluster, this is an additional application that makes it easier to deploy and configure groups of Kubernetes objects that form an application. Instructructions for installing Helm can be found on the Helm Website.

Once Helm is installed, the next step is to download the Helm chart for the Financial Asset Recommender tutorial, which you can get from the associated Github repository. In particular, on the machine that you use to communicate with the cluster and has Helm installed, clone the git repository:

git clone https://github.com/terrierteam/Infinitech-FAR-ProfitabilityEstimator.git

Next you need to make a small configuration change based on your Kubernetes cluster configuration. Kubernetes clusters are typically closed systems, i.e. services running in them are not visable to the out-side world by default. The helm chart provided will get around this limitation by creating a Kubernetes Ingress object that specifies a public endpoint that will allow pass-through access to the Jupyter server that runs the tutorial from the outside. However, to configure an ingress, we need to specify a unique hostname for the service that will DNS resolve to the cluster external end-point. For example, if your cluster is running on a server at http://mykubecluster.us-east-2.amazonaws.com, then we might want http://jupyter.mykubecluster.us-east-2.amazonaws.com to point to the jupyter notebook server. To configure this, you need to open up the Kubernetes/infinitech-far-fe/values.yaml file in your cloned copy of the git repository in a text editor, then un-comment (delete the ‘#’) in line 53 and replace the text after the ‘host: ‘ with your unique hostname for the service (i.e. your equivalent to http://jupyter.mykubecluster.us-east-2.amazonaws.com), then save the file. Once done, in a terminal (e.g. Bash for Linux, Terminal for MacOS or PowerShell for Windows), navigate to the cloned git repository run:

helm install infinitech-far-fe ./Kubernetes/infinitech-far-fe --namespace mykubenamespace

Where ‘mykubenamespace’ should be replaced with the namespace within your Kubernetes cluster you want the application to be installed into. This will start the services running on your Kubernetes cluster. You can then access the notebook by entering the unique hostname you specified earlier into a web browser. You can also remove the rest API service once you are finished with it via:

helm uninstall infinitech-far-fe --namespace mykubenamespace

Deploy as Containerized Microservice

The tutorial notebook discussed above walks you through the process of downloading timeseries financial data, preparing and then training an asset recommendation model based on that data. However, often we want to use the resultant model within a larger application. This is supported by hosting a containerized service that exposes a Restful API end-point that uses the resultant model to produce recommendations on-demand for specified assets or by providing the needed time-series features to make a prediction for a previously unseen asset. The specification for this API can be found here. Once you have a model trained, you can deploy the model as a microservice on Kuberntes cluster. However, note that you will have needed to store the trained model within a persistant storage volume that can be subsequently mounted to the API service container (so it can access your model).

Deploy via Kubernetes Cluster

Deploying the tutorial notebook server on an existing Kubernetes cluster is facilitated via a Helm Chart. This is a specification of the different Kubernetes objects that need to be created on the cluster for the service to function. You will first need to have Helm installed on the machine that you use to communicate with the Kubernetes cluster, this is an additional application that makes it easier to deploy and configure groups of Kubernetes objects that form an application. Instructructions for installing Helm can be found on the Helm Website.

Once Helm is installed, the next step is to download the Helm chart for the Financial Asset Recommender tutorial, which you can get from the associated Github repository. In particular, on the machine that you use to communicate with the cluster and has Helm installed, clone the git repository:

git clone https://github.com/terrierteam/Infinitech-FAR-ProfitabilityEstimator.git

Next you need to configure the deployment to specify where the service should obtain the trained recommendation model and list of assets from. To configure this, you need to open up the Kubernetes/infinitech-far-fe-s/values.yaml file in your cloned copy of the git repository in a text editor, then edit the first two entries: ‘modelLocation’ and ‘assetDBLocation’. By default these will load example models from a Google Drive folder. Once done, in a terminal (e.g. Bash for Linux, Terminal for MacOS or PowerShell for Windows), navigate to the cloned git repository run:

helm install infinitech-far-fe-s ./Kubernetes/infinitech-far-fe-s --namespace mykubenamespace

Where ‘mykubenamespace’ should be replaced with the namespace within your Kubernetes cluster you want the application to be installed into. This will start the application running on your Kubernetes cluster. As part of the helm chart a service object will be created with the name “infinitech-far-fe-s*” (where * is replaced with a generated number for the deployment. You can send API requests via this service on port 80. You can also remove the rest API service once you are finished with it via:

helm uninstall infinitech-far-fe-s --namespace mykubenamespace