% Copyright (c) 2001-2009 by Ales Cerny %************************************************************************% % chapter4exe4.m - supplementary program to % % Ales Cerny (2009) Mathematical Techniques in Finance (2nd ed.) % % Princeton University Press http://press.princeton.edu/titles/9079.html % %************************************************************************% % This code is provided 'as-is', without any express or implied warranty. % % Permission is granted to anyone to use this code for any purpose, % subject to the following restrictions: % % 1. The origin of this code must not be misrepresented; you must not % claim that you wrote the original code. % 2. Modified code versions must be plainly marked as such, and must not % be misrepresented as being the original code. % 3. This notice may not be removed from any source distribution. % NOTICE TO STUDENTS: To avoid accusations of plagiarism, if you use this % code or its modifications in assessed work you should prepend it with a % note stating: % "This is the original/modified version of the code chapter4exe4.m by % Ales Cerny (2009), Mathematical Techniques in Finance (2nd ed.), % Princeton University Press. The original version is available from % http://www.martingales.info/mtfweb2". % A similar acknowledgement should appear prominently inside your written % report. % One period optimal investment with CRRA utility, incomplete markets, two % risky asset, one year horizon. clear; clc %*******************% % parameters % %*******************% outputflag = 1; % 1 output should be printed, 0 nothing be printed. IPTolerance = 10^(-6); gama=5; Risky1 = [-0.2 -0.2 0.2 0.2]; Risky2 = [-0.1 0.2 -0.1 0.2]; XDistr = [0.125 0.125 0.375 0.375]; RiskFreeRate = 0.02; X = [(Risky1-RiskFreeRate) ; (Risky2-RiskFreeRate)]; % quadratic utility calculations EX = X*XDistr'; % E[X] OmegaX = (X.*(ones(size(X,1),1)*XDistr))*X'; % OmegaX=E[XX'] SigmaX = OmegaX - EX*EX'; % SigmaX = E[XX']-E[X]E[X]' [IP,beta]= HARAmax(X,XDistr,gama,IPTolerance,outputflag); disp(' '); disp(sprintf('HARA investment potential %12.4f ', IP)); disp(sprintf('QU investment potential %12.4f ', 1-sqrt(1/(1+EX'*(SigmaX\EX))))); disp(sprintf('%s',['HARA alpha ' num2str(beta'/gama,'%12.4f')])); disp(sprintf('%s',['QU alpha ' num2str((OmegaX\EX)'/gama,'%12.4f')])); disp(' ');