braverock / PerformanceAnalytics

211 stars 105 forks source link

Probabilistic Sharpe inconsistent behaviour #168

Open ghost opened 3 years ago

ghost commented 3 years ago

Description

I am trying to get the probabilistic Sharpe ratio by passing a vector with the reference Sharpe. Strangely, when I pass as reference Sharpe the Sharpe ratios of my assets computed by SharpeRatio function, the ProbabilisticSharpe function gives an expected output with assets and their respective prob Sharpe ratios.

When I using own reference ratio it only produces a vector with the prob sharpe and NAs in the confidence intervals.

Expected behaviour

sharpe = SharpeRatio(returns, Rf = 0, p = 0.95, FUN = c("StdDev", "VaR", "ES")[1], annualize = F)
prob_sharpe = ProbSharpeRatio(R = returns, Rf = 0,refSR = sharpe, p = 0.95)

```r
$sr_prob
                                     Artemis UK (SR > 0.03 )
Probabilistic Sharpe Ratio(p= 95 %):                     0.5
                                     BG American (SR > 0.08 )
Probabilistic Sharpe Ratio(p= 95 %):                      0.5
                                     BG European (SR > 0.06 )
Probabilistic Sharpe Ratio(p= 95 %):                      0.5
                                     BG Income (SR > 0.06 )
Probabilistic Sharpe Ratio(p= 95 %):                    0.5
                                     BG Pacific (SR > 0.09 )
Probabilistic Sharpe Ratio(p= 95 %):                     0.5
                                     BG Positive Change (SR > 0.09 )
Probabilistic Sharpe Ratio(p= 95 %):                             0.5
                                     BNY Investment (SR > 0.05 )
Probabilistic Sharpe Ratio(p= 95 %):                         0.5
                                     Fidelity Global Tech (SR > 0.08 )
Probabilistic Sharpe Ratio(p= 95 %):                               0.5
                                     MI UK Growth (SR > 0.08 )
Probabilistic Sharpe Ratio(p= 95 %):                       0.5
                                     portfolio_ISA (SR > 0.05 )
Probabilistic Sharpe Ratio(p= 95 %):                        0.5
                                     World ex-UK (SR > 0.06 )
Probabilistic Sharpe Ratio(p= 95 %):                      0.5

$sr_confidence_interval
                     Lower Bound Sharpe Ratio Upper Bound
Artemis UK                0.0097       0.0320      0.0543
BG American               0.0591       0.0812      0.1034
BG European               0.0379       0.0602      0.0825
BG Income                 0.0341       0.0568      0.0795
BG Pacific                0.0648       0.0873      0.1099
BG Positive Change        0.0665       0.0890      0.1116
BNY Investment            0.0296       0.0516      0.0737
Fidelity Global Tech      0.0625       0.0849      0.1073
MI UK Growth              0.0568       0.0817      0.1067
portfolio_ISA             0.0281       0.0513      0.0745
World ex-UK               0.0413       0.0636      0.0858

Minimal, reproducible example

Now I just replaced the Sharpe values as follows:

Ref_sharpe = rep(sharpe[, c('World ex-UK')], ncol(sharpe))
sharpe_temp = sharpe
sharpe_temp[1, ] = Ref_sharpe

prob_sharpe = ProbSharpeRatio(R = returns, Rf = 0,refSR = sharpe_temp, p = 0.95)

and I got this:

$sr_prob
 [1] 0.9049119 0.9584034 0.9685389 0.9410357 0.8843830 0.5000000 0.9049119
 [8] 0.9584034 0.9685389 0.9410357 0.8843830

$sr_confidence_interval
  Lower Bound Sharpe Ratio Upper Bound     NA     NA     NA     NA     NA
1      0.0591       0.0648      0.0665 0.0625 0.0568 0.0413 0.0591 0.0648
      NA     NA     NA     NA     NA    NA     NA     NA     NA     NA     NA
1 0.0665 0.0625 0.0568 0.0812 0.0873 0.089 0.0849 0.0817 0.0636 0.1034 0.1099
      NA     NA     NA     NA     NA     NA     NA     NA     NA
1 0.1116 0.1073 0.1067 0.0858 0.1034 0.1099 0.1116 0.1073 0.1067

Not sure what is going on. Any help or suggestion?