Menu

Tree [5d754a] master /
 History

HTTPS access


File Date Author Commit
 .gitignore 2014-06-06 Antonello Lobianco Antonello Lobianco [5f4a77] 1) Added tollerance as I parameter; 2) Added er...
 Array.cpp 2014-05-28 Antonello Lobianco Antonello Lobianco [80cbc0] Initial commit
 Array.h 2014-05-28 Antonello Lobianco Antonello Lobianco [80cbc0] Initial commit
 QuadProg++.cpp 2014-06-06 Antonello Lobianco Antonello Lobianco [5f4a77] 1) Added tollerance as I parameter; 2) Added er...
 QuadProg++.h 2014-05-28 Antonello Lobianco Antonello Lobianco [80cbc0] Initial commit
 README.txt 2016-02-15 Antonello Lobianco Antonello Lobianco [5d754a] The portfolio optimal mean and variance is now ...
 anyoption.cpp 2014-05-28 Antonello Lobianco Antonello Lobianco [80cbc0] Initial commit
 anyoption.h 2014-05-28 Antonello Lobianco Antonello Lobianco [80cbc0] Initial commit
 libgcc_s_dw2-1.dll 2014-05-28 Antonello Lobianco Antonello Lobianco [80cbc0] Initial commit
 libstdc++-6.dll 2014-05-28 Antonello Lobianco Antonello Lobianco [80cbc0] Initial commit
 main.cpp 2016-02-15 Antonello Lobianco Antonello Lobianco [5d754a] The portfolio optimal mean and variance is now ...
 means_lorraine.dat 2014-05-28 Antonello Lobianco Antonello Lobianco [80cbc0] Initial commit
 portopt.cpp 2016-02-15 Antonello Lobianco Antonello Lobianco [5d754a] The portfolio optimal mean and variance is now ...
 portopt.h 2016-02-15 Antonello Lobianco Antonello Lobianco [5d754a] The portfolio optimal mean and variance is now ...
 portopt.i 2016-02-15 Antonello Lobianco Antonello Lobianco [5d754a] The portfolio optimal mean and variance is now ...
 pythonExample.py 2016-02-15 Antonello Lobianco Antonello Lobianco [5d754a] The portfolio optimal mean and variance is now ...
 vars_lorraine.dat 2014-05-28 Antonello Lobianco Antonello Lobianco [80cbc0] Initial commit
 windows_screenshot.png 2014-05-28 Antonello Lobianco Antonello Lobianco [80cbc0] Initial commit

Read Me

*****************************************************************************
***          !! Welcome to PortOpt - The Portfolio Optimizer !!           ***
*** For info & doc: http://lobianco.org/antonello/personal:portfolio:home ***
*****************************************************************************

This file is part of PortOpt [Portfolio Optimizer]: an open-source (LGPLed) C++ program  (with Python binding) implementing the Markowitz(1952) mean-variance model with agent's linear indifference curves toward risk in order to find the optimal assets portfolio under risk.

You have to provide PortOpt (in text files or - if you use the api- using your own code) the variance/covariance matrix of the assets, their average returns and the agent risk preference.

It returns the vector of assets'shares that compose the optimal portfolio. 

In order to minimise the variance it internally uses QuadProg++, a library that implement the algorithm of Goldfarb and Idnani for the solution of a (convex) Quadratic Programming problem by means of an active-set dual method.

Compile with:
  Option 1 - as a stand-alone program:
  g++ -std=c++0x -O -o portopt_executable QuadProg++.cpp Array.cpp anyoption.cpp portopt.cpp  main.cpp 
 
  Option 2 - as a library to be used in your C/C++ program:
  g++ -fPIC -std=c++0x -O -c QuadProg++.cpp Array.cpp anyoption.cpp portopt.cpp main.cpp 
  g++ -std=c++0x -O -shared -Wl,-soname,portopt.so -o portopt.so QuadProg++.o Array.o anyoption.o portopt.o
  (then link your program e.g. with:
   g++ -std=c++0x -O -o portopt_executable main.o -Wl,-rpath,'$ORIGIN' -L . portopt.so
   ./portopt_executable
  )
 
  Option 3 - as a lib to be used in python, using swig:
  swig -c++ -python portopt.i
  g++ -fPIC -std=c++0x -O -c QuadProg++.cpp Array.cpp anyoption.cpp portopt.cpp portopt_wrap.cxx main.cpp -I/usr/include/python2.7 -I/usr/lib/python2.7
  g++ -std=c++0x -O -shared -Wl,-soname,_portopt.so -o _portopt.so QuadProg++.o Array.o anyoption.o portopt.o portopt_wrap.o
  (then please refer to the python example for usage) 

Usage:
Linux: ./portopt [options]
Windows: portopt.exe [options] (from a DOS prompt: (a) START->run->"cmd"; (b) cd \path\to\portopt )
As a lib from C++:
  call  double solveport (const vector< vector <double> > &VAR, const vector<double> &MEANS, const double &alpha, vector<double> &x_h, int &errorcode, string &errormessage, double & port_opt_mean, double & port_opt_var, const double tolerance = 0.000001)
As a lib from python:
  import portopt
  results      = portopt.solveport(var,means,alpha,[tolerance])
  functioncost = results[0]
  shares       = results[1]
  errorcode    = results[2]
  errormessage = results[3]
  opt_mean     = results[4]
  opt_var      = results[5]

Options:
 -h  --help                                   Prints this help 
 -v  --var-file [input_var_file_name]         Input file containing the variance/covariance matrix (relative path)   
 -m  --means-file [input_means_file_name]     Input file containing the means vector (relative path)  
 -a  --alpha [alpha_coefficient]              Coefficient between production and risk in the linear indifference curves   
 -f  --field-delimiter [field_delimiter]      Character to use as field delimiter (default: ';')  
 -s  --decimal-separator [decimal-separator]  Character to use as decimal delimiter (default: '.')  
 -t  --tolerance [tolerance]                  A tolerance level to distinguish from zero (default: 0.000001)


Notes:
  - Higher the alpha, lower the agent risk aversion;
  - Set a negative alpha to retrieve the portfolio with the lowest possible variance;
  - Set alpha to zero to retrieve the portfolio with the highest mean, independently from variance (solution not guaranteed to be unique);
  - Assets shares are returned in the x_h vector, eventual error code (0: all fine, 1: input data error, 2: no solutions, 3: didn't solve, 4: solver internal error) in the errorcode parameter. 
  
  
Copyright (C) 2014 Antonello Lobianco.

PortOpt is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

PortOpt is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with PortOpt.  If not, see <http://www.gnu.org/licenses/>.

Acknowledgements:
This work was supported by the French National Research Agency through the Laboratory of Excellence ARBRE, a part of the "Investissements d'Avenir" Program (ANR 11 -- LABX-0002-01) and by a grant overseen by Office National des Forêts through the Forêts pour Demain International Teaching and Research Chair.