Construct a socially responsible investment portfolio

Get the code View the demo Watch the tech talk Try the app Build on IBM Cloud


Construct portfolios the right way by using the same capabilities as the quants, with a simplified interface for personal and advisor use. Tap into the growing demand in the industry to incorporate an individual’s unique constraints and preferences, such as socially responsible investing.


This code pattern demonstrates how to configure a request to the Portfolio Optimization service to create a custom investment portfolio that matches the risk and return properties of a selected benchmark.

The IBM Cloud Investment Portfolio service enables you to store, update, and query investment portfolios and associated holdings through API calls. This service can hold a set of client portfolios, that you want to rebalance, a set of benchmark portfolios, whose properties that you want to match, and a set of eligible investments to use in our analysis.

The IBM Cloud Portfolio Optimization service uses a linear optimization framework to find the best combination of assets that meet a given set of criteria. You’ll use this framework for constructing portfolios and rebalancing on both an absolute (for example, minimizing risk and maximizing return) and a relative basis (for example, with respect to another portfolio).

This pattern walks you through the steps of a standard use case for creating (or rebalancing) an investment portfolio to minimize tracking error, or the difference between your portfolio and a standardized one, known as a benchmark. We’ll walk you through the collection and payload construction of constraints, such as an aversion to “sin stocks”, socially responsible investment weighting, and general allocation requirements.

This pattern also includes a simplified user interface we’ve designed to better collect this information from the user, and display the resulting trades that are needed to be made to arrive at the optimized, socially responsible set of investments.



  1. The user or firm seeds the Investment Portfolio service with information prior to running, including eligible investments, benchmarks, and any user portfolios. This in turn populates choice in the UI.
  2. The user accesses the web interface and supplies their goals, requirements, and constraints.
  3. The client preferences are submitted and supplemented with information from the Portfolio Service to construct the optimizer payload, which is submitted to the Portfolio Optimizer service.
  4. The results of the optimization are returned to the user interface for subsequent iteration or analysis.


Ready to put this code pattern to use? Complete details on how to get started running and using this application are in the README.