[R-SIG-Finance] Shaded regions as an indicator in quantmod

Jeff Ryan jeff.a.ryan at gmail.com
Mon Dec 1 04:28:40 CET 2008


Brian,

The issue is that the recently released quantmod utilizes additions in
the yet to be released version of xts.  A package update coordination
error on my part.

I will reply again once the update is available.

Thanks,
Jeff

On Fri, Nov 28, 2008 at 7:24 PM, Brian Lee Yung Rowe <brian at muxspace.com> wrote:
> Hmm, that didn't work either.
>
>> addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333",
>> border=NA)
> Error in coredata(x)[lchob at xsubset, ] : incorrect number of dimensions
> In addition: Warning message:
> In merge.zoo(lchob at xdata, ta, fill = ifelse(is.logical(ta), 0, NA),  :
>   Index vectors are of different classes: POSIXt Date integer integer
>
> I couldn't peer into lchob to see wha the xsubset slot contained, but I did
> try using a different series for times
>> times <- index(QQQQ)
>
> but I got the same error.
>
> BTW is there any reason that the year is off by 1 year in the help pages? I
> noticed the same thing in the previous release.
>
> Version:   0.3-7
> Date:      2007-11-17
>
> Brian
>
>
> ----- Original message -----
> Sent: 2008/11/28 08:26:36
> Subject: Re:Re: Re: [R-SIG-Finance] Shaded regions as an indicator in
> quantmod
>
> Hi Brian,
>
> Try version 0.3-7 from CRAN (released last week sometime...)
>
> http://cran.r-project.org/web/packages/quantmod/index.html
>
> Jeff
>
> On Fri, Nov 28, 2008 at 6:28 AM, Brian Lee Yung Rowe wrote:
>> Hi Jeff,
>>
>> This sounds promising, but I couldn't get it to work.
>>
>>> chartSeries(QQQQ)
>>> times <- timeBasedSeq('20071001/2007')
>>> addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333",
>>> border=NA)
>> Warning message:
>> In plot.xy(xy.coords(x, y), type = type, ...) :
>> "border" is not a graphical parameter
>>> addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333")
>> Warning message:
>> In plot.xy(xy.coords(x, y), type = type, ...) :
>> "border" is not a graphical parameter
>>
>> Re-executing the sequence without the border parameter removes the error
>> message, but I don't see any bars. The series name does appear in the
>> legend
>> area, though.
>>
>>> chartSeries(QQQQ)
>>> addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333")
>>
>> I'm using version 0.3-6 revision 433. Any thoughts on what I'm doing
>> wrong?
>>
>> Brian
>>
>>
>> ----- Original message -----
>> Sent: 2008/11/27 17:58:54
>> Subject: Re:Re: [R-SIG-Finance] Shaded regions as an indicator in quantmod
>>
>> quantmod can do this now as well:
>>
>> If addTA is passed a logical vector of the same length as your series
>> or passed an ?xtsible object of any length it will cause bands to be
>> drawn. Points in the vector/time that are TRUE will be cause event
>> blocks to be drawn on/under the series.
>>
>> An example:
>>
>>> library(quantmod)
>>> chartSeries(QQQQ)
>>> times <- timeBasedSeq(20071001/2007) # create a Date sequence from
>>> 2007-10-01 to 2007-12-31
>>> addTA(xts(rep(TRUE,length(times)), times), on=-1, col="#333333",
>>> border=NA)
>>
>> A few comments about 'addTA':
>>
>> 1) the 'on' argument which plot you want it drawn on. Starting with
>> the main series window=1. Negative values cause the values to be drawn
>> under the main graphics.
>>
>> 2) 'col' and 'border' are arguments to the 'rect' call internal, which
>> draws the bands underneath.
>>
>> See ?addTA for further details.
>>
>> HTH
>> Jeff
>>
>>
>>
>>
>> On Thu, Nov 27, 2008 at 11:24 AM, Eric Zivot wrote:
>>> You can use the chart.TimeSeries() function in the package
>>> PerformanceAnalytics to do this very easily. See the examples in the help
>>> file for adding shading to user defined event times.
>>> ez
>>>
>>> _____
>>>
>>> From: r-sig-finance-bounces at stat.math.ethz.ch
>>> [mailto:r-sig-finance-bounces at stat.math.ethz.ch] On Behalf Of Brian Lee
>>> Yung
>>> Rowe
>>> Sent: Thursday, November 27, 2008 9:19 AM
>>> To: r-sig-finance at stat.math.ethz.ch
>>> Subject: [R-SIG-Finance] Shaded regions as an indicator in quantmod
>>>
>>>
>>> Hi,
>>>
>>> I want to produce charts using quantmod similar to the ones available
>>> from
>>> FRED. Specifically, FRED has this handy feature of rendering the
>>> NBER-defined recession periods under the displayed time series.
>>>
>>> It seems like calling newTA with the appropriate function handle could
>>> produce the output necessary to define the shading bars, but I'm not sure
>>> if
>>> any of the existing charting types can generate the correct look and
>>> feel.
>>> Anybody have suggestions?
>>>
>>> Thanks,
>>> Brian
>>>
>>> [[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.
>>>
>>
>>
>>
>> --
>> Jeffrey Ryan
>> jeffrey.ryan at insightalgo.com
>>
>> ia: insight algorithmics
>> www.insightalgo.com
>
>
>
> --
> Jeffrey Ryan
> jeffrey.ryan at insightalgo.com
>
> ia: insight algorithmics
> www.insightalgo.com



-- 
Jeffrey Ryan
jeffrey.ryan at insightalgo.com

ia: insight algorithmics
www.insightalgo.com



More information about the R-SIG-Finance mailing list