[R-SIG-Finance] table.Drawdowns table in PerformanceAnalytics
H. Felix Wittmann
hfwittmann at googlemail.com
Thu Dec 2 16:08:26 CET 2010
Brian,
thank you for your answer. I enclose the patch (the relevant lines are
enclosed by case 0/ end case 0
Felix
PS : in the next few days I will probably have some more suggestions for
patches, should I post this to r-sig-finance at r-project.org, too, or just
email you.
On 02/12/10 15:34, Brian G. Peterson wrote:
> Felix,
>
> I'm glad you find the package useful.
>
> I also agree with your logic. If you have te time to craft a patch,
> we would be happy to include it (with attribution), otherwise I'll add
> it to my list of things to do.
>
> Regards,
>
> - Brian
>
> On 12/02/2010 08:29 AM, H. Felix Wittmann wrote:
>> Brian,
>>
>> first of all: thanks again for an excellent package. I believe you've
>> done a great job for the community!
>>
>> I have noticed that table.Drawdowns produces spurious/erroneous results
>> when number of drawdowns is less than 1.
>>
>> In my view it would be desirable in the case of no drawdowns to have an
>> output similar to the cases with one/two drawdowns in the series. ie
>> somthing like this
>>
>>
>> *Desired output when number of drawdowns is less than 1.*
>>
>> [1] From Trough To Depth Length To Trough
>> Recovery
>> <0 rows> (or 0-length row.names)
>>
>> Warning message:
>> In table.Drawdowns(z.two.drawdowns) : Only 0 available in the data.
>>
>>
>> I include some code (in blue, output in brown)
>>
>> require(PerformanceAnalytics)
>> set.seed(seed = 166, kind = NULL, normal.kind = NULL)
>>
>>
>> time <- as.Date('01/12/2010', "%d/%m/%Y") + +seq(10)*31
>>
>> z.two.drawdowns <-
>> zoo(c(-0.1,0.2,-0.05,(rnorm(10)/10+1)/10),order.by = time)
>> z.one.drawdown <- zoo(c(-0.1,(rnorm(10)/10+1)/10),order.by = time)
>> z.no.drawdown <- zoo((rnorm(10)/10+1)/10,order.by = time)
>>
>>
>>
>> table.Drawdowns(z.two.drawdowns)
>> From Trough To Depth Length To Trough Recovery
>> 1 2011-01-01 2011-01-01 2011-02-01 -0.10 2 1 1
>> 2 2011-03-04 2011-03-04 2011-04-04 -0.05 2 1 1
>> Warning message:
>> In table.Drawdowns(z.two.drawdowns) : Only 2 available in the data.
>> From Trough To Depth Length To Trough Recovery
>>
>> table.Drawdowns(z.one.drawdown)
>>
>> 1 2011-01-01 2011-01-01 2011-03-04 -0.1 3 1 2
>> Warning message:
>> In table.Drawdowns(z.one.drawdown) : Only 1 available in the data.
>>
>> table.Drawdowns(z.no.drawdown)
>>
>> Error in if (runs$return[j] > runs$return[j + 1]) { :
>> missing value where TRUE/FALSE needed
>> Calls: table.Drawdowns -> sortDrawdowns
>>
>>
>> As one can see from the above, the output in the case of no drawdowns is
>> markedly different. However, I would prefer it to be similar. Happy to
>> provide patches.
>>
>> Cheers, Felix
>>
>>
>
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: table.Drawdowns.r
URL: <https://stat.ethz.ch/pipermail/r-sig-finance/attachments/20101202/df04eb57/attachment.pl>
More information about the R-SIG-Finance
mailing list