Closed dawadam closed 10 months ago
@dawadam what version of package are you using? can you share the exact script you're running?
I'm using the latest version, but it works now. Probably a typing error.
const since = 1690848000000
const h24 = 60 * 1000 * 60 * 24 * 5
//
const testConfigRequest: Config = {
instrument: 'eurusd',
dates: {
from: since,
to: since + h24,
},
timeframe: 'm1',
format: "csv"
}
const test: string = await getHistoricalRates(testConfigRequest)
Why ConfigCsvItem
interface and others are not exported ?
@dawadam there is an expoerted csv-based config: CurrentRatesConfigCsv
import { CurrentRatesConfigCsv } from 'dukascopy-node';
if you are on one of the latest version of typescript (4.9+) you can use 'satisfies' keyword that preserves "narrowness" of the input config and allows for proper inference of the output type:
const testConfigRequest = {
instrument: 'eurusd',
dates: {
from: since,
to: since + h24,
},
timeframe: 'm1',
format: 'csv',
} satisfies CurrentRatesConfigCsv;
const test = await getHistoricalRates(testConfigRequest);
//^ const test: string
or with Config
const since = 1690848000000;
const h24 = 60 * 1000 * 60 * 24 * 5;
//
const testConfigRequest = {
instrument: 'eurusd',
dates: {
from: since,
to: since + h24,
},
timeframe: 'm1',
format: 'csv',
} satisfies Config;
const test = await getHistoricalRates(testConfigRequest)
//^ const test: string
When using format "csv", result of getHistoricalRates methode is string, but result type not.