Description

MATLAB code

Problem 1

Problem 2

Problem 3

Results

Table 1. Comparison of Solutions of Problems 1-3

 

 

Description

Case study Portfolio Optimization with Nonlinear Transaction Costs (see Formal Problem Statement) in MATLAB Environment is solved with mpsg_solver PSG function and includes three optimization problems (see Formal Problem Statement).

 

Problem 1 considers linear transaction costs and includes the budget constraint with Polynomial Absolute function and power coefficients.
Problem 2 considers linear transaction costs, similar to Problem 1. However, it is based on linear version of the budget constraint (with linear functions).
Problem 3 includes the nonlinear budget constraint with Polynomial Absolute function and power coefficients.

 

MATLAB code for Portfolio Optimization with Nonlinear Transaction Costs is in file CS_Nonlinear_Transaction_Costs_CVaR_POLYNOMABS.m.

 

Data are saved in files:

 

Solution of Problem in MATLAB

 

Formal Problem

Statement

Data

Problem 1

 

Optimization Problem 1 (CS.1-CS.4)

problem_1_Trans_Costs.mat

Problem 2

 

Optimization Problem 2 (CS.5-CS.8)

problem_2_Trans_Costs.mat

Problem 3

 

Optimization Problem 3 (CS.9-CS.12)

problem_3_Trans_Costs.mat

 

 

 

MATLAB code

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

 

In file CS_Nonlinear_Transaction_Costs_CVaR_POLYNOMABS_Toolbox.m:

 

Problem 1

 

problem_name = 'problem_1_Trans_Costs_Toolbox.mat';

 

Load the problem and data:

 

load(['.\' problem_name]);

tbpsg_export_to_workspace(toolboxstruc_arr);

 

Define problem statement:

 

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

'maximize',...

'Objective: objective_expected_gain_1, linearize = 1',...

'  avg_g(matrix_loss_1)',...

'Constraint: <= 0, linearize = 1',...

'  polynom_abs(matrix_polynom_abs_1)',...

'  linear(matrix_initial_prices)',...              

'Constraint: constraint_on_CVaR_1, <= 1000, linearize = 1',...

'  cvar_risk(0.90000000, matrix_loss_1)',...

'Box: >= point_lowerbounds, <= point_upperbounds',...

'');

 

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

%tbpsg_toolbox(problem_statement,toolboxstruc_arr);

 

Optimize problem:

 

[solution_str1, outargstruc_arr1] = tbpsg_run(problem_statement,toolboxstruc_arr);

 

 

Extract optimal point for the problem "problem_1_Trans_Costs":

 

point_variables = tbpsg_optimal_point_vars(solution_str1, outargstruc_arr1);

X_opt1 = tbpsg_optimal_point_data(solution_str1, outargstruc_arr1)';

 

fprintf('solution: %s\n', solution_str1);

 

 

Problem 2

 

problem_name = 'problem_2_Trans_Costs_Toolbox.mat';

 

Load the problem and data:

 

load(['.\' problem_name]);

tbpsg_export_to_workspace(toolboxstruc_arr);

 

Define problem statement:

 

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

'maximize',...

'Objective: objective_expected_gain_2, linearize = 1',...

'  avg_g(matrix_loss_2)',...

'Constraint: <= 1000, linearize = 1',...

'  cvar_risk_2(0.90000000, matrix_loss_2)',...

'Constraint: <= 0',...

'  linear(matrix_budget)',...

'Box: >= point_lowerbounds, <= point_upperbounds',...

'');

 

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

%tbpsg_toolbox(problem_statement,toolboxstruc_arr);

 

Optimize problem:

 

[solution_str2, outargstruc_arr2] = tbpsg_run(problem_statement,toolboxstruc_arr);

 

 

Extract optimal point for the problem "problem_2_Trans_Costs":

 

point_variables = tbpsg_optimal_point_vars(solution_str2, outargstruc_arr2);

X_opt2 = tbpsg_optimal_point_data(solution_str2, outargstruc_arr2)';

 

X_opt2_long = X_opt2(1:2:end);

X_opt2_short = X_opt2(2:2:end);

 

fprintf('solution: %s\n', solution_str2);

 

 

Problem 3

 

problem_name = 'problem_3_Trans_Costs_Toolbox.mat';

 

Load the problem and data:

 

load(['.\' problem_name]);

tbpsg_export_to_workspace(toolboxstruc_arr);

 

Define problem statement:

 

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

'maximize',...

'Objective: objective_expected_gain_1, linearize = 1',...

'  avg_g(matrix_loss_1)',...

'Constraint: <= 0',...

'  linear(matrix_initial_prices)',...

'  polynom_abs(matrix_polynom_abs_2)',...

'Constraint: <= 1000, linearize = 1',...

'  cvar_risk(0.90000000, matrix_loss_1)',...

'Box: >= point_lowerbounds, <= point_upperbounds',...

'');

 

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

%tbpsg_toolbox(problem_statement,toolboxstruc_arr);

 

 

Optimize problem:

 

[solution_str3, outargstruc_arr3] = tbpsg_run(problem_statement,toolboxstruc_arr);

 

Extract optimal point for the problem "problem_3_Trans_Costs":

 

point_variables = tbpsg_optimal_point_vars(solution_str3, outargstruc_arr3);

X_opt3 = tbpsg_optimal_point_data(solution_str3, outargstruc_arr3)';

 

fprintf('solution: %s\n', solution_str3);

 

Display table comparing solutions for three problems:

 

fprintf('Compare Optimal Solutions for Three Problems');

fprintf('\n\n Component   Problem_1      Problem_2      Problem_2   Problem_3\n');

fprintf('                          long position  short position\n');

for j=1:1:length(point_variables)

   fprintf('%6s%16f%15f%14f%14f\n', point_variables{j},X_opt1(j),X_opt2_long(j), X_opt2_short(j),X_opt3(j));

end

 

 

 

Results

Table 1. Comparison of Solutions of Problems 1-3

Component   Problem_1      Problem_2      Problem_2   Problem_3

                         long position  short position

   aa       57.866184      57.866184      0.000000     28.339480

  aep      -39.603960       0.000000     39.603962    -39.603960

  agc      -31.434185       0.000000     31.434185    -15.512097

  aig       27.027027      27.027027      0.000000      0.414658

  ait      -38.787879       0.000000     38.787880    -16.678772

  alt     -113.074200       0.000000    113.074200    -28.269952

  arc      -27.777778       0.000000     27.777779    -15.525287

  avp       68.669528      68.669525      0.000000      6.759822

  axp       26.890756      26.890757      0.000000     26.890756

   ba       61.185468      61.185467      0.000000     -3.449192

  bac      -36.363636       0.000000     36.363636    -12.295229

  bax      -34.632035       0.000000     34.632034    -17.094627

   bc      143.497760     143.497760      0.000000     23.195000

  bcc       86.253369      86.253372      0.000000     13.426171

  bdk       47.832586      47.832584      0.000000     -5.961267

  bel      -38.882139       0.000000     38.882137    -13.848223

  bhi       96.969697      96.969696      0.000000     16.299233

  bmy       41.612484      41.612484      0.000000      4.332810

  bni      -66.945607       0.000000     66.945610    -23.324559

   bs     -250.000000       0.000000    250.000000    -17.791169

    c       32.045530      32.045528      0.000000     -4.868256

  cbs       80.808081      80.808083      0.000000     21.398613

  cen      -71.032313       0.000000     71.032310    -17.018208

  cgp      -56.737589       0.000000     56.737587    -11.072844

  cha       69.414317      69.414314      0.000000     20.873344

   ci       30.888031      30.888031      0.000000     -3.481200

   cl       55.603745      55.603745      0.000000      0.837950

  col       99.688474      99.688477      0.000000     -2.454808

  cpb      -38.049941       0.000000     38.049942    -24.789605

  csc       41.290323      41.290321      0.000000     -5.254600

 csco       71.748879      71.748878      0.000000     26.882552

  dal      -41.343669       0.000000     41.343670     -7.657693

   dd      -36.488027       0.000000     36.488026     -7.103296

  dis      -79.207921       0.000000     79.207924     -9.141350

  dow       23.038157      23.038157      0.000000     -3.582221

   ek      -26.315789       0.000000     26.315790    -15.276536

  etr      -64.257028       0.000000     64.257027    -16.333934

    f      -46.376812       0.000000     46.376812     -7.314124

  fcx      164.948450     164.948460      0.000000      4.783043

  fdx       88.765406      88.765404      0.000000     11.745142

  flr      -51.036683       0.000000     51.036682     -8.309632

   gd      -37.037037       0.000000     37.037037     -9.550204

   ge       26.600166      26.600166      0.000000      4.112174

   gm      -36.363636       0.000000     36.363636     -5.628974

  hal       70.640177      70.640175      0.000000      8.347402

  het      159.203980     159.203980      0.000000     11.842007

  hig      -42.895442       0.000000     42.895443     -8.488540

   hm     -147.465440       0.000000    147.465440    -19.532824

  hnz      -35.714286       0.000000     35.714287    -15.196241

  hon       31.434185      31.434185      0.000000      9.465887

  hrs      -65.708419       0.000000     65.708420    -11.534697

  hwp       40.201005      40.201004      0.000000     10.703998

  ibm       32.000000      32.000000      0.000000      9.794812

  iff      -60.037523       0.000000     60.037525     -5.884921

 intc       47.690015      47.690014      0.000000     10.042008

   ip      -44.137931       0.000000     44.137932     -7.304685

  jnj       -0.000000       0.000000      0.000000     -4.378575

   km     -179.775280       0.000000    179.775280     -6.052459

   ko      -33.934252       0.000000     33.934254     -9.875256

  ltd       87.671233      87.671234      0.000000      5.875608

   lu       63.492063      63.492062      0.000000     10.726641

  may      -56.974051       0.000000     56.974052     -7.056461

  mcd       68.891400      68.891403      0.000000     -2.211304

  mer       43.478261      43.478260      0.000000      8.029168

  mkg       97.859327      97.859329      0.000000      4.197196

  mmm       23.719379      23.720615      0.000000     -3.963917

  mob       -0.000000       0.000000      0.000000     -4.080268

  mrk      -31.295868       0.000000     31.295868     -7.209837

 msft       38.415366      38.415367      0.000000      6.871320

  mtc      -38.461538       0.000000     38.461540     -8.962128

  nsc      -68.522484       0.000000     68.522484     -7.960004

  nsm      216.216220     216.216220      0.000000     14.219438

   nt      128.514060     128.514050      0.000000     11.545924

  one      -47.690015       0.000000     47.690014     -5.450827

 orcl      116.550120     116.550120      0.000000      9.564157

  oxy      -93.023256       0.000000     93.023254     -7.600155

  pep      -65.708419       0.000000     65.708420     -6.407939

   pg      -26.711185       0.000000     26.711185     -3.687962

  pnu      -40.201005       0.000000     40.201004     -6.313073

  prd      -36.249525       0.000000     36.246004     -3.130691

  ral      -67.796610       0.000000     67.796608     -7.544621

  rok       58.823529      58.823528      0.000000      5.348785

 rtnb      -35.437431       0.000000     35.437431     -4.948689

    s      -47.761194       0.000000     47.761192     -6.988060

  slb       41.184041      41.184040      0.000000     -0.566637

   so      -64.516129       0.000000     64.516129     -7.593499

    t      -51.689604       0.000000     51.689606     -3.813024

  tan       87.312605      87.312607      0.000000     20.745351

  tek      126.984130     126.984120      0.000000      7.859000

  txn       79.899965      79.899963      0.000000      9.561655

  ucm      -51.696284       0.000000     51.696285     -6.449936

  uis       94.674556      94.674553      0.000000      6.331597

  usb      -54.888508       0.000000     54.888508     -5.845273

  utx       52.545156      52.545155      0.000000      4.464782

  wfc      -23.964565       0.000000     23.969716     -3.043909

  wmb       71.910112      71.910110      0.000000      2.563881

  wmt       72.153456      72.153458      0.000000      3.226680

   wy       46.647230      46.647232      0.000000     -2.648977

  xon      -27.397260       0.000000     27.397261     -5.053101

  xrx      -46.920821       0.000000     46.920822     -4.092645

 

Analysis of this table shows that problem 1  and problem 2 are equivalent.