[R-SIG-Finance] oanda and yahoo get.hist.quote
Jeff Ryan
jeff.a.ryan at gmail.com
Mon Oct 15 06:31:56 CEST 2007
If you need 7 day data - skip this. If you want data to match
weekdays - available from the St. Louis Fed's FRED system are Daily
Exchange Rates that have dates that match standard trading days in the
US - rates as of noon if I remember correctly...
Using quantmod:
>library(quantmod)
>getSymbols("^GSPC",src="yahoo",from="1999-01-04")
>getSymbols("DEXUSEU",src="FRED")
>showSymbols()
GSPC DEXUSEU
"yahoo" "FRED"
>all.data <- cbind(GSPC,DEXUSEU) # through the magic of zoo
>all.data
GSPC.Open GSPC.High GSPC.Low GSPC.Close GSPC.Volume GSPC.Adjusted
1999-01-04 1229.23 1248.81 1219.10 1228.10 877000000 1228.10
1999-01-05 1228.10 1246.11 1228.10 1244.78 775000000 1244.78
1999-01-06 1244.78 1272.50 1244.78 1272.34 986900000 1272.34
1999-01-07 1272.34 1272.34 1257.68 1269.73 863000000 1269.73
1999-01-08 1269.73 1278.24 1261.82 1275.09 937800000 1275.09
1999-01-11 1275.09 1276.22 1253.34 1263.88 818000000 1263.88
DEXUSEU
1999-01-04 1.1812
1999-01-05 1.1760
1999-01-06 1.1636
1999-01-07 1.1672
1999-01-08 1.1554
1999-01-11 1.1534
....
The downside is that, at present, the FX data is *not* fetched with a
'from' or 'to' argument - so you get the full record from FRED. The
default for yahoo data with getSymbols is only from 2007 onward - so I
conveniently fetched matching time periods for both data.
If you want to get rid of non-matching dates na.omit(all.data) works well.
Anyway, my 2 cents.
quantmod is on CRAN and at http://www.quantmod.com
There are many other data methods implemented for getSymbols as well
(database and local files), with many more planned (including oanda,
economagic, and some others...) in the coming weeks.
St.Louis Fed is at: http://research.stlouisfed.org/fred2/
Jeff Ryan
On 10/14/07, Alexander Moreno <alexander.f.moreno at gmail.com> wrote:
> Hi,
>
> I have S&P index data (^gspc) that I got from get.hist.quote from yahoo,
> and fx data from the same function from Oanda. The Oanda data has
> 7-days, and the S&P data has 5. Anyone know how to get them to match up
> for the same time period?
>
> Best,
> Alex
>
> _______________________________________________
> 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.
>
More information about the R-SIG-Finance
mailing list