dukascopy-node-plus 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +1 -1
- package/dist/esm/{chunk-DWZJECKF.js → chunk-3Q3J6T4N.js} +1 -1
- package/dist/esm/chunk-476J4KQE.js +35 -0
- package/dist/esm/chunk-VHUFHYTL.js +155 -0
- package/dist/esm/chunk-YLYLH52F.js +113 -0
- package/dist/esm/cli/index.js +1 -1
- package/dist/esm/index.example.nostream.js +37 -0
- package/dist/esm/index.example.stream.js +40 -0
- package/dist/esm/index.js +9 -99
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.example.nostream.js +13854 -0
- package/dist/index.example.stream.d.mts +2 -0
- package/dist/index.example.stream.d.ts +2 -0
- package/dist/{index.example.js → index.example.stream.js} +140 -130
- package/dist/index.js +123 -125
- package/package.json +2 -2
- package/dist/esm/chunk-KWYYNULA.js +0 -184
- package/dist/esm/index.example.js +0 -27
- /package/dist/{index.example.d.mts → index.example.nostream.d.mts} +0 -0
- /package/dist/{index.example.d.ts → index.example.nostream.d.ts} +0 -0
|
@@ -13706,158 +13706,168 @@ var import_debug = __toESM(require("debug"));
|
|
|
13706
13706
|
var import_stream = require("stream");
|
|
13707
13707
|
var import_promises = require("stream/promises");
|
|
13708
13708
|
var DEBUG_NAMESPACE = "dukascopy-node";
|
|
13709
|
-
|
|
13709
|
+
function getHistoricalRatesToStream(config) {
|
|
13710
13710
|
const stream = new import_stream.Readable({
|
|
13711
13711
|
objectMode: true,
|
|
13712
13712
|
async read(_size) {
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
|
|
13720
|
-
|
|
13721
|
-
|
|
13722
|
-
|
|
13723
|
-
|
|
13724
|
-
|
|
13725
|
-
|
|
13726
|
-
|
|
13727
|
-
|
|
13728
|
-
|
|
13729
|
-
|
|
13730
|
-
|
|
13731
|
-
|
|
13732
|
-
|
|
13733
|
-
|
|
13734
|
-
|
|
13735
|
-
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
|
|
13739
|
-
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
|
|
13749
|
-
|
|
13750
|
-
|
|
13751
|
-
|
|
13752
|
-
|
|
13713
|
+
}
|
|
13714
|
+
});
|
|
13715
|
+
try {
|
|
13716
|
+
const { input, isValid, validationErrors } = validateConfigNode(config);
|
|
13717
|
+
(0, import_debug.default)(`${DEBUG_NAMESPACE}:config`)("%O", {
|
|
13718
|
+
input,
|
|
13719
|
+
isValid,
|
|
13720
|
+
validationErrors
|
|
13721
|
+
});
|
|
13722
|
+
if (!isValid) {
|
|
13723
|
+
stream.emit("error", { validationErrors });
|
|
13724
|
+
stream.push(null);
|
|
13725
|
+
return stream;
|
|
13726
|
+
}
|
|
13727
|
+
const {
|
|
13728
|
+
instrument,
|
|
13729
|
+
dates: { from, to },
|
|
13730
|
+
timeframe,
|
|
13731
|
+
priceType,
|
|
13732
|
+
volumes,
|
|
13733
|
+
volumeUnits,
|
|
13734
|
+
utcOffset,
|
|
13735
|
+
ignoreFlats,
|
|
13736
|
+
format,
|
|
13737
|
+
batchSize,
|
|
13738
|
+
pauseBetweenBatchesMs,
|
|
13739
|
+
useCache,
|
|
13740
|
+
cacheFolderPath,
|
|
13741
|
+
retryCount,
|
|
13742
|
+
pauseBetweenRetriesMs,
|
|
13743
|
+
retryOnEmpty
|
|
13744
|
+
} = input;
|
|
13745
|
+
const [startDate, endDate] = normaliseDates({
|
|
13746
|
+
instrument,
|
|
13747
|
+
startDate: from,
|
|
13748
|
+
endDate: to,
|
|
13749
|
+
timeframe,
|
|
13750
|
+
utcOffset
|
|
13751
|
+
});
|
|
13752
|
+
const [startDateMs, endDateMs] = [+startDate, +endDate];
|
|
13753
|
+
const onItemFetch = process.env.DEBUG ? (url, buffer, isCacheHit) => {
|
|
13754
|
+
(0, import_debug.default)(`${DEBUG_NAMESPACE}:fetcher`)(
|
|
13755
|
+
url,
|
|
13756
|
+
`| ${formatBytes(buffer.length)} |`,
|
|
13757
|
+
`${isCacheHit ? "cache" : "network"}`
|
|
13758
|
+
);
|
|
13759
|
+
} : void 0;
|
|
13760
|
+
const bufferFetcher = new BufferFetcher({
|
|
13761
|
+
batchSize,
|
|
13762
|
+
pauseBetweenBatchesMs,
|
|
13763
|
+
cacheManager: useCache ? new CacheManager({ cacheFolderPath }) : void 0,
|
|
13764
|
+
retryCount,
|
|
13765
|
+
pauseBetweenRetriesMs,
|
|
13766
|
+
onItemFetch,
|
|
13767
|
+
retryOnEmpty
|
|
13768
|
+
});
|
|
13769
|
+
const bodyHeaders = timeframe === "tick" /* tick */ ? tickHeaders : candleHeaders;
|
|
13770
|
+
let firstLine = true;
|
|
13771
|
+
let urlsProcessed = 0;
|
|
13772
|
+
const urlsforFetchingData = generateUrls({
|
|
13773
|
+
instrument: input.instrument,
|
|
13774
|
+
timeframe: input.timeframe,
|
|
13775
|
+
priceType: input.priceType,
|
|
13776
|
+
startDate,
|
|
13777
|
+
endDate
|
|
13778
|
+
});
|
|
13779
|
+
(0, import_promises.pipeline)(
|
|
13780
|
+
import_stream.Readable.from(urlsforFetchingData),
|
|
13781
|
+
new import_stream.Transform({
|
|
13782
|
+
objectMode: true,
|
|
13783
|
+
transform: async (url, _, callback) => {
|
|
13784
|
+
const bufferObject = {
|
|
13753
13785
|
url,
|
|
13754
|
-
|
|
13755
|
-
|
|
13756
|
-
|
|
13757
|
-
|
|
13758
|
-
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
|
|
13762
|
-
|
|
13763
|
-
|
|
13764
|
-
|
|
13765
|
-
|
|
13766
|
-
|
|
13767
|
-
|
|
13768
|
-
|
|
13769
|
-
|
|
13770
|
-
|
|
13771
|
-
|
|
13772
|
-
|
|
13773
|
-
|
|
13774
|
-
|
|
13775
|
-
|
|
13776
|
-
|
|
13777
|
-
|
|
13778
|
-
|
|
13779
|
-
|
|
13780
|
-
|
|
13781
|
-
|
|
13782
|
-
|
|
13783
|
-
|
|
13784
|
-
isCacheHit: useCache
|
|
13785
|
-
};
|
|
13786
|
-
try {
|
|
13787
|
-
const processedData = processData({
|
|
13788
|
-
instrument: input.instrument,
|
|
13789
|
-
requestedTimeframe: input.timeframe,
|
|
13790
|
-
bufferObjects: [bufferObject],
|
|
13791
|
-
priceType: input.priceType,
|
|
13792
|
-
volumes: input.volumes,
|
|
13793
|
-
volumeUnits: input.volumeUnits,
|
|
13794
|
-
ignoreFlats: input.ignoreFlats
|
|
13795
|
-
});
|
|
13796
|
-
processedData.forEach((item) => {
|
|
13797
|
-
const [timestamp] = item;
|
|
13798
|
-
if (timestamp && timestamp >= startDateMs && timestamp < endDateMs) {
|
|
13799
|
-
if (input.format === "array" /* array */) {
|
|
13800
|
-
this.push(item);
|
|
13801
|
-
} else {
|
|
13802
|
-
const bodyHeaders = timeframe === "tick" /* tick */ ? tickHeaders : candleHeaders;
|
|
13803
|
-
if (format === "json" /* json */) {
|
|
13804
|
-
const data = item.reduce((all, item2, i) => {
|
|
13805
|
-
const name = bodyHeaders[i];
|
|
13806
|
-
all[name] = item2;
|
|
13807
|
-
return all;
|
|
13808
|
-
}, {});
|
|
13809
|
-
this.push(data);
|
|
13810
|
-
} else if (format === "csv" /* csv */) {
|
|
13811
|
-
if (firstLine) {
|
|
13812
|
-
const csvHeaders = bodyHeaders.join(",");
|
|
13813
|
-
this.push(csvHeaders);
|
|
13814
|
-
firstLine = false;
|
|
13815
|
-
}
|
|
13816
|
-
this.push(item.join(","));
|
|
13817
|
-
}
|
|
13818
|
-
}
|
|
13786
|
+
buffer: await bufferFetcher.fetchBuffer(url),
|
|
13787
|
+
isCacheHit: useCache
|
|
13788
|
+
};
|
|
13789
|
+
try {
|
|
13790
|
+
const processedData = processData({
|
|
13791
|
+
instrument: input.instrument,
|
|
13792
|
+
requestedTimeframe: input.timeframe,
|
|
13793
|
+
bufferObjects: [bufferObject],
|
|
13794
|
+
priceType: input.priceType,
|
|
13795
|
+
volumes: input.volumes,
|
|
13796
|
+
volumeUnits: input.volumeUnits,
|
|
13797
|
+
ignoreFlats: input.ignoreFlats
|
|
13798
|
+
});
|
|
13799
|
+
processedData.forEach((item) => {
|
|
13800
|
+
const [timestamp] = item;
|
|
13801
|
+
if (timestamp && timestamp >= startDateMs && timestamp < endDateMs) {
|
|
13802
|
+
if (input.format === "array" /* array */) {
|
|
13803
|
+
stream.push(item);
|
|
13804
|
+
} else if (format === "json" /* json */) {
|
|
13805
|
+
const data = item.reduce((all, item2, i) => {
|
|
13806
|
+
const name = bodyHeaders[i];
|
|
13807
|
+
all[name] = item2;
|
|
13808
|
+
return all;
|
|
13809
|
+
}, {});
|
|
13810
|
+
stream.push(data);
|
|
13811
|
+
} else if (format === "csv" /* csv */) {
|
|
13812
|
+
if (firstLine) {
|
|
13813
|
+
const csvHeaders = bodyHeaders.join(",");
|
|
13814
|
+
stream.push(csvHeaders);
|
|
13815
|
+
firstLine = false;
|
|
13819
13816
|
}
|
|
13820
|
-
|
|
13821
|
-
|
|
13822
|
-
|
|
13823
|
-
callback(err);
|
|
13817
|
+
stream.push(`
|
|
13818
|
+
${item.join(",")}`);
|
|
13819
|
+
}
|
|
13824
13820
|
}
|
|
13821
|
+
});
|
|
13822
|
+
if (++urlsProcessed === urlsforFetchingData.length) {
|
|
13823
|
+
stream.push(null);
|
|
13825
13824
|
}
|
|
13826
|
-
|
|
13827
|
-
|
|
13828
|
-
|
|
13829
|
-
this.push(null);
|
|
13825
|
+
callback();
|
|
13826
|
+
} catch (err) {
|
|
13827
|
+
callback(err);
|
|
13830
13828
|
}
|
|
13831
|
-
}
|
|
13832
|
-
|
|
13833
|
-
|
|
13834
|
-
|
|
13835
|
-
|
|
13836
|
-
|
|
13837
|
-
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
}
|
|
13829
|
+
}
|
|
13830
|
+
})
|
|
13831
|
+
).catch((err) => {
|
|
13832
|
+
stream.emit("error", err);
|
|
13833
|
+
stream.push(null);
|
|
13834
|
+
});
|
|
13835
|
+
} catch (err) {
|
|
13836
|
+
stream.emit("error", err);
|
|
13837
|
+
stream.push(null);
|
|
13838
|
+
}
|
|
13841
13839
|
return stream;
|
|
13842
13840
|
}
|
|
13843
13841
|
|
|
13844
|
-
// src/index.example.ts
|
|
13842
|
+
// src/index.example.stream.ts
|
|
13843
|
+
var printMemory = () => {
|
|
13844
|
+
const formatMemoryUsage = (data) => `${Math.round(data / 1024 / 1024 * 100) / 100} MB`;
|
|
13845
|
+
const memoryData = process.memoryUsage();
|
|
13846
|
+
const memoryUsage = {
|
|
13847
|
+
rss: `${formatMemoryUsage(memoryData.rss)} -> Resident Set Size - total memory allocated for the process execution`,
|
|
13848
|
+
heapTotal: `${formatMemoryUsage(memoryData.heapTotal)} -> total size of the allocated heap`,
|
|
13849
|
+
heapUsed: `${formatMemoryUsage(memoryData.heapUsed)} -> actual memory used during the execution`,
|
|
13850
|
+
external: `${formatMemoryUsage(memoryData.external)} -> V8 external memory`
|
|
13851
|
+
};
|
|
13852
|
+
console.log(memoryUsage);
|
|
13853
|
+
};
|
|
13845
13854
|
(async () => {
|
|
13846
13855
|
try {
|
|
13856
|
+
printMemory();
|
|
13847
13857
|
const data = await getHistoricalRatesToStream({
|
|
13848
13858
|
instrument: "eurusd",
|
|
13849
13859
|
dates: {
|
|
13850
13860
|
from: /* @__PURE__ */ new Date("2021-02-01"),
|
|
13851
|
-
to: /* @__PURE__ */ new Date("2021-03
|
|
13861
|
+
to: /* @__PURE__ */ new Date("2021-02-03")
|
|
13852
13862
|
},
|
|
13853
|
-
timeframe: "
|
|
13863
|
+
timeframe: "m1",
|
|
13854
13864
|
format: "csv"
|
|
13855
13865
|
});
|
|
13856
|
-
data.on("data", (
|
|
13857
|
-
|
|
13866
|
+
data.on("data", (_chunk) => {
|
|
13867
|
+
process.stdout.write(_chunk);
|
|
13858
13868
|
});
|
|
13859
13869
|
data.on("end", () => {
|
|
13860
|
-
|
|
13870
|
+
printMemory();
|
|
13861
13871
|
});
|
|
13862
13872
|
} catch (error) {
|
|
13863
13873
|
console.log("error", error);
|
package/dist/index.js
CHANGED
|
@@ -13767,7 +13767,7 @@ function formatBytes(bytes, decimals = 2) {
|
|
|
13767
13767
|
}
|
|
13768
13768
|
|
|
13769
13769
|
// package.json
|
|
13770
|
-
var version = "1.1.
|
|
13770
|
+
var version = "1.1.1";
|
|
13771
13771
|
|
|
13772
13772
|
// src/getHistoricalRates.ts
|
|
13773
13773
|
var import_debug = __toESM(require("debug"));
|
|
@@ -13990,138 +13990,136 @@ var import_debug2 = __toESM(require("debug"));
|
|
|
13990
13990
|
var import_stream = require("stream");
|
|
13991
13991
|
var import_promises = require("stream/promises");
|
|
13992
13992
|
var DEBUG_NAMESPACE2 = "dukascopy-node";
|
|
13993
|
-
|
|
13993
|
+
function getHistoricalRatesToStream(config) {
|
|
13994
13994
|
const stream = new import_stream.Readable({
|
|
13995
13995
|
objectMode: true,
|
|
13996
13996
|
async read(_size) {
|
|
13997
|
-
|
|
13998
|
-
|
|
13999
|
-
|
|
14000
|
-
|
|
14001
|
-
|
|
14002
|
-
|
|
14003
|
-
|
|
14004
|
-
|
|
14005
|
-
|
|
14006
|
-
|
|
14007
|
-
|
|
14008
|
-
|
|
14009
|
-
|
|
14010
|
-
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
|
|
14017
|
-
|
|
14018
|
-
|
|
14019
|
-
|
|
14020
|
-
|
|
14021
|
-
|
|
14022
|
-
|
|
14023
|
-
|
|
14024
|
-
|
|
14025
|
-
|
|
14026
|
-
|
|
14027
|
-
|
|
14028
|
-
|
|
14029
|
-
|
|
14030
|
-
|
|
14031
|
-
|
|
14032
|
-
|
|
14033
|
-
|
|
14034
|
-
|
|
14035
|
-
|
|
14036
|
-
|
|
13997
|
+
}
|
|
13998
|
+
});
|
|
13999
|
+
try {
|
|
14000
|
+
const { input, isValid, validationErrors } = validateConfigNode(config);
|
|
14001
|
+
(0, import_debug2.default)(`${DEBUG_NAMESPACE2}:config`)("%O", {
|
|
14002
|
+
input,
|
|
14003
|
+
isValid,
|
|
14004
|
+
validationErrors
|
|
14005
|
+
});
|
|
14006
|
+
if (!isValid) {
|
|
14007
|
+
stream.emit("error", { validationErrors });
|
|
14008
|
+
stream.push(null);
|
|
14009
|
+
return stream;
|
|
14010
|
+
}
|
|
14011
|
+
const {
|
|
14012
|
+
instrument,
|
|
14013
|
+
dates: { from, to },
|
|
14014
|
+
timeframe,
|
|
14015
|
+
priceType,
|
|
14016
|
+
volumes,
|
|
14017
|
+
volumeUnits,
|
|
14018
|
+
utcOffset,
|
|
14019
|
+
ignoreFlats,
|
|
14020
|
+
format,
|
|
14021
|
+
batchSize,
|
|
14022
|
+
pauseBetweenBatchesMs,
|
|
14023
|
+
useCache,
|
|
14024
|
+
cacheFolderPath,
|
|
14025
|
+
retryCount,
|
|
14026
|
+
pauseBetweenRetriesMs,
|
|
14027
|
+
retryOnEmpty
|
|
14028
|
+
} = input;
|
|
14029
|
+
const [startDate, endDate] = normaliseDates({
|
|
14030
|
+
instrument,
|
|
14031
|
+
startDate: from,
|
|
14032
|
+
endDate: to,
|
|
14033
|
+
timeframe,
|
|
14034
|
+
utcOffset
|
|
14035
|
+
});
|
|
14036
|
+
const [startDateMs, endDateMs] = [+startDate, +endDate];
|
|
14037
|
+
const onItemFetch = process.env.DEBUG ? (url, buffer, isCacheHit) => {
|
|
14038
|
+
(0, import_debug2.default)(`${DEBUG_NAMESPACE2}:fetcher`)(
|
|
14039
|
+
url,
|
|
14040
|
+
`| ${formatBytes(buffer.length)} |`,
|
|
14041
|
+
`${isCacheHit ? "cache" : "network"}`
|
|
14042
|
+
);
|
|
14043
|
+
} : void 0;
|
|
14044
|
+
const bufferFetcher = new BufferFetcher({
|
|
14045
|
+
batchSize,
|
|
14046
|
+
pauseBetweenBatchesMs,
|
|
14047
|
+
cacheManager: useCache ? new CacheManager({ cacheFolderPath }) : void 0,
|
|
14048
|
+
retryCount,
|
|
14049
|
+
pauseBetweenRetriesMs,
|
|
14050
|
+
onItemFetch,
|
|
14051
|
+
retryOnEmpty
|
|
14052
|
+
});
|
|
14053
|
+
const bodyHeaders = timeframe === "tick" /* tick */ ? tickHeaders : candleHeaders;
|
|
14054
|
+
let firstLine = true;
|
|
14055
|
+
let urlsProcessed = 0;
|
|
14056
|
+
const urlsforFetchingData = generateUrls({
|
|
14057
|
+
instrument: input.instrument,
|
|
14058
|
+
timeframe: input.timeframe,
|
|
14059
|
+
priceType: input.priceType,
|
|
14060
|
+
startDate,
|
|
14061
|
+
endDate
|
|
14062
|
+
});
|
|
14063
|
+
(0, import_promises.pipeline)(
|
|
14064
|
+
import_stream.Readable.from(urlsforFetchingData),
|
|
14065
|
+
new import_stream.Transform({
|
|
14066
|
+
objectMode: true,
|
|
14067
|
+
transform: async (url, _, callback) => {
|
|
14068
|
+
const bufferObject = {
|
|
14037
14069
|
url,
|
|
14038
|
-
|
|
14039
|
-
|
|
14040
|
-
|
|
14041
|
-
|
|
14042
|
-
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
|
|
14046
|
-
|
|
14047
|
-
|
|
14048
|
-
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
|
|
14053
|
-
|
|
14054
|
-
|
|
14055
|
-
|
|
14056
|
-
|
|
14057
|
-
|
|
14058
|
-
|
|
14059
|
-
|
|
14060
|
-
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
|
|
14067
|
-
|
|
14068
|
-
isCacheHit: useCache
|
|
14069
|
-
};
|
|
14070
|
-
try {
|
|
14071
|
-
const processedData = processData({
|
|
14072
|
-
instrument: input.instrument,
|
|
14073
|
-
requestedTimeframe: input.timeframe,
|
|
14074
|
-
bufferObjects: [bufferObject],
|
|
14075
|
-
priceType: input.priceType,
|
|
14076
|
-
volumes: input.volumes,
|
|
14077
|
-
volumeUnits: input.volumeUnits,
|
|
14078
|
-
ignoreFlats: input.ignoreFlats
|
|
14079
|
-
});
|
|
14080
|
-
processedData.forEach((item) => {
|
|
14081
|
-
const [timestamp] = item;
|
|
14082
|
-
if (timestamp && timestamp >= startDateMs && timestamp < endDateMs) {
|
|
14083
|
-
if (input.format === "array" /* array */) {
|
|
14084
|
-
this.push(item);
|
|
14085
|
-
} else {
|
|
14086
|
-
const bodyHeaders = timeframe === "tick" /* tick */ ? tickHeaders : candleHeaders;
|
|
14087
|
-
if (format === "json" /* json */) {
|
|
14088
|
-
const data = item.reduce((all, item2, i) => {
|
|
14089
|
-
const name = bodyHeaders[i];
|
|
14090
|
-
all[name] = item2;
|
|
14091
|
-
return all;
|
|
14092
|
-
}, {});
|
|
14093
|
-
this.push(data);
|
|
14094
|
-
} else if (format === "csv" /* csv */) {
|
|
14095
|
-
if (firstLine) {
|
|
14096
|
-
const csvHeaders = bodyHeaders.join(",");
|
|
14097
|
-
this.push(csvHeaders);
|
|
14098
|
-
firstLine = false;
|
|
14099
|
-
}
|
|
14100
|
-
this.push(item.join(","));
|
|
14101
|
-
}
|
|
14102
|
-
}
|
|
14070
|
+
buffer: await bufferFetcher.fetchBuffer(url),
|
|
14071
|
+
isCacheHit: useCache
|
|
14072
|
+
};
|
|
14073
|
+
try {
|
|
14074
|
+
const processedData = processData({
|
|
14075
|
+
instrument: input.instrument,
|
|
14076
|
+
requestedTimeframe: input.timeframe,
|
|
14077
|
+
bufferObjects: [bufferObject],
|
|
14078
|
+
priceType: input.priceType,
|
|
14079
|
+
volumes: input.volumes,
|
|
14080
|
+
volumeUnits: input.volumeUnits,
|
|
14081
|
+
ignoreFlats: input.ignoreFlats
|
|
14082
|
+
});
|
|
14083
|
+
processedData.forEach((item) => {
|
|
14084
|
+
const [timestamp] = item;
|
|
14085
|
+
if (timestamp && timestamp >= startDateMs && timestamp < endDateMs) {
|
|
14086
|
+
if (input.format === "array" /* array */) {
|
|
14087
|
+
stream.push(item);
|
|
14088
|
+
} else if (format === "json" /* json */) {
|
|
14089
|
+
const data = item.reduce((all, item2, i) => {
|
|
14090
|
+
const name = bodyHeaders[i];
|
|
14091
|
+
all[name] = item2;
|
|
14092
|
+
return all;
|
|
14093
|
+
}, {});
|
|
14094
|
+
stream.push(data);
|
|
14095
|
+
} else if (format === "csv" /* csv */) {
|
|
14096
|
+
if (firstLine) {
|
|
14097
|
+
const csvHeaders = bodyHeaders.join(",");
|
|
14098
|
+
stream.push(csvHeaders);
|
|
14099
|
+
firstLine = false;
|
|
14103
14100
|
}
|
|
14104
|
-
|
|
14105
|
-
|
|
14106
|
-
|
|
14107
|
-
callback(err);
|
|
14101
|
+
stream.push(`
|
|
14102
|
+
${item.join(",")}`);
|
|
14103
|
+
}
|
|
14108
14104
|
}
|
|
14105
|
+
});
|
|
14106
|
+
if (++urlsProcessed === urlsforFetchingData.length) {
|
|
14107
|
+
stream.push(null);
|
|
14109
14108
|
}
|
|
14110
|
-
|
|
14111
|
-
|
|
14112
|
-
|
|
14113
|
-
this.push(null);
|
|
14109
|
+
callback();
|
|
14110
|
+
} catch (err) {
|
|
14111
|
+
callback(err);
|
|
14114
14112
|
}
|
|
14115
|
-
}
|
|
14116
|
-
|
|
14117
|
-
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
}
|
|
14113
|
+
}
|
|
14114
|
+
})
|
|
14115
|
+
).catch((err) => {
|
|
14116
|
+
stream.emit("error", err);
|
|
14117
|
+
stream.push(null);
|
|
14118
|
+
});
|
|
14119
|
+
} catch (err) {
|
|
14120
|
+
stream.emit("error", err);
|
|
14121
|
+
stream.push(null);
|
|
14122
|
+
}
|
|
14125
14123
|
return stream;
|
|
14126
14124
|
}
|
|
14127
14125
|
// Annotate the CommonJS export names for ESM import in node:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dukascopy-node-plus",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Node.js library for downloading historical market tick data for for Crypto, Stocks, ETFs, CFDs, Forex",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"dukascopy-node": "./dist/cli/index.js"
|
|
14
14
|
},
|
|
15
15
|
"scripts": {
|
|
16
|
-
"build": "rm -rf dist && tsup-node src/index.ts src/cli/index.ts src/index.example.ts --format esm,cjs --dts --legacy-output",
|
|
16
|
+
"build": "rm -rf dist && tsup-node src/index.ts src/cli/index.ts src/index.example.stream.ts src/index.example.nostream.ts --format esm,cjs --dts --legacy-output",
|
|
17
17
|
"test": "vitest run",
|
|
18
18
|
"coverage": "vitest run --coverage",
|
|
19
19
|
"format": "prettier --config .prettierrc 'src/**/*.ts' --write",
|