3

I have been trying to find some source code in R using either Quantmod, TrueFX or Quandl for downloading historical Hourly and H4 currency data. Unfortunately almost every provider only has daily data.

TrueFX provides historical tick-data in CSV files but I just do not want to overload my DB with that massive amount of data since my strategy will only use H1 as the lowest periodicity...

I know workarounds like the csv export from MT4 but that creates system-dependencies that I am trying to avoid.

Is it possible to download H1/H4 historical currency data with one of the R APIs? and does anyone has some examples?

Thanks a lot in advance, HL

FXQuantTrader
  • 6,221
  • 3
  • 31
  • 62
H701
  • 41
  • 3

2 Answers2

1

Bit late, however:

I personally use Oanda and their REST .Json api. It is well documented and allows you to download many different intervals like H1 and H4 candles (referred to as granularity) or in real time. All using only a demo account.

With R you can use different .json libraries and than set up an hourly cronjob with wget or load the streaming .json rates from an Oanda REST url.

Here is a R .json api from github jasonlite

Jeroen
  • 51
  • 3
0

You might find the answer I provided here useful.

Exact time stamp on quantmod currency (FX) data

... be careful that what you think is daily data, actually is daily data.

A couple of suggestions if you want free FX data at higher frequency snapshots than daily:

1) Take the trueFX tickdata, use it to convert to 4 hour bar data. Use xts's to.period on chunks of the tick data in memory (e.g. one month at a time etc if your RAM permits) and simply store the 4 hour bar data you create in a much smaller csv file, database or whatever. Some caution though: you may need to carefully handle bar creation close to weekends etc (5pm EST Fri to 5pm EST Sun), and start/end of bar timestamps for each OHLC step). You get flexibility in this approach. As to the quality/reliability of the trueFX data which pools across different FX price providers who generate their own tick prices, that's another issue...

2) Do you have an Interactive Brokers account? If so, you can use Jeff Ryan's IBrokers R package to call up to a rolling year of FX data (free) at frequencies of 5 seconds to daily bar data ... The sooner you start collecting data, the better as it is a rolling one year window ... Note that IB has a blackout period in prices of about 15 mins at 5pm EST, which is the time when systems globally restart in FX (and apply rollover interest on positions for the day).

Community
  • 1
  • 1
FXQuantTrader
  • 6,221
  • 3
  • 31
  • 62
  • Thanks! Regarding your answer in 2) "The sooner you start collecting data, the better as it is a rolling one year window " .... Do you mean I can download only one year of historical data a year from today only? – H701 Mar 13 '17 at 09:39
  • Yes; a rolling window of historical data from today, going back roughly 365 days. At least last time I checked, which was some time ago... – FXQuantTrader Mar 14 '17 at 01:54
  • Downloading the tickdata from TrueFX has been a long headache due to issues on how to handle login credentials using wget, curl, or download.file Is it possible to download hourly data from Quandl using something like: library(Quandl) Quandl('EUR/USD',type=hourly) ? – H701 Apr 20 '17 at 07:15