[R-SIG-Finance] addBBands don't work

Joshua Ulrich josh.m.ulrich at gmail.com
Tue Apr 5 03:52:16 CEST 2011


On Mon, Apr 4, 2011 at 8:43 PM, Sávio Ramos <savio.debian at gmail.com> wrote:
> The command addBBands don't work. The error message is:
>
> PETR4<- as.xts(read.zoo("
> http://ichart.finance.yahoo.com/table.csv?s=PETR4.SA&d=3&e=3&f=2011&g=d&a=0&b=3&c=2000&ignore=.csv",
> sep=",", format="%Y-%m-%d", header=TRUE))
>
You're already using quantmod, why not just use:
PETR4 <- getSymbols("PETR4.SA, auto.assign=FALSE)

> candleChart(PETR4,multi.col=TRUE,theme="white",subset='last 7 months',
> line.type="0.1")
>
>
>> addBBands()
>
> ## Erro em BBands(xx, n = n, maType = maType, sd = sd) :
> ##   Price series must be either High-Low-Close, or Close/univariate.
>
This is because the data has two columns that match "Close" (Close and
Adj.Close).  Either rename the columns after you pull the data, or
just use getSymbols.

PETR4 <- getSymbols("PETR4.SA", auto.assign=FALSE)
candleChart(PETR4,multi.col=TRUE,theme="white",subset='last 7
months',line.type="0.1")
addBBands()

>
>
> The format of data is:
>
>> head(PETR4)
>             Open   High    Low  Close     Volume Adj.Close
> 2000-01-03 115.25 118.25 114.50 117.49 1105920000     37.32
> 2000-01-04 115.00 115.00 110.25 111.00  901920000     35.25
> 2000-01-05 110.25 112.50 106.25 109.88 1344800000     34.90
> 2000-01-06 109.25 112.38 108.50 109.50 1064240000     34.78
> 2000-01-07 111.25 113.25 110.00 110.00  653520000     34.94
> 2000-01-10 112.38 113.75 112.00 112.25  611360000     35.65
>
>
> Any help?
> Thanks.
>
>        [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org 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.
>



More information about the R-SIG-Finance mailing list