SlideShare a Scribd company logo
Zurich University
of Applied Sciences www.zhaw.ch/engineering Study
Project work (Engineering and
Management, Business Mathematics)
Risk Allocation Engine
Author Harbin Ademi
Stipe Ivankovic
Main supervisor Prof. Dr. Marc Wildi
Industrial partner Credit Suisse
External supervisor René Frei
Date 21.12.2018
Risk Allocation Engine (Projectwork)
 
DECLARATION OF ORIGINALITY
 
Project Work at the School of Engineering
 
 
 
 
By submitting this project work, the undersigned student confirm that this work is his/her own
work and was written without the help of a third party. (Group works: the performance of the
other group members are not considered as third party).
 
The student declares that all sources in the text (including Internet pages) and appendices
have been correctly disclosed. This means that there has been no plagiarism, i.e. no
sections of the project work have been partially or wholly taken from other texts and
represented as the student’s own work or included without being correctly referenced.
 
Any misconduct will be dealt with according to paragraphs 39 and 40 of the General
Academic Regulations for Bachelor’s and Master’s Degree courses at the Zurich University of
Applied Sciences (Rahmenprüfungsordnung ZHAW (RPO)) and subject to the provisions for
disciplinary action stipulated in the University regulations.
 
 
 
 
 
 
 
 
 
City, Date: Signature:
 
 
  ……………………………………………………………………..  …………………………..…………………………………………………... 
 
 
    …………………………..…………………………………………………... 
 
 
    …………………………..…………………………………………………... 
 
 
   
 
The original signed and dated document (no copies) must be included after the title sheet
in the ZHAW version of all project works submitted.
 
 
 
 
 
 
Zurich University 
of Applied Sciences
Winterthur, 21.12.2018
Risk Allocation Engine (Projectwork)
Abstract
Banks are often confronted with the situation where they have to construct a portfolio from
scratch. In order to make decisions about which assets to use, so that the portfolio makes a
profit with as little risk as possible, we have developed an engine that allows you to import
assets, check their characteristics and then generate an optimal portfolio.
The portfolio has been optimized in such a way, that from 2008 to 2018 it has the lowest
possible risk, even in high-volatility phases and the Sharpe ratio is improved by rebalancing
the assets. For optimization purposes, various rolling windows were used, which performed
differently. What stood out was, that a Sharpe ratio improved by almost 30% through the
use of a specific method.
The paper shows that the Sharpe ratio of the portfolio can best be improved by taking assets
from different asset allocation classes and minimizing volatility by diversifying the portfolio
as much as possible.
I
Risk Allocation Engine (Projectwork)
Contents
1 Introduction 1
1.1 Starting position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.4 Structure of the work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
2 Theoretical Basics 2
2.1 Portfolio return . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
2.2 Portfolio variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2.3 Sharpe Ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.4 Volatility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
2.5 Value at Risk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.6 Drawdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.7 Markowitz model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.8 Diversification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
2.9 Capital Asset Pricing Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
3 Results 14
3.1 Asset Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.2 Performance Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.1 Rolling Returns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3.2.2 Cumulative Returns . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
3.2.3 Drawdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2.4 Volatility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.2.5 Correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.3 Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.3.1 Annually rebalancing 120 days Rolling Window . . . . . . . . . . . . 20
3.3.2 Annually Rebalancing 252 days Rolling Window . . . . . . . . . . . . 23
3.3.3 Quarterly Rebalancing 60 days Rolling Window . . . . . . . . . . . . 25
3.3.4 Quarterly Rebalancing 120 days Rolling Window . . . . . . . . . . . 27
3.3.5 Correlation between the portfolio and other assets . . . . . . . . . . . 29
4 Conclusion and Outlook 30
5 Attachment 31
5.1 Applying the Shinyapp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.1.1 Read data an first steps . . . . . . . . . . . . . . . . . . . . . . . . . 31
5.1.2 Executable calculations and performances . . . . . . . . . . . . . . . 34
5.1.3 Optimization options . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
III
1 Introduction
Since the market is constantly volatile due to various events, regular adjustments to the
portfolio are necessary to ensure the best possible portfolio performance. This is why it is
so important for investors, that their money is invested securely and profitably. In order to
achieve this, it is necessary to be able to review past performances retrospectively in order
to make other or even the same decisions for future performances.
1.1 Starting position
In the beginning we met with Ren´e Frei who works for Credit Suisse. He gave us the task to
program a framework, which gives him the possibility to read in assets, to determine their
weighting and finally to check the portfolio for different characteristics. The data for our
sample portfolio was provided by Ren´e Frei from the Bloomberg Terminal.
1.2 Objective
The goal is to develop an engine that reads in assets and creates performance plots for each
asset and their allocation class. In addition, the portfolio is rebalanced using different time
periods in order to achieve the best possible sharpe ratio. After that, the optimized portfolio
is compared with the unoptimized portfolio given at the beginning.
1.3 Methods
To develop the engine, the Shinyapp package which can be executed in R-Studio, is used.
This package works like a Gui and can be used by the user, without programming knowl-
edge to read in different asset data and then the program evaluates the data using various
mathematical formulas.
1.4 Structure of the work
In the first part of the thesis the basics are explained, which contains all formulas, that are
necessary for the project work. In the second part of the thesis, the engine is used and
tested with the given data to check the characteristic of the assets. In the third part, the
optimization was carried out and represented by performance plots. This shows the weights
across the time period and if the optimization influenced the sharpe ratio or not. The final
part of the work refers to the analysis of the results as well as the possibility to improve the
engine.
1
2 Theoretical Basics
For the calculations in this paper we need some formulas, which we will discuss in this part
of the paper.
2.1 Portfolio return
The return is the effective amount you get back as an investor for a certain time period.[1]
First, some basic formulas are needed[11].
Formulas for the return:
The total return R is
R =
X1
X0
(1)
Where X1 is the return and X0 is the amount paid at time 0
The relative return r is
r =
X1 − X0
X0
(2)
These formulas are given because
R = r + 1 (3)
This leads to
X1 = (1 + r) ∗ X0 (4)
For the portfolio return, this means
n
i=1
X0i = X0 (5)
X0i is the invested amount. This can not be negative because short selling is not allowed.
The invested X0i amounts are fractions of the total investment.
X0i = X0 ∗ wi (6)
wi are the weights of individual securities. So the total return R of the portfolio is
R =
1
X0
∗
n
i=1
wi ∗ Ri ∗ X0 =
n
i=1
Ri ∗ wi (7)
Weights are normalized to 1 because of this
r =
n
i=1
wi ∗ ri (8)
The vector notation for the weight vector w is
w = (w1, ..., wn)T
(9)
2
Secondary condition to weight factor
w = (1, ..., 1)T
(10)
So this leads to
wT
∗ 1 = 1 (11)
The total return R is now
R = (R1, ..., Rn)T
(12)
an the relativ return r is
r = (r1, ..., rn)T
(13)
this leads to total return of the portfolio R(PTF)
R(PTF) = wT
∗ R (14)
and to the relativ return of the portfolio r(PTF)
r(PTF) = wT
∗ r (15)
3
2.2 Portfolio variance
The variance is a scatter by a certain amount. It is the square size of the standard deviation.
The variance does not appear as a negative number because it always defines a distance[12].
The definition for the variance is
σ2
= var[y] = E[(y − y)2
] (16)
the standard deviation is = σ
formula for the variance
var[x] = E[(x − x)2
] = E[x2
] − 2E[x]x + x2
= E[x2
] − x2
(17)
next the formula for the covariance between two variables to see their dependence on each
other.
cov(x1x2) = E[(x1 − x1)(x2 − x2)] (18)
The smaller the result, the less correlated the two variables. This means that if cov(x1, x2) =
0 then the two variables are uncorrelated. If cov of the two variables is positive, both numbers
grow and fall proportionally to each other. If cov of the two variables is negative, one variable
increases as the other decreases. The correlation coefficient is
p12 =
σ12
σ1σ2
(19)
If you know the covariance of two variables, you can calculate the variance of them. By the
definition of variance and covariance
var(x + y) = σ2
x ∗ 2σxy ∗ σ2
y (20)
variance-(covariancematrix)
(21)
cov(x) = cov(x, x) =
σ11 . . . σ1n
...
...
...
σn1 . . . σnn
On the diagonal are the variances of the elements of the vector σii = σ2i. Outside the
diagonal are the covariances. The correlations can be represented analogous in the form of
a correlation matrix by ρ
(22)
ρ =
ρ11 . . . ρ1n
...
...
...
ρn1 . . . ρnn
Where ρij is given as
ρij =
cov(xixj)
σiσj
(23)
4
The weighted sum is given as
θ = wT
∗ x =
n
i=1
wixi (24)
So the variance is
var(θ) = wT
∗ cov(x, x) ∗ w = wT
∗ Σw (25)
Σ is the cov(x, x) for the portfoliovariance that means
σ2
(ptf) = E[(r(ptf)r(ptf))(r(ptf)r(ptf))T
] (26)
this leads to variance of the portfolio σ2
(ptf)
σ2
(ptf) = wT
Σw (27)
5
2.3 Sharpe Ratio
Sharpe’s key figure makes it possible to compare assets performances with each other. It
compares the excess return of an asset with that of a safe, risk-free investment through the
volatility. The Sharpe Ratio distinguishes between 3 options, if the Sharpe coefficient is > 1,
then the higher risk has paid off according to the return, is the coefficient between 0 and 1,
then you have indeed made more but the risk was too large. If the amount is < 0 then you
have not even reached the return on the safe investment[3]. The Sharpe quotient is given as
S =
D
σD
(28)
Where D is the excess return, this is calculated as follows
Di = Rα
i − Rf
i (29)
D =
1
n
n
i=1
Di (30)
Rα
i is the return of the invested investment and Rf
i is the return of the risk free investment.
The volatility σD is determined here with the empirical standard function.
σD =
n
i=1(Di − D)2
n − 1
(31)
The sign of the quotient tells us whether it is an excess performance or a deficit performance.
However, it is unreadable how high the risk is.
6
2.4 Volatility
Volatility is a measurement for the return distribution around the expected return. It can
be calculated by using the standard deviation or the variance and shows the range of the
returns to which it can increase or decrease during a time period. That is the reason why
volatility is also a measurement of risk. The easiest way to calculate risk is with the simple
standard deviation[14]:
σ =
1
N
n
i=1
(xi − µ)2 (32)
The higher the standard deviation the higher the risk of the security. If the price fluctuates
rapidly over a short period of time, it has a high volatility and large losses are more likely.
If the fluctuation over a long time period is slow, it has a low volatility and the likelihood of
losses is less. Unfortunately, the simple standard deviation is not very adaptable for financial
data because it can’t handle changing volatility which is more common in the market. To
model an adaptive model that shows a dependency structure for the volatility or generates
the so called volatility clusters the GARCH - Model is a better fit. Therefor the conditional
volatility is introduced:
t = σtut (33)
σ2
t = cσ2
+
n
j=1
αjσ2
t−j +
m
k=1
βk
2
t−k (34)
Where ut is a sequence of standardized iid variables and the conditional volatility σ2
t now
depends on:
• The unconditional volatility σ2
• Past observation 2
t−k
• Lagged conditional volatilities σ2
t−j
This is a better approach to model the changing volatility and fits more quickly to the
respective market situation. To learn more about the model, please read the script by M.
Wildi ”An Introduction to Conditional Volatility Models”.
7
2.5 Value at Risk
Value at Risk is a statistical measure of risk for a security or a portfolio of assets. It is
measured in price, which gives the amount of returns expected to be lost over a certain
time period or in percentage at a defined confidence level. For example, if the daily 95%
confidence level of an asset is at 10$, there is a possibility of 5% that the asset will lose 10$
or more of its price. It is assumed that the returns are normally distributed with a mean of
0 and variance σ2
:
Figure 1: S&P 500 Returns as a normal distribution (blue line) with 95% confidence level
(red line).
To calculate the VaR for daily returns, the conditional variance σ2
t is taken from the
GARCH- Model for a more adaptive VaR:
V aR = σ2
t ∗ q (35)
Where q is the approximate value of the percentile point for a predefined confidence level of
the normal distribution.
8
2.6 Drawdown
The drawdown is a measure of a loss of value based on a previously occurring high and a
subsequent low within a period. Where drawdowns are all lows and the maximum drawdown
is the cumulative lows.[7] The necessary formula for the drawdown is:
DDt = min0,
pt − pmax
pmax
(36)
Where pmax is the peak in the interval and pt is the current value of the invested portfolio.
The calculation of the average drawdown is more informative if one is interested in the area
in which the drawdown of the portfolio is likely to fall most of the time.
1
T
T
t=1
DDt (37)
To define the lowest point in the whole observed period you need the maximum drawdown
of this result
MDDt = max(DDt) (38)
This calculates the maximum average, percentage decrease since investment start. And
therefore shows the worst possible case for the drawdown.
9
2.7 Markowitz model
Markowitz does not look at the individual investments on their own but always in relation
to the entire portfolio in order to assess them. Three parameters are required to describe the
result and each individual investment is calculated as the result of the entire portfolio. These
parameters are the following: The future return of each investment, the fluctuation range
of the returns of all investments, these as an expression of the risk measured as standard
deviation or variance, and the development of the investments to each other to know their
correlation to each other. These characteristics can be used to optimize the overall result by
cleverly combining several investments (”diversify”): More return with the same risk or less
risk with the same return. The return-to-risk ratio of a diversified portfolio is superior to any
investment in a single investment[5]. Assumptions to show the necessary calculations[11].
There are n instruments available.
The expected returns are r = (r1, ..., rn), Covariance matrix is Σ.
Portfolio weights given by the vector w = (w1, ..., wn)T
. Now it is possible to calculate the
minimum variance to the expected portfolio return. The result is the following optimization
problem:
Minimize
1
2
wT
Σw (39)
With the constraints
wT
r = r(PTF) (40)
and n
i=1
wi = 1 (41)
With Lagrange results:
L =
1
2
wT
Σw − λ(wT
r − r(PTF)) − µ(
n
i=1
wi − 1) (42)
To get the minimum, one has to remove the gradient with regard to w.
wL = Σw − λr − µ1 = 0 (43)
component derived
dL
dw1
=
n
i=1
σ1iwi − λr1 − µ = 0 (44)
dL
dwn
=
n
i=1
σniwi − λrn − µ = 0 (45)
Results with the constraints
(46)
10








σ11 . . . σ1n −r1 −1
...
...
...
...
...
σn1 . . . σnn −rn −1
r1 . . . rn 0 0
1 . . . 1 0 0
















W1
...
Wn
λ
µ








=








0
...
0
r(ptf)
1








Negative coefficients mean short sales, since this is not considered in this paper, this must
be limited. This means that the formula is extended by one more constraint.
wi ≥ 0 for i = 1, ..., n (47)
This results in a quadratic optimization problem. And this results in a quadratic cost function
with linear constraints. Further, it means that some coefficients that would be negative with
short sales are 0 in this case. The problem with Markowitz is that the return distribution is
only fully determined if the covariance matrix and expected values are normally distributed.
However, this is not usually the case since, e.g. extreme events occur more often than a
normal distribution allows. In addition, extreme events often have the case that they are
more correlated than usual.
2.8 Diversification
Diversification is the distribution of investments across multiple assets. The aim is to reduce
the unsystematic risk of the portfolio as much as possible, because with increasing number
of securities the risk decreases. Suppose that wi = 1
n
and σij = σ2
δij. (δij denotes the
”Kronecker Delta”, which assumes the value 1, if i = j and 0 otherwise) Then, for the
portfolio return r(ptf) this means
r(ptf) = wT
r (48)
and for the portfolio variance σ2
(ptf)
σ2
(ptf) =
1
n2
n
i=1
σ2
=
σ2
n
(49)
This has to mean that the portfolio variance can be made arbitrarily small by sufficiently
large diversification. However, the greater the correlation, the greater the threshold for
diversification. Diversification always involves a loss, a reduction in the return, whereby the
variance does not necessarily become much smaller.That means, if returns are uncorrelated,
the variance can be arbitrarily reduced by diversifying. But if there is correlation, then you
can reduce the variance only up to a certain limit, but not below this limit. This point is
called non-diversifiable market risk.
11
2.9 Capital Asset Pricing Model
The CAPM is a capital market balance model that deals with the part of risky assets that
can not be eliminated through diversification. The CAPM is based on the Capital Markets
Model and the Securities Lines Model. This model describes a linear dependency of the
return of an investment, which has only one risk influence variable. It is assumed that
throughout the market only in a single risky fund is invested. It is also assumed that the
market is in equilibrium state. This means that all securities that are not efficient are sold
and exchanged through efficient ones. In equilibrium state, these sales are already done.
This means that in the ideal world, where every investor is a mean-variance optimizer, they
all make the same estimates. So if everyone invests in the same efficient portfolio, then this
is the market portfolio[12]. This market portfolio is marked with the point M. The point M
given by (σM, rM) denotes the searched Market portfolio. Furthermore, the capital market
line is needed The capital market line is a straight line, starting from the risk-free point rf
through M. the beta of an attachment i is called βi. βi is the only one plant wich must be
known for the CAPM.
The expected excess return of an Instrument is
ri − rrf (50)
Accordingly, the expected excess return of the Market portfolio is.
rM − rrf (51)
For CAPM, the expected excess return of any instrument is proportional to the expected
excess return of the market portfolios with proportionality Constant β. Since β is the
covariance of the instrument with the market portfolio, which is normalized with the variance
of the market portfolio, this statement can also be summarized as follows: The expected
excess return of any instrument is proportional to the covariance of the instrument with the
Market portfolio. So the beta of a portfolio is
βp =
n
i=1
wi ∗ βi (52)
For the estimator of the mean value of the return applies
r =
1
n
∗
n
i=1
ri (53)
The estimate of variance is
s2
=
1
n − 1
n
i=1
(ri − r)2
(54)
the estimate for the geometric mean is
µ = [
n
i=1
(1 + ri)]
1
n − 1 (55)
12
the covariance is
cov(r, rm) =
1
n − 1
n
i=1
(ri − r)(rMi − rM ) (56)
beacuse cov(r, rm) is σiM we get βi
βi =
σiM
σ2
M
(57)
Thet leads to the CAPM formula
r =
Q − P
P
= rrf + β(rM − rrf ) (58)
13
3 Results
3.1 Asset Allocation
Firstly, we was to asign each asset to its allocation class and determine the weights for the
assets. The initial portfolio weights and the allocation were given by Ren´e Frei. We ana-
lyzed the performance from 2008 up to today. The weights of the allocation classes are the
summed asset weights of the corresponding classes. These classes give us a better overview
of how the assets in the same class perform together.
Figure 2: Allocation class table with the corresponding weights
Figure 3: Portfolio and allocation weights
14
3.2 Performance Plots
3.2.1 Rolling Returns
After that, we were able to plot different graphs for each asset or asset class to analyze its
performance. The next plots 4 - 5 are the rolling returns, which show how the assets or the
asset classes performed for a specific time window. For example, if we look at the rolling
return with a one year window, we see that the SP 500 gained nearly 40 % in September
2012 in one year. In the Application, we can change the rolling windows to have a deeper
look on the returns along our time period.
Figure 4: Rolling asset returns with one year rolling window
Figure 5: Rolling allocation returns with one year rolling window
15
3.2.2 Cumulative Returns
The plots 6 - 7 are the cumulative returns of the assets or asset classes. Those plots show
how the value of an asset or asset class changed over the time, if we invested for example
one dollar in January 2008. As we can see, the SPX Index had the best cumulative return
at the end of 2018. But if we look at the HFRXGL Index, January 2008 was a bad time to
get in. From the beginning of 2008 until 2009 the HFRXGL Index kept making losses and
after that, the profits could not outweigh the losses so the price stayed under 1 dollar.
Figure 6: Cumulative asset returns
Figure 7: Cumulative allocation returns
16
3.2.3 Drawdown
The drawdown plots 8 - 9 give us a better look on the losses which the assets made since
the beginning of the investment. They also give us more information about the time an
asset needs to recoup its losses. If we look for example at the SP 500 Index, we see that
the asset declined more than 50 % within a year since the beginning of 2008. To recoup
these losses, the asset needed nearly four years to get back to the value from the beginning.
The HFXRGL Index is also an interesting plot to look at. As mentioned in ”Cumulative
Returns”, the profits could not outweigh the losses, so the drawdown value remains under 0.
Figure 8: Drawdown of assets
Figure 9: Drawdown of allocation classes
17
3.2.4 Volatility
The next characteristic we wanted to look at, was the volatility or the risk of an asset. The
plots 10 and 11 show different spike highs for each asset. The SPX Index reached, for exam-
ple, a daily standard deviation of more than 5 % in September 2008. In general, we can say
that the higher the spikes are the bigger the risk of an asset is. So if we compare the SPX
Index with the HFRXGL Index or Stocks with Alterative Investments, we recognize that the
SPX Index has much more spikes than the HFRXGL Index thus the SPX Index is a riskier
asset than the HFRXGL Index or bonds a less volatile than stocks.
Figure 10: Volatility of assets
Figure 11: Volatility of allocation classes
18
3.2.5 Correlation
In order to optimize the portfolio as best as possible, it is important to check the behavior of
the assets in it against each other. It is very inconvenient to have assets in a portfolio that
behave the same or have large positive correlation because if the price of an asset goes down,
then the others also follow the downtrend and thus the whole portfolio makes a big loss.
Therefor diversification is a must to reach the best portfolio performance as possible. The
correlation plot below shows the correlation between the asset returns in our portfolio. The
greater the correlation between the asset, the greater the number in the plot. The significant
level of the correlations is represented by the red stars and the scatterplot for the relationship
is also plotted. We see a strong relationship between the SPX Index and the HFRXGL Index
and a much greater correlation between the LUATTRUU Index and the LUACTRUU Index
which both are bonds. We also detect a weak negative correlation between the SPX Index
and the LUATTRUU Index or the SPX Index and the LUACTTRUU Index. The negative
relation indicates that if the SPX Index makes gains, the LUATTRUU Index makes losses.
So it is very recommended having, for example, SPX Index and LUATTRUU in the portfolio
to reduce the portfolio risk.
Figure 12: Correlation of asset
19
3.3 Optimization
To analyze the performance of the optimization properly, we simulated four different cases
with different rebalancing periods and different rolling windows to compare them. The first
two cases were annually rebalancing periods with a rolling window of 252 days and 120 days
and the others were quarterly rebalancing periods with a rolling window of 60 days and
120 days. We also plotted the SP 500 and the unoptimized portfolio, which have the same
portfolio weights across our observed time period, in the same plot as the optimized plot to
see the performances in comparison to each other.
3.3.1 Annually rebalancing 120 days Rolling Window
The first optimization was with an annually rebalancing period and a 120 days rolling win-
dow. The rolling window is a time period, which in this case takes every year 120 historical
days to calculate the mean and the standard deviation for optimization purpose. The fol-
lowing plot 13 gives us the optimized weights for each asset or asset class across the time
period.
Figure 13: Annually portfolio and allocation class weights with 120 days rolling window
20
We see that the most used assets are bonds and alternative investments. The reason behind
that is that maximization of the Sharpe ratio can be done by maximizing the return or by
minimizing the standard deviation. Our optimizer pays also attention to the correlation
between the assets thus it is explanatory that it prefers those assets which have a negative
correlation to each other. If we look back at Figure 12, we see that the LUATTRUU- and
the LUACTRUU Index have negative correlation to the HFRXGL Index so they will be
preferred. Even if the LUATTRUU- and the LUACTRUU Index don’t have big returns,
they have good Sharpe ratios because of their small risk or volatility. In order to see that,
we can look at Figure 6 and Figure 10.
Figure 14: Sharpe ratio performance table with 120 days rolling window for SP500, the
unoptimized portfolio and the optimized portfolio
Figure 15: Cumulative returns with 120 days rolling window
21
Figure 16: Volatility with 120 days rolling window
The cumulative return of the optimized portfolio is the worst if we compare it to the SP
500 Index and the unoptimized portfolio. This means that if we hadn’t changed the weights
of the assets, the performance of the cumulative returns would have been better. But if we
compare the volatilities, we recognize that the optimized portfolio had the best performance
or the lowest risk and therefore also the Sharpe ratio is better than the others.
22
3.3.2 Annually Rebalancing 252 days Rolling Window
For the second optimization we took 252 days instead of 120 days for our rolling window.
Figure 17: Annually portfolio and allocation class weights with 252 days rolling window
The main difference between the 120 days rolling window optimization and the now used
252 days rolling window optimization is, that this one has greater weights for alternative
investments than the first one and that the LUACTRUU Index was used less. To check if
this approach is better as the first one, we have to take a look at the following performance
plots 18 - 20.
Figure 18: Sharpe ratio performance table with 252 days rolling window for SP500, the
unoptimized portfolio and the optimized portfolio
23
Figure 19: Cumulative returns with 252 days rolling window
Figure 20: Volatility with 252 days rolling window
It looks like the first optimization performance has the same pattern as the second one. But
if we look at the Sharpe ratio we notice that it is smaller than the first one and even smaller
than unoptimized portfolio with the same rolling window length. This could indicate that
we have used too much historical data that was not really relevant for the future.
24
3.3.3 Quarterly Rebalancing 60 days Rolling Window
The third optimization was carried out with a quarterly rebalancing and 60 days for the
rolling window.
Figure 21: Quarterly portfolio and allocation class with 252 days rolling window
Figure 22: Sharpe ratio performance table with 60 days rolling window for SP500, the
unoptimized portfolio and the optimized portfolio
25
Figure 23: Cumulative returns with 60 days quarterly rolling window
Figure 24: Volatility with 60 days quarterly rolling window
Here in figures 21 - 24, a quarterly optimization would make sense again because the Sharpe
ratio is better than that of the unoptimized portfolio but it is smaller than of the annually
rebalanced optimization with a rolling window of 120 days. However, we must note that
the weights were already determined from March and the downtrend starting in April was
therefore included in the calculation. This downtrend was not taken into account in the
optimizations above, as the weight determination did not take place until December.
26
3.3.4 Quarterly Rebalancing 120 days Rolling Window
The last optimization is also quarterly rebalanced but with a rolling window of 120 days.
Figure 25: Quarterly portfolio and allocation class weights with 120 days rolling window
Figure 26: Sharpe ratio performance table with 120 days rolling window for SP500, the
unoptimized portfolio and the optimized portfolio
27
Figure 27: Cumulative returns with 120 days quarterly rolling window
Figure 28: Volatility with 120 days quarterly rolling window
Here in figure 25 - 28, we have the same issue as in annual optimization. If we use too much
data for the optimization, we achieve a worse Sharpe ratio. Even if the standard deviation
remains almost constant with a greater rolling window, we can see a clear difference when
we look at the mean of the returns.
28
3.3.5 Correlation between the portfolio and other assets
To check how the optimized portfolio behave in relation to other assets, which can be up-
loaded in the application, or how the relationship changed by optimization, we made a
correlation plot of the best performing optimization to get a better view. The first row is
the unoptimized portfolio and the second row the optimized one.
Figure 29: Correlation between the optimized portfolio, unoptimized portfolio and assets
We can see that the correlation between the portfolio and the assets changes after optimizing
it. To observe it more closely, we can take a look at an example. A big difference between the
optimized and unoptimized portfolio can be observed in relation to the LD06TRUU. Since
LD06TRUU is an index of corporate bonds and the weighting of bonds in the optimized
portfolio is also increasing, it makes sense that the correlation is also increasing.
29
4 Conclusion and Outlook
We have seen that different assets also have different characteristics. While assets show very
good returns but are more volatile, bonds are less risky but have lower returns. With the
right combination of assets, we could minimize the volatility of the portfolio so that we could
still make acceptable returns on a small risk and thus improve the Sharpe ratio. Through
our optimization, we were able to increase the Sharpe ratio of our sample portfolio by almost
30% with quarterly rebalancing and a rolling window of 60 days. The risk was kept as small
as possible by rarely involving the SPX Index in the portfolio. Unfortunately, we were only
able to improve the Sharpe ratio by almost 2% during the annual rebalancing with a rolling
window of 120 days. The remaining optimizations were unsuccessful as they performed worse
than the unoptimized portfolios. However, it should be noted that the rebalancing costs were
not considered. To sum up, we can say that the risk can be made quite small by periodi-
cally rebalancing, whereby the return of the portfolio suffers as a result. If we compare the
cumulative plots of the optimizations, we see that we never achieved better returns than the
unoptimized portfolio which was determined by Ren´e Frei at the beginning.
We are not quite sure whether a periodic rebalancing really makes sense, because quarterly
optimization can cause many costs and the annual rebalancing does not achieve the desired
performance. Therefore, one could investigate in further work, how the performance would
be with an event-driven optimization. It would be possible to include various indicators,
such as the interest rates of bonds, and when a predetermined level has been reached, the
portfolio would be rebalanced. This method would cause less rebalancing costs and could
perform much better.
The application can be found at the page URL: https://ademihar.shinyapps.io/Risk Shiny/.
30
5 Attachment
This section contains a description of how to use the Shinyapp and all references.
5.1 Applying the Shinyapp
In order to use the Shinyapp you some information is needed, which will be explained in
this part of the thesis. Here are the various representations and calculations. As well as the
reading of different time series, the presentation of asset allocations and the optimization of
the portfolio.
5.1.1 Read data an first steps
When you start the app you will get to the Load Data page (Figure 30). Here you have
the possibility to read your data in the sidebar. The data should be in a CSV format like
Figure 31, where the first line must contain the names of the assets, green frame and the
first column must contain the time intervals, red frame. At the top of the sidebar you can
read in assets and then divide them by selecting a button as shown in the red framed area of
Figure 30, depending on the type of separator. The default is Comma. Below you can read
in the corresponding indicators, also here default Comma.
Figure 30: Startpicture on Load data tab with red frame.
31
Figure 31: Example for format with green frame names and the red frame time intervals.
After reading in, the data of the assets and the indicators, in the output area, they are
automatically displayed and plotted in log format, in the upper area the asset data outputs
in the lower area the indicators. (Figure 32)
Figure 32: After loading data and separating it with semicolon shown with red arrow.
32
Our data in figure 32 is separated with semicolon, therefore the change to semicolon. In the
lower area you have the possibility to set the time interval. Basic setting here is between
2000 and 2006. For the following representations the time series between 2008 and 2018 are
used.(Figure 33)
Figure 33: Shows posibility to change the time period in red frame.
33
5.1.2 Executable calculations and performances
With the app you can check different performances and perform calculations. To do this
you switch to the next tab ”Asset Allocation”. On this page you end up on the ”Weight-
Allocation” tabpanel. it should look like figure 34. Here you first select the appropriate
allocations for the different assets, in figure red frame. Allocations must be weighted before
output. To do this, select the desired weighting in % in the sidebar, whereby you can set a
maximum of 100% for all allocations together, figure green frame.
Figure 34: Shows weighting of allocations for the assets.
The selected assets with the selected allocation are displayed directly in the right part, in
the output area of the app. After entering the weighting, you now have the option, at the
bottom of the sidebar, to select the confidence level for the Value at Risk plot. (Figure 35)
Figure 35: Shows posibility to choose the confidence level.
There are 4 more tabpanels which will be discussed later at the results. They are Overview,
Asset-Performance, Allocation-Performance and Correlation.
34
5.1.3 Optimization options
The last tab contains the section Portfolio Optimization. Here you have the opportunity to
optimize the portfolio with the selected assets and allocations with different interventions.
Figure 36: Portfolio-optimization befor changing values
In this area of the sidebar you now have the opportunity to define whether you want to
optimize the portfolio for standard deviation or for the returns, you can also choose both
what would be the sharpe ratio. Both are selected by default. The next step is to use the
slider to determine how much the engine is allowed to change the weights of the allocations,
to optimize. Underneath, the constraints are displayed directly. In the default setting these
are in the minimum at 0 and in the maximum at 1. In addition, all allocations contained in
the portfolio are automatically displayed here.
35
Figure 37: Portfolio-optimization befor changing values top part
At the bottom of the sidebar, under Rebalance Period, you can set how often you want to
rebalance. You can choose Yearly, Quarterly or Monthly, where Yearly is 252 days, Quarter
is 60 days and Monthly is 20 days. Finally, it is possible to define the Rolling Window. Then
you have to press the run button for the output in the output window.
36
References
[1] Rendite, URL: https://de.wikipedia.org/wiki/Rendite [Stand: 05.12.2018]
[2] Varianz, (Stochastik) URL: https://de.wikipedia.org/wiki/Varianz(Stochastik)[Stand : 05.12.2018]
[3] Boersenlexikon, Erklaerung Sharpe URL: http://www.finanztreff.de/wissen/boersenlexikon/sharpe-
ratio/5334 [Stand: 05.12.2018]
[4] Aktien-Basiswissen,was ist DiversifikationURL: http://www.finanztreff.de/wissen/aktien/was-
ist-diversifikation/5420 [Stand: 05.12.2018]
[5] Anlegercampus, Die Moderne Portfolio-Theorie nach Harry M.Markowitz URL:
http://www.anlegercampus.net/geld-anlegen-ohne-wetten/2-das-abc-erfolgreicher-
geldanlage-so-viel-sollten-sie-wissen-ein-ueberblick/die-moderne-portfoliotheorie-nach-
markowitz/ [Stand: 05.12.2018]
[6] Capital Asset Pricing Model URL: https://de.wikipedia.org/wiki/Capital Asset Pricing Model
[Stand: 05.12.2018]
[7] Maximum-Drawdown URL: https://de.wikipedia.org/wiki/MaximumDrawdown[Stand : 05.12.2018]
[8] Stefan Mittnik. (2016): Rechnen mit dem Risiko: Die wichtigsten Risikomasse im
¨UberblickURL : https : //ch.scalable.capital/mittnik − on − markets/rechnen − mit − dem − risiko
[9] VolatilitRL: https://de.wikipedia.org/wiki/Volatilit%C3%A4t [Stand: 05.12.2018]
[10] Boersenlexikon, Erklaerung Volatilit¨atURL : http : //www.finanztreff.de/wissen/boersenlexikon/v
[11] Wolfgang Breymann.(2017):Mathematik der Finanzm¨arkte1 :
KlassischePortfoliotheoriefrbeliebigvieleInstrumenteV orlesung
[12] Wolfgang Breymann.(2017):Mathematik der Finanzm¨arkte1 :
DasCapital − Asset − PricingModell(CAPM)V orlesung
37
[13] Wolfgang Breymann.(2016):Mathematik der Finanzm¨arkte1 :
ModelleundDatenV orlesung
[14] Marc Wildi.(2018):An Introduction to Conditional Volatility Models.
List of Figures
1 S&P 500 Returns as a normal distribution (blue line) with 95% confidence
level (red line). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2 Allocation class table with the corresponding weights . . . . . . . . . . . . . 14
3 Portfolio and allocation weights . . . . . . . . . . . . . . . . . . . . . . . . . 14
4 Rolling asset returns with one year rolling window . . . . . . . . . . . . . . . 15
5 Rolling allocation returns with one year rolling window . . . . . . . . . . . . 15
6 Cumulative asset returns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
7 Cumulative allocation returns . . . . . . . . . . . . . . . . . . . . . . . . . . 16
8 Drawdown of assets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
9 Drawdown of allocation classes . . . . . . . . . . . . . . . . . . . . . . . . . 17
10 Volatility of assets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
11 Volatility of allocation classes . . . . . . . . . . . . . . . . . . . . . . . . . . 18
12 Correlation of asset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
13 Annually portfolio and allocation class weights with 120 days rolling window 20
14 Sharpe ratio performance table with 120 days rolling window for SP500, the
unoptimized portfolio and the optimized portfolio . . . . . . . . . . . . . . . 21
15 Cumulative returns with 120 days rolling window . . . . . . . . . . . . . . . 21
16 Volatility with 120 days rolling window . . . . . . . . . . . . . . . . . . . . . 22
17 Annually portfolio and allocation class weights with 252 days rolling window 23
18 Sharpe ratio performance table with 252 days rolling window for SP500, the
unoptimized portfolio and the optimized portfolio . . . . . . . . . . . . . . . 23
19 Cumulative returns with 252 days rolling window . . . . . . . . . . . . . . . 24
20 Volatility with 252 days rolling window . . . . . . . . . . . . . . . . . . . . . 24
21 Quarterly portfolio and allocation class with 252 days rolling window . . . . 25
22 Sharpe ratio performance table with 60 days rolling window for SP500, the
unoptimized portfolio and the optimized portfolio . . . . . . . . . . . . . . . 25
23 Cumulative returns with 60 days quarterly rolling window . . . . . . . . . . 26
24 Volatility with 60 days quarterly rolling window . . . . . . . . . . . . . . . . 26
25 Quarterly portfolio and allocation class weights with 120 days rolling window 27
26 Sharpe ratio performance table with 120 days rolling window for SP500, the
unoptimized portfolio and the optimized portfolio . . . . . . . . . . . . . . . 27
27 Cumulative returns with 120 days quarterly rolling window . . . . . . . . . . 28
38
28 Volatility with 120 days quarterly rolling window . . . . . . . . . . . . . . . 28
29 Correlation between the optimized portfolio, unoptimized portfolio and assets 29
30 Startpicture on Load data tab with red frame. . . . . . . . . . . . . . . . . . 31
31 Example for format with green frame names and the red frame time intervals. 32
32 After loading data and separating it with semicolon shown with red arrow. . 32
33 Shows posibility to change the time period in red frame. . . . . . . . . . . . 33
34 Shows weighting of allocations for the assets. . . . . . . . . . . . . . . . . . . 34
35 Shows posibility to choose the confidence level. . . . . . . . . . . . . . . . . . 34
36 Portfolio-optimization befor changing values . . . . . . . . . . . . . . . . . . 35
37 Portfolio-optimization befor changing values top part . . . . . . . . . . . . . 36
39

More Related Content

PDF
my book
PDF
2010 RDF credit Risk
 
PDF
Staff Report and Recommendations in Value of DER, 10-27-16
PDF
PDF
ma574-final-paper
PDF
Mb2521002105
PPTX
PPTX
TO STUDY THE OPTIMIZATION OF PORTFOLIO RISK AND RETURN
my book
2010 RDF credit Risk
 
Staff Report and Recommendations in Value of DER, 10-27-16
ma574-final-paper
Mb2521002105
TO STUDY THE OPTIMIZATION OF PORTFOLIO RISK AND RETURN

Similar to Risk Allocation Engine (Projectwork) (20)

PDF
Investing Concept Of Risk And Return PowerPoint Presentation Slides
PPT
Portfolio management
PPTX
Portfolio analysis
PDF
vatter_pdm_1.1
PPTX
IM_5.pptx
PDF
A Deep Dive In The Mean Variance Efficiency Of The Market Portfolio
PPT
Ch_05 - Risk and Return Valuation Theory.ppt
PPT
Ch_05 - Risk and Return Valuation Theory.ppt
PPTX
UZ Investments & Portfolio Management 2.pptx
PDF
Risk And Return Relationship PowerPoint Presentation Slides
PPTX
Forming an efficient portfolio and client education
PDF
Market Risk And Return PowerPoint Presentation Slides
PDF
Portfolio Analysis in US stock market using Markowitz model
PDF
Financial Concepts Risk Return PowerPoint Presentation Slides
PDF
EvalInvStrats_web
PDF
Finance Risk And Return PowerPoint Presentation Slides
PPTX
Accounting for decision making assignment
PDF
ChAPTER 8 Risk and Return.pdf
PPTX
PORTFOLIO MANAGEMENT.pptx
Investing Concept Of Risk And Return PowerPoint Presentation Slides
Portfolio management
Portfolio analysis
vatter_pdm_1.1
IM_5.pptx
A Deep Dive In The Mean Variance Efficiency Of The Market Portfolio
Ch_05 - Risk and Return Valuation Theory.ppt
Ch_05 - Risk and Return Valuation Theory.ppt
UZ Investments & Portfolio Management 2.pptx
Risk And Return Relationship PowerPoint Presentation Slides
Forming an efficient portfolio and client education
Market Risk And Return PowerPoint Presentation Slides
Portfolio Analysis in US stock market using Markowitz model
Financial Concepts Risk Return PowerPoint Presentation Slides
EvalInvStrats_web
Finance Risk And Return PowerPoint Presentation Slides
Accounting for decision making assignment
ChAPTER 8 Risk and Return.pdf
PORTFOLIO MANAGEMENT.pptx
Ad

Recently uploaded (20)

PDF
1a In Search of the Numbers ssrn 1488130 Oct 2009.pdf
PDF
NAPF_RESPONSE_TO_THE_PENSIONS_COMMISSION_8 _2_.pdf
PDF
HCWM AND HAI FOR BHCM STUDENTS(1).Pdf and ptts
PDF
ECONOMICS AND ENTREPRENEURS LESSONSS AND
PPT
KPMG FA Benefits Report_FINAL_Jan 27_2010.ppt
PPTX
EABDM Slides for Indifference curve.pptx
PPTX
4.5.1 Financial Governance_Appropriation & Finance.pptx
PPTX
Introduction to Managemeng Chapter 1..pptx
PDF
illuminati Uganda brotherhood agent in Kampala call 0756664682,0782561496
PDF
CLIMATE CHANGE AS A THREAT MULTIPLIER: ASSESSING ITS IMPACT ON RESOURCE SCARC...
PDF
Understanding University Research Expenditures (1)_compressed.pdf
PDF
final_dropping_the_baton_-_how_america_is_failing_to_use_russia_sanctions_and...
PDF
Bitcoin Layer August 2025: Power Laws of Bitcoin: The Core and Bubbles
PPTX
Introduction to Customs (June 2025) v1.pptx
PDF
Q2 2025 :Lundin Gold Conference Call Presentation_Final.pdf
PDF
Spending, Allocation Choices, and Aging THROUGH Retirement. Are all of these ...
PPTX
social-studies-subject-for-high-school-globalization.pptx
PPTX
kyc aml guideline a detailed pt onthat.pptx
PPTX
introuction to banking- Types of Payment Methods
PDF
Mathematical Economics 23lec03slides.pdf
1a In Search of the Numbers ssrn 1488130 Oct 2009.pdf
NAPF_RESPONSE_TO_THE_PENSIONS_COMMISSION_8 _2_.pdf
HCWM AND HAI FOR BHCM STUDENTS(1).Pdf and ptts
ECONOMICS AND ENTREPRENEURS LESSONSS AND
KPMG FA Benefits Report_FINAL_Jan 27_2010.ppt
EABDM Slides for Indifference curve.pptx
4.5.1 Financial Governance_Appropriation & Finance.pptx
Introduction to Managemeng Chapter 1..pptx
illuminati Uganda brotherhood agent in Kampala call 0756664682,0782561496
CLIMATE CHANGE AS A THREAT MULTIPLIER: ASSESSING ITS IMPACT ON RESOURCE SCARC...
Understanding University Research Expenditures (1)_compressed.pdf
final_dropping_the_baton_-_how_america_is_failing_to_use_russia_sanctions_and...
Bitcoin Layer August 2025: Power Laws of Bitcoin: The Core and Bubbles
Introduction to Customs (June 2025) v1.pptx
Q2 2025 :Lundin Gold Conference Call Presentation_Final.pdf
Spending, Allocation Choices, and Aging THROUGH Retirement. Are all of these ...
social-studies-subject-for-high-school-globalization.pptx
kyc aml guideline a detailed pt onthat.pptx
introuction to banking- Types of Payment Methods
Mathematical Economics 23lec03slides.pdf
Ad

Risk Allocation Engine (Projectwork)

  • 1. Zurich University of Applied Sciences www.zhaw.ch/engineering Study Project work (Engineering and Management, Business Mathematics) Risk Allocation Engine Author Harbin Ademi Stipe Ivankovic Main supervisor Prof. Dr. Marc Wildi Industrial partner Credit Suisse External supervisor René Frei Date 21.12.2018
  • 3.   DECLARATION OF ORIGINALITY   Project Work at the School of Engineering         By submitting this project work, the undersigned student confirm that this work is his/her own work and was written without the help of a third party. (Group works: the performance of the other group members are not considered as third party).   The student declares that all sources in the text (including Internet pages) and appendices have been correctly disclosed. This means that there has been no plagiarism, i.e. no sections of the project work have been partially or wholly taken from other texts and represented as the student’s own work or included without being correctly referenced.   Any misconduct will be dealt with according to paragraphs 39 and 40 of the General Academic Regulations for Bachelor’s and Master’s Degree courses at the Zurich University of Applied Sciences (Rahmenprüfungsordnung ZHAW (RPO)) and subject to the provisions for disciplinary action stipulated in the University regulations.                   City, Date: Signature:       ……………………………………………………………………..  …………………………..…………………………………………………...          …………………………..…………………………………………………...          …………………………..…………………………………………………...            The original signed and dated document (no copies) must be included after the title sheet in the ZHAW version of all project works submitted.             Zurich University  of Applied Sciences Winterthur, 21.12.2018
  • 5. Abstract Banks are often confronted with the situation where they have to construct a portfolio from scratch. In order to make decisions about which assets to use, so that the portfolio makes a profit with as little risk as possible, we have developed an engine that allows you to import assets, check their characteristics and then generate an optimal portfolio. The portfolio has been optimized in such a way, that from 2008 to 2018 it has the lowest possible risk, even in high-volatility phases and the Sharpe ratio is improved by rebalancing the assets. For optimization purposes, various rolling windows were used, which performed differently. What stood out was, that a Sharpe ratio improved by almost 30% through the use of a specific method. The paper shows that the Sharpe ratio of the portfolio can best be improved by taking assets from different asset allocation classes and minimizing volatility by diversifying the portfolio as much as possible. I
  • 7. Contents 1 Introduction 1 1.1 Starting position . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2 Objective . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.3 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.4 Structure of the work . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 2 Theoretical Basics 2 2.1 Portfolio return . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2.2 Portfolio variance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.3 Sharpe Ratio . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.4 Volatility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.5 Value at Risk . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.6 Drawdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9 2.7 Markowitz model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 2.8 Diversification . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.9 Capital Asset Pricing Model . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 3 Results 14 3.1 Asset Allocation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14 3.2 Performance Plots . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.2.1 Rolling Returns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.2.2 Cumulative Returns . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 3.2.3 Drawdown . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 3.2.4 Volatility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 3.2.5 Correlation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 3.3 Optimization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20 3.3.1 Annually rebalancing 120 days Rolling Window . . . . . . . . . . . . 20 3.3.2 Annually Rebalancing 252 days Rolling Window . . . . . . . . . . . . 23 3.3.3 Quarterly Rebalancing 60 days Rolling Window . . . . . . . . . . . . 25 3.3.4 Quarterly Rebalancing 120 days Rolling Window . . . . . . . . . . . 27 3.3.5 Correlation between the portfolio and other assets . . . . . . . . . . . 29 4 Conclusion and Outlook 30 5 Attachment 31 5.1 Applying the Shinyapp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 5.1.1 Read data an first steps . . . . . . . . . . . . . . . . . . . . . . . . . 31 5.1.2 Executable calculations and performances . . . . . . . . . . . . . . . 34 5.1.3 Optimization options . . . . . . . . . . . . . . . . . . . . . . . . . . . 35 III
  • 8. 1 Introduction Since the market is constantly volatile due to various events, regular adjustments to the portfolio are necessary to ensure the best possible portfolio performance. This is why it is so important for investors, that their money is invested securely and profitably. In order to achieve this, it is necessary to be able to review past performances retrospectively in order to make other or even the same decisions for future performances. 1.1 Starting position In the beginning we met with Ren´e Frei who works for Credit Suisse. He gave us the task to program a framework, which gives him the possibility to read in assets, to determine their weighting and finally to check the portfolio for different characteristics. The data for our sample portfolio was provided by Ren´e Frei from the Bloomberg Terminal. 1.2 Objective The goal is to develop an engine that reads in assets and creates performance plots for each asset and their allocation class. In addition, the portfolio is rebalanced using different time periods in order to achieve the best possible sharpe ratio. After that, the optimized portfolio is compared with the unoptimized portfolio given at the beginning. 1.3 Methods To develop the engine, the Shinyapp package which can be executed in R-Studio, is used. This package works like a Gui and can be used by the user, without programming knowl- edge to read in different asset data and then the program evaluates the data using various mathematical formulas. 1.4 Structure of the work In the first part of the thesis the basics are explained, which contains all formulas, that are necessary for the project work. In the second part of the thesis, the engine is used and tested with the given data to check the characteristic of the assets. In the third part, the optimization was carried out and represented by performance plots. This shows the weights across the time period and if the optimization influenced the sharpe ratio or not. The final part of the work refers to the analysis of the results as well as the possibility to improve the engine. 1
  • 9. 2 Theoretical Basics For the calculations in this paper we need some formulas, which we will discuss in this part of the paper. 2.1 Portfolio return The return is the effective amount you get back as an investor for a certain time period.[1] First, some basic formulas are needed[11]. Formulas for the return: The total return R is R = X1 X0 (1) Where X1 is the return and X0 is the amount paid at time 0 The relative return r is r = X1 − X0 X0 (2) These formulas are given because R = r + 1 (3) This leads to X1 = (1 + r) ∗ X0 (4) For the portfolio return, this means n i=1 X0i = X0 (5) X0i is the invested amount. This can not be negative because short selling is not allowed. The invested X0i amounts are fractions of the total investment. X0i = X0 ∗ wi (6) wi are the weights of individual securities. So the total return R of the portfolio is R = 1 X0 ∗ n i=1 wi ∗ Ri ∗ X0 = n i=1 Ri ∗ wi (7) Weights are normalized to 1 because of this r = n i=1 wi ∗ ri (8) The vector notation for the weight vector w is w = (w1, ..., wn)T (9) 2
  • 10. Secondary condition to weight factor w = (1, ..., 1)T (10) So this leads to wT ∗ 1 = 1 (11) The total return R is now R = (R1, ..., Rn)T (12) an the relativ return r is r = (r1, ..., rn)T (13) this leads to total return of the portfolio R(PTF) R(PTF) = wT ∗ R (14) and to the relativ return of the portfolio r(PTF) r(PTF) = wT ∗ r (15) 3
  • 11. 2.2 Portfolio variance The variance is a scatter by a certain amount. It is the square size of the standard deviation. The variance does not appear as a negative number because it always defines a distance[12]. The definition for the variance is σ2 = var[y] = E[(y − y)2 ] (16) the standard deviation is = σ formula for the variance var[x] = E[(x − x)2 ] = E[x2 ] − 2E[x]x + x2 = E[x2 ] − x2 (17) next the formula for the covariance between two variables to see their dependence on each other. cov(x1x2) = E[(x1 − x1)(x2 − x2)] (18) The smaller the result, the less correlated the two variables. This means that if cov(x1, x2) = 0 then the two variables are uncorrelated. If cov of the two variables is positive, both numbers grow and fall proportionally to each other. If cov of the two variables is negative, one variable increases as the other decreases. The correlation coefficient is p12 = σ12 σ1σ2 (19) If you know the covariance of two variables, you can calculate the variance of them. By the definition of variance and covariance var(x + y) = σ2 x ∗ 2σxy ∗ σ2 y (20) variance-(covariancematrix) (21) cov(x) = cov(x, x) = σ11 . . . σ1n ... ... ... σn1 . . . σnn On the diagonal are the variances of the elements of the vector σii = σ2i. Outside the diagonal are the covariances. The correlations can be represented analogous in the form of a correlation matrix by ρ (22) ρ = ρ11 . . . ρ1n ... ... ... ρn1 . . . ρnn Where ρij is given as ρij = cov(xixj) σiσj (23) 4
  • 12. The weighted sum is given as θ = wT ∗ x = n i=1 wixi (24) So the variance is var(θ) = wT ∗ cov(x, x) ∗ w = wT ∗ Σw (25) Σ is the cov(x, x) for the portfoliovariance that means σ2 (ptf) = E[(r(ptf)r(ptf))(r(ptf)r(ptf))T ] (26) this leads to variance of the portfolio σ2 (ptf) σ2 (ptf) = wT Σw (27) 5
  • 13. 2.3 Sharpe Ratio Sharpe’s key figure makes it possible to compare assets performances with each other. It compares the excess return of an asset with that of a safe, risk-free investment through the volatility. The Sharpe Ratio distinguishes between 3 options, if the Sharpe coefficient is > 1, then the higher risk has paid off according to the return, is the coefficient between 0 and 1, then you have indeed made more but the risk was too large. If the amount is < 0 then you have not even reached the return on the safe investment[3]. The Sharpe quotient is given as S = D σD (28) Where D is the excess return, this is calculated as follows Di = Rα i − Rf i (29) D = 1 n n i=1 Di (30) Rα i is the return of the invested investment and Rf i is the return of the risk free investment. The volatility σD is determined here with the empirical standard function. σD = n i=1(Di − D)2 n − 1 (31) The sign of the quotient tells us whether it is an excess performance or a deficit performance. However, it is unreadable how high the risk is. 6
  • 14. 2.4 Volatility Volatility is a measurement for the return distribution around the expected return. It can be calculated by using the standard deviation or the variance and shows the range of the returns to which it can increase or decrease during a time period. That is the reason why volatility is also a measurement of risk. The easiest way to calculate risk is with the simple standard deviation[14]: σ = 1 N n i=1 (xi − µ)2 (32) The higher the standard deviation the higher the risk of the security. If the price fluctuates rapidly over a short period of time, it has a high volatility and large losses are more likely. If the fluctuation over a long time period is slow, it has a low volatility and the likelihood of losses is less. Unfortunately, the simple standard deviation is not very adaptable for financial data because it can’t handle changing volatility which is more common in the market. To model an adaptive model that shows a dependency structure for the volatility or generates the so called volatility clusters the GARCH - Model is a better fit. Therefor the conditional volatility is introduced: t = σtut (33) σ2 t = cσ2 + n j=1 αjσ2 t−j + m k=1 βk 2 t−k (34) Where ut is a sequence of standardized iid variables and the conditional volatility σ2 t now depends on: • The unconditional volatility σ2 • Past observation 2 t−k • Lagged conditional volatilities σ2 t−j This is a better approach to model the changing volatility and fits more quickly to the respective market situation. To learn more about the model, please read the script by M. Wildi ”An Introduction to Conditional Volatility Models”. 7
  • 15. 2.5 Value at Risk Value at Risk is a statistical measure of risk for a security or a portfolio of assets. It is measured in price, which gives the amount of returns expected to be lost over a certain time period or in percentage at a defined confidence level. For example, if the daily 95% confidence level of an asset is at 10$, there is a possibility of 5% that the asset will lose 10$ or more of its price. It is assumed that the returns are normally distributed with a mean of 0 and variance σ2 : Figure 1: S&P 500 Returns as a normal distribution (blue line) with 95% confidence level (red line). To calculate the VaR for daily returns, the conditional variance σ2 t is taken from the GARCH- Model for a more adaptive VaR: V aR = σ2 t ∗ q (35) Where q is the approximate value of the percentile point for a predefined confidence level of the normal distribution. 8
  • 16. 2.6 Drawdown The drawdown is a measure of a loss of value based on a previously occurring high and a subsequent low within a period. Where drawdowns are all lows and the maximum drawdown is the cumulative lows.[7] The necessary formula for the drawdown is: DDt = min0, pt − pmax pmax (36) Where pmax is the peak in the interval and pt is the current value of the invested portfolio. The calculation of the average drawdown is more informative if one is interested in the area in which the drawdown of the portfolio is likely to fall most of the time. 1 T T t=1 DDt (37) To define the lowest point in the whole observed period you need the maximum drawdown of this result MDDt = max(DDt) (38) This calculates the maximum average, percentage decrease since investment start. And therefore shows the worst possible case for the drawdown. 9
  • 17. 2.7 Markowitz model Markowitz does not look at the individual investments on their own but always in relation to the entire portfolio in order to assess them. Three parameters are required to describe the result and each individual investment is calculated as the result of the entire portfolio. These parameters are the following: The future return of each investment, the fluctuation range of the returns of all investments, these as an expression of the risk measured as standard deviation or variance, and the development of the investments to each other to know their correlation to each other. These characteristics can be used to optimize the overall result by cleverly combining several investments (”diversify”): More return with the same risk or less risk with the same return. The return-to-risk ratio of a diversified portfolio is superior to any investment in a single investment[5]. Assumptions to show the necessary calculations[11]. There are n instruments available. The expected returns are r = (r1, ..., rn), Covariance matrix is Σ. Portfolio weights given by the vector w = (w1, ..., wn)T . Now it is possible to calculate the minimum variance to the expected portfolio return. The result is the following optimization problem: Minimize 1 2 wT Σw (39) With the constraints wT r = r(PTF) (40) and n i=1 wi = 1 (41) With Lagrange results: L = 1 2 wT Σw − λ(wT r − r(PTF)) − µ( n i=1 wi − 1) (42) To get the minimum, one has to remove the gradient with regard to w. wL = Σw − λr − µ1 = 0 (43) component derived dL dw1 = n i=1 σ1iwi − λr1 − µ = 0 (44) dL dwn = n i=1 σniwi − λrn − µ = 0 (45) Results with the constraints (46) 10
  • 18.         σ11 . . . σ1n −r1 −1 ... ... ... ... ... σn1 . . . σnn −rn −1 r1 . . . rn 0 0 1 . . . 1 0 0                 W1 ... Wn λ µ         =         0 ... 0 r(ptf) 1         Negative coefficients mean short sales, since this is not considered in this paper, this must be limited. This means that the formula is extended by one more constraint. wi ≥ 0 for i = 1, ..., n (47) This results in a quadratic optimization problem. And this results in a quadratic cost function with linear constraints. Further, it means that some coefficients that would be negative with short sales are 0 in this case. The problem with Markowitz is that the return distribution is only fully determined if the covariance matrix and expected values are normally distributed. However, this is not usually the case since, e.g. extreme events occur more often than a normal distribution allows. In addition, extreme events often have the case that they are more correlated than usual. 2.8 Diversification Diversification is the distribution of investments across multiple assets. The aim is to reduce the unsystematic risk of the portfolio as much as possible, because with increasing number of securities the risk decreases. Suppose that wi = 1 n and σij = σ2 δij. (δij denotes the ”Kronecker Delta”, which assumes the value 1, if i = j and 0 otherwise) Then, for the portfolio return r(ptf) this means r(ptf) = wT r (48) and for the portfolio variance σ2 (ptf) σ2 (ptf) = 1 n2 n i=1 σ2 = σ2 n (49) This has to mean that the portfolio variance can be made arbitrarily small by sufficiently large diversification. However, the greater the correlation, the greater the threshold for diversification. Diversification always involves a loss, a reduction in the return, whereby the variance does not necessarily become much smaller.That means, if returns are uncorrelated, the variance can be arbitrarily reduced by diversifying. But if there is correlation, then you can reduce the variance only up to a certain limit, but not below this limit. This point is called non-diversifiable market risk. 11
  • 19. 2.9 Capital Asset Pricing Model The CAPM is a capital market balance model that deals with the part of risky assets that can not be eliminated through diversification. The CAPM is based on the Capital Markets Model and the Securities Lines Model. This model describes a linear dependency of the return of an investment, which has only one risk influence variable. It is assumed that throughout the market only in a single risky fund is invested. It is also assumed that the market is in equilibrium state. This means that all securities that are not efficient are sold and exchanged through efficient ones. In equilibrium state, these sales are already done. This means that in the ideal world, where every investor is a mean-variance optimizer, they all make the same estimates. So if everyone invests in the same efficient portfolio, then this is the market portfolio[12]. This market portfolio is marked with the point M. The point M given by (σM, rM) denotes the searched Market portfolio. Furthermore, the capital market line is needed The capital market line is a straight line, starting from the risk-free point rf through M. the beta of an attachment i is called βi. βi is the only one plant wich must be known for the CAPM. The expected excess return of an Instrument is ri − rrf (50) Accordingly, the expected excess return of the Market portfolio is. rM − rrf (51) For CAPM, the expected excess return of any instrument is proportional to the expected excess return of the market portfolios with proportionality Constant β. Since β is the covariance of the instrument with the market portfolio, which is normalized with the variance of the market portfolio, this statement can also be summarized as follows: The expected excess return of any instrument is proportional to the covariance of the instrument with the Market portfolio. So the beta of a portfolio is βp = n i=1 wi ∗ βi (52) For the estimator of the mean value of the return applies r = 1 n ∗ n i=1 ri (53) The estimate of variance is s2 = 1 n − 1 n i=1 (ri − r)2 (54) the estimate for the geometric mean is µ = [ n i=1 (1 + ri)] 1 n − 1 (55) 12
  • 20. the covariance is cov(r, rm) = 1 n − 1 n i=1 (ri − r)(rMi − rM ) (56) beacuse cov(r, rm) is σiM we get βi βi = σiM σ2 M (57) Thet leads to the CAPM formula r = Q − P P = rrf + β(rM − rrf ) (58) 13
  • 21. 3 Results 3.1 Asset Allocation Firstly, we was to asign each asset to its allocation class and determine the weights for the assets. The initial portfolio weights and the allocation were given by Ren´e Frei. We ana- lyzed the performance from 2008 up to today. The weights of the allocation classes are the summed asset weights of the corresponding classes. These classes give us a better overview of how the assets in the same class perform together. Figure 2: Allocation class table with the corresponding weights Figure 3: Portfolio and allocation weights 14
  • 22. 3.2 Performance Plots 3.2.1 Rolling Returns After that, we were able to plot different graphs for each asset or asset class to analyze its performance. The next plots 4 - 5 are the rolling returns, which show how the assets or the asset classes performed for a specific time window. For example, if we look at the rolling return with a one year window, we see that the SP 500 gained nearly 40 % in September 2012 in one year. In the Application, we can change the rolling windows to have a deeper look on the returns along our time period. Figure 4: Rolling asset returns with one year rolling window Figure 5: Rolling allocation returns with one year rolling window 15
  • 23. 3.2.2 Cumulative Returns The plots 6 - 7 are the cumulative returns of the assets or asset classes. Those plots show how the value of an asset or asset class changed over the time, if we invested for example one dollar in January 2008. As we can see, the SPX Index had the best cumulative return at the end of 2018. But if we look at the HFRXGL Index, January 2008 was a bad time to get in. From the beginning of 2008 until 2009 the HFRXGL Index kept making losses and after that, the profits could not outweigh the losses so the price stayed under 1 dollar. Figure 6: Cumulative asset returns Figure 7: Cumulative allocation returns 16
  • 24. 3.2.3 Drawdown The drawdown plots 8 - 9 give us a better look on the losses which the assets made since the beginning of the investment. They also give us more information about the time an asset needs to recoup its losses. If we look for example at the SP 500 Index, we see that the asset declined more than 50 % within a year since the beginning of 2008. To recoup these losses, the asset needed nearly four years to get back to the value from the beginning. The HFXRGL Index is also an interesting plot to look at. As mentioned in ”Cumulative Returns”, the profits could not outweigh the losses, so the drawdown value remains under 0. Figure 8: Drawdown of assets Figure 9: Drawdown of allocation classes 17
  • 25. 3.2.4 Volatility The next characteristic we wanted to look at, was the volatility or the risk of an asset. The plots 10 and 11 show different spike highs for each asset. The SPX Index reached, for exam- ple, a daily standard deviation of more than 5 % in September 2008. In general, we can say that the higher the spikes are the bigger the risk of an asset is. So if we compare the SPX Index with the HFRXGL Index or Stocks with Alterative Investments, we recognize that the SPX Index has much more spikes than the HFRXGL Index thus the SPX Index is a riskier asset than the HFRXGL Index or bonds a less volatile than stocks. Figure 10: Volatility of assets Figure 11: Volatility of allocation classes 18
  • 26. 3.2.5 Correlation In order to optimize the portfolio as best as possible, it is important to check the behavior of the assets in it against each other. It is very inconvenient to have assets in a portfolio that behave the same or have large positive correlation because if the price of an asset goes down, then the others also follow the downtrend and thus the whole portfolio makes a big loss. Therefor diversification is a must to reach the best portfolio performance as possible. The correlation plot below shows the correlation between the asset returns in our portfolio. The greater the correlation between the asset, the greater the number in the plot. The significant level of the correlations is represented by the red stars and the scatterplot for the relationship is also plotted. We see a strong relationship between the SPX Index and the HFRXGL Index and a much greater correlation between the LUATTRUU Index and the LUACTRUU Index which both are bonds. We also detect a weak negative correlation between the SPX Index and the LUATTRUU Index or the SPX Index and the LUACTTRUU Index. The negative relation indicates that if the SPX Index makes gains, the LUATTRUU Index makes losses. So it is very recommended having, for example, SPX Index and LUATTRUU in the portfolio to reduce the portfolio risk. Figure 12: Correlation of asset 19
  • 27. 3.3 Optimization To analyze the performance of the optimization properly, we simulated four different cases with different rebalancing periods and different rolling windows to compare them. The first two cases were annually rebalancing periods with a rolling window of 252 days and 120 days and the others were quarterly rebalancing periods with a rolling window of 60 days and 120 days. We also plotted the SP 500 and the unoptimized portfolio, which have the same portfolio weights across our observed time period, in the same plot as the optimized plot to see the performances in comparison to each other. 3.3.1 Annually rebalancing 120 days Rolling Window The first optimization was with an annually rebalancing period and a 120 days rolling win- dow. The rolling window is a time period, which in this case takes every year 120 historical days to calculate the mean and the standard deviation for optimization purpose. The fol- lowing plot 13 gives us the optimized weights for each asset or asset class across the time period. Figure 13: Annually portfolio and allocation class weights with 120 days rolling window 20
  • 28. We see that the most used assets are bonds and alternative investments. The reason behind that is that maximization of the Sharpe ratio can be done by maximizing the return or by minimizing the standard deviation. Our optimizer pays also attention to the correlation between the assets thus it is explanatory that it prefers those assets which have a negative correlation to each other. If we look back at Figure 12, we see that the LUATTRUU- and the LUACTRUU Index have negative correlation to the HFRXGL Index so they will be preferred. Even if the LUATTRUU- and the LUACTRUU Index don’t have big returns, they have good Sharpe ratios because of their small risk or volatility. In order to see that, we can look at Figure 6 and Figure 10. Figure 14: Sharpe ratio performance table with 120 days rolling window for SP500, the unoptimized portfolio and the optimized portfolio Figure 15: Cumulative returns with 120 days rolling window 21
  • 29. Figure 16: Volatility with 120 days rolling window The cumulative return of the optimized portfolio is the worst if we compare it to the SP 500 Index and the unoptimized portfolio. This means that if we hadn’t changed the weights of the assets, the performance of the cumulative returns would have been better. But if we compare the volatilities, we recognize that the optimized portfolio had the best performance or the lowest risk and therefore also the Sharpe ratio is better than the others. 22
  • 30. 3.3.2 Annually Rebalancing 252 days Rolling Window For the second optimization we took 252 days instead of 120 days for our rolling window. Figure 17: Annually portfolio and allocation class weights with 252 days rolling window The main difference between the 120 days rolling window optimization and the now used 252 days rolling window optimization is, that this one has greater weights for alternative investments than the first one and that the LUACTRUU Index was used less. To check if this approach is better as the first one, we have to take a look at the following performance plots 18 - 20. Figure 18: Sharpe ratio performance table with 252 days rolling window for SP500, the unoptimized portfolio and the optimized portfolio 23
  • 31. Figure 19: Cumulative returns with 252 days rolling window Figure 20: Volatility with 252 days rolling window It looks like the first optimization performance has the same pattern as the second one. But if we look at the Sharpe ratio we notice that it is smaller than the first one and even smaller than unoptimized portfolio with the same rolling window length. This could indicate that we have used too much historical data that was not really relevant for the future. 24
  • 32. 3.3.3 Quarterly Rebalancing 60 days Rolling Window The third optimization was carried out with a quarterly rebalancing and 60 days for the rolling window. Figure 21: Quarterly portfolio and allocation class with 252 days rolling window Figure 22: Sharpe ratio performance table with 60 days rolling window for SP500, the unoptimized portfolio and the optimized portfolio 25
  • 33. Figure 23: Cumulative returns with 60 days quarterly rolling window Figure 24: Volatility with 60 days quarterly rolling window Here in figures 21 - 24, a quarterly optimization would make sense again because the Sharpe ratio is better than that of the unoptimized portfolio but it is smaller than of the annually rebalanced optimization with a rolling window of 120 days. However, we must note that the weights were already determined from March and the downtrend starting in April was therefore included in the calculation. This downtrend was not taken into account in the optimizations above, as the weight determination did not take place until December. 26
  • 34. 3.3.4 Quarterly Rebalancing 120 days Rolling Window The last optimization is also quarterly rebalanced but with a rolling window of 120 days. Figure 25: Quarterly portfolio and allocation class weights with 120 days rolling window Figure 26: Sharpe ratio performance table with 120 days rolling window for SP500, the unoptimized portfolio and the optimized portfolio 27
  • 35. Figure 27: Cumulative returns with 120 days quarterly rolling window Figure 28: Volatility with 120 days quarterly rolling window Here in figure 25 - 28, we have the same issue as in annual optimization. If we use too much data for the optimization, we achieve a worse Sharpe ratio. Even if the standard deviation remains almost constant with a greater rolling window, we can see a clear difference when we look at the mean of the returns. 28
  • 36. 3.3.5 Correlation between the portfolio and other assets To check how the optimized portfolio behave in relation to other assets, which can be up- loaded in the application, or how the relationship changed by optimization, we made a correlation plot of the best performing optimization to get a better view. The first row is the unoptimized portfolio and the second row the optimized one. Figure 29: Correlation between the optimized portfolio, unoptimized portfolio and assets We can see that the correlation between the portfolio and the assets changes after optimizing it. To observe it more closely, we can take a look at an example. A big difference between the optimized and unoptimized portfolio can be observed in relation to the LD06TRUU. Since LD06TRUU is an index of corporate bonds and the weighting of bonds in the optimized portfolio is also increasing, it makes sense that the correlation is also increasing. 29
  • 37. 4 Conclusion and Outlook We have seen that different assets also have different characteristics. While assets show very good returns but are more volatile, bonds are less risky but have lower returns. With the right combination of assets, we could minimize the volatility of the portfolio so that we could still make acceptable returns on a small risk and thus improve the Sharpe ratio. Through our optimization, we were able to increase the Sharpe ratio of our sample portfolio by almost 30% with quarterly rebalancing and a rolling window of 60 days. The risk was kept as small as possible by rarely involving the SPX Index in the portfolio. Unfortunately, we were only able to improve the Sharpe ratio by almost 2% during the annual rebalancing with a rolling window of 120 days. The remaining optimizations were unsuccessful as they performed worse than the unoptimized portfolios. However, it should be noted that the rebalancing costs were not considered. To sum up, we can say that the risk can be made quite small by periodi- cally rebalancing, whereby the return of the portfolio suffers as a result. If we compare the cumulative plots of the optimizations, we see that we never achieved better returns than the unoptimized portfolio which was determined by Ren´e Frei at the beginning. We are not quite sure whether a periodic rebalancing really makes sense, because quarterly optimization can cause many costs and the annual rebalancing does not achieve the desired performance. Therefore, one could investigate in further work, how the performance would be with an event-driven optimization. It would be possible to include various indicators, such as the interest rates of bonds, and when a predetermined level has been reached, the portfolio would be rebalanced. This method would cause less rebalancing costs and could perform much better. The application can be found at the page URL: https://ademihar.shinyapps.io/Risk Shiny/. 30
  • 38. 5 Attachment This section contains a description of how to use the Shinyapp and all references. 5.1 Applying the Shinyapp In order to use the Shinyapp you some information is needed, which will be explained in this part of the thesis. Here are the various representations and calculations. As well as the reading of different time series, the presentation of asset allocations and the optimization of the portfolio. 5.1.1 Read data an first steps When you start the app you will get to the Load Data page (Figure 30). Here you have the possibility to read your data in the sidebar. The data should be in a CSV format like Figure 31, where the first line must contain the names of the assets, green frame and the first column must contain the time intervals, red frame. At the top of the sidebar you can read in assets and then divide them by selecting a button as shown in the red framed area of Figure 30, depending on the type of separator. The default is Comma. Below you can read in the corresponding indicators, also here default Comma. Figure 30: Startpicture on Load data tab with red frame. 31
  • 39. Figure 31: Example for format with green frame names and the red frame time intervals. After reading in, the data of the assets and the indicators, in the output area, they are automatically displayed and plotted in log format, in the upper area the asset data outputs in the lower area the indicators. (Figure 32) Figure 32: After loading data and separating it with semicolon shown with red arrow. 32
  • 40. Our data in figure 32 is separated with semicolon, therefore the change to semicolon. In the lower area you have the possibility to set the time interval. Basic setting here is between 2000 and 2006. For the following representations the time series between 2008 and 2018 are used.(Figure 33) Figure 33: Shows posibility to change the time period in red frame. 33
  • 41. 5.1.2 Executable calculations and performances With the app you can check different performances and perform calculations. To do this you switch to the next tab ”Asset Allocation”. On this page you end up on the ”Weight- Allocation” tabpanel. it should look like figure 34. Here you first select the appropriate allocations for the different assets, in figure red frame. Allocations must be weighted before output. To do this, select the desired weighting in % in the sidebar, whereby you can set a maximum of 100% for all allocations together, figure green frame. Figure 34: Shows weighting of allocations for the assets. The selected assets with the selected allocation are displayed directly in the right part, in the output area of the app. After entering the weighting, you now have the option, at the bottom of the sidebar, to select the confidence level for the Value at Risk plot. (Figure 35) Figure 35: Shows posibility to choose the confidence level. There are 4 more tabpanels which will be discussed later at the results. They are Overview, Asset-Performance, Allocation-Performance and Correlation. 34
  • 42. 5.1.3 Optimization options The last tab contains the section Portfolio Optimization. Here you have the opportunity to optimize the portfolio with the selected assets and allocations with different interventions. Figure 36: Portfolio-optimization befor changing values In this area of the sidebar you now have the opportunity to define whether you want to optimize the portfolio for standard deviation or for the returns, you can also choose both what would be the sharpe ratio. Both are selected by default. The next step is to use the slider to determine how much the engine is allowed to change the weights of the allocations, to optimize. Underneath, the constraints are displayed directly. In the default setting these are in the minimum at 0 and in the maximum at 1. In addition, all allocations contained in the portfolio are automatically displayed here. 35
  • 43. Figure 37: Portfolio-optimization befor changing values top part At the bottom of the sidebar, under Rebalance Period, you can set how often you want to rebalance. You can choose Yearly, Quarterly or Monthly, where Yearly is 252 days, Quarter is 60 days and Monthly is 20 days. Finally, it is possible to define the Rolling Window. Then you have to press the run button for the output in the output window. 36
  • 44. References [1] Rendite, URL: https://de.wikipedia.org/wiki/Rendite [Stand: 05.12.2018] [2] Varianz, (Stochastik) URL: https://de.wikipedia.org/wiki/Varianz(Stochastik)[Stand : 05.12.2018] [3] Boersenlexikon, Erklaerung Sharpe URL: http://www.finanztreff.de/wissen/boersenlexikon/sharpe- ratio/5334 [Stand: 05.12.2018] [4] Aktien-Basiswissen,was ist DiversifikationURL: http://www.finanztreff.de/wissen/aktien/was- ist-diversifikation/5420 [Stand: 05.12.2018] [5] Anlegercampus, Die Moderne Portfolio-Theorie nach Harry M.Markowitz URL: http://www.anlegercampus.net/geld-anlegen-ohne-wetten/2-das-abc-erfolgreicher- geldanlage-so-viel-sollten-sie-wissen-ein-ueberblick/die-moderne-portfoliotheorie-nach- markowitz/ [Stand: 05.12.2018] [6] Capital Asset Pricing Model URL: https://de.wikipedia.org/wiki/Capital Asset Pricing Model [Stand: 05.12.2018] [7] Maximum-Drawdown URL: https://de.wikipedia.org/wiki/MaximumDrawdown[Stand : 05.12.2018] [8] Stefan Mittnik. (2016): Rechnen mit dem Risiko: Die wichtigsten Risikomasse im ¨UberblickURL : https : //ch.scalable.capital/mittnik − on − markets/rechnen − mit − dem − risiko [9] VolatilitRL: https://de.wikipedia.org/wiki/Volatilit%C3%A4t [Stand: 05.12.2018] [10] Boersenlexikon, Erklaerung Volatilit¨atURL : http : //www.finanztreff.de/wissen/boersenlexikon/v [11] Wolfgang Breymann.(2017):Mathematik der Finanzm¨arkte1 : KlassischePortfoliotheoriefrbeliebigvieleInstrumenteV orlesung [12] Wolfgang Breymann.(2017):Mathematik der Finanzm¨arkte1 : DasCapital − Asset − PricingModell(CAPM)V orlesung 37
  • 45. [13] Wolfgang Breymann.(2016):Mathematik der Finanzm¨arkte1 : ModelleundDatenV orlesung [14] Marc Wildi.(2018):An Introduction to Conditional Volatility Models. List of Figures 1 S&P 500 Returns as a normal distribution (blue line) with 95% confidence level (red line). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2 Allocation class table with the corresponding weights . . . . . . . . . . . . . 14 3 Portfolio and allocation weights . . . . . . . . . . . . . . . . . . . . . . . . . 14 4 Rolling asset returns with one year rolling window . . . . . . . . . . . . . . . 15 5 Rolling allocation returns with one year rolling window . . . . . . . . . . . . 15 6 Cumulative asset returns . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 7 Cumulative allocation returns . . . . . . . . . . . . . . . . . . . . . . . . . . 16 8 Drawdown of assets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17 9 Drawdown of allocation classes . . . . . . . . . . . . . . . . . . . . . . . . . 17 10 Volatility of assets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18 11 Volatility of allocation classes . . . . . . . . . . . . . . . . . . . . . . . . . . 18 12 Correlation of asset . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 13 Annually portfolio and allocation class weights with 120 days rolling window 20 14 Sharpe ratio performance table with 120 days rolling window for SP500, the unoptimized portfolio and the optimized portfolio . . . . . . . . . . . . . . . 21 15 Cumulative returns with 120 days rolling window . . . . . . . . . . . . . . . 21 16 Volatility with 120 days rolling window . . . . . . . . . . . . . . . . . . . . . 22 17 Annually portfolio and allocation class weights with 252 days rolling window 23 18 Sharpe ratio performance table with 252 days rolling window for SP500, the unoptimized portfolio and the optimized portfolio . . . . . . . . . . . . . . . 23 19 Cumulative returns with 252 days rolling window . . . . . . . . . . . . . . . 24 20 Volatility with 252 days rolling window . . . . . . . . . . . . . . . . . . . . . 24 21 Quarterly portfolio and allocation class with 252 days rolling window . . . . 25 22 Sharpe ratio performance table with 60 days rolling window for SP500, the unoptimized portfolio and the optimized portfolio . . . . . . . . . . . . . . . 25 23 Cumulative returns with 60 days quarterly rolling window . . . . . . . . . . 26 24 Volatility with 60 days quarterly rolling window . . . . . . . . . . . . . . . . 26 25 Quarterly portfolio and allocation class weights with 120 days rolling window 27 26 Sharpe ratio performance table with 120 days rolling window for SP500, the unoptimized portfolio and the optimized portfolio . . . . . . . . . . . . . . . 27 27 Cumulative returns with 120 days quarterly rolling window . . . . . . . . . . 28 38
  • 46. 28 Volatility with 120 days quarterly rolling window . . . . . . . . . . . . . . . 28 29 Correlation between the optimized portfolio, unoptimized portfolio and assets 29 30 Startpicture on Load data tab with red frame. . . . . . . . . . . . . . . . . . 31 31 Example for format with green frame names and the red frame time intervals. 32 32 After loading data and separating it with semicolon shown with red arrow. . 32 33 Shows posibility to change the time period in red frame. . . . . . . . . . . . 33 34 Shows weighting of allocations for the assets. . . . . . . . . . . . . . . . . . . 34 35 Shows posibility to choose the confidence level. . . . . . . . . . . . . . . . . . 34 36 Portfolio-optimization befor changing values . . . . . . . . . . . . . . . . . . 35 37 Portfolio-optimization befor changing values top part . . . . . . . . . . . . . 36 39