Calculations of daily Value-at-Risk (VaR) for any $N$-asset portfolio, as we have studied it already in Part 1, heavily depend on the covariance matrix we need to estimate. This estimation requires historical return time-series. Often negligible but superbly important question one should ask here is: *How long?!* How long those return-series ought to be in order to provide us with fair and sufficient information on the daily return distribution of each asset held in the portfolio?

It is intuitive that taking data covering solely past 250 trading days and, for example, past 2500 days (**moving element**) would have a substantial **impact** on the calculation of current portfolio VaR. In this short post, we will examine this relation.

**Case Study (Supplementary Research)**

Using the example of 7-asset portfolio from Part 1, we modify our Matlab code that allows us to download the history of stock (adjusted) close prices covering past 10 calendar years (ca. 3600 days),

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | % Applied Portfolio VaR Decomposition. (2) Impact vs Moving Elements. % (c) 2015 QuantAtRisk.com, by Pawel Lachowicz clear all; close all; clc; format short % Read the list of the portfolio components fileID = fopen('portfolio.lst'); tmp = textscan(fileID, '%s'); fclose(fileID); pc=tmp{1}; % a list as a cell array % fetch stock data for last 10 years since: t0=735976; % 12-Jan-2015 date2=datestr(t0,'yyyy-mm-dd'); % from date1=datestr(t0-10*365,'yyyy-mm-dd'); % to %{ % create an empty array for storing stock data stockd={}; % scan the tickers and fetch the data from Quandl.com for i=1:length(pc) quandlc=['WIKI/',pc{i}]; fprintf('%4.0f %s\n',i,quandlc); % fetch the data of the stock from Quandl % using recommanded Quandl's command and % saving them directly into Matlab's FTS object (fts) fts=0; [fts,headers]=Quandl.get(quandlc,'type','fints', ... 'authcode','YourQuandlCode',... 'start_date',date1,'end_date',date2); stockd{i}=fts; % entire FTS object in an array's cell end save data2 %} load data2 |

Assuming the same initial holdings (position sizes) for each asset:

39 40 41 42 43 44 45 46 | % an initial dollar expose per position d=[ 55621.00; ... 101017.00; ... 23409.00; ... 1320814.00; ... 131145.00; ... 321124.00; ... 1046867.00]; |

we aim at calculation of the portfolio VaR,

$$

\mbox{VaR}_P = 1.65 \sigma_P C = 1.65\left(\boldsymbol{d}’ \boldsymbol{M}_2 \boldsymbol{d} \right)^{1/2}

$$ in a function of time or, alternatively speaking, in a function of varying length of return time-series:

48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | % examine VaR_P as a function of historical data % taken into account e=[]; for td=(10*250):-1:60 % loop over trading days rs=[]; for i=1:length(pc) cp=fts2mat(stockd{i}.Adj_Close,0); rv=cp(2:end,1)./cp(1:end-1,1)-1; rs=[rs rv(end-td:end)]; end rs(isnan(rs))=0.0; % covariance matrix M2=cov(rs); % the portfolio volatility vol_P=sqrt(d'*M2*d); % diversified portfolio VaR VaR_P=1.65*vol_P; e=[e; td VaR_P]; end |

The meaning of the loop is straightforward: How does $\mbox{VaR}_P$ change if we take only last 60 trading days into account, and what is its value when we include more and more data going back in time as far as 10 years?

The best way to illustrate the results is to compare *running* portfolio VaR with the stock market itself, here reflected by ETF of SPY,

68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 | % download close price time-series for SPY (ETF) % tracking S&P500 Index [fts,headers]=Quandl.get('GOOG/NYSE_SPY','type','fints', ... 'authcode','YourQuandlCode',... 'start_date',date1,'end_date',date2); SPY_cp=fts2mat(fts.Close,0); % plot results subplot(2,1,1) xtmp=(2501:-1:1)./250; plot(xtmp,SPY_cp(end-10*250:end,1)); xlim([min(xtmp) max(xtmp)]); set(gca,'xdir','reverse'); ylabel('SPY Close Price [$]') subplot(2,1,2) plot(e(:,1)./250,e(:,2),'r'); set(gca,'xdir','reverse'); ylabel('VaR_P [$]') xlabel('Time since 12-Jan-2015 [trading years]') |

uncovering the big picture as follows:

And now all becomes clear! Firstly, $\mbox{VaR}_P$ of our 7-asset portfolio is a function of data. Secondly, $\mbox{VaR}_P$ changes in the way that we might expect as contrasted with the market behaviour. In this point, note an evident increase in $\mbox{VaR}_P$ value if we include not 6 but 7 years of data. Why? The market went down in 2008 and the impact of it had been imprinted in the daily losses of single stocks. Therefore this contribution enriched the left tail of their return distributions. An inclusion of this information in our covariance matrix in a natural way increases the level of $\mbox{VaR}_P$.

So, how long? How many data should we include to get *fair* estimation of $\mbox{VaR}_P$? It’s not so easy to address. I would go with a lower bound of at least 1 year. As for the upper limit, it depends. If you are optimistic that in 2015 stocks will keep their upward momentum, look back up to 5 years. If you are a cautious investor, include 7 to 10 years of data.

**Footnote**

Some of you may still wonder why *Impact vs Moving Elements*?! Well, I believe the inspiration for a good title may come from the most unexpected direction. It was 2013 when I heard that song for the first time and I loved it! Through ages, beautiful women have always inspired men, therefore let me share my inspiration with you. You can become inspired too ;-)