The first step of every analysis is getting enough data.
I am interested in the foreign exchange market and curious about the pattern about the exchange rate change; therefore, I try to find some convenient way to obtain the ForEx data.
Thanks to the "quantmod" package recently developed by some kind people, now I can download the forex data at least for some preliminary analysis, if not perfect data I hope to have.
The follows are what I have learnt from an example in the "quantmod" webiste.
# for example, I need to have forex data about USD again CAD price from 2004 to the current
require(quantmod)
getSymbols("USD/CAD",src="oanda",from="2012-01-01")
forex12 <- USDCAD
getSymbols("USD/CAD",src="oanda",from="2011-01-01",to="2011-12-31")
forex11 <- USDCAD
getSymbols("USD/CAD",src="oanda",from="2010-01-01",to="2010-12-31")
forex10 <- USDCAD
getSymbols("USD/CAD",src="oanda",from="2009-01-01",to="2009-12-31")
forex09 <- USDCAD
getSymbols("USD/CAD",src="oanda",from="2008-01-01",to="2008-12-31")
forex08 <- USDCAD
getSymbols("USD/CAD",src="oanda",from="2007-01-01",to="2007-12-31")
forex07 <- USDCAD
getSymbols("USD/CAD",src="oanda",from="2006-01-01",to="2006-12-31")
forex06 <- USDCAD
getSymbols("USD/CAD",src="oanda",from="2005-01-01",to="2005-12-31")
forex05 <- USDCAD
getSymbols("USD/CAD",src="oanda",from="2004-01-01",to="2004-12-31")
forex04 <- USDCAD
forex <-rbind(forex04,forex05,forex06,forex07,forex08,forex09,forex10,forex11,forex12)
# make a rough plot to see the daily change
chartSeries(forex,theme = chartTheme("white"))
This downloading method works well, but I still feel the data is not enough to support some analysis, particular some short term trading strategy, so I really need to figure out if there is any way to have data in 5 mins or hours instead of on a daily average.
No comments:
Post a Comment