Description

MATLAB code

Results

Table 1. Solution of Problem 1

 

 

Description

This section demonstrates how to solve Problem 1 (CS.1) - (CS.4) (see Formal Problem Statement) using General text format of PSG (function tbpsg_run)in MATLAB Environment.

 

Main MATLAB code is in file CS_Beyond_BlackLitterman_CVaR_Toolbox.m.

Scenarios of rates of returns of instruments in the portfolio are saved in file matrix_prior_scenarios.mat:

 

MATLAB code

Let us describe the main operations. To run case study you need to do the following main steps:

 

In file CS_Beyond_BlackLitterman_CVaR_Toolbox.m:

 

clc

clear;

 

Load the matrix “matrix_prior_scenarios”:

 

load('.\matrix_prior_scenarios.mat');

 

Define problem statement:

 

problem_statement = sprintf('%s\n',...

'minimize',...

'  cvar_risk(0.95, matrix_prior_scenarios)',...

'Constraint: constraint_budget, == 1',...

'  linear(matrix_budget)',...

'Constraint: constraint_return, >= 0.00105',...

'  avg_g(matrix_prior_scenarios)',...

'Box: >= 0',...

'Solver: precision = 3');

 

Pack the matrix of scenarios:

 

toolboxstruc_arr(1) = tbpsg_matrix_pack('matrix_prior_scenarios',matrix_prior_scenarios_arr,header_matrix_prior_scenarios);

 

Define the matrix “matrix_budget”:

 

header_matrix_budget = {'x1',   'x2',   'x3',   'x4',   'scenario_probability', 'scenario_benchmark'};

matrix_budget = [1   1   1   1   1   0];

 

Pack the matrix of budget constraints:

 

toolboxstruc_arr(2) = tbpsg_matrix_pack('matrix_budget',matrix_budget,header_matrix_budget);

 

Set point "point_lowerbounds":

 

header_point_lowerbounds = {'x1'   'x2'   'x3'   'x4'};

point_lowerbounds = [0 0 0 0];

 

Pack the lowerbound point:

toolboxstruc_arr(3) = tbpsg_point_pack('point_lowerbounds',point_lowerbounds,header_point_lowerbounds);

 

% Uncomment the following line to open the problem in Toolbox Window

% tbpsg_toolbox(problem_statement,toolboxstruc_arr);

Optimize problem:

 

[solution_str, outargstruc_arr] = tbpsg_run(problem_statement, toolboxstruc_arr);

 

 

Results

Table 1. Solution of Problem 1

 

Problem: solution_status = optimal

Timing: Data_loading_time = 0.01, Preprocessing_time = 0.00, Solving_time = 0.01

Variables: optimal_point = point_problem_1_32

Objective: objective_cvar = 0.054853433649

Constraint: constraint_budget = 1.000000000000e+000, [2.220446049250e-016]

Constraint: constraint_return = 1.050000000000e-003, [-2.168404344971e-019]

Function: avg_g_example_return(matrix_prior_scenarios) = 1.050000000000e-003

Function: cvar_risk_example(9.500000E-01,matrix_prior_scenarios) = 5.485343364889e-002

Function: linear_example_budget(matrix_budget) = 1.000000000000e+000

 

Note. This result maths with Solution of Problem 1 obtained by PSG subroutine riskprog.