Project
Title: Optimum Composition for a Stock Portfolio
Sergio Vicente Simioni
September, 26, 2015

Report Content

  1. Executive Summary
  2. Conclusions
  3. Data Analysis

  4. Executive Summary

The proposal of this project is to analyse several current stocks from the BOVESPA ( Sao Paulo Stock Exchange ) and identify the best composition of portfolio aiming maximize the portfolio expected return, while minimize the risk for this given level of expected return.

This project was approached by utilizing the Modern Portfolio Theory, fathered by Harry Markowitz. The MPT is a mathematical formulation of the concept of diversification in investing, with the aim of selecting a collection of investment assets that has lower overall risk than any other combination of assets with the same expected return. This is possible, intuitively speaking, because different types of assets sometimes change in value in opposite directions.For example, to the extent prices in the stock market move differently from prices in the bond market, a combination of both types of assets can in theory generate lower overall risk than either individually. Diversification can lower risk even if assets’ returns are positively correlated.

In order to compare investment options, Markowitz developed a system to describe each investment or each asset class with math, using unsystematic risk statistics. Then he further applied that to the portfolios that contain the investment options. He looked at the expected rate-of-return and the expected volatility for each investment. He named his risk-reward equation The Efficient Frontier.

The Efficient Frontier equation shows the boundaries where the portfolio of assets is maximized in terms of returns and minimized in terms of risks.

  1. Conclusions

After analysing the 16 main current stocks from the BOVESPA ( Sao Paulo Stock Exchange ) it was identified that the best portfolio combination is shown below according to the TABLE A

Final Results

Portfolio Weights:
AMBEV BBAS3 BBDC3 BBDC4 BBSE3 BRFS3 CIEL3 ITSA4 ITUB4 KROT3 PETR3 PETR4 UGPA3 VALE3 VALE5
0.00390 0.0000 0.0000 0.00020 0.09640 0.2725 0.0419 0.2012 0.099 0.0000 0.00000 0.0000 0.21790 0.0000 0.0670

Target Returns and Risks:
Point of the Efficient Frontier Curve = 22
Average daily return = 0.0003
Risk = 0.0093

  1. Data Analysis

Loading the files necessary to develop the project

library(financeR)
library(xts)
library(fPortfolio)

Loading the returns file obtained from BOVESPA

stocks <- read.csv("C:/Users/Sergio Simioni/Desktop/STOCKS/stocks_2.csv", sep=";")

Printing the first 5 rows of the table

head(stocks)
##         Date    AMBEV    BBAS3    BBDC3    BBDC4    BBSE3    BRFS3
## 1 16/09/2015  0.02046  0.00960  0.02777  0.03732  0.03239 -0.00071
## 2 15/09/2015  0.01060  0.03630  0.01781  0.01923 -0.00572  0.00429
## 3 14/09/2015  0.00000  0.04146  0.05214  0.04464  0.03711  0.00029
## 4 11/09/2015 -0.01617 -0.02671  0.00204 -0.01104  0.05769  0.00763
## 5 10/09/2015 -0.00208 -0.01749 -0.01764 -0.02160 -0.01811 -0.01419
## 6 09/09/2015 -0.02040  0.00292  0.00483  0.01180 -0.02444 -0.01455
##      CIEL3    ITSA4    ITUB4    KROT3    PETR3    PETR4    UGPA3    VALE3
## 1  0.02212  0.02075  0.01663  0.01399  0.08591  0.06405  0.01990  0.02366
## 2 -0.00053 -0.00644  0.02465 -0.02055 -0.01133 -0.00907 -0.00469 -0.02872
## 3  0.01459  0.04865  0.04035  0.01742  0.00227  0.00783  0.03214 -0.01542
## 4  0.01565  0.02778  0.00189  0.00702 -0.05371 -0.03890  0.00376 -0.02457
## 5 -0.01806 -0.02965 -0.01999 -0.00697 -0.03822 -0.05006  0.00235  0.04617
## 6  0.01449  0.01090  0.01123  0.01893 -0.03682 -0.02894 -0.01834  0.00687
##      VALE5
## 1  0.02228
## 2 -0.03581
## 3 -0.01978
## 4 -0.02063
## 5  0.04167
## 6  0.00000

Checking the number of rows

scenarios <- dim(stocks)[1]
scenarios
## [1] 621

Checking the number of columns

assets <- dim(stocks)[2]
assets
## [1] 16

Convert the file xts to timeSeries

stocks <- as.timeSeries(stocks)

Specifications

spec <- portfolioSpec()
setSolver(spec) <- "solveRquadprog"
setNFrontierPoints(spec) <- 30

Constraints

constraints <- c("LongOnly")
portfolioConstraints(stocks, spec, constraints)
## 
## Title:
##  Portfolio Constraints
## 
## Lower/Upper Bounds:
##       AMBEV BBAS3 BBDC3 BBDC4 BBSE3 BRFS3 CIEL3 ITSA4 ITUB4 KROT3 PETR3
## Lower     0     0     0     0     0     0     0     0     0     0     0
## Upper     1     1     1     1     1     1     1     1     1     1     1
##       PETR4 UGPA3 VALE3 VALE5
## Lower     0     0     0     0
## Upper     1     1     1     1
## 
## Equal Matrix Constraints:
##        ceq AMBEV BBAS3 BBDC3 BBDC4 BBSE3 BRFS3 CIEL3 ITSA4 ITUB4 KROT3
## Budget  -1    -1    -1    -1    -1    -1    -1    -1    -1    -1    -1
##        PETR3 PETR4 UGPA3 VALE3 VALE5
## Budget    -1    -1    -1    -1    -1
## attr(,"na.action")
## Return 
##      1 
## attr(,"class")
## [1] "omit"
## 
## Cardinality Constraints:
##       AMBEV BBAS3 BBDC3 BBDC4 BBSE3 BRFS3 CIEL3 ITSA4 ITUB4 KROT3 PETR3
## Lower     0     0     0     0     0     0     0     0     0     0     0
## Upper     1     1     1     1     1     1     1     1     1     1     1
##       PETR4 UGPA3 VALE3 VALE5
## Lower     0     0     0     0
## Upper     1     1     1     1

TABLE A: Optimization of the portfolio

frontier <- portfolioFrontier(stocks, spec, constraints)
print(frontier)
## 
## Title:
##  MV Portfolio Frontier 
##  Estimator:         covEstimator 
##  Solver:            solveRquadprog 
##  Optimize:          minRisk 
##  Constraints:       LongOnly 
##  Portfolio Points:  5 of 29 
## 
## Portfolio Weights:
##     AMBEV  BBAS3  BBDC3  BBDC4  BBSE3  BRFS3  CIEL3  ITSA4  ITUB4  KROT3
## 1  0.7586 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.2414
## 8  0.2354 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1133 0.0000 0.1711
## 15 0.0767 0.0000 0.0164 0.1157 0.0000 0.0543 0.0767 0.2576 0.0000 0.0564
## 22 0.0039 0.0000 0.0000 0.0002 0.0964 0.2725 0.0419 0.2012 0.0990 0.0000
## 29 0.0000 0.0000 0.0000 0.0000 1.0000 0.0000 0.0000 0.0000 0.0000 0.0000
##     PETR3  PETR4  UGPA3  VALE3  VALE5
## 1  0.0000 0.0000 0.0000 0.0000 0.0000
## 8  0.0011 0.1119 0.0000 0.0414 0.3259
## 15 0.0000 0.0170 0.1068 0.0603 0.1620
## 22 0.0000 0.0000 0.2179 0.0000 0.0670
## 29 0.0000 0.0000 0.0000 0.0000 0.0000
## 
## Covariance Risk Budgets:
##     AMBEV  BBAS3  BBDC3  BBDC4  BBSE3  BRFS3  CIEL3  ITSA4  ITUB4  KROT3
## 1  0.8928 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.1072
## 8  0.4086 0.0000 0.0000 0.0000 0.0000 0.0000 0.0000 0.0190 0.0000 0.2317
## 15 0.1345 0.0000 0.0137 0.1093 0.0000 0.0240 0.0602 0.2311 0.0000 0.0872
## 22 0.0028 0.0000 0.0000 0.0002 0.1048 0.2864 0.0405 0.1888 0.0959 0.0000
## 29 0.0000 0.0000 0.0000 0.0000 1.0000 0.0000 0.0000 0.0000 0.0000 0.0000
##     PETR3  PETR4  UGPA3  VALE3  VALE5
## 1  0.0000 0.0000 0.0000 0.0000 0.0000
## 8  0.0005 0.0763 0.0000 0.0189 0.2449
## 15 0.0000 0.0200 0.0593 0.0636 0.1970
## 22 0.0000 0.0000 0.2230 0.0000 0.0576
## 29 0.0000 0.0000 0.0000 0.0000 0.0000
## 
## Target Returns and Risks:
##       mean     Cov    CVaR     VaR
## 1  -0.0020  0.0383  0.0759  0.0226
## 8  -0.0012  0.0181  0.0439  0.0215
## 15 -0.0005  0.0109  0.0262  0.0162
## 22  0.0003  0.0093  0.0185  0.0142
## 29  0.0010  0.0175  0.0354  0.0273
## 
## Description:
##  Sun Sep 27 08:50:37 2015 by user: Sergio Simioni

Plot of the efficient frontier

tailoredFrontierPlot(object = frontier)

Plot of the weights

weightsPlot(frontier, col = rainbow(assets))

References:Harry Markowitz: The Journal of Finance Vol. 7, No. 1. (Mar., 1952), pp. 77-91

Note: This activity has a purely didactic proposal for a Data Science Course, utilization for investment proposals are not permitted without author’s approval.