Typescript
dukascopy-node
is built with Typescript and is shipped with all the interfaces and enums for easier development experience.
import { getHistoricalRates, Config } from "dukascopy-node";
const config: Config = {
instrument: "eurusd",
dates: {
from: new Date("2021-03-30"),
to: new Date("2021-03-31"),
},
timeframe: "d1",
format: "json",
priceType: "bid",
};
getHistoricalRates(config).then((data) => console.log(data));
Config awareness
Through the power of overloads in Typescript, dukascopy-node
knows the precise shape of the output.
JsonItem
When json
is requested as format for non-tick timeframe
import { getHistoricalRates, Config } from "dukascopy-node";
const config: Config = {
instrument: "eurusd",
dates: {
from: new Date("2021-03-30"),
to: new Date("2021-03-31"),
},
timeframe: "d1",
format: "json",
priceType: "bid",
};
getHistoricalRates(config).then((data) => console.log(data));
ArrayItem
When array
is requested as format for non-tick timeframe
import { getHistoricalRates, Config } from "dukascopy-node";
const config: Config = {
instrument: "eurusd",
dates: {
from: new Date("2021-03-30"),
to: new Date("2021-03-31"),
},
timeframe: "d1",
format: "array",
priceType: "bid",
};
getHistoricalRates(config).then((data) => console.log(data));
JsonItemTick
When json
is requested as format for tick timeframe
import { getHistoricalRates, Config } from "dukascopy-node";
const config: Config = {
instrument: "eurusd",
dates: {
from: new Date("2021-03-30"),
to: new Date("2021-03-31"),
},
timeframe: "tick",
format: "json",
priceType: "bid",
};
getHistoricalRates(config).then((data) => console.log(data));
ArrayTickItem
When array
is requested as format for tick timeframe
import { getHistoricalRates, Config } from "dukascopy-node";
const config: Config = {
instrument: "eurusd",
dates: {
from: new Date("2021-03-30"),
to: new Date("2021-03-31"),
},
timeframe: "tick",
format: "array",
priceType: "bid",
};
getHistoricalRates(config).then((data) => console.log(data));
string
When csv
is requested as format
import { getHistoricalRates, Config } from "dukascopy-node";
const config: Config = {
instrument: "eurusd",
dates: {
from: new Date("2021-03-30"),
to: new Date("2021-03-31"),
},
timeframe: "d1",
format: "csv",
priceType: "bid",
};
getHistoricalRates(config).then((data) => console.log(data));