Portfolio Selection Problem

Portfolio selection problem is a classic problem in finance, which aims to select a combination of financial assets to maximize the expected return of a portfolio for a given level of risk or minimize the risk for a given expected return. It is based on the assumption that investors are risk-averse, and they try to maximize their returns while minimizing the risk.

The portfolio selection problem can be formulated as an optimization problem with the following objectives and constraints:

Objectives and Constraints

Objective:

  • Minimize the portfolio risk for a given level of return
  • Maximize the portfolio return for a given level of risk

Constraints:

  • The sum of weights of all assets in the portfolio must be equal to 1. (The portfolio must be fully invested.)
  • The expected return of the portfolio must be greater than or equal to a minimum required return.
  • The portfolio risk, measured by the variance of the portfolio return, must be less than or equal to a maximum allowable risk.
  • The weights of individual assets in the portfolio must be non-negative. (No short selling is allowed.)

The mathematical formulation of the problem is given below:

Let n be the number of assets in the portfolio, and wi be the weight of asset i in the portfolio.

Objective function:

  • Minimize the portfolio risk: minimize 0.5 * w’ * Σ * w
  • Maximize the portfolio return: maximize w’ * R

where Σ is the covariance matrix of asset returns, w’ is the transpose of the weight vector w, and R is the vector of expected returns of the assets.

Constraints:

  • ∑ wi = 1
  • w’ * R ≥ required_return
  • w’ * Σ * w ≤ allowable_risk
  • wi ≥ 0 for all i

Here, the first constraint ensures that the portfolio is fully invested, the second constraint ensures that the expected return of the portfolio meets the minimum required return, the third constraint ensures that the portfolio risk is below the maximum allowable risk, and the fourth constraint ensures that the weights of individual assets in the portfolio are non-negative.

Solving this optimization problem gives the weights of individual assets in the optimal portfolio, which maximizes the expected return or minimizes the risk for a given level of return or risk.

Here’s an example of a portfolio selection problem formulated as a linear programming problem using the Python pulp library:

import pulp

# Define the data for the problem
n_assets = 4  # number of assets in the portfolio
assets = ['Asset1', 'Asset2', 'Asset3', 'Asset4']  # names of the assets
expected_returns = [0.1, 0.05, 0.12, 0.07]  # expected return of each asset
volatilities = [0.2, 0.1, 0.3, 0.15]  # volatility of each asset
budget = 100000  # total budget for the portfolio

# Create the LP problem object
problem = pulp.LpProblem('Portfolio Selection', pulp.LpMaximize)

# Define the decision variables
x = pulp.LpVariable.dicts('x', assets, lowBound=0)

# Define the objective function
problem += pulp.lpSum([expected_returns[i] * x[assets[i]] for i in range(n_assets)])

# Define the constraints
problem += pulp.lpSum([volatilities[i] * x[assets[i]] for i in range(n_assets)]) <= 0.2  # volatility constraint
problem += pulp.lpSum([x[assets[i]] for i in range(n_assets)]) == budget  # budget constraint

# Solve the problem
problem.solve()

# Print the results
print('Portfolio Selection:')
for i in range(n_assets):
    print('{}: {:.2f}%'.format(assets[i], 100 * x[assets[i]].value()))
print('Expected Return: {:.2f}%'.format(100 * pulp.value(problem.objective)))
print('Volatility: {:.2f}%'.format(100 * pulp.lpSum([volatilities[i] * x[assets[i]] for i in range(n_assets)]).value()))

In this example, we define a portfolio selection problem with 4 assets, each with a given expected return and volatility. We want to select a portfolio of assets that maximizes the expected return subject to a constraint on the total volatility and a constraint on the total budget for the portfolio. We define the decision variables x_i as the fraction of the budget allocated to asset i, and formulate the problem as a linear program.

The pulp.LpVariable.dicts function is used to define the decision variables as a dictionary, where the keys are the names of the assets and the values are the LpVariable objects. We define the objective function as the sum of the expected returns of the selected assets, and add the volatility constraint and budget constraint as linear constraints. Finally, we call the solve() method to solve the problem, and print the selected portfolio and the corresponding expected return and volatility.