3

I am trying to retrieve the OHLC Price data for currency pairs. As you can see below I have managed to get the Close price for a defined period of time. Ideally I would also like the Open, High and Low prices too. From there I aim to analyse the data to create a forex trading system.

Here is my work so far:

> getSymbols("GBP/USD",src="oanda", from="2014-05-30", to= "2014-06-14")  
[1] "GBPUSD"  
Warning message:  
In download.file(paste(oanda.URL, from.date, to.date, "exch=", currency.pair[1],  :  
  downloaded length 18395 != reported length 200  
> last(GBPUSD,4)    
               GBP.USD  
2014-06-11  1.6787  
2014-06-12  1.6773  
2014-06-13  1.6820  
2014-06-14  1.6959  
tonytonov
  • 25,060
  • 16
  • 82
  • 98
user3740289
  • 265
  • 3
  • 15

1 Answers1

3

Yahoo provides free daily currency data in OHLC format for at least currencies converted to USD, which can be accessed via quantmod:

library(quantmod)
getSymbols("GBP=X",src="yahoo",from="2005-01-01")
getSymbols("AUD=X",src="yahoo",from="2005-01-01")
getSymbols("EUR=X",src="yahoo",from="2005-01-01")
# `EUR=X` (which is USD/EUR) is the number of Euros per 1 USD.

tail(`EUR=X`)
# EUR=X.Open EUR=X.High EUR=X.Low EUR=X.Close EUR=X.Volume EUR=X.Adjusted
# 2016-08-05    0.89811   0.905050  0.895940     0.89809            0        0.89809
# 2016-08-08    0.90190   0.903040  0.900414     0.90175            0        0.90175
# 2016-08-09    0.90197   0.903179  0.899119     0.90223            0        0.90223
# 2016-08-10    0.89943   0.899430  0.892857     0.89962            0        0.89962
# 2016-08-11    0.89397   0.897827  0.893580     0.89394            0        0.89394
# 2016-08-12    0.89775   0.898260  0.891266     0.89774            0        0.89774

Note that volume is not available by most data providers as FX is an OTC market. The answers to this question might also be useful to you: yahoo API discussion

Notwithstanding, be aware of the caveats discussed here when using Yahoo daily fx data. Exact time stamp on quantmod currency (FX) data

Community
  • 1
  • 1
FXQuantTrader
  • 6,821
  • 3
  • 36
  • 67