[R-SIG-Finance] Drawdown functions from PerformanceAnalytics
Brian G. Peterson
brian at braverock.com
Thu Sep 2 13:38:18 CEST 2010
Samuel is correct.
Returns are multiplied times assets to get returns in a currency (or
price change). As such, whole number returns don't make any sense.
This is the convention used by every statistical finance package I've
ever seen, including R.
If you have cash 'returns' in a currency, you'll bneed to convert them
to simple returns first. see 'Return,calculate', among others.
Just to finish out the example:
#####
# Using Samuel's modified series:
maxDrawdown(xts(c(0,0.10,-0.10,-0.01,0.01,0.02), Sys.Date()-6:1),
geometric=T)
# [1] 0.109
maxDrawdown(xts(c(0,0.10,-0.10,-0.01,0.01,0.02), Sys.Date()-6:1),
geometric=FALSE)
# [1] 0.1
# and now chaning so that there are no repeated numbers
maxDrawdown(xts(c(0,0.05,-0.10,-0.01,0.01,0.02), Sys.Date()-6:1),
geometric=FALSE)
# [1] 0.1047619
maxDrawdown(xts(c(0,0.05,-0.10,-0.01,0.01,0.02), Sys.Date()-6:1),
geometric=TRUE)
# [1] 0.109
# and charting for a visual representation,
# drawdowns are the third panel
charts.PerformanceSummary(xts(c(0,0.05,-0.10,-0.01,0.01,0.02),
Sys.Date()-6:1))
#####
Regards,
- Brian
On 09/02/2010 04:55 AM, Samuel Le wrote:
> I think your asset returns are not supposed to be in percentage, so you should use c(0,0.10,-0.10,-0.01,0.01,0.02) instead.
>
> Samuel
>
> -----Original Message-----
> From: r-sig-finance-bounces at stat.math.ethz.ch [mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of Mark Breman
> Sent: 02 September 2010 10:21
> To: r-sig-finance at stat.math.ethz.ch
> Subject: [R-SIG-Finance] Drawdown functions from PerformanceAnalytics
>
> Hello everyone,
>
> I'm looking at the Drawdown functions from the PerformanceAnalytics package
> and I just don't get it.
> The docs say that the input should be Asset Returns and the output will be
> drawdown levels as percentages but if I call them with a simple return
> series I don't get what I expect.
>
> For instance: if I have a simple returns series like c(0, 10, -10, -1, 1, 2)
> I would expect the maximum drawdown to be -11 (or 110%), but instead I get:
>
>> library(PerformanceAnalytics)
>> maxDrawdown(xts(c(0, 10, -10, -1, 1, 2), Sys.Date()-6:1), geometric=T)
> [1] 10
>
> Changing the geometric parameter to False also gives me not what I would
> expect:
>
>> maxDrawdown(xts(c(0, 10, -10, -1, 1, 2), Sys.Date()-6:1), geometric=F)
> [1] 1
>
> findDrawdowns() gives me an error:
>
>> findDrawdowns(xts(c(0, 10, -10, -1, 1, 2), Sys.Date()-6:1), geometric=T)
> Error in if (drawdowns[i]< sofar) { : argument is of length zero
>
> Here is my sessionInfo()
>
>> sessionInfo()
> R version 2.11.1 (2010-05-31)
> i486-pc-linux-gnu
>
> locale:
> [1] LC_CTYPE=en_US.utf8 LC_NUMERIC=C LC_TIME=en_US.utf8
> LC_COLLATE=en_US.utf8 LC_MONETARY=C
> [6] LC_MESSAGES=en_US.utf8 LC_PAPER=en_US.utf8 LC_NAME=C
> LC_ADDRESS=C LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_US.utf8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] fTrading_2100.76 fBasics_2110.79 MASS_7.3-5
> timeSeries_2120.89 timeDate_2120.90
> [6] XML_3.1-1 quantmod_0.3-14 TTR_0.20-2
> Defaults_1.1-1 PerformanceAnalytics_1.0.3
> [11] xts_0.7-5 zoo_1.6-4
>
> loaded via a namespace (and not attached):
> [1] grid_2.11.1 lattice_0.18-8 tools_2.11.1
>
> Can someone explain the unexpected results or is it just broken?
>
> Thanks,
>
> -Mark-
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature database 5416 (20100901) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
> __________ Information from ESET NOD32 Antivirus, version of virus signature database 5416 (20100901) __________
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list