Reputation: 11
I want to get data on Birkshire-Hathaway (BRK.B) that is listed on the NYSE.
It seems that I can't use getSymbols because that function allows my to get data from yahoo finance, and BRK.B is not listed on yahoo finance.
How do I get data on BRK.B?
Thanks! Old
I tried getSymbols("BRK.B")
I hoped for data on Berkshire Hathaway.
Upvotes: 1
Views: 202
Reputation: 176718
The ticker is "BRK-B" on Yahoo. You can import it using
brk.b <- getSymbols("BRK-B", auto.assign = FALSE)
In this case, I strongly recommend using auto.assign = FALSE
and assigning the output to a value instead of letting getSymbols()
create an object for you.
Otherwise getSymbols()
will create an object named BRK-B
which can be confusing to use, because you will always have to use backticks to access it. For example:
#
# not recommended!
#
quantmod::getSymbols("BRK-B")
## [1] "BRK-B"
head(BRK-B)
## Error: object 'BRK' not found
head(`BRK-B`)
## BRK-B.Open BRK-B.High BRK-B.Low BRK-B.Close BRK-B.Volume BRK-B.Adjusted
## 2007-01-03 73.56 73.72 72.60 72.86 1385000 72.86
## 2007-01-04 72.86 72.94 72.06 72.20 1070000 72.20
## 2007-01-05 72.66 72.66 71.26 71.56 930000 71.56
## 2007-01-08 71.82 71.90 71.50 71.72 760000 71.72
## 2007-01-09 71.72 73.04 71.66 73.00 610000 73.00
## 2007-01-10 73.00 73.18 72.30 73.02 775000 73.02
Upvotes: 1