Skip to contents

sortDrawdowns(findDrawdowns(R)) Gives the drawdowns in order of worst to best

Usage

sortDrawdowns(runs)

Arguments

runs

pass in runs array from findDrawdowns to be sorted

Details

Returns a sorted list:

  • return depth of drawdown

  • from starting period

  • to ending period

  • length length in periods

References

Bacon, C. Practical Portfolio Performance Measurement and Attribution. Wiley. 3rd Edition. 2023. p. 194-196

Author

Peter Carl
modified with permission from prototype function by Sankalp Upadhyay

Examples


data(edhec)
findDrawdowns(edhec[, "Funds of Funds", drop = FALSE])
#> $return
#>  [1]  0.00000000 -0.00770000  0.00000000 -0.01326634  0.00000000 -0.07069135
#>  [7]  0.00000000 -0.03877182  0.00000000 -0.03737506  0.00000000 -0.01627767
#> [13]  0.00000000 -0.00150000  0.00000000 -0.02601701  0.00000000 -0.00040000
#> [19]  0.00000000 -0.01742180  0.00000000 -0.01843796  0.00000000 -0.01490000
#> [25]  0.00000000 -0.01655473  0.00000000 -0.02220000  0.00000000 -0.20591447
#> [31]  0.00000000 -0.00400000  0.00000000 -0.00739256  0.00000000 -0.07837768
#> [37]  0.00000000 -0.00070000  0.00000000 -0.05932734  0.00000000 -0.08276940
#> [43]  0.00000000 -0.00190000  0.00000000 -0.00950000  0.00000000
#> 
#> $from
#>  [1]   1   3   5  10  14  17  27  40  44  45  54  55  60  62  63  66  74  75  76
#> [20]  88  95  99 103 106 107 113 118 128 130 131 210 211 212 213 215 222 248 251
#> [39] 252 254 276 278 283 285 286 289 290
#> 
#> $trough
#>  [1]   1   3   5  11  14  22  27  41  44  47  54  57  60  62  63  70  74  75  76
#> [20]  92  95 100 103 106 107 115 118 128 130 144 210 211 212 214 215 230 248 251
#> [39] 252 264 276 279 283 285 286 289 290
#> 
#> $to
#>  [1]   3   5  10  14  17  27  40  44  45  54  55  60  62  63  66  74  75  76  88
#> [20]  95  99 103 106 107 113 118 128 130 131 210 211 212 213 215 222 248 251 252
#> [39] 254 276 278 283 285 286 289 290 294
#> 
#> $length
#>  [1]  3  3  6  5  4 11 14  5  2 10  2  6  3  2  4  9  2  2 13  8  5  5  4  2  7
#> [26]  6 11  3  2 80  2  2  2  3  8 27  4  2  3 23  3  6  3  2  4  2  5
#> 
#> $peaktotrough
#>  [1]  1  1  1  2  1  6  1  2  1  3  1  3  1  1  1  5  1  1  1  5  1  2  1  1  1
#> [26]  3  1  1  1 14  1  1  1  2  1  9  1  1  1 11  1  2  1  1  1  1  1
#> 
#> $recovery
#>  [1]  2  2  5  3  3  5 13  3  1  7  1  3  2  1  3  4  1  1 12  3  4  3  3  1  6
#> [26]  3 10  2  1 66  1  1  1  1  7 18  3  1  2 12  2  4  2  1  3  1  4
#> 
sortDrawdowns(findDrawdowns(edhec[, "Funds of Funds", drop = FALSE]))
#> $return
#>  [1] -0.20591447 -0.08276940 -0.07837768 -0.07069135 -0.05932734 -0.03877182
#>  [7] -0.03737506 -0.02601701 -0.02220000 -0.01843796 -0.01742180 -0.01655473
#> [13] -0.01627767 -0.01490000 -0.01326634 -0.00950000 -0.00770000 -0.00739256
#> [19] -0.00400000 -0.00190000 -0.00150000 -0.00070000 -0.00040000  0.00000000
#> [25]  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000
#> [31]  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000
#> [37]  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000
#> [43]  0.00000000  0.00000000  0.00000000  0.00000000  0.00000000
#> 
#> $from
#>  [1] 131 278 222  17 254  40  45  66 128  99  88 113  55 106  10 289   3 213 211
#> [20] 285  62 251  75   1   5  14  27  44  54  60  63  74  76  95 103 107 118 130
#> [39] 210 212 215 248 252 276 283 286 290
#> 
#> $trough
#>  [1] 144 279 230  22 264  41  47  70 128 100  92 115  57 106  11 289   3 214 211
#> [20] 285  62 251  75   1   5  14  27  44  54  60  63  74  76  95 103 107 118 130
#> [39] 210 212 215 248 252 276 283 286 290
#> 
#> $to
#>  [1] 210 283 248  27 276  44  54  74 130 103  95 118  60 107  14 290   5 215 212
#> [20] 286  63 252  76   3  10  17  40  45  55  62  66  75  88  99 106 113 128 131
#> [39] 211 213 222 251 254 278 285 289 294
#> 
#> $length
#>  [1] 80  6 27 11 23  5 10  9  3  5  8  6  6  2  5  2  3  3  2  2  2  2  2  3  6
#> [26]  4 14  2  2  3  4  2 13  5  4  7 11  2  2  2  8  4  3  3  3  4  5
#> 
#> $peaktotrough
#>  [1] 14  2  9  6 11  2  3  5  1  2  5  3  3  1  2  1  1  2  1  1  1  1  1  1  1
#> [26]  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1  1
#> 
#> $recovery
#>  [1] 66  4 18  5 12  3  7  4  2  3  3  3  3  1  3  1  2  1  1  1  1  1  1  2  5
#> [26]  3 13  1  1  2  3  1 12  4  3  6 10  1  1  1  7  3  2  2  2  3  4
#>