[Returnanalytics-commits] r3346 - in pkg/PortfolioAnalytics/sandbox: . RFinance2014 RFinance2014/data

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Thu Apr 3 20:33:08 CEST 2014


Author: rossbennett34
Date: 2014-04-03 20:33:08 +0200 (Thu, 03 Apr 2014)
New Revision: 3346

Added:
   pkg/PortfolioAnalytics/sandbox/RFinance2014/
   pkg/PortfolioAnalytics/sandbox/RFinance2014/data/
   pkg/PortfolioAnalytics/sandbox/RFinance2014/data/edhec.csv
   pkg/PortfolioAnalytics/sandbox/RFinance2014/data/edhec.rda
   pkg/PortfolioAnalytics/sandbox/RFinance2014/data/parse_edhec.R
   pkg/PortfolioAnalytics/sandbox/RFinance2014/edhec.rda
   pkg/PortfolioAnalytics/sandbox/RFinance2014/edhec_eda.R
   pkg/PortfolioAnalytics/sandbox/RFinance2014/optimize.R
   pkg/PortfolioAnalytics/sandbox/RFinance2014/presentation.Rmd
   pkg/PortfolioAnalytics/sandbox/RFinance2014/presentation.html
   pkg/PortfolioAnalytics/sandbox/RFinance2014/presentation.md
   pkg/PortfolioAnalytics/sandbox/RFinance2014/slides.pdf
Log:
Initial commit of framework for RFinance 2014 PortfolioAnalytics Presentation

Added: pkg/PortfolioAnalytics/sandbox/RFinance2014/data/edhec.csv
===================================================================
--- pkg/PortfolioAnalytics/sandbox/RFinance2014/data/edhec.csv	                        (rev 0)
+++ pkg/PortfolioAnalytics/sandbox/RFinance2014/data/edhec.csv	2014-04-03 18:33:08 UTC (rev 3346)
@@ -0,0 +1,206 @@
+date;Convertible Arbitrage;CTA Global;Distressed Securities;Emerging Markets;Equity Market Neutral;Event Driven;Fixed Income Arbitrage;Global Macro;Long/Short Equity;Merger Arbitrage;Relative Value;Short Selling;Funds Of Funds
+31/01/1997;1.19%;3.93%;1.78%;7.91%;1.89%;2.13%;1.91%;5.73%;2.81%;1.50%;1.80%;-1.66%;3.17%
+28/02/1997;1.23%;2.98%;1.22%;5.25%;1.01%;0.84%;1.22%;1.75%;-0.06%;0.34%;1.18%;4.26%;1.06%
+31/03/1997;0.78%;-0.21%;-0.12%;-1.20%;0.16%;-0.23%;1.09%;-1.19%;-0.84%;0.60%;0.10%;7.78%;-0.77%
+30/04/1997;0.86%;-1.70%;0.30%;1.19%;1.19%;-0.05%;1.30%;1.72%;0.84%;-0.01%;1.22%;-1.29%;0.09%
+31/05/1997;1.56%;-0.15%;2.33%;3.15%;1.89%;3.46%;1.18%;1.08%;3.94%;1.97%;1.73%;-7.37%;2.75%
+30/06/1997;2.12%;0.85%;2.17%;5.81%;1.65%;2.58%;1.08%;2.18%;2.23%;2.31%;1.98%;-0.65%;2.25%
+31/07/1997;1.93%;5.91%;2.34%;5.60%;2.47%;3.07%;0.95%;7.38%;4.54%;2.00%;1.81%;-4.29%;4.35%
+31/08/1997;1.34%;-4.73%;1.47%;-0.66%;0.17%;0.71%;0.87%;-1.80%;1.07%;0.79%;1.03%;-0.72%;0.51%
+30/09/1997;1.22%;1.98%;3.50%;2.29%;2.02%;3.29%;1.19%;2.90%;4.29%;1.97%;1.83%;-1.55%;3.34%
+31/10/1997;1.00%;-0.98%;-0.64%;-5.72%;0.95%;0.61%;-0.32%;-1.42%;0.10%;0.94%;0.79%;5.72%;-0.99%
+30/11/1997;0.00%;1.33%;0.54%;-3.78%;0.41%;1.34%;0.53%;1.06%;-0.26%;2.23%;1.11%;2.17%;-0.34%
+31/12/1997;0.68%;2.86%;0.73%;1.60%;0.66%;1.54%;0.79%;2.64%;1.04%;1.58%;0.82%;1.61%;0.89%
+31/01/1998;1.45%;1.04%;0.95%;-4.29%;0.60%;0.55%;-0.26%;-0.50%;0.13%;0.55%;1.32%;0.14%;-0.36%
+28/02/1998;1.46%;-0.65%;2.27%;3.39%;1.35%;2.94%;0.98%;1.28%;3.42%;2.12%;1.30%;1.55%;2.56%
+31/03/1998;1.44%;1.22%;2.52%;3.18%;1.79%;2.63%;1.28%;5.70%;3.36%;1.64%;1.45%;6.37%;3.73%
+30/04/1998;1.26%;-2.96%;1.65%;0.41%;0.67%;1.04%;0.75%;0.34%;1.20%;1.39%;1.45%;6.57%;1.25%
+31/05/1998;0.56%;1.93%;0.06%;-8.25%;0.80%;-0.83%;0.40%;0.95%;-0.87%;-0.09%;0.53%;14.37%;-0.72%
+30/06/1998;-0.06%;0.51%;-0.47%;-4.22%;1.08%;0.02%;-0.80%;1.20%;1.67%;0.72%;0.26%;-0.53%;0.21%
+31/07/1998;0.60%;-0.10%;-0.69%;0.19%;0.12%;-0.37%;1.06%;0.58%;-0.06%;0.07%;0.11%;3.43%;-0.07%
+31/08/1998;-3.19%;6.91%;-8.36%;-19.22%;-1.07%;-8.86%;-1.43%;-2.63%;-5.52%;-5.44%;-3.41%;24.63%;-6.16%
+30/09/1998;-1.96%;4.54%;-2.15%;-3.95%;0.61%;-1.10%;-3.62%;-0.59%;2.06%;0.76%;0.05%;-3.76%;-0.37%
+31/10/1998;-2.14%;0.04%;-0.29%;1.40%;0.52%;0.91%;-8.01%;-2.23%;1.69%;1.59%;-1.40%;-10.77%;-0.02%
+30/11/1998;2.69%;-0.89%;1.64%;4.30%;1.58%;2.44%;0.52%;1.94%;2.91%;2.20%;1.98%;-7.56%;2.20%
+31/12/1998;1.13%;2.21%;1.08%;-0.98%;2.09%;2.19%;1.20%;2.33%;4.08%;2.24%;1.64%;-5.31%;2.22%
+31/01/1999;2.19%;-1.67%;1.81%;-1.20%;1.01%;2.01%;1.58%;0.86%;2.58%;1.12%;1.95%;-6.65%;2.02%
+28/02/1999;0.82%;1.97%;-0.21%;1.02%;0.23%;-0.42%;2.08%;-1.11%;-1.69%;0.36%;0.85%;8.33%;-0.63%
+31/03/1999;1.36%;-0.65%;1.59%;5.85%;0.33%;1.93%;1.60%;0.24%;2.29%;1.33%;1.16%;-1.54%;2.13%
+30/04/1999;2.43%;2.10%;4.18%;6.30%;1.07%;4.29%;1.06%;3.29%;3.12%;2.18%;2.38%;-3.75%;4.00%
+31/05/1999;1.66%;-1.50%;2.07%;0.61%;0.89%;2.15%;0.72%;-0.55%;0.95%;2.10%;1.46%;0.09%;1.19%
+30/06/1999;1.02%;2.34%;2.73%;6.54%;1.68%;2.97%;0.88%;2.14%;3.15%;2.22%;1.48%;-4.12%;2.82%
+31/07/1999;1.01%;-0.51%;0.84%;-0.61%;1.35%;0.96%;0.51%;-0.18%;1.77%;1.47%;1.10%;0.92%;0.88%
+31/08/1999;0.48%;-0.27%;0.20%;-1.47%;0.95%;-0.27%;-0.28%;-0.61%;0.22%;0.50%;0.62%;4.68%;0.28%
+30/09/1999;0.96%;0.64%;-0.41%;-0.69%;0.95%;0.90%;0.92%;-0.02%;1.13%;1.16%;1.05%;4.01%;0.52%
+31/10/1999;0.45%;-3.54%;0.27%;2.88%;0.66%;0.54%;0.87%;0.73%;2.12%;0.96%;0.70%;-1.30%;1.30%
+30/11/1999;1.24%;1.66%;2.20%;6.92%;1.33%;2.84%;1.06%;4.05%;4.81%;2.37%;1.37%;-12.39%;4.83%
+31/12/1999;1.40%;1.42%;3.00%;12.30%;1.98%;2.86%;0.97%;6.12%;7.45%;0.90%;1.83%;-11.37%;6.22%
+31/01/2000;2.27%;1.28%;0.88%;0.77%;0.75%;0.88%;0.41%;0.21%;0.75%;1.43%;1.73%;4.27%;1.69%
+29/02/2000;2.67%;-0.22%;4.21%;5.28%;2.53%;3.46%;0.97%;4.08%;6.99%;2.39%;1.85%;-13.40%;6.66%
+31/03/2000;2.43%;-1.38%;1.03%;3.18%;1.34%;0.69%;-0.61%;-1.04%;0.06%;1.31%;1.63%;-2.30%;0.39%
+30/04/2000;2.23%;-2.41%;-1.01%;-5.41%;1.68%;-0.59%;-0.06%;-3.04%;-2.01%;1.88%;0.92%;10.28%;-2.69%
+31/05/2000;1.49%;1.14%;-1.32%;-4.33%;0.62%;-0.34%;1.07%;-0.70%;-0.97%;1.46%;0.80%;7.04%;-1.22%
+30/06/2000;1.79%;-1.24%;2.03%;3.34%;1.71%;2.68%;0.58%;1.54%;3.49%;1.67%;1.76%;-11.07%;3.11%
+31/07/2000;0.93%;-1.31%;0.64%;0.25%;0.63%;0.57%;0.18%;0.37%;0.06%;1.16%;0.84%;5.53%;-0.22%
+31/08/2000;1.62%;1.89%;1.40%;3.68%;2.10%;1.73%;1.07%;2.48%;3.45%;1.57%;1.57%;-11.35%;2.67%
+30/09/2000;1.41%;-2.08%;-0.19%;-4.62%;0.58%;0.48%;0.76%;-1.49%;-0.16%;1.37%;0.75%;12.04%;-0.69%
+31/10/2000;0.52%;0.75%;-0.73%;-2.56%;0.40%;-0.68%;0.06%;-0.24%;-0.84%;0.26%;-0.04%;7.84%;-1.04%
+30/11/2000;-0.81%;4.25%;-2.09%;-3.85%;0.45%;-1.36%;0.66%;1.25%;-1.53%;1.02%;0.06%;16.57%;-2.05%
+31/12/2000;-0.02%;6.82%;0.01%;1.16%;1.60%;1.27%;0.48%;4.72%;2.48%;1.25%;0.75%;0.63%;1.33%
+31/01/2001;3.44%;0.25%;3.08%;5.86%;0.75%;2.98%;1.63%;2.14%;1.65%;1.11%;3.33%;-2.71%;2.23%
+28/02/2001;1.82%;-0.16%;1.00%;-2.21%;1.20%;0.45%;0.54%;-0.72%;-2.64%;0.54%;0.30%;10.21%;-0.89%
+31/03/2001;1.62%;4.38%;-0.37%;-1.75%;1.08%;-0.42%;0.51%;0.38%;-1.99%;-0.61%;-0.11%;6.20%;-0.68%
+30/04/2001;1.57%;-3.62%;0.48%;1.14%;0.75%;1.10%;0.94%;0.49%;2.46%;0.58%;1.74%;-9.91%;1.04%
+31/05/2001;0.33%;0.81%;2.35%;2.78%;0.77%;1.85%;0.68%;0.32%;0.43%;1.61%;1.41%;-1.30%;0.80%
+30/06/2001;0.12%;-0.77%;3.60%;1.60%;0.17%;0.63%;0.17%;0.17%;0.19%;-0.87%;0.19%;1.10%;0.13%
+31/07/2001;0.91%;-0.40%;0.73%;-2.86%;0.31%;0.49%;0.54%;-0.40%;-1.44%;0.79%;0.10%;3.53%;-0.40%
+31/08/2001;1.42%;1.53%;1.06%;0.30%;0.94%;0.90%;1.05%;0.06%;-0.96%;0.99%;-0.31%;7.52%;0.19%
+30/09/2001;0.78%;2.46%;-0.14%;-4.25%;0.23%;-2.54%;-0.13%;-0.70%;-3.48%;-2.67%;-2.21%;9.41%;-1.42%
+31/10/2001;1.17%;3.36%;1.03%;2.78%;0.58%;1.48%;1.34%;2.08%;0.99%;0.85%;1.64%;-2.98%;0.95%
+30/11/2001;0.80%;-5.43%;0.86%;4.83%;0.55%;1.05%;-0.24%;0.21%;2.00%;0.14%;1.36%;-6.55%;0.58%
+31/12/2001;-0.94%;1.48%;0.15%;4.21%;0.56%;1.07%;0.53%;1.38%;1.80%;0.45%;0.97%;-2.51%;0.99%
+31/01/2002;1.48%;-0.72%;1.86%;2.73%;0.65%;0.78%;0.86%;0.69%;-0.37%;0.77%;0.97%;3.43%;0.30%
+28/02/2002;-0.49%;-2.02%;-0.33%;1.81%;-0.07%;-0.71%;0.56%;-0.35%;-1.23%;-0.44%;-0.11%;3.90%;-0.15%
+31/03/2002;0.53%;0.09%;0.52%;3.31%;0.47%;1.53%;0.45%;0.64%;1.55%;0.73%;1.45%;-4.46%;0.90%
+30/04/2002;0.96%;-1.04%;1.39%;1.44%;0.76%;0.46%;1.13%;0.98%;-0.42%;-0.13%;0.70%;4.83%;0.52%
+31/05/2002;0.33%;2.70%;0.91%;0.01%;0.53%;0.01%;0.99%;1.23%;-0.34%;0.00%;0.31%;3.46%;0.50%
+30/06/2002;0.04%;6.55%;-1.17%;-2.92%;0.22%;-2.83%;0.69%;-0.22%;-2.49%;-1.70%;-1.07%;5.48%;-0.95%
+31/07/2002;-1.59%;4.13%;-1.33%;-3.09%;-0.13%;-3.00%;0.57%;-0.78%;-3.89%;-1.74%;-1.85%;6.44%;-1.40%
+31/08/2002;0.50%;2.20%;0.09%;1.19%;0.69%;0.60%;0.97%;0.63%;0.41%;0.61%;0.58%;0.15%;0.37%
+30/09/2002;1.46%;2.84%;-0.44%;-2.52%;0.15%;-0.70%;-0.33%;0.54%;-1.60%;-0.28%;-1.10%;7.31%;-0.33%
+31/10/2002;1.04%;-3.76%;-0.31%;1.54%;0.16%;0.31%;-0.63%;-0.86%;1.23%;0.32%;0.84%;-4.05%;-0.31%
+30/11/2002;2.51%;-1.64%;2.39%;1.90%;0.25%;2.16%;0.54%;0.47%;2.24%;0.54%;1.85%;-5.47%;1.06%
+31/12/2002;1.57%;4.89%;2.22%;0.48%;0.94%;0.44%;1.53%;1.92%;-1.49%;0.46%;0.23%;4.43%;0.77%
+31/01/2003;2.83%;4.41%;2.43%;0.12%;0.83%;1.54%;1.06%;1.82%;0.05%;0.40%;0.67%;1.62%;0.72%
+28/02/2003;1.33%;4.02%;0.92%;0.84%;0.24%;0.26%;0.79%;1.66%;-0.37%;0.18%;-0.04%;1.30%;0.31%
+31/03/2003;0.89%;-4.45%;1.13%;0.19%;0.15%;0.83%;0.19%;-1.22%;0.20%;-0.07%;0.49%;-0.75%;-0.04%
+30/04/2003;1.50%;0.65%;3.45%;4.50%;0.31%;2.72%;0.91%;1.17%;2.98%;0.99%;1.86%;-6.56%;1.34%
+31/05/2003;1.36%;4.90%;2.70%;4.33%;1.07%;3.01%;2.07%;3.97%;3.62%;1.54%;2.12%;-4.99%;2.05%
+30/06/2003;-0.58%;-1.92%;2.67%;2.68%;0.34%;1.81%;0.44%;0.56%;1.28%;0.48%;0.71%;-1.62%;0.68%
+31/07/2003;-0.72%;-1.71%;1.17%;1.04%;-0.06%;1.19%;-0.92%;-0.35%;1.18%;0.53%;0.41%;-3.61%;0.25%
+31/08/2003;-0.87%;0.78%;1.37%;3.74%;0.31%;1.33%;0.43%;2.02%;1.79%;0.70%;0.58%;-3.54%;0.78%
+30/09/2003;1.71%;-0.19%;2.42%;2.64%;0.78%;1.33%;1.05%;2.15%;0.94%;0.77%;0.86%;1.36%;1.21%
+31/10/2003;1.46%;1.04%;2.67%;2.59%;1.15%;1.91%;0.35%;1.11%;2.99%;1.11%;1.59%;-6.56%;1.52%
+30/11/2003;0.92%;0.18%;1.54%;0.96%;0.46%;1.16%;0.69%;0.31%;1.30%;0.44%;1.02%;-1.36%;0.70%
+31/12/2003;0.54%;3.81%;1.98%;4.03%;0.54%;1.72%;1.01%;2.93%;1.91%;0.98%;1.27%;-1.78%;1.39%
+31/01/2004;1.19%;1.99%;3.01%;2.51%;1.09%;2.34%;0.92%;1.17%;1.92%;0.97%;1.46%;-0.90%;1.56%
+29/02/2004;0.17%;5.29%;0.75%;2.53%;0.63%;1.13%;0.84%;1.50%;1.23%;0.51%;0.57%;0.18%;1.11%
+31/03/2004;0.61%;-0.51%;0.46%;1.72%;0.32%;0.16%;0.03%;0.64%;0.41%;0.17%;0.38%;-1.48%;0.43%
+30/04/2004;0.20%;-5.32%;0.93%;-2.52%;-0.82%;0.02%;0.62%;-1.78%;-1.65%;-0.39%;-0.45%;3.84%;-0.68%
+31/05/2004;-1.28%;-1.18%;-0.10%;-1.81%;0.24%;-0.23%;0.40%;-0.81%;-0.35%;0.00%;-0.37%;-0.24%;-0.82%
+30/06/2004;-1.06%;-3.16%;2.02%;0.20%;0.42%;1.13%;0.55%;-0.19%;0.91%;0.17%;0.22%;-0.51%;0.34%
+31/07/2004;0.13%;-1.19%;0.19%;-0.27%;0.06%;-0.82%;0.62%;-0.14%;-1.54%;-0.92%;0.07%;6.38%;-0.49%
+31/08/2004;0.40%;-0.84%;0.88%;1.33%;-0.09%;0.35%;0.36%;-0.39%;-0.22%;0.11%;0.31%;1.26%;-0.10%
+30/09/2004;-0.17%;2.20%;1.04%;2.80%;0.85%;1.03%;0.12%;0.08%;2.10%;0.42%;0.52%;-2.16%;0.99%
+31/10/2004;-0.44%;3.58%;1.43%;1.85%;-0.05%;1.24%;0.28%;1.38%;0.74%;0.74%;0.40%;-0.92%;0.68%
+30/11/2004;0.81%;4.75%;3.37%;3.28%;1.40%;3.06%;0.75%;2.80%;3.08%;1.64%;1.49%;-5.74%;2.44%
+31/12/2004;0.56%;0.00%;2.66%;2.01%;0.58%;2.44%;0.60%;0.33%;1.78%;1.33%;0.99%;-3.91%;1.45%
+31/01/2005;-0.96%;-4.38%;0.37%;1.43%;0.81%;0.04%;0.44%;-0.47%;-0.17%;0.00%;0.12%;3.87%;0.06%
+28/02/2005;-0.58%;0.05%;1.34%;3.46%;0.80%;1.44%;0.85%;1.71%;2.10%;0.65%;0.81%;1.18%;1.36%
+31/03/2005;-1.40%;-0.06%;0.32%;-1.97%;0.19%;-0.04%;0.24%;-0.27%;-0.96%;0.32%;-0.42%;2.44%;-0.44%
+30/04/2005;-3.16%;-3.54%;-0.52%;-0.49%;-0.30%;-1.28%;-0.03%;-0.80%;-1.84%;-1.05%;-1.08%;3.93%;-1.41%
+31/05/2005;-1.33%;2.32%;0.06%;0.72%;0.47%;0.65%;-0.10%;0.88%;1.15%;0.95%;-0.02%;-4.75%;0.18%
+30/06/2005;1.07%;2.60%;1.33%;1.60%;0.81%;1.33%;0.10%;1.16%;1.95%;0.85%;0.95%;-0.32%;1.31%
+31/07/2005;1.64%;-0.13%;1.73%;2.57%;0.78%;2.15%;0.81%;1.19%;2.65%;1.15%;1.49%;-2.42%;1.34%
+31/08/2005;0.66%;1.00%;1.24%;1.52%;0.62%;0.92%;0.36%;0.83%;0.97%;0.61%;0.53%;2.59%;0.79%
+30/09/2005;1.42%;0.79%;1.12%;4.02%;0.87%;1.00%;0.62%;2.69%;2.22%;0.35%;1.22%;1.98%;1.47%
+31/10/2005;-0.15%;-0.92%;-0.32%;-2.30%;0.01%;-1.73%;0.57%;-0.74%;-1.74%;-1.45%;-0.38%;2.33%;-1.49%
+30/11/2005;0.04%;3.79%;1.00%;2.79%;0.61%;1.25%;0.15%;1.64%;2.11%;1.12%;0.67%;-3.00%;1.60%
+31/12/2005;0.92%;-1.53%;1.22%;2.84%;0.68%;1.42%;0.54%;1.35%;2.49%;1.38%;1.26%;-0.35%;1.91%
+31/01/2006;2.50%;1.74%;2.53%;5.26%;1.15%;3.41%;0.93%;2.58%;3.81%;2.72%;2.38%;-2.88%;2.86%
+28/02/2006;1.16%;-1.86%;0.65%;1.61%;0.46%;0.51%;0.41%;0.02%;0.16%;1.04%;0.73%;0.64%;0.37%
+31/03/2006;1.07%;2.84%;1.72%;1.22%;0.98%;1.85%;0.55%;0.94%;2.38%;1.44%;1.57%;-1.39%;1.64%
+30/04/2006;0.64%;3.87%;1.93%;3.65%;1.02%;1.64%;1.21%;2.38%;1.72%;1.19%;1.26%;-0.12%;1.71%
+31/05/2006;0.91%;-1.46%;0.86%;-3.89%;0.02%;0.08%;0.59%;-1.55%;-2.48%;0.09%;-0.25%;2.46%;-1.33%
+30/06/2006;0.12%;-1.42%;-0.15%;-0.97%;0.63%;0.12%;0.36%;-0.15%;-0.62%;0.87%;0.21%;1.18%;-0.28%
+31/07/2006;0.66%;-2.16%;0.09%;0.67%;0.51%;-0.11%;0.64%;0.06%;-0.31%;0.58%;0.17%;1.73%;-0.05%
+31/08/2006;0.98%;0.20%;0.99%;1.33%;-0.09%;1.12%;0.37%;-0.39%;1.14%;0.53%;0.92%;-1.56%;0.66%
+30/09/2006;0.93%;-0.55%;0.33%;0.11%;0.09%;0.35%;0.14%;-0.67%;0.05%;0.41%;0.40%;-2.36%;-0.03%
+31/10/2006;0.54%;1.02%;1.94%;2.57%;0.65%;2.06%;0.67%;0.97%;1.94%;1.32%;1.32%;-3.80%;1.63%
+30/11/2006;0.92%;2.26%;1.79%;3.23%;0.75%;1.82%;0.60%;1.99%;2.00%;1.42%;1.29%;-2.68%;1.85%
+31/12/2006;1.27%;1.46%;1.65%;2.91%;1.07%;1.68%;0.72%;1.16%;1.53%;1.33%;1.28%;0.39%;1.75%
+31/01/2007;1.30%;1.13%;1.50%;0.79%;0.83%;2.01%;0.69%;0.61%;1.21%;1.91%;1.35%;-1.07%;1.21%
+28/02/2007;1.17%;-1.44%;1.45%;1.00%;0.51%;2.07%;1.06%;0.18%;0.82%;2.55%;1.14%;0.28%;0.96%
+31/03/2007;0.60%;-1.41%;1.08%;1.85%;1.01%;1.46%;0.60%;0.27%;1.15%;0.63%;0.81%;-0.51%;0.96%
+30/04/2007;0.26%;2.41%;1.64%;2.55%;0.89%;1.97%;0.71%;1.52%;1.98%;1.60%;1.34%;-2.65%;1.63%
+31/05/2007;1.10%;2.30%;1.80%;2.70%;1.21%;2.13%;0.55%;1.92%;2.24%;1.71%;1.56%;-1.99%;2.04%
+30/06/2007;0.11%;2.29%;0.27%;2.36%;0.77%;-0.07%;0.48%;1.07%;0.77%;-0.53%;1.00%;2.36%;0.82%
+31/07/2007;-0.53%;-1.22%;-0.56%;2.75%;0.51%;-0.32%;0.07%;1.16%;0.09%;-0.54%;0.04%;4.86%;0.41%
+31/08/2007;-1.45%;-2.80%;-1.18%;-2.74%;-0.94%;-1.44%;-0.48%;-1.16%;-1.60%;0.01%;-0.77%;0.92%;-2.22%
+30/09/2007;1.61%;4.69%;0.95%;4.28%;1.23%;1.34%;1.64%;3.30%;2.56%;1.31%;1.53%;-2.07%;1.99%
+31/10/2007;1.77%;2.80%;1.75%;4.85%;1.68%;2.14%;1.14%;3.04%;2.81%;1.91%;2.00%;-0.26%;3.03%
+30/11/2007;-1.31%;-0.16%;-1.69%;-2.37%;-0.18%;-2.02%;-0.94%;-0.63%;-2.25%;-1.49%;-1.12%;7.19%;-1.48%
+31/12/2007;-0.77%;1.17%;0.02%;1.30%;0.54%;0.07%;0.36%;1.04%;0.43%;-0.25%;0.22%;0.56%;0.40%
+31/01/2008;-0.09%;2.55%;-2.33%;-5.03%;-1.12%;-2.71%;-0.12%;-0.10%;-4.00%;-1.26%;-1.18%;5.56%;-2.72%
+29/02/2008;-0.83%;6.20%;0.14%;2.80%;1.20%;0.84%;-0.49%;3.12%;1.40%;0.60%;0.64%;3.00%;1.42%
+31/03/2008;-3.17%;-0.56%;-1.26%;-3.79%;-0.49%;-1.68%;-3.06%;-1.69%;-2.36%;-0.45%;-1.62%;1.92%;-2.62%
+30/04/2008;0.76%;-0.78%;0.88%;1.90%;0.59%;1.18%;1.87%;0.78%;2.23%;1.49%;1.30%;-4.61%;0.97%
+31/05/2008;1.07%;1.62%;1.37%;1.63%;1.26%;1.76%;1.03%;1.14%;2.27%;1.36%;1.59%;-1.42%;1.72%
+30/06/2008;-0.81%;3.30%;-0.31%;-2.74%;1.56%;-1.13%;-0.27%;0.30%;-1.64%;-1.09%;-0.84%;7.51%;-0.68%
+31/07/2008;-1.88%;-3.33%;-1.82%;-3.30%;-1.00%;-1.66%;-0.23%;-2.13%;-2.61%;0.11%;-1.25%;0.72%;-2.64%
+31/08/2008;-0.66%;-1.14%;-0.72%;-3.36%;-1.35%;-0.25%;-0.03%;-1.33%;-1.46%;0.51%;-0.23%;-2.15%;-1.56%
+30/09/2008;-10.27%;0.10%;-5.18%;-9.82%;-2.85%;-6.27%;-5.06%;-3.13%;-6.75%;-2.76%;-5.38%;3.78%;-6.18%
+31/10/2008;-12.37%;3.45%;-7.75%;-13.31%;-0.44%;-6.25%;-8.67%;-1.57%;-6.29%;-2.45%;-6.92%;11.70%;-6.00%
+30/11/2008;-2.76%;2.14%;-4.35%;-3.91%;-5.87%;-3.01%;-3.08%;0.33%;-1.88%;0.06%;-2.09%;4.28%;-1.92%
+31/12/2008;1.77%;1.40%;-1.97%;-0.10%;0.05%;-0.71%;-0.35%;1.18%;0.81%;1.62%;0.31%;-1.46%;-1.19%
+31/01/2009;4.91%;-0.16%;0.82%;-1.12%;0.79%;1.32%;1.12%;0.29%;-0.17%;0.56%;1.00%;2.82%;0.60%
+28/02/2009;1.64%;-0.31%;-1.22%;-1.33%;-0.46%;-0.91%;0.65%;-0.55%;-1.61%;0.06%;-0.16%;3.28%;-0.37%
+31/03/2009;2.35%;-1.80%;0.22%;3.50%;0.21%;1.17%;0.57%;0.48%;1.88%;1.25%;1.00%;-4.62%;0.08%
+30/04/2009;5.00%;-1.40%;3.87%;6.63%;-0.12%;3.37%;2.21%;1.27%;3.75%;0.81%;3.42%;-8.20%;0.92%
+31/05/2009;5.78%;2.13%;5.04%;8.84%;1.46%;4.42%;3.65%;3.48%;5.16%;1.07%;3.92%;0.08%;3.12%
+30/06/2009;2.41%;-1.47%;1.98%;0.13%;0.36%;1.23%;1.26%;-0.76%;0.09%;1.04%;1.01%;-0.94%;0.24%
+31/07/2009;6.11%;-0.12%;3.11%;4.51%;0.42%;2.91%;3.22%;1.66%;2.77%;0.68%;2.60%;-5.96%;1.53%
+31/08/2009;3.15%;0.54%;2.44%;1.66%;0.70%;2.07%;2.02%;0.50%;1.57%;1.02%;1.62%;-1.65%;1.13%
+30/09/2009;3.68%;1.51%;4.10%;5.36%;0.85%;3.36%;3.25%;2.31%;2.85%;1.10%;2.20%;-3.94%;1.71%
+31/10/2009;1.19%;-1.47%;1.39%;1.08%;-0.05%;0.43%;1.85%;-0.04%;-0.86%;0.26%;0.32%;3.14%;-0.21%
+30/11/2009;0.80%;3.32%;2.02%;1.51%;0.09%;1.52%;0.96%;1.65%;1.30%;0.68%;0.89%;-2.27%;0.82%
+31/12/2009;2.15%;-2.53%;3.24%;2.29%;0.72%;2.35%;1.41%;-0.28%;1.86%;1.02%;1.61%;-3.73%;0.66%
+31/01/2010;0.53%;-2.78%;1.87%;-0.78%;0.28%;0.77%;1.72%;-0.84%;-0.95%;0.48%;0.60%;1.83%;-0.36%
+28/02/2010;0.36%;0.90%;0.31%;-0.19%;0.50%;0.76%;0.23%;0.47%;0.84%;0.57%;0.57%;-2.61%;0.13%
+31/03/2010;2.29%;2.75%;3.36%;4.21%;0.77%;2.73%;1.36%;1.71%;2.87%;1.09%;1.79%;-4.96%;1.71%
+30/04/2010;1.99%;1.00%;2.51%;1.33%;0.18%;1.64%;1.13%;0.76%;1.00%;0.38%;1.22%;-2.87%;0.85%
+31/05/2010;-2.44%;-2.48%;-2.50%;-4.80%;-0.50%;-2.57%;-1.02%;-1.28%;-3.71%;-1.15%;-1.86%;4.45%;-2.72%
+30/06/2010;0.17%;0.11%;-1.05%;-0.39%;-0.45%;-1.06%;0.78%;-0.23%;-1.61%;0.23%;-0.34%;4.19%;-0.79%
+31/07/2010;2.27%;-0.80%;1.43%;2.96%;0.90%;1.70%;1.00%;0.33%;1.91%;1.27%;1.74%;-4.26%;0.69%
+31/08/2010;1.21%;3.10%;-0.49%;0.28%;-0.44%;-0.32%;0.88%;1.08%;-0.96%;0.70%;0.31%;3.89%;0.06%
+30/09/2010;1.89%;2.67%;2.17%;4.29%;1.60%;2.72%;1.32%;2.63%;4.08%;1.34%;2.15%;-8.26%;2.19%
+31/10/2010;2.14%;3.11%;2.06%;2.32%;1.05%;1.87%;1.07%;1.59%;2.08%;0.47%;1.49%;-1.79%;1.48%
+30/11/2010;-0.12%;-2.24%;0.65%;-0.49%;0.44%;0.28%;0.56%;-0.47%;0.66%;-0.25%;0.37%;-1.62%;-0.09%
+31/12/2010;1.45%;4.36%;3.11%;2.26%;0.94%;2.60%;0.55%;2.50%;3.42%;1.16%;1.57%;-5.07%;2.05%
+31/01/2011;1.81%;-0.63%;1.73%;-0.65%;0.56%;1.41%;1.81%;-0.55%;0.52%;0.93%;0.97%;-0.76%;0.13%
+28/02/2011;1.62%;1.77%;1.44%;0.11%;0.59%;1.29%;1.03%;0.95%;1.39%;0.62%;1.12%;-3.14%;0.83%
+31/03/2011;0.38%;-1.64%;0.43%;1.54%;0.80%;0.20%;0.22%;-0.28%;0.21%;0.31%;0.34%;-1.70%;-0.18%
+30/04/2011;0.20%;3.67%;1.29%;1.40%;1.05%;1.14%;0.97%;2.11%;1.39%;0.89%;0.72%;-1.97%;1.14%
+31/05/2011;-0.17%;-3.39%;-0.14%;-1.91%;-0.37%;-0.52%;0.33%;-1.50%;-1.08%;-0.11%;-0.05%;1.34%;-1.16%
+30/06/2011;-0.91%;-2.39%;-0.68%;-1.00%;-0.14%;-1.38%;-0.10%;-1.30%;-1.17%;-0.14%;-0.56%;2.70%;-1.38%
+31/07/2011;-0.33%;2.58%;-0.15%;0.77%;-0.03%;-0.30%;0.18%;1.29%;-0.30%;-0.49%;-0.06%;1.99%;0.34%
+31/08/2011;-1.95%;0.07%;-4.02%;-3.90%;-1.61%;-4.01%;-0.85%;-0.63%;-4.21%;-1.19%;-2.00%;6.69%;-2.52%
+30/09/2011;-1.90%;-0.57%;-3.70%;-6.95%;-1.59%;-3.41%;-0.48%;-1.42%;-4.61%;-1.02%;-1.97%;7.77%;-2.62%
+31/10/2011;1.29%;-3.17%;2.37%;3.65%;1.61%;2.98%;0.63%;0.53%;3.90%;1.72%;1.47%;-7.21%;0.94%
+30/11/2011;-0.94%;0.14%;-1.08%;-2.72%;0.02%;-0.58%;-0.34%;-0.66%;-1.31%;0.17%;-0.24%;1.31%;-0.93%
+31/12/2011;0.29%;0.34%;0.50%;-1.81%;0.06%;-0.34%;0.45%;-0.22%;-0.56%;0.56%;0.12%;0.41%;-0.54%
+31/01/2012;2.36%;0.46%;3.24%;3.95%;0.95%;2.88%;1.16%;1.90%;3.27%;0.95%;2.02%;-6.79%;1.47%
+29/02/2012;2.18%;0.91%;2.02%;3.41%;0.71%;1.70%;1.19%;1.34%;2.48%;1.11%;1.72%;-5.22%;1.40%
+31/03/2012;0.65%;-2.04%;0.91%;-1.33%;0.23%;0.58%;0.61%;-0.61%;0.33%;0.24%;0.55%;-1.23%;0.01%
+30/04/2012;-0.17%;-0.03%;-0.12%;-0.27%;-0.13%;-0.18%;0.34%;-0.59%;-0.68%;-0.11%;-0.20%;0.57%;-0.33%
+31/05/2012;-0.77%;2.59%;-1.86%;-5.31%;-1.15%;-1.91%;-0.03%;-0.67%;-3.75%;-0.48%;-1.00%;6.77%;-1.40%
+30/06/2012;0.72%;-2.72%;-0.09%;0.26%;0.06%;0.07%;0.46%;-0.63%;0.60%;0.23%;0.70%;-2.58%;-0.37%
+31/07/2012;0.92%;3.12%;0.89%;0.81%;0.41%;0.48%;1.25%;1.44%;0.39%;0.06%;1.17%;0.87%;0.76%
+31/08/2012;0.76%;-0.82%;1.61%;0.75%;0.49%;1.29%;0.82%;0.37%;1.08%;0.44%;0.95%;-3.67%;0.68%
+30/09/2012;0.57%;-1.04%;1.69%;2.73%;0.43%;1.20%;0.76%;0.51%;1.57%;0.06%;1.02%;-3.85%;0.73%
+31/10/2012;0.17%;-3.10%;1.18%;0.28%;0.28%;0.48%;0.58%;-0.83%;0.09%;-0.79%;0.30%;0.05%;-0.25%
+30/11/2012;0.41%;-0.04%;0.82%;1.31%;0.37%;0.80%;0.54%;0.27%;0.52%;1.00%;0.56%;-1.50%;0.46%
+31/12/2012;0.98%;0.57%;2.59%;3.30%;0.37%;1.93%;0.73%;1.11%;1.45%;1.45%;1.17%;-3.87%;1.08%
+31/01/2013;1.58%;1.86%;2.19%;3.03%;1.35%;2.14%;1.16%;1.65%;3.08%;-0.16%;2.04%;-4.52%;2.06%
+28/02/2013;0.09%;-0.99%;0.52%;-0.12%;0.33%;0.41%;0.56%;-0.12%;0.37%;0.39%;0.47%;-0.35%;0.32%
+31/03/2013;0.77%;0.89%;1.49%;0.68%;0.35%;1.43%;1.13%;0.64%;1.44%;0.69%;1.30%;-1.89%;0.93%
+30/04/2013;0.52%;1.92%;1.75%;0.63%;0.08%;0.78%;0.50%;1.14%;0.64%;0.61%;0.55%;-2.86%;0.76%
+31/05/2013;1.34%;-2.61%;2.23%;0.33%;0.24%;1.87%;0.50%;-0.23%;1.35%;0.59%;1.01%;-2.45%;0.67%
+30/06/2013;-0.81%;-2.73%;-1.05%;-3.21%;0.28%;-1.13%;-1.22%;-1.76%;-0.94%;-0.22%;-1.02%;0.56%;-1.33%
+31/07/2013;0.60%;-0.76%;1.40%;0.75%;1.00%;1.49%;0.67%;0.16%;2.15%;1.03%;1.17%;-3.69%;0.91%
+31/08/2013;0.46%;-1.39%;-0.34%;-1.22%;-0.59%;-0.11%;0.14%;-0.91%;-0.76%;-0.01%;-0.46%;1.07%;-0.68%
+30/09/2013;0.43%;-0.57%;1.64%;2.35%;0.63%;1.60%;0.47%;0.69%;2.33%;0.84%;1.40%;-4.52%;1.27%
+31/10/2013;0.95%;1.45%;1.61%;2.38%;1.42%;1.45%;0.85%;0.94%;2.04%;0.45%;1.45%;-2.07%;1.25%
+30/11/2013;0.07%;1.14%;1.22%;0.30%;1.05%;1.19%;0.67%;0.69%;1.54%;0.30%;0.87%;-1.65%;1.09%
+31/12/2013;0.48%;0.52%;1.20%;1.01%;0.76%;1.22%;0.40%;0.65%;1.57%;0.61%;1.02%;-1.55%;1.09%
+31/01/2014;1.37%;-1.75%;0.47%;-1.95%;0.42%;0.30%;0.75%;-0.88%;-0.32%;0.46%;0.02%;0.94%;-0.33%
\ No newline at end of file

Added: pkg/PortfolioAnalytics/sandbox/RFinance2014/data/edhec.rda
===================================================================
(Binary files differ)


Property changes on: pkg/PortfolioAnalytics/sandbox/RFinance2014/data/edhec.rda
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: pkg/PortfolioAnalytics/sandbox/RFinance2014/data/parse_edhec.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/RFinance2014/data/parse_edhec.R	                        (rev 0)
+++ pkg/PortfolioAnalytics/sandbox/RFinance2014/data/parse_edhec.R	2014-04-03 18:33:08 UTC (rev 3346)
@@ -0,0 +1,11 @@
+library(xts)
+
+df <- read.table("data/edhec.csv", header=TRUE, as.is=TRUE, sep=";")
+head(df)
+
+edhec <- xts(apply(df[,-1], 2, function(x) as.numeric(gsub("%", "", x))) / 100, as.Date(df[,1], format="%d/%m/%Y"))
+save(edhec, file="edhec.rda")
+# load("edhec.rda")
+# head(edhec)
+# library(PerformanceAnalytics)
+# data(edhec)

Added: pkg/PortfolioAnalytics/sandbox/RFinance2014/edhec.rda
===================================================================
(Binary files differ)


Property changes on: pkg/PortfolioAnalytics/sandbox/RFinance2014/edhec.rda
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: pkg/PortfolioAnalytics/sandbox/RFinance2014/edhec_eda.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/RFinance2014/edhec_eda.R	                        (rev 0)
+++ pkg/PortfolioAnalytics/sandbox/RFinance2014/edhec_eda.R	2014-04-03 18:33:08 UTC (rev 3346)
@@ -0,0 +1,78 @@
+# script for data analysis
+
+library(PerformanceAnalytics)
+library(lattice)
+library(corrplot)
+
+load("data/edhec.rda")
+
+head(edhec)
+R <- edhec[,1:4]
+p <- 0.95
+
+first(R)
+last(R)
+
+# plot the timeseries of returns
+# plot(as.zoo(edhec))
+xyplot(R, scales=list(y="same"))
+charts.BarVaR(R, width=36, methods=c("ModifiedES", "ModifiedVaR"))
+dev.off()
+
+# boxplot to compare return distributions
+# mar(bottom, left, top, right)
+# default: par(mar=c(5, 4, 4, 2) + 0.1)
+par(mar=c(10, 4, 4, 2) + 0.1)
+boxplot(coredata(R[,order(ES(R, p=p, invert=FALSE))]),
+        cex.axis=0.8, las=3, ylab="Returns", pch=18,
+        main="Return Distribution\n(sorted by Modified ES (95%))")
+par(mar=c(5, 4, 4, 2) + 0.1)
+dev.off()
+
+# head(R[,order(ES(R, invert=FALSE))])
+# head(R[,order(StdDev(R))])
+# chart.Boxplot(R[,order(ES(R, invert=FALSE))])
+# chart.Boxplot(R[,order(StdDev(R))])
+# boxplot(coredata(R), col=c(2:5), cex.names=0.8, las=3)
+
+# chart the distribution of returns
+for(i in 1:ncol(R)){
+  chart.Histogram(R[,i], methods=c("add.density", "add.normal"), 
+                  colorset=c("lightgray", "black", "blue"))
+  legend("topleft", legend=c("kernel density estimate", "normal"), 
+         lty=c(1,1), col=c("black", "blue"), bty="n")
+  Sys.sleep(1)
+}
+
+
+# chart the correlation and covariance
+# from http://cran.r-project.org/web/packages/corrplot/vignettes/corrplot-intro.html
+cor.mtest <- function(mat, conf.level = 0.95) {
+  mat <- as.matrix(mat)
+  n <- ncol(mat)
+  p.mat <- lowCI.mat <- uppCI.mat <- matrix(NA, n, n)
+  diag(p.mat) <- 0
+  diag(lowCI.mat) <- diag(uppCI.mat) <- 1
+  for (i in 1:(n - 1)) {
+    for (j in (i + 1):n) {
+      tmp <- cor.test(mat[, i], mat[, j], conf.level = conf.level)
+      p.mat[i, j] <- p.mat[j, i] <- tmp$p.value
+      lowCI.mat[i, j] <- lowCI.mat[j, i] <- tmp$conf.int[1]
+      uppCI.mat[i, j] <- uppCI.mat[j, i] <- tmp$conf.int[2]
+    }
+  }
+  return(list(p.mat, lowCI.mat, uppCI.mat))
+}
+res <- cor.mtest(R)
+
+corrplot(cor(R), p.mat=res[[1]], main="Correlation", 
+         sig.level=0.05, tl.cex=0.8)
+
+# corrplot(M, method="number", bg="gray", tl.cex=0.8)
+# corrplot.mixed(M, bg="gray", tl.cex=0.8)
+
+# If I compare sample min variance portfolio to a ledoit-shrinkage or robust, 
+# I should use plotcov to compare covaiance matrices
+
+
+

Added: pkg/PortfolioAnalytics/sandbox/RFinance2014/optimize.R
===================================================================
--- pkg/PortfolioAnalytics/sandbox/RFinance2014/optimize.R	                        (rev 0)
+++ pkg/PortfolioAnalytics/sandbox/RFinance2014/optimize.R	2014-04-03 18:33:08 UTC (rev 3346)
@@ -0,0 +1,271 @@
+# script used to run the portfolio optimizations
+
+library(PortfolioAnalytics)
+# Load the updated edhec dataset
+load("data/edhec.rda")
+
+# For now, use the first 8
+R <- edhec[,1:8]
+# Abreviate column names for convenience and plotting
+colnames(R) <- c("CA", "CTAG", "DS", "EM", "EQN", "ED", "FA", "GM")
+funds <- colnames(R)
+
+# Example 1
+# Box constraints, minimum variance portfolio
+# specify portfolio
+init <- portfolio.spec(funds)
+
+# Add constraints
+port1 <- add.constraint(init, type="full_investment")
+port1 <- add.constraint(port1, type="box", min=0.05, max=0.6)
+
+# Add objective
+port1 <- add.objective(port1, type="risk", name="var")
+
+# Custom moment function to use 
+robust.sigma <- function(R, ...){
+  out <- list()
+  set.seed(1234)
+  out$sigma <- MASS::cov.rob(R, method="mcd", ...)$cov
+  return(out)
+}
+
+# Rebalancing parameters
+# Set rebalancing frequency
+rebal.freq <- "quarters"
+# Training Period
+training <- 120
+# Trailing Period
+trailing <- 72
+
+# Run optimization
+# Sample Covariance Matrix Estimate
+opt.minVarSample <- optimize.portfolio.rebalancing(R, port1, 
+                                                   optimize_method="ROI", 
+                                                   rebalance_on=rebal.freq, 
+                                                   training_period=training, 
+                                                   trailing_periods=trailing)
+ret.minVarSample <- summary(opt.minVarSample)$portfolio_returns
+
+
+# MCD Covarinace Matrix Estimate
+opt.minVarRobust <- optimize.portfolio.rebalancing(R, port1, 
+                                                   optimize_method="ROI", 
+                                                   momentFUN=robust.sigma,
+                                                   rebalance_on=rebal.freq, 
+                                                   training_period=training, 
+                                                   trailing_periods=trailing)
+
+# Chart the weights
+chart.Weights(opt.minVarSample, main="minVarSample Weights")
+chart.Weights(opt.minVarRobust, main="minVarRobust Weights")
+
+# Calculate the turnover per period
+turnover.rebalancing <- function(object){
+  weights <- extractWeights(object)
+  n <- nrow(weights)
+  out <- vector("numeric", n)
+  out[1] <- NA
+  for(i in 2:n){
+    out[i] <- out[i] <- sum(abs(as.numeric(weights[i,]) - as.numeric(weights[i-1,])))
+  }
+  xts(out, index(weights))
+}
+
+# Compute the average turnover
+to.minVarSample <- mean(turnover.rebalancing(opt.minVarSample), na.rm=TRUE)
+to.minVarRobust <- mean(turnover.rebalancing(opt.minVarRobust), na.rm=TRUE)
+
+
+# Calculate the diversification per period
+diversification.rebalancing <- function(object){
+  weights <- extractWeights(object)
+  n <- nrow(weights)
+  out <- vector("numeric", n)
+  for(i in 1:n){
+    out[i] <- 1 - sum(weights[i,]^2)
+  }
+  xts(out, index(weights))
+}
+
+# Compute the average diversification
+div.minVarSample <- mean(diversification.rebalancing(opt.minVarSample))
+div.minVarRobust <- mean(diversification.rebalancing(opt.minVarRobust))
+
+# Compute the returns
+ret.minVarSample <- summary(opt.minVarSample)$portfolio_returns
+ret.minVarRobust <- summary(opt.minVarRobust)$portfolio_returns
+ret.minVar <- cbind(ret.minVarSample, ret.minVarRobust)
+colnames(ret.minVar) <- c("Sample", "Robust")
+charts.PerformanceSummary(ret.minVar)
+
+## Example 2
+
+# Example 2 will consider three portfolios
+# - meanES
+# - meanES with 30% component contribution limit
+# - meanES equal risk contribution
+
+# meanES
+# Add constraints
+port2 <- add.constraint(init, type="full_investment")
+port2 <- add.constraint(port2, type="box", min=0, max=0.6)
+
+# Add objectives
+port2 <- add.objective(port2, type="return", name="mean")
+port2 <- add.objective(port2, type="risk", name="ES", 
+                       arguments=list(p=0.92, clean="boudt"))
+
+opt.MeanES.ROI <- optimize.portfolio(R, port2, optimize_method="ROI", trace=TRUE)
+plot(opt.MeanES.ROI)
+
+# relax the constraints for random portfolio
+port2$constraints[[1]]$min_sum <- 0.99
+port2$constraints[[1]]$max_sum <- 1.01
+
+search.size <- 20000
+
+set.seed(123)
+rp <- random_portfolios(port2, permutations=search.size)
+
+#set.seed(123)
+#rp1 <- random_portfolios(port2, permutations=search.size)
+#all.equal(rp, rp1)
+
+
+opt.MeanES.RP <- optimize.portfolio(R, port2, optimize_method="random", 
+                                    rp=rp, trace=TRUE)
+#extractObjectiveMeasures(combine.optimizations(list(opt.MeanES.ROI, opt.MeanES.RP)))
+#extractWeights(combine.optimizations(list(opt.MeanES.ROI, opt.MeanES.RP)))
+
+plot(opt.MeanES.RP, neighbors=25)
+
+# Calculate the component contribution to risk
+portContribES <- ES(R, p=0.92, portfolio_method="component", 
+                    weights=extractWeights(opt.MeanES.RP))
+portContribES$pct_contrib_MES
+
+# Now suppose we want to place limits on percent component contribution to risk
+port3 <- add.objective(port2, type="risk_budget", name="ES", 
+                       arguments=list(p=0.92, clean="boudt"), max_prisk=0.35)
+
+opt.MeanES.RB <- optimize.portfolio(R, port3, optimize_method="random", 
+                                   trace=TRUE, rp=rp)
+opt.MeanES.RB
+
+chart.RiskBudget(opt.MeanES.RB, risk.type="percentage", neighbors=25)
+
+
+port4 <- add.objective(port2, type="risk_budget", name="ES", 
+                       arguments=list(p=0.92, clean="boudt"), 
+                       min_concentration=TRUE)
+opt.MeanES.EqRB <- optimize.portfolio(R, port4, optimize_method="random", 
+                                   trace=TRUE, rp=rp)
+opt.MeanES.EqRB
+chart.RiskBudget(opt.MeanES.EqRB, risk.type="percentage", neighbors=25)
+
+# plot
+# - opt.meanES.ROI
+# - opt.meanES.RP
+# - opt.meanES.RB
+# - opt.meanES.EqRB
+
+xtract <- extractStats(opt.MeanES.RP)
+
+# plot the feasible space
+par(mar=c(6,4,4,1)+0.1)
+plot(xtract[,"ES"], xtract[,"mean"], col="gray", 
+     xlab="ES", ylab="Mean",
+     xlim=c(0, max(xtract[,"ES"])))
+
+# opt.MeanES.ROI
+points(x=opt.MeanES.ROI$objective_measures$ES,
+       y=opt.MeanES.ROI$objective_measures$mean,
+       pch=15, col="blue")
+text(x=opt.MeanES.ROI$objective_measures$ES,
+       y=opt.MeanES.ROI$objective_measures$mean,
+       labels="Mean ES ROI", pos=4, col="blue", cex=0.8)
+
+# opt.MeanES.RP
+points(x=opt.MeanES.RP$objective_measures$ES,
+       y=opt.MeanES.RP$objective_measures$mean,
+       pch=15, col="purple")
+text(x=opt.MeanES.RP$objective_measures$ES,
+     y=opt.MeanES.RP$objective_measures$mean,
+     labels="Mean ES RP", pos=1, col="purple", cex=0.8)
+
+# opt.MeanES.RB
+points(x=opt.MeanES.RB$objective_measures$ES$MES,
+       y=opt.MeanES.RB$objective_measures$mean,
+       pch=15, col="black")
+text(x=opt.MeanES.RB$objective_measures$ES$MES,
+     y=opt.MeanES.RB$objective_measures$mean,
+     labels="Mean ES RB", pos=4, col="black", cex=0.8)
+
+# opt.MeanES.EqRB
+points(x=opt.MeanES.EqRB$objective_measures$ES$MES,
+       y=opt.MeanES.EqRB$objective_measures$mean,
+       pch=15, col="darkgreen")
+text(x=opt.MeanES.EqRB$objective_measures$ES$MES,
+     y=opt.MeanES.EqRB$objective_measures$mean,
+     labels="Mean ES EqRB", pos=4, col="darkgreen", cex=0.8)
+
+
+# Backtest these three portfolios
+# I'm going to add a risk budget object to port2 with multiplier=0 so that
+# it is calculated, but does not affect the optimization
+port2 <- add.objective(port2, name="ES", type="risk_budget", arguments=list(p=0.92), multiplier=0)
+
+
+# Rebalancing parameters
+# Set rebalancing frequency
+rebal.freq <- "quarters"
+# Training Period
+training <- 120
+# Trailing Period
+trailing <- 72
+
+bt.opt.MeanES <- optimize.portfolio.rebalancing(R, port2, rp=rp,
+                                                optimize_method="random", 
+                                                rebalance_on=rebal.freq, 
+                                                training_period=training, 
+                                                trailing_periods=trailing)
+chart.RiskBudget(bt.opt.MeanES, main="Mean ES", risk.type="percentage")
+
+bt.opt.MeanES.RB <- optimize.portfolio.rebalancing(R, port3, rp=rp,
+                                                   optimize_method="random", 
+                                                   rebalance_on=rebal.freq, 
+                                                   training_period=training, 
+                                                   trailing_periods=trailing)
+chart.RiskBudget(bt.opt.MeanES.RB, main="Mean-ES 30% Limit", 
+                 risk.type="percentage")
+
+
+bt.opt.MeanES.EqRB <- optimize.portfolio.rebalancing(R, port4, rp=rp,
+                                                     optimize_method="random", 
+                                                     rebalance_on=rebal.freq, 
+                                                     training_period=training, 
+                                                     trailing_periods=trailing)
+chart.RiskBudget(bt.opt.MeanES.EqRB, main="Mean-ES Equal Risk", 
+                 risk.type="percentage")
+
[TRUNCATED]

To get the complete diff run:
    svnlook diff /svnroot/returnanalytics -r 3346


More information about the Returnanalytics-commits mailing list