Saturday, May 30, 2015

Estimating Portfolio Return using History

In this post we want to assess the returns of the portfolio using the History.

Portfolio

           Portfolio is a  group of financial assets such as stocks, bonds and cash equivalents held by investors. Portfolio can be explained as below:-
                  1) Portfolio members      =  I  = {I1  ,I2  ,...In}.
                  2) Portfolio distribution  = D  = {D1,D2,..Dn},(D1+D2+..+Dn=1)
                  3) Portfolio value            = V  = I*D  

Portfolio Returns Assessment
         
        Guidance :-
           large changes tend to be followed by large changes-of either sign-and small changes                          by small changes(Mandelbrot 1963).

        Solution:-
            Obtain how current portfolio would have performed in given period by doing the following:-
             







PortfolioHistory


PortInformation






I1 I2 I3


I1 I2 I3 PortfolioVALUE PortfolioRETURN






01/01/01 2.3 2 3


01/01/01 1.15 0.6 0.6 2.35 .






01/02/01 4 5 6


01/02/01 2 1.5 1.2 4.7 1

CurrPortfolioDistribution

01/03/01 2 3 4


01/03/01 1 0.9 0.8 2.7 -0.425532

0.5 0.3 0.2
* 01/04/01 2.1 2 3
=
01/04/01 1.05 0.6 0.6 2.25 -0.166667






01/05/01 2.5 2.2 3.1


01/05/01 1.25 0.66 0.62 2.53 0.1244444






01/06/01 1.95 2.22 3.11


01/06/01 0.975 0.666 0.622 2.263 -0.105534














































01/02/15 1.95 2.22 3.11


01/02/15 0.975 0.666 0.622 2.263 -0.105534



















          Statistics:-

Moments
N5000000Sum Weights5
Mean0.08534245Sum Observations0.42671227
Std Deviation0.54750851Variance0.29976557
Skewness1.54600233Kurtosis2.75815662
Uncorrected SS1.23547895Corrected SS1.19906228
Coeff Variation641.542972Std Error Mean0.24485325


Quantiles (Definition 5)
LevelQuantile
100% Max1.000000
99%1.000000
95%1.000000
90%1.000000
75% Q30.124444
50% Median-0.105534
25% Q1-0.166667
10%-0.425532
5%-0.425532
1%-0.425532
0% Min-0.425532
           Var with 95% is 0.425532 so the loss will not be more than 42.5532% (Too high right, blame it on our sample data).

Variations:-

    1) Windowed approach (i.e consider only past K returns for VaR calculation with smaller window           size quickly adapt to volatility & larger window of high precision).

As per the study of historical data with parametric assumption we found the VaR. There are better 
alternatives, we can see about the same in future posts.

Better Alernatives:-
   
   1) RiskMetrics Exponential Smoothing [Places exponentially declining weights on historical data,            starting with an initial weight, and then declining to zero as we go further into the past].
   2) Adaptive Volatility Estimation.
   3) GARCH
   4) Multivariate Density Estimate(which i like the most!!).

Thanks 
Srinivas

Saturday, May 23, 2015

VaR BackTesting

VaR Analysis:-

One of widely used risk metric in financial industry is VaR(Value At Risk) .VaR is a risk measure which will give a magical number about loss (for a given period D with probability p% loss will not exceed x%).

For effective backtesting, VaR should exhibit following desirable characters:-
                 1)  Unbiasedness   [Average of Indicator Variable should be x%].
                  2) Don'tBunchUp [VaR estimates do not bunch up over a particular state of economy].

Verification:-
Backtesting is used to verify VaR validity[accept or reject], Major concerns here is to balance following types of errors:-

                 1) Type-I Error  [Possiblity that an accurate risk model would be classified as inaccurate].
                 2) Type-II Error [Possiblity that an inaccurate model would not be classified as accurate].

There is no statistical way to handle both Type I & Type II error so Basel came up with zone based approach of handling VaR and deciding Risk Weight.








Zone Description Exceptions
Count
Scaling factor
Increase
Cumulative
Probability


Green Zone
Test results are consistent with an accurate model,
And the possibility of erroneously accepting an
Inaccurate model is low.
0 0 8.11%

1 0 28.58%

2 0 54.32%

3 0 75.81%

4 0 89.22%

Yellow Zone
Test results are either consistent with either accurate or
Inaccurate models, and the supervisor should encourage
A bank to present additional information about its model
Before taking action.
5 0.4 95.88%

6 0.5 98.63%

7 0.65 99.60%

8 0.75 99.89%

9 0.85 99.97%

Red Zone Test results are extremely unlikely to have resulted
From an accurate model, and the probability of
Erroneously rejecting an accurate model on this
Basis is remote.
10 or more 1 99.99%







SASImplementation 






VaRData:-
Data table contains Observations  containing (Date,PredictedVaR and ActualLoss), as below:-

ObsDATEPredictedVaRActualLoss
113894102232400000
213895496875450000
313898406250393750
413899306250387500
513900506250387500
613901506250475000
713902510938475000
813905515625478906


Backtesting Result:-

Using below procedure we get ExceptionCount and Zone in which VaR lies.  

proc IML;
 use Work.VarData;
 read all var {"ActualLoss","PredictedVaR"};
 close Work.VarData;
 indicatorVar             =(ActualLoss>PredictedVar);
 excessLoss               =(ActualLoss-PredictedVar);
 ExceptionCount       = indicatorVar[+,1];
 ExcpetionPercentage=(ExceptionCount/nrow(indicatorVar));
 if ExceptionCount > =10 then do;
   Zone="Red Zone";
 end;
 else do;
    if ExceptionCount <= 4 then do;
      Zone="Green Zone";
    end;
    else do;    
      Zone="Yello Zone";
    end;
 end;
 print Zone ExceptionCount ExcpetionPercentage;
run; 
ZoneExceptionCountExcpetionPercentage
Green Zone20.25


Conclusion:-

After analysis of ActualLoss & PredictedVaR we calculated ExceptionCount and then found the VaR is in Yellow Zone.So not a big problem :). 

Based on 
Thanks & Regards,
Srinivasan
                     











Wednesday, May 20, 2015

FRTB Partial RiskFactor

Partial RiskFactor:-
       
           In FRTB, partial RiskFactor approach is specified under Revised Standardised Approach as a preferred way of arriving at risk weights. In this approach instruments with similar characters are grouped together in buckets and regulatory prescribed risk weights will be applied to their notional positions.
       
         We have implemented Partial RiskFactor using Clustering procedure of SAS!!! Happy Reading.

Partial RiskFactor Implementation:-
           In SAS CLUSTER can be used, CLUSTER hierarchically clusters the observations in a SAS dataset by using one of 11 methods. PROC CLUSTER computes possibly squared Eucledian distance as part of Clustering.  The methods differ by how distance between two clusters is computed(refer Appendix).

          We have used Wald's method for clustering as it is robust and reliable among the available options.  Please see the portfolio data:-

Input Data:-
 data Portfolio;
      input IReturn IRisk Sector Instrument$20.;
      datalines;
   14.7  5.7  5  Instr1    
   24.7  6.7  4  Instr5
   20.7  5.7  5  Instr9
   24.7  5.7  4  Instr13
   11.5 11.9  3  Instr2
   12.5 12.9  3  Instr10
   :
   ;

Clustering Process:-

To obtain approximate estimate of  pooled within-cluster covariance matrix using aceclus. 
     proc aceclus data=Portfolio out=Ace p=.03  noprint;
         var IReturn IRisk Sector;
     run;

To perform clustering of Instruments use below steps:-
     proc cluster data=Ace method=ward ccc pseudo print=7 outtree=Tree;
        var IReturn IRisk Sector;
         id Instrument;
     run;
     proc tree data=Tree ncl=6 out=clus3;
        copy IReturn IRisk Sector;
     run;
After clustering we can see the hierarchical grouping of instruments and their groups as in below.
Horizontal Dendrogram of Cluster Analysis Results

Obtaining cluster Membership:-

To obtain cluster & their constituent instruments use the below procedures.

proc sort data=clus3; by cluster;

proc print data=clus3; by cluster;
var IReturn IRisk Sector;
run;


Cluster Analysis of Portofolio                                                                  


ObsIReturnIRiskSector
113.411.72
213.411.72
313.411.72
413.411.72
512.012.41
612.012.31
711.511.93
812.311.93
911.012.41
1012.512.93
ObsIReturnIRiskSector
1124.76.74
1224.75.74
ObsIReturnIRiskSector
1320.75.75
ObsIReturnIRiskSector
1414.75.75
ObsIReturnIRiskSector
1512.51.23
ObsIReturnIRiskSector
16312.41


Using the above procedure we can decide which instruments will go into which cluster.

How to assign RiskWeight:-
     Based on Risk&Return attributed of the cluster supervisor will decide that :) .
     Here cluster2,cluster3 will have less riskweights, cluster6 will have more risk weights.

As per your problem choose the required clustering methods( listed in appendix),number of clusters, instrument attributes.

Thanks & Regards
Srinivasan

Appendix
The following are the types of clustering methods:-

     

Description Disadvantage
Average Linkage Distance between two clusters is the average distance between pairs of observations, one in each cluster.
Tends to join clusters with small variances.
Slightly biased toward producing clusters with the same variance.
Centroid Method Distance between two clusters is defined as the (squared) Euclidean distance between their centroids
or means. The centroid method is more robust to outliers than most other hierarchical methods.
Might not perform as well as Ward’s method or average linkage.
Complete Linkage Distance between two clusters is the maximum distance between an observation in one cluster and
an observation in the other cluster.
It can be Severely distorted by moderate outliers.
Strongly biased toward producing clusters with roughly equal diameters.
Density Linkage Class of clustering methods that use nonparametric probability density estimates. Density linkage
consists of two steps:
1) A new dissimilarity measure, , based on density estimates and adjacencies is computed.
2) A single linkage cluster analysis is performed using dissimilarity analysis is performed.
Types are:-
kth-Nearest-Neighbor Method
Uniform-Kernel Method
Wong’s Hybrid Method

Maximum Likelihood Similar to Ward’s minimum-variance method but removes the bias toward equal-sized clusters. EML is somewhat biased toward unequal-sized clusters.
Single Linkage Distance between two clusters is the minimum distance between an observation in one cluster and
an observation in the other cluster. Single linkage has many desirable theoretical properties.
Sacrifices performance in the recovery of compact clusters in return for the ability to
Detect elongated and irregular clusters.
Tends to chop off the tails of distributions before separating the main clusters.
Ward’s Minimum-Variance Method Distance between two clusters is ANOVA sum of squares between the two clusters added up over all
the variables. At each generation, the within-cluster sum of squares is minimized over all partitions
obtainable by merging two clusters from the previous generation.
Strongly biased toward producing clusters with roughly same number of observations.
Also very sensitive to outliers