Leo4815162342 / dukascopy-node

✨ Download historical price tick data for Crypto, Stocks, ETFs, CFDs, Forex via CLI and Node.js ✨
https://dukascopy-node.app
MIT License
365 stars 68 forks source link

[feature] expose ConfigArrayItem type in public #185

Closed dawadam closed 4 months ago

dawadam commented 4 months ago

Hi, is it possible to expose ConfigArrayItem type in public ?

To use it to prepare parmetters outside method, like this :

        const symbol = 'EURUSD'

        const configRequest: ConfigArrayItem = {
            instrument: symbol as Config['instrument'],
            priceType: 'bid',
            dates: {
                from: since,
                to: to
            },
            timeframe: 'd1',
            format: "json",
            useCache: true,
            cacheFolderPath: './cache/dukascopy',
            ignoreFlats: false,
            retryOnEmpty: true,
            retryCount: 2
        }

        // bid
        const dataBid = await getHistoricalRates(configRequest);

        // ask
        configRequest.priceType = 'ask'
        const dataAsk = await getHistoricalRates(configRequest);

Actualy message when import is : The '"dukascopy-node"' module declares 'ConfigArrayItem' locally, but it is not exported.

Leo4815162342 commented 4 months ago

HI @dawadam I've added the config-based types: ConfigArrayTickItem, ConfigArrayItem, ConfigJsonTickItem, ConfigJsonItem, which are now exported from the lib. This change is available in version 1.39.3:

Note that for format json you'd need ConfigJsonItem type instead of ConfigArrayItem

const configRequest: ConfigJsonItem = {
    instrument: 'arcamxmxn',
    priceType: 'bid',
    dates: {
      from: since,
      to: to
    },
    timeframe: 'd1',
    format: 'json', //  <====
    useCache: true,
    cacheFolderPath: './cache/dukascopy',
    ignoreFlats: false,
    retryOnEmpty: true,
    retryCount: 2
  };