Dukascopy offers historical tick data. Through their historical data website you can download what you want, but registration is required, and lots of manual clicking.
However if you are comfortable with scripting, you can directly download the tick data yourself. The URL pattern is http://www.dukascopy.com/datafeed/{currency}/{year}/{month}/{day}/{hour}h_ticks.bi5
, so for example http://www.dukascopy.com/datafeed/AUDCAD/2017/00/01/23h_ticks.bi5
gets you ticks for AUDCAD from 1 January 2017, 23:00-23:59:59.999 UTC.
Note that the months are zero-based (I don't know why), so Jan-Dec is 00-11 (two digits). Every hour is present as a file, even if the market is closed.
The file format is an LZMA-compressed binary packed file, so you will need to decompress it to CSV or other format according to your need. Each tick is 20 bytes, five four-byte fields:
- (long) the relative time from the hour, in milliseconds
- (long) the ask price, in points
- (long) the bid price, in points
- (float) the ask volume
- (float) the bid volume
In python, I use a struct.unpack('>LLLff', bytes)
to extract the fields.
The data format is very space efficient for transfer and storage, but not efficient for processing, so I convert it to a time series for my storage.
I based my code on this guide, and there's plenty of GitHub repositories to help.