[R-SIG-Finance] Newbie question on getSymbols() in quantmod
Jeff Ryan
jeff.a.ryan at gmail.com
Wed Dec 31 06:04:21 CET 2008
An alternate approach uses setSymbolLookup
setSymbolLookup(HSBC=list(src='yahoo', name="0005.HK"))
You can put this in a start up file for future R sessions. See ?setSymbolLookup
> getSymbols("HSBC")
[1] "HSBC"
> str(HSBC)
An 'xts' object from 2007-01-01 to 2008-12-29 containing:
Data: num [1:510, 1:6] 142 143 144 145 144 ...
- attr(*, "dimnames")=List of 2
..$ : NULL
..$ : chr [1:6] "0005.HK.Open" "0005.HK.High" "0005.HK.Low"
"0005.HK.Close" ...
Indexed by objects of class: [Date]
xts Attributes:
List of 2
$ src : chr "yahoo"
$ updated: POSIXct[1:1], format: "2008-12-31 05:02:43"
HTH
Jeff
On Tue, Dec 30, 2008 at 9:31 PM, Brian Lee Yung Rowe <brian at muxspace.com> wrote:
> Try:
>
> HSBC <- getSymbols("0005.HK",src="yahoo", auto.assign=FALSE)
>
> Brian
>
>
> On Wed, 2008-12-31 at 10:58 +0800, L.-Y. Hin wrote:
>> Dear gurus,
>>
>> I am learning the quantmod library, and trying to download
>> the equity series for HSBC from yahoo.
>>
>> I checked from yahoo finance that the symbol is 0005.HK,
>> and then I used
>>
>>
>> > library(quantmod)
>> > getSymbols("0005.HK",src="yahoo")
>> [1] "0005.HK"
>> > candleChart(0005.HK)
>> Error: unexpected symbol in "candleChart(0005.HK"
>> > chartSeries(0005.HK)
>> Error: unexpected symbol in "chartSeries(0005.HK"
>> > Cl(0005.HK)
>> Error: unexpected symbol in "Cl(0005.HK"
>>
>> It seems like probably no data has been loaded by the
>> approach above.
>>
>>
>> However, the same scripts work for NYSE equities like
>> > getSymbols("A",src="yahoo")
>> [1] "A"
>> > chartSeries(A)
>> > length(Cl(A)) #To check whether OHLC data has been loaded
>> [1] 503
>>
>>
>> I suspect the problem is in the way I tried to load 0005.HK....
>>
>>
>> I'll be very grateful for your kind advice.
>>
>>
>> Many thanks
>>
>> Lin
>>
>> _______________________________________________
>> 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.
>
> _______________________________________________
> 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
More information about the R-SIG-Finance
mailing list