dukascopy-node-plus 1.1.4 → 1.2.5
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/README.md +435 -23
- package/dist/cli/index.js +3529 -94
- package/dist/esm/chunk-5ZJB4AEL.js +154 -0
- package/dist/esm/{chunk-Z4O2KLFU.js → chunk-GDKYDWLQ.js} +5275 -52
- package/dist/esm/{chunk-KAQS2RYD.js → chunk-PVYCTSWT.js} +5 -7
- package/dist/esm/cli/index.js +36 -25
- package/dist/esm/index.example.nostream.js +5 -6
- package/dist/esm/index.example.stream.js +5 -5
- package/dist/esm/index.js +16 -13
- package/dist/index.d.ts +1823 -33
- package/dist/index.example.nostream.d.ts +0 -1
- package/dist/index.example.nostream.js +3480 -59
- package/dist/index.example.stream.d.ts +0 -1
- package/dist/index.example.stream.js +3539 -126
- package/dist/index.js +5675 -465
- package/package.json +82 -82
- package/dist/cli/index.d.mts +0 -1
- package/dist/esm/chunk-EN4CESUH.js +0 -164
- package/dist/esm/chunk-VHVSB2KI.js +0 -6
- package/dist/index.d.mts +0 -6818
- package/dist/index.example.nostream.d.mts +0 -2
- package/dist/index.example.stream.d.mts +0 -2
- /package/dist/esm/{chunk-476J4KQE.js → chunk-ASWACD3L.js} +0 -0
package/package.json
CHANGED
|
@@ -1,82 +1,82 @@
|
|
|
1
|
-
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "dukascopy-node-plus",
|
|
3
|
+
"version": "1.2.5",
|
|
4
|
+
"description": "Node.js library for downloading historical market tick data for for Crypto, Stocks, ETFs, CFDs, Forex",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"bin": {
|
|
12
|
+
"dukascopy-cli": "./dist/cli/index.js",
|
|
13
|
+
"dukascopy-node": "./dist/cli/index.js"
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
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
|
+
"test": "vitest run",
|
|
18
|
+
"coverage": "vitest run --coverage",
|
|
19
|
+
"format": "prettier --config .prettierrc.json 'src/**/*.ts' --write",
|
|
20
|
+
"lint": "eslint ./src --ext ts --ext js",
|
|
21
|
+
"type-check": "tsc --noEmit --skipLibCheck",
|
|
22
|
+
"gen:meta": "tsx src/utils/instrument-meta-data/generate-data.ts",
|
|
23
|
+
"gen:instruments-md": "tsx src/utils/instrument-meta-data/generate-instrument-md.ts",
|
|
24
|
+
"release": "standard-version && git push --follow-tags origin master && pnpm build && npm publish",
|
|
25
|
+
"release:beta": "pnpm build && npm publish --tag beta"
|
|
26
|
+
},
|
|
27
|
+
"author": {
|
|
28
|
+
"name": "Dr. Mohammed REZGUI"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "https://github.com/kyo06/dukascopy-node-plus"
|
|
34
|
+
},
|
|
35
|
+
"homepage": "https://www.dukascopy-node.app",
|
|
36
|
+
"keywords": [
|
|
37
|
+
"dukascopy",
|
|
38
|
+
"stock-data",
|
|
39
|
+
"forex-data",
|
|
40
|
+
"historical-data",
|
|
41
|
+
"ohlc",
|
|
42
|
+
"tick-data",
|
|
43
|
+
"exchange-rates",
|
|
44
|
+
"commodities",
|
|
45
|
+
"cfd",
|
|
46
|
+
"crypto",
|
|
47
|
+
"ethusd",
|
|
48
|
+
"btcusd"
|
|
49
|
+
],
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"chalk": "5.3.0",
|
|
52
|
+
"cli-progress": "3.12.0",
|
|
53
|
+
"commander": "12.0.0",
|
|
54
|
+
"dayjs": "1.11.10",
|
|
55
|
+
"debug": "4.3.4",
|
|
56
|
+
"fastest-validator": "1.17.0",
|
|
57
|
+
"fs-extra": "11.2.0",
|
|
58
|
+
"lzma-purejs-requirejs": "1.0.0",
|
|
59
|
+
"node-fetch": "2.7.0",
|
|
60
|
+
"python-struct": "1.1.3"
|
|
61
|
+
},
|
|
62
|
+
"devDependencies": {
|
|
63
|
+
"@types/cli-progress": "3.11.5",
|
|
64
|
+
"@types/debug": "4.1.12",
|
|
65
|
+
"@types/fs-extra": "11.0.4",
|
|
66
|
+
"@types/node": "18.19.130",
|
|
67
|
+
"@types/node-fetch": "2.6.11",
|
|
68
|
+
"@typescript-eslint/eslint-plugin": "8.46.2",
|
|
69
|
+
"@typescript-eslint/parser": "8.46.2",
|
|
70
|
+
"msw": "2.11.6",
|
|
71
|
+
"prettier": "3.2.5",
|
|
72
|
+
"standard-version": "9.5.0",
|
|
73
|
+
"tsup": "5.12.5",
|
|
74
|
+
"tsx": "4.20.6",
|
|
75
|
+
"typescript": "5.9.3",
|
|
76
|
+
"vite": "5.2.8",
|
|
77
|
+
"vitest": "3.2.4"
|
|
78
|
+
},
|
|
79
|
+
"engines": {
|
|
80
|
+
"node": ">=18"
|
|
81
|
+
}
|
|
82
|
+
}
|
package/dist/cli/index.d.mts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
@@ -1,164 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
candleHeaders,
|
|
3
|
-
tickHeaders
|
|
4
|
-
} from "./chunk-476J4KQE.js";
|
|
5
|
-
import {
|
|
6
|
-
BufferFetcher,
|
|
7
|
-
CacheManager,
|
|
8
|
-
formatBytes,
|
|
9
|
-
generateUrls,
|
|
10
|
-
normaliseDates,
|
|
11
|
-
processData,
|
|
12
|
-
validateConfigNode
|
|
13
|
-
} from "./chunk-Z4O2KLFU.js";
|
|
14
|
-
|
|
15
|
-
// src/getHistoricalRatesToStream.ts
|
|
16
|
-
import debug from "debug";
|
|
17
|
-
import { Readable, Transform } from "stream";
|
|
18
|
-
import { pipeline } from "stream/promises";
|
|
19
|
-
var DEBUG_NAMESPACE = "dukascopy-node";
|
|
20
|
-
function getHistoricalRatesToStream(config) {
|
|
21
|
-
const stream = new Readable({
|
|
22
|
-
objectMode: true,
|
|
23
|
-
async read(_size) {
|
|
24
|
-
}
|
|
25
|
-
});
|
|
26
|
-
try {
|
|
27
|
-
const { input, isValid, validationErrors } = validateConfigNode(config);
|
|
28
|
-
debug(`${DEBUG_NAMESPACE}:config`)("%O", {
|
|
29
|
-
input,
|
|
30
|
-
isValid,
|
|
31
|
-
validationErrors
|
|
32
|
-
});
|
|
33
|
-
if (!isValid) {
|
|
34
|
-
stream.emit("error", { validationErrors });
|
|
35
|
-
stream.push(null);
|
|
36
|
-
return stream;
|
|
37
|
-
}
|
|
38
|
-
const {
|
|
39
|
-
instrument,
|
|
40
|
-
dates: { from, to },
|
|
41
|
-
timeframe,
|
|
42
|
-
priceType,
|
|
43
|
-
volumes,
|
|
44
|
-
volumeUnits,
|
|
45
|
-
utcOffset,
|
|
46
|
-
ignoreFlats,
|
|
47
|
-
format,
|
|
48
|
-
batchSize,
|
|
49
|
-
pauseBetweenBatchesMs,
|
|
50
|
-
useCache,
|
|
51
|
-
cacheFolderPath,
|
|
52
|
-
retryCount,
|
|
53
|
-
pauseBetweenRetriesMs,
|
|
54
|
-
retryOnEmpty
|
|
55
|
-
} = input;
|
|
56
|
-
const [startDate, endDate] = normaliseDates({
|
|
57
|
-
instrument,
|
|
58
|
-
startDate: from,
|
|
59
|
-
endDate: to,
|
|
60
|
-
timeframe,
|
|
61
|
-
utcOffset
|
|
62
|
-
});
|
|
63
|
-
const [startDateMs, endDateMs] = [+startDate, +endDate];
|
|
64
|
-
const onItemFetch = process.env.DEBUG ? (url, buffer, isCacheHit) => {
|
|
65
|
-
debug(`${DEBUG_NAMESPACE}:fetcher`)(
|
|
66
|
-
url,
|
|
67
|
-
`| ${formatBytes(buffer.length)} |`,
|
|
68
|
-
`${isCacheHit ? "cache" : "network"}`
|
|
69
|
-
);
|
|
70
|
-
} : void 0;
|
|
71
|
-
const bufferFetcher = new BufferFetcher({
|
|
72
|
-
batchSize,
|
|
73
|
-
pauseBetweenBatchesMs,
|
|
74
|
-
cacheManager: useCache ? new CacheManager({ cacheFolderPath }) : void 0,
|
|
75
|
-
retryCount,
|
|
76
|
-
pauseBetweenRetriesMs,
|
|
77
|
-
onItemFetch,
|
|
78
|
-
retryOnEmpty
|
|
79
|
-
});
|
|
80
|
-
const bodyHeaders = timeframe === "tick" /* tick */ ? tickHeaders : candleHeaders;
|
|
81
|
-
let firstLine = true;
|
|
82
|
-
let urlsProcessed = 0;
|
|
83
|
-
const urlsforFetchingData = generateUrls({
|
|
84
|
-
instrument: input.instrument,
|
|
85
|
-
timeframe: input.timeframe,
|
|
86
|
-
priceType: input.priceType,
|
|
87
|
-
startDate,
|
|
88
|
-
endDate
|
|
89
|
-
});
|
|
90
|
-
const promiseProcessedData = urlsforFetchingData.map((url) => {
|
|
91
|
-
return new Promise((resolve, reject) => {
|
|
92
|
-
bufferFetcher.fetch([url]).then((bufferObjects) => {
|
|
93
|
-
try {
|
|
94
|
-
const processedData = processData({
|
|
95
|
-
instrument: input.instrument,
|
|
96
|
-
requestedTimeframe: input.timeframe,
|
|
97
|
-
bufferObjects,
|
|
98
|
-
priceType: input.priceType,
|
|
99
|
-
volumes: input.volumes,
|
|
100
|
-
volumeUnits: input.volumeUnits,
|
|
101
|
-
ignoreFlats: input.ignoreFlats
|
|
102
|
-
});
|
|
103
|
-
resolve(processedData);
|
|
104
|
-
} catch (err) {
|
|
105
|
-
reject(err);
|
|
106
|
-
}
|
|
107
|
-
}).catch((err) => {
|
|
108
|
-
reject(err);
|
|
109
|
-
});
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
pipeline(
|
|
113
|
-
Readable.from(promiseProcessedData),
|
|
114
|
-
new Transform({
|
|
115
|
-
objectMode: true,
|
|
116
|
-
transform: async (processedDataPr, _, callback) => {
|
|
117
|
-
const processedData = await processedDataPr;
|
|
118
|
-
try {
|
|
119
|
-
processedData.forEach((item) => {
|
|
120
|
-
const [timestamp] = item;
|
|
121
|
-
if (timestamp && timestamp >= startDateMs && timestamp < endDateMs) {
|
|
122
|
-
if (input.format === "array" /* array */) {
|
|
123
|
-
stream.push(item);
|
|
124
|
-
} else if (format === "json" /* json */) {
|
|
125
|
-
const data = item.reduce((all, item2, i) => {
|
|
126
|
-
const name = bodyHeaders[i];
|
|
127
|
-
all[name] = item2;
|
|
128
|
-
return all;
|
|
129
|
-
}, {});
|
|
130
|
-
stream.push(data);
|
|
131
|
-
} else if (format === "csv" /* csv */) {
|
|
132
|
-
if (firstLine) {
|
|
133
|
-
const csvHeaders = bodyHeaders.join(",");
|
|
134
|
-
stream.push(csvHeaders);
|
|
135
|
-
firstLine = false;
|
|
136
|
-
}
|
|
137
|
-
stream.push(`
|
|
138
|
-
${item.join(",")}`);
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
});
|
|
142
|
-
if (++urlsProcessed === urlsforFetchingData.length) {
|
|
143
|
-
stream.push(null);
|
|
144
|
-
}
|
|
145
|
-
callback();
|
|
146
|
-
} catch (err) {
|
|
147
|
-
callback(err);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
|
-
).catch((err) => {
|
|
152
|
-
stream.emit("error", err);
|
|
153
|
-
stream.push(null);
|
|
154
|
-
});
|
|
155
|
-
} catch (err) {
|
|
156
|
-
stream.emit("error", err);
|
|
157
|
-
stream.push(null);
|
|
158
|
-
}
|
|
159
|
-
return stream;
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
export {
|
|
163
|
-
getHistoricalRatesToStream
|
|
164
|
-
};
|