Output formats
dukascopy-node returns data as arrays, JSON objects or CSV. See the exact shape of candles and ticks in every format.
There are three output formats: array, json and csv. Set them with format in Node.js or -f in the CLI. The default is array in Node.js and json in the CLI.
All examples on this page download daily EUR/USD candles for February 2021.
array
Section titled “array”Compact arrays of numbers. The smallest and fastest format to work with in code.
npx dukascopy-node -i eurusd -from 2021-02-01 -to 2021-03-01 -t d1 -f array -vconst data = await getHistoricalRates({ instrument: 'eurusd', dates: { from: '2021-02-01', to: '2021-03-01' }, timeframe: 'd1', format: 'array'});[ [1612137600000, 1.21225, 1.21363, 1.2056, 1.20676, 165569.8187], [1612224000000, 1.20676, 1.20877, 1.20115, 1.20365, 147916.4607], [1612310400000, 1.20365, 1.205, 1.2004, 1.20412, 119397.1138]]Each candle is [timestamp, open, high, low, close, volume]. Full example: basic-array.output.json.
An array of objects with named fields. The most readable format.
npx dukascopy-node -i eurusd -from 2021-02-01 -to 2021-03-01 -t d1 -f json -vconst data = await getHistoricalRates({ instrument: 'eurusd', dates: { from: '2021-02-01', to: '2021-03-01' }, timeframe: 'd1', format: 'json'});[ { "timestamp": 1612137600000, "open": 1.21225, "high": 1.21363, "low": 1.2056, "close": 1.20676, "volume": 165569.8187 }]Full example: basic-json.output.json.
A CSV string with a header row, ready for spreadsheets, pandas or a database import. In Node.js you get the whole file as one string.
npx dukascopy-node -i eurusd -from 2021-02-01 -to 2021-03-01 -t d1 -f csv -vconst csv = await getHistoricalRates({ instrument: 'eurusd', dates: { from: '2021-02-01', to: '2021-03-01' }, timeframe: 'd1', format: 'csv'});timestamp,open,high,low,close,volume1612137600000,1.21225,1.21363,1.2056,1.20676,165569.81871612224000000,1.20676,1.20877,1.20115,1.20365,147916.46071612310400000,1.20365,1.205,1.2004,1.20412,119397.1138Full example: basic-csv.output.csv.
Tick data
Section titled “Tick data”With timeframe: 'tick' every row is a single price change with both sides of the market instead of a candle:
| Format | Shape |
|---|---|
array |
[timestamp, askPrice, bidPrice, askVolume, bidVolume] |
json |
{ timestamp, askPrice, bidPrice, askVolume, bidVolume } |
csv |
timestamp,askPrice,bidPrice,askVolume,bidVolume header and rows |
See downloading tick data for examples.
Fields
Section titled “Fields”| Field | Description |
|---|---|
timestamp |
Unix epoch milliseconds, UTC. For candles, the start of the period. |
open, high, low, close |
Prices of the candle, for the bid or ask side chosen with priceType. |
volume |
Traded volume in volumeUnits (millions by default). Left out when volumes is false. |
askPrice, bidPrice |
Best ask and bid at the moment of the tick. |
askVolume, bidVolume |
Volume available at those prices, in volumeUnits. |
Volumes and flats
Section titled “Volumes and flats”volumes: false(or leaving out-vin the CLI) removes the volume column.volumeUnitsscales volumes tomillions(default),thousandsorunits.- Candles with zero volume, typically weekends and holidays, are skipped. Set
ignoreFlats: false(or--flats) to keep them.
File output in the CLI
Section titled “File output in the CLI”The CLI writes the result to ./download (change it with --directory), naming the file after the request, for example eurusd-d1-bid-2021-02-01-2021-03-01.csv. json and array both produce .json files; add --inline to write them without line breaks. Use --file-name to choose your own name.