[R-SIG-Finance] table.Drawdowns table in PerformanceAnalytics
Brian G. Peterson
brian at braverock.com
Thu Dec 2 16:53:45 CET 2010
Felix,
Since these are specific to PerformanceAnalytics, we probably don't need
to bother the list with the discussion.
Any patches committed will be made with complete attribution, and our
gratitude for the feedback and contribution.
Regards,
- Brian
On 12/02/2010 09:08 AM, H. Felix Wittmann wrote:
> 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
>>>
>>>
>>
>>
>
--
Brian G. Peterson
http://braverock.com/brian/
Ph: 773-459-4973
IM: bgpbraverock
More information about the R-SIG-Finance
mailing list