Minimum-CVaR versus minimum-variance portfolios

Một phần của tài liệu Financial risk modelling and portfolio optimization with r second edition (Trang 262 - 265)

In this first application, a comparison between a global minimum-CVaR and a global minimum-variance portfolio is conducted in the form of a back-test for an index-based equity portfolio. The monthly returns of the following stock indexes are considered: the S&P 500, the Nikkei 225, the FTSE 100, the French CAC 40, the German DAX, and the Hang Seng. The sample period of the index data runs from 31 July 1991 to 30 June 2011 and comprises a total of 240 observations. TheRcode for conducting the back-test is shown in Listings 12.1 and 12.2.

First, the packages are brought into memory. The data setStockIndexis con- tained in the packageFRAPO and the routines of the packagefPortfoliofor opti- mizing the minimum-CVaR and minimum-variance portfolios are utilized. In line 4 of Listing 12.1, the data set is loaded into the workspace and in line 5 the discrete percentage returns are computed.

The commands in which the portfolio specifications are defined are given on lines 8–14. First, a default specification is assigned to the object pspecwhich can be used directly for the global minimum-variance portfolios (objectgmv). In order to define a CVaR portfolio (objectcvar) some amendments to the default portfolio

k k Rcode 12.1Minimum-CVaR versus minimum-variance portfolio: back-test.

l i b r a r y ( FRAPO ) 1

l i b r a r y ( f P o r t f o l i o ) 2

# # R e t r i e v i n g d a t a and c a l c u l a t i n g r e t u r n s 3

d a t a ( S t o c k I n d e x ) 4

S t o c k R e t u r n <− na . o m i t ( t i m e S e r i e s ( r e t u r n s e r i e s ( S t o c k I n d e x , 5

method = " d i s c r e t e " ) , 6

c h a r v e c = rownames 7

( S t o c k I n d e x ) ) ) 8

# # S p e c i f y i n g p o r t f o l i o 9

p s p e c <− p o r t f o l i o S p e c ( ) 10

gmv <− p s p e c 11

c v a r <− p s p e c 12

s e t T y p e ( c v a r ) <− "CVaR" 13

s e t A l p h a ( c v a r ) <− 0 . 1 14

s e t S o l v e r ( c v a r ) <− " s o l v e R g l p k . CVAR" 15

# # C o n d u c t i n g backt e s t 16

end <− t i m e ( S t o c k R e t u r n ) [ 6 0 : 2 3 9 ] 17

f r o m <− t i m e ( S t o c k R e t u r n ) [ 1 : l e n g t h ( end ) ] 18

wGMV <− m a t r i x (NA, n c o l = n c o l ( S t o c k R e t u r n ) , nrow = l e n g t h ( end ) ) 19

wCVAR <− wGMV 20

f o r ( i i n 1 : l e n g t h ( end ) ) { 21

s e r i e s <− window ( S t o c k R e t u r n , s t a r t = f r om [ i ] , end = end [ i ] ) 22

gmvpf <− m i n v a r i a n c e P o r t f o l i o ( d a t a = s e r i e s , s p e c = gmv , 23

c o n s t r a i n t s = " LongOnly " ) 24

wGMV[ i , ] <− c ( g e t W e i g h t s ( gmvpf ) ) 25

c v a r p f <− m i n r i s k P o r t f o l i o ( d a t a = s e r i e s , s p e c = c v a r , 26

c o n s t r a i n t s = " LongOnly " ) 27

wCVAR[ i , ] <− c ( g e t W e i g h t s ( c v a r p f ) ) 28

} 29

definition have to be made. The type of the portfolio has to be set to"CVaR"with the setType()function. A confidence level has to be assigned. Here, a 10% level is as- signed to the portfolio specification by thesetAlpha()function. Incidentally, and as stated previously, the confidence level must be specified in return and not in loss space, hence a value of 0.1 coincides with the 90% confidence level of the loss distri- bution. Finally, the solver to be used is GLPK, hence the character string"solveR- glpk.CVAR"is assigned tocvarby thesetSolver()function. That is all it takes to define the two approaches for optimizing the portfolios in the following.

The back-test itself is carried out in lines 15–28. The portfolios will be optimized with respect to subsamples of size 60, that is, a prior data history of 5 years is em- ployed. The start and end points for the sliding data windows are assigned to the objectsfromandend. Next, two matrices are defined which are designated to store the portfolio weight vectors as rows. Hence, sufficient memory is allotted which will not hamper the speed of execution in the ensuing for loop. Executing the back-test in

k k Rcode 12.2Plotting wealth trajectory.

# # Compute P o r t f o l i o v a l u e s ( s u b s e q u e n t r e t u r n s ) 1

wGMVL1 <− l a g ( t i m e S e r i e s (wGMV, c h a r v e c = end ) , k = 1 ) 2

c o l n a m e s (wGMVL1) <− c o l n a m e s ( S t o c k R e t u r n ) 3

wCVARL1 <− l a g ( t i m e S e r i e s (wCVAR, c h a r v e c = end ) , k = 1 ) 4

c o l n a m e s (wCVARL1) <− c o l n a m e s ( S t o c k R e t u r n ) 5

# # R e t u r n f a c t o r s and p o r t f o l i o v a l u e s 6

GMVRetFac <− 1 + rowSums (wGMVL1 7

S t o c k R e t u r n [ t i m e (wGMVL1) , ] ) / 100 8

GMVRetFac [ 1 ] <− 100 9

GMVPort <− t i m e S e r i e s ( cumprod ( GMVRetFac ) , 10

c h a r v e c = names ( GMVRetFac ) ) 11

CVARRetFac <− 1 + rowSums (wCVARL1 12

S t o c k R e t u r n [ t i m e (wCVARL1) , ] ) / 100 13

CVARRetFac [ 1 ] <− 100 14

CVARPort <− t i m e S e r i e s ( cumprod ( CVARRetFac ) , 15

c h a r v e c = names ( CVARRetFac ) ) 16

# # P l o t t i n g o f p o r t f o l i o v a l u e s 17

y l i m s <− r a n g e ( c b i n d ( GMVPort , CVARPort ) ) 18

p l o t ( GMVPort , y l i m = y l i m s , x l a b = " " , 19

y l a b = " P o r t f o l i o V a l u e ( I n d e x ) " ) 20

l i n e s ( CVARPort , c o l = " b l u e " ) 21

l e g e n d ( " t o p l e f t " , 22

l e g e n d = c ( " Minimum−V a r i a n c e " , " Minimum−CVaR" ) , 23

c o l = c ( " b l a c k " , " b l u e " ) , l t y = 1 ) 24

# # R e l a t i v e p e r f o r m a n c e 25

R e l O u t P e r f <− ( CVARPort − GMVPort ) / GMVPort 100 26

p l o t ( R e l O u t P e r f , t y p e = " h " , c o l = " b l u e " , x l a b = " " , 27

y l a b = " P e r c e n t " , 28

main = " R e l a t i v e Out−P e r f o r m a n c e Min−CVaR v s . 29

Min−V a r i a n c e " ) 30

a b l i n e ( h = 0 , c o l = " g r e y " ) 31

aforloop might be considered as notR-like and one could have put the back-test in terms of thefapply()function which is contained in the packagetimeSeries, for instance, or one could have created an object for the returns with class attribute zooin the first place and utilized therollapply()function of the packagezoo instead. However, the aim of putting the back-test in aforloop is threefold. First, it shows that the prejudice againstforloops is unjustified (if they are properly set up).

Second, by looking at the body of theforloop, the user sees exactly what is happen- ing. Finally, the definition of a function that must be called from eitherfapply() orrollapply()is avoided. Within theforloop, the relevant data window from StockReturnis assigned to the objectseries. This object, together with the specificationgmvand the long-only constraint, is then used next in the determina- tion of the solution for global minimum-variance portfolios, which is accomplished by theminvariancePortfolio()function. The corresponding weight vector

k k is retrieved by the access functiongetWeights()and stored in theith row of the

matrix objectwGMV. The same is done in lines 25–27 for the global minimum-CVaR portfolios. Here, the functionminriskPortfolio()is called, and as arguments the series object and the long-only constraint together with the portfolio specification objectcvarare employed. The optimal portfolio weight vector is then assigned into theith row of the objectwCVAR.

In order to compute the portfolios’ equity lines, the inner products between the lagged portfolio weights and the subsequent returns have to be computed for each of the two portfolio approaches. This is accomplished in the first part of Listing 12.2.

From these portfolio return streams, the return factors can swiftly be computed by means of thecumprod()function, given that the returns have previously been calculated as discrete percentage changes and the initial wealth position has been assumed to be equal to 100. The portfolio values for the back-test period are assigned to the objectsGMVPortandCVARPortfor the global minimum-variance portfolios and the global minimum-CVaR portfolios, respectively.

These two equity curves are then displayed by means of lines 17–24 (see Figure 12.5) and the relative performance with respect to the equity line of the GMV portfolio as a bar-plot in the final lines of the listing (see Figure 12.6).

For this back-test design, the CVaR portfolio approach outperforms the GMV port- folio solutions. However, the sharp portfolio draw-downs witnessed during the finan- cial market crisis during 2007 and 2008 could not be averted by either of the two approaches.

Một phần của tài liệu Financial risk modelling and portfolio optimization with r second edition (Trang 262 - 265)

Tải bản đầy đủ (PDF)

(436 trang)