Quick start
Download your first historical price dataset in under a minute, from the command line or from Node.js, and learn what the output looks like.
dukascopy-node downloads historical prices from Dukascopy’s free data feed and turns them into CSV or JSON. You choose an instrument, a date range and a timeframe, and get the prices back as a file or as data in your code.
From the command line
Section titled “From the command line”-
Find the id of the instrument you want on the instruments page, for example
eurusdfor EUR/USD. -
Run the CLI with a date range and a timeframe. This downloads daily EUR/USD candles for February 2021 as CSV:
Terminal window npx dukascopy-node -i eurusd -from 2021-02-01 -to 2021-03-01 -t d1 -f csv -
Open the saved file,
download/eurusd-d1-bid-2021-02-01-2021-03-01.csv:timestamp,open,high,low,close1612137600000,1.21225,1.21363,1.2056,1.206761612224000000,1.20676,1.20877,1.20115,1.203651612310400000,1.20365,1.205,1.2004,1.20412
While it runs, the CLI prints what it is downloading, followed by a progress bar:
----------------------------------------------------Downloading historical price data for:----------------------------------------------------Instrument: Euro vs US DollarTimeframe: d1From date: Feb 1, 2021To date: Mar 1, 2021Price type: bidVolumes: falseUTC Offset: 0Include flats: falseFormat: csv----------------------------------------------------Tip
The CLI leaves volumes out unless you pass -v. Add -v to get a volume column.
From Node.js
Section titled “From Node.js”Install the package (see installation), then call getHistoricalRates:
import { getHistoricalRates } from 'dukascopy-node';
const candles = await getHistoricalRates({ instrument: 'eurusd', dates: { from: '2021-02-01', to: '2021-03-01' }, timeframe: 'd1', format: 'json'});
console.log(candles[0]);// {// timestamp: 1612137600000,// open: 1.21225,// high: 1.21363,// low: 1.2056,// close: 1.20676,// volume: 165569.8187// }CommonJS works too: const { getHistoricalRates } = require('dukascopy-node');.
What you get back
Section titled “What you get back”- Timestamps are Unix epoch milliseconds in UTC, marking the start of each candle (
1612137600000is 2021-02-01 00:00 UTC). The CLI can format them. - Candles (
s1tomn1) haveopen,high,low,closeand, optionally,volume. - Ticks (
tick) haveaskPrice,bidPrice,askVolumeandbidVolumefor every price change. See tick data. - Formats:
array(Node.js default),json(CLI default) orcsv. See output formats.