@yuants/vendor-hyperliquid 0.9.10 → 0.10.0
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/api/client.js +36 -2
- package/dist/api/client.js.map +1 -1
- package/dist/api/private-api.js +52 -41
- package/dist/api/private-api.js.map +1 -1
- package/dist/api/public-api.js +22 -11
- package/dist/api/public-api.js.map +1 -1
- package/dist/api/rate-limit.js +205 -0
- package/dist/api/rate-limit.js.map +1 -0
- package/dist/api/rate-limit.test.js +129 -0
- package/dist/api/rate-limit.test.js.map +1 -0
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/lib/api/client.d.ts.map +1 -1
- package/lib/api/client.js +35 -1
- package/lib/api/client.js.map +1 -1
- package/lib/api/private-api.d.ts +65 -1
- package/lib/api/private-api.d.ts.map +1 -1
- package/lib/api/private-api.js +59 -43
- package/lib/api/private-api.js.map +1 -1
- package/lib/api/public-api.d.ts +54 -1
- package/lib/api/public-api.d.ts.map +1 -1
- package/lib/api/public-api.js +33 -12
- package/lib/api/public-api.js.map +1 -1
- package/lib/api/rate-limit.d.ts +21 -0
- package/lib/api/rate-limit.d.ts.map +1 -0
- package/lib/api/rate-limit.js +214 -0
- package/lib/api/rate-limit.js.map +1 -0
- package/lib/api/rate-limit.test.d.ts +2 -0
- package/lib/api/rate-limit.test.d.ts.map +1 -0
- package/lib/api/rate-limit.test.js +131 -0
- package/lib/api/rate-limit.test.js.map +1 -0
- package/lib/index.d.ts +0 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -2
- package/lib/index.js.map +1 -1
- package/package.json +5 -5
- package/temp/build/typescript/ts_HOjXkPSo.json +1 -1
- package/temp/package-deps.json +10 -10
- package/temp/test/jest/haste-map-1a3370ad4952cc1cbecf8fc42c6e9732-7b2990dcc44090c4eba2c52e971c544c-6a2a6e27ca3579da37751287ea19ab4c +0 -0
- package/temp/test/jest/perf-cache-1a3370ad4952cc1cbecf8fc42c6e9732-da39a3ee5e6b4b0d3255bfef95601890 +1 -0
- package/dist/services/markets/interest-rate.js +0 -61
- package/dist/services/markets/interest-rate.js.map +0 -1
- package/dist/services/markets/ohlc.js +0 -111
- package/dist/services/markets/ohlc.js.map +0 -1
- package/lib/services/markets/interest-rate.d.ts +0 -2
- package/lib/services/markets/interest-rate.d.ts.map +0 -1
- package/lib/services/markets/interest-rate.js +0 -63
- package/lib/services/markets/interest-rate.js.map +0 -1
- package/lib/services/markets/ohlc.d.ts +0 -2
- package/lib/services/markets/ohlc.d.ts.map +0 -1
- package/lib/services/markets/ohlc.js +0 -113
- package/lib/services/markets/ohlc.js.map +0 -1
package/temp/package-deps.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"apps/vendor-hyperliquid/AGENTS.md": "f0f3df594ce55fbaf78fb040f2850d1abee3449a",
|
|
3
|
-
"apps/vendor-hyperliquid/CHANGELOG.json": "
|
|
4
|
-
"apps/vendor-hyperliquid/CHANGELOG.md": "
|
|
5
|
-
"apps/vendor-hyperliquid/SESSION_NOTES.md": "
|
|
3
|
+
"apps/vendor-hyperliquid/CHANGELOG.json": "cc033904ef6eabffc1d47c0b11c1ae35aeb29b0a",
|
|
4
|
+
"apps/vendor-hyperliquid/CHANGELOG.md": "9208e31e8d8bf6bcfe758eb6cd02de118c0c9601",
|
|
5
|
+
"apps/vendor-hyperliquid/SESSION_NOTES.md": "bc090edd4a5471e5d4aebc06c952d07b189cf566",
|
|
6
6
|
"apps/vendor-hyperliquid/config/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
|
|
7
7
|
"apps/vendor-hyperliquid/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd",
|
|
8
8
|
"apps/vendor-hyperliquid/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
|
|
9
9
|
"apps/vendor-hyperliquid/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
|
|
10
10
|
"apps/vendor-hyperliquid/etc/vendor-hyperliquid.api.md": "66675bd88afa1fe945f0d4023984c1c9c3e60a34",
|
|
11
|
-
"apps/vendor-hyperliquid/package.json": "
|
|
12
|
-
"apps/vendor-hyperliquid/src/api/client.ts": "
|
|
13
|
-
"apps/vendor-hyperliquid/src/api/private-api.ts": "
|
|
14
|
-
"apps/vendor-hyperliquid/src/api/public-api.ts": "
|
|
11
|
+
"apps/vendor-hyperliquid/package.json": "b9314a1a3c34165fd7c852fff096172c0584eacc",
|
|
12
|
+
"apps/vendor-hyperliquid/src/api/client.ts": "bf895e6ced296c604a8125eae9bb136b2c51844f",
|
|
13
|
+
"apps/vendor-hyperliquid/src/api/private-api.ts": "15351a4f84fcf9184e5189dbee22034e24cc4159",
|
|
14
|
+
"apps/vendor-hyperliquid/src/api/public-api.ts": "3905476af7b579e2c91d13addbca65ba5b0d7ec7",
|
|
15
|
+
"apps/vendor-hyperliquid/src/api/rate-limit.test.ts": "67747ec114097f999cf2f55fc8cee7c246253f8d",
|
|
16
|
+
"apps/vendor-hyperliquid/src/api/rate-limit.ts": "c805cebb859bcc0e1351badd45ec4c83e5e60d8f",
|
|
15
17
|
"apps/vendor-hyperliquid/src/api/sign.ts": "94f4e5604a01d197d164b42415b17789ab2b6889",
|
|
16
18
|
"apps/vendor-hyperliquid/src/api/types.ts": "70347eb8b5e691770073dd043788ed5fae0c3eb4",
|
|
17
19
|
"apps/vendor-hyperliquid/src/cli.ts": "9bf6b5559a6c6f33da20e74cc6c5d702c60ec891",
|
|
18
|
-
"apps/vendor-hyperliquid/src/index.ts": "
|
|
20
|
+
"apps/vendor-hyperliquid/src/index.ts": "bb209f7ba158c087250e2ca8397f0a15477fa464",
|
|
19
21
|
"apps/vendor-hyperliquid/src/services/accounts/perp.ts": "ee8784d7331889b97069d5b3f452340b2e19ee55",
|
|
20
22
|
"apps/vendor-hyperliquid/src/services/accounts/spot.ts": "814857d05bdda34ca7827fc69c2564db1f5f5d3d",
|
|
21
23
|
"apps/vendor-hyperliquid/src/services/exchange.ts": "e36dcefff1e239e6b44c7ea1aa0632f59cbce653",
|
|
22
24
|
"apps/vendor-hyperliquid/src/services/interest-rate-service.ts": "5eb252b2b33552f3c70a82b39b7a85927ceebeac",
|
|
23
|
-
"apps/vendor-hyperliquid/src/services/markets/interest-rate.ts": "a93246729016cbe8486bc45b5a00aff57fab07ec",
|
|
24
|
-
"apps/vendor-hyperliquid/src/services/markets/ohlc.ts": "6cea84e64ff68ef3a760b35d2e637b66a1ca1615",
|
|
25
25
|
"apps/vendor-hyperliquid/src/services/markets/product.ts": "406d7686f062288a63bcc2aa3146b0f0942ad724",
|
|
26
26
|
"apps/vendor-hyperliquid/src/services/markets/quote.ts": "9f7391d6253a1ff46cab63567a708954efde4f88",
|
|
27
27
|
"apps/vendor-hyperliquid/src/services/ohlc-service.ts": "61cd4b3c4980b070a2cc38a90efd1d5a236fb2ad",
|
|
Binary file
|
package/temp/test/jest/perf-cache-1a3370ad4952cc1cbecf8fc42c6e9732-da39a3ee5e6b4b0d3255bfef95601890
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"/home/runner/work/Yuan/Yuan/apps/vendor-hyperliquid/lib/api/rate-limit.test.js":[1,937]}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
2
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
3
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
5
|
-
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
6
|
-
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
7
|
-
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
8
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
9
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
10
|
-
function fulfill(value) { resume("next", value); }
|
|
11
|
-
function reject(value) { resume("throw", value); }
|
|
12
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
13
|
-
};
|
|
14
|
-
import { createSeriesProvider } from '@yuants/data-series';
|
|
15
|
-
import { Terminal } from '@yuants/protocol';
|
|
16
|
-
import { decodePath, formatTime } from '@yuants/utils';
|
|
17
|
-
import { getHistoricalFundingRates } from '../../api/public-api';
|
|
18
|
-
const terminal = Terminal.fromNodeEnv();
|
|
19
|
-
createSeriesProvider(terminal, {
|
|
20
|
-
tableName: 'interest_rate',
|
|
21
|
-
series_id_prefix_parts: ['HYPERLIQUID', 'PERPETUAL'],
|
|
22
|
-
reversed: true,
|
|
23
|
-
serviceOptions: { concurrent: 1 },
|
|
24
|
-
queryFn: function (_a) {
|
|
25
|
-
return __asyncGenerator(this, arguments, function* ({ series_id, started_at, ended_at }) {
|
|
26
|
-
var _b;
|
|
27
|
-
const start = started_at || 0;
|
|
28
|
-
const end = ended_at || Date.now();
|
|
29
|
-
const [, , instId] = decodePath(series_id);
|
|
30
|
-
const coin = (_b = instId === null || instId === void 0 ? void 0 : instId.split('-')) === null || _b === void 0 ? void 0 : _b[0];
|
|
31
|
-
if (!coin) {
|
|
32
|
-
throw new Error(`Invalid product in series_id: ${series_id}`);
|
|
33
|
-
}
|
|
34
|
-
let current = start;
|
|
35
|
-
while (current <= end) {
|
|
36
|
-
const res = yield __await(getHistoricalFundingRates({ coin, startTime: current, endTime: end }));
|
|
37
|
-
if (!res || res.length === 0) {
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
const filtered = res.filter((v) => v.time >= current && v.time <= end);
|
|
41
|
-
if (!filtered.length) {
|
|
42
|
-
break;
|
|
43
|
-
}
|
|
44
|
-
yield yield __await(filtered.map((v) => ({
|
|
45
|
-
series_id,
|
|
46
|
-
product_id: series_id,
|
|
47
|
-
datasource_id: 'HYPERLIQUID',
|
|
48
|
-
created_at: formatTime(v.time),
|
|
49
|
-
long_rate: `${-parseFloat(v.fundingRate)}`,
|
|
50
|
-
short_rate: `${v.fundingRate}`,
|
|
51
|
-
settlement_price: '',
|
|
52
|
-
})));
|
|
53
|
-
if (res.length < 500) {
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
current = filtered[filtered.length - 1].time + 1;
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
},
|
|
60
|
-
});
|
|
61
|
-
//# sourceMappingURL=interest-rate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interest-rate.js","sourceRoot":"","sources":["../../../src/services/markets/interest-rate.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,oBAAoB,CAAgB,QAAQ,EAAE;IAC5C,SAAS,EAAE,eAAe;IAC1B,sBAAsB,EAAE,CAAC,aAAa,EAAE,WAAW,CAAC;IACpD,QAAQ,EAAE,IAAI;IACd,cAAc,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE;IACjC,OAAO,EAAE;4DAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE;;YAC3D,MAAM,KAAK,GAAG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AAE,GAAG,CAAC,CAAC,WAAW,EAAE;oBAC9B,gBAAgB,EAAE,EAAE;iBACrB,CAAC,CACH,CAAA,CAAC;gBACF,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;oBACrB,MAAM;gBACR,CAAC;gBACD,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC","sourcesContent":["import { IInterestRate } from '@yuants/data-interest-rate';\nimport { createSeriesProvider } from '@yuants/data-series';\nimport { Terminal } from '@yuants/protocol';\nimport { decodePath, formatTime } from '@yuants/utils';\nimport { getHistoricalFundingRates } from '../../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\ncreateSeriesProvider<IInterestRate>(terminal, {\n tableName: 'interest_rate',\n series_id_prefix_parts: ['HYPERLIQUID', 'PERPETUAL'],\n reversed: true,\n serviceOptions: { concurrent: 1 },\n queryFn: async function* ({ series_id, started_at, ended_at }) {\n const start = started_at || 0;\n const end = ended_at || Date.now();\n const [, , instId] = decodePath(series_id);\n const coin = instId?.split('-')?.[0];\n if (!coin) {\n throw new Error(`Invalid product in series_id: ${series_id}`);\n }\n let current = start;\n while (current <= end) {\n const res = await getHistoricalFundingRates({ coin, startTime: current, endTime: end });\n if (!res || res.length === 0) {\n break;\n }\n const filtered = res.filter((v) => v.time >= current && v.time <= end);\n if (!filtered.length) {\n break;\n }\n yield filtered.map(\n (v): IInterestRate => ({\n series_id,\n product_id: series_id,\n datasource_id: 'HYPERLIQUID',\n created_at: formatTime(v.time),\n long_rate: `${-parseFloat(v.fundingRate)}`,\n short_rate: `${v.fundingRate}`,\n settlement_price: '',\n }),\n );\n if (res.length < 500) {\n break;\n }\n current = filtered[filtered.length - 1].time + 1;\n }\n },\n});\n"]}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
2
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
3
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
4
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
5
|
-
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
6
|
-
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
7
|
-
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
8
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
9
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
10
|
-
function fulfill(value) { resume("next", value); }
|
|
11
|
-
function reject(value) { resume("throw", value); }
|
|
12
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
13
|
-
};
|
|
14
|
-
import { createSeriesProvider } from '@yuants/data-series';
|
|
15
|
-
import { Terminal } from '@yuants/protocol';
|
|
16
|
-
import { decodePath, encodePath, formatTime } from '@yuants/utils';
|
|
17
|
-
import { getCandleSnapshot } from '../../api/public-api';
|
|
18
|
-
const terminal = Terminal.fromNodeEnv();
|
|
19
|
-
const DURATION_TO_HYPERLIQUID_INTERVAL = {
|
|
20
|
-
PT1M: '1m',
|
|
21
|
-
PT3M: '3m',
|
|
22
|
-
PT5M: '5m',
|
|
23
|
-
PT15M: '15m',
|
|
24
|
-
PT30M: '30m',
|
|
25
|
-
PT1H: '1h',
|
|
26
|
-
PT2H: '2h',
|
|
27
|
-
PT4H: '4h',
|
|
28
|
-
PT8H: '8h',
|
|
29
|
-
PT12H: '12h',
|
|
30
|
-
P1D: '1d',
|
|
31
|
-
P3D: '3d',
|
|
32
|
-
P1W: '1w',
|
|
33
|
-
P1M: '1M',
|
|
34
|
-
};
|
|
35
|
-
const DURATION_TO_PERIOD_IN_SEC = {
|
|
36
|
-
PT1M: 60,
|
|
37
|
-
PT3M: 180,
|
|
38
|
-
PT5M: 300,
|
|
39
|
-
PT15M: 900,
|
|
40
|
-
PT30M: 1800,
|
|
41
|
-
PT1H: 3600,
|
|
42
|
-
PT2H: 7200,
|
|
43
|
-
PT4H: 14400,
|
|
44
|
-
PT8H: 28800,
|
|
45
|
-
PT12H: 43200,
|
|
46
|
-
P1D: 86400,
|
|
47
|
-
P3D: 259200,
|
|
48
|
-
P1W: 604800,
|
|
49
|
-
P1M: 2592000,
|
|
50
|
-
};
|
|
51
|
-
createSeriesProvider(terminal, {
|
|
52
|
-
tableName: 'ohlc',
|
|
53
|
-
series_id_prefix_parts: ['HYPERLIQUID'],
|
|
54
|
-
reversed: true,
|
|
55
|
-
serviceOptions: { concurrent: 1 },
|
|
56
|
-
queryFn: function (_a) {
|
|
57
|
-
return __asyncGenerator(this, arguments, function* ({ series_id, ended_at }) {
|
|
58
|
-
var _b;
|
|
59
|
-
const [datasource_id, instType, symbol, duration] = decodePath(series_id);
|
|
60
|
-
const product_id = encodePath(datasource_id, instType, symbol);
|
|
61
|
-
const period_in_sec = DURATION_TO_PERIOD_IN_SEC[duration];
|
|
62
|
-
if (!datasource_id || !instType || !symbol || !duration || !period_in_sec) {
|
|
63
|
-
throw new Error(`Invalid series_id: ${series_id}`);
|
|
64
|
-
}
|
|
65
|
-
if (datasource_id !== 'HYPERLIQUID') {
|
|
66
|
-
throw new Error(`Invalid datasource for series_id: ${series_id}`);
|
|
67
|
-
}
|
|
68
|
-
const coin = (_b = symbol === null || symbol === void 0 ? void 0 : symbol.split('-')) === null || _b === void 0 ? void 0 : _b[0];
|
|
69
|
-
if (!coin) {
|
|
70
|
-
throw new Error(`Invalid product symbol: ${symbol}`);
|
|
71
|
-
}
|
|
72
|
-
const interval = DURATION_TO_HYPERLIQUID_INTERVAL[duration];
|
|
73
|
-
if (!interval) {
|
|
74
|
-
throw new Error(`Unsupported duration: ${duration}`);
|
|
75
|
-
}
|
|
76
|
-
const startTime = 0;
|
|
77
|
-
const res = yield __await(getCandleSnapshot({
|
|
78
|
-
req: {
|
|
79
|
-
coin,
|
|
80
|
-
interval,
|
|
81
|
-
startTime,
|
|
82
|
-
endTime: ended_at,
|
|
83
|
-
},
|
|
84
|
-
}));
|
|
85
|
-
if (!res || !res.length) {
|
|
86
|
-
return yield __await(void 0);
|
|
87
|
-
}
|
|
88
|
-
const data = res
|
|
89
|
-
.filter((x) => x.t < ended_at)
|
|
90
|
-
.map((x) => ({
|
|
91
|
-
series_id,
|
|
92
|
-
datasource_id,
|
|
93
|
-
product_id,
|
|
94
|
-
duration,
|
|
95
|
-
created_at: formatTime(x.t),
|
|
96
|
-
closed_at: formatTime(x.t + period_in_sec * 1000),
|
|
97
|
-
open: x.o,
|
|
98
|
-
high: x.h,
|
|
99
|
-
low: x.l,
|
|
100
|
-
close: x.c,
|
|
101
|
-
volume: x.v,
|
|
102
|
-
open_interest: '0',
|
|
103
|
-
}))
|
|
104
|
-
.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
|
|
105
|
-
if (data.length > 0) {
|
|
106
|
-
yield yield __await(data);
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
|
-
},
|
|
110
|
-
});
|
|
111
|
-
//# sourceMappingURL=ohlc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ohlc.js","sourceRoot":"","sources":["../../../src/services/markets/ohlc.ts"],"names":[],"mappings":";;;;;;;;;;;;;AACA,OAAO,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UA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BAC7B,GAAG,CACF,CAAC,CAAC,EAAS,EAAE,CAAC,CAAC;gBACb,SAAS;gBACT,aAAa;gBACb,UAAU;gBACV,QAAQ;gBACR,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;gBAC3B,SAAS,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,GAAG,aAAa,GAAG,IAAI,CAAC;gBACjD,IAAI,EAAE,CAAC,CAAC,CAAC;gBACT,IAAI,EAAE,CAAC,CAAC,CAAC;gBACT,GAAG,EAAE,CAAC,CAAC,CAAC;gBACR,KAAK,EAAE,CAAC,CAAC,CAAC;gBACV,MAAM,EAAE,CAAC,CAAC,CAAC;gBACX,aAAa,EAAE,GAAG;aACnB,CAAC,CACH;iBACA,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YACvF,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpB,oBAAM,IAAI,CAAA,CAAC;YACb,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC","sourcesContent":["import { IOHLC } from '@yuants/data-ohlc';\nimport { createSeriesProvider } from '@yuants/data-series';\nimport { Terminal } from '@yuants/protocol';\nimport { decodePath, encodePath, formatTime } from '@yuants/utils';\nimport { getCandleSnapshot } from '../../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst DURATION_TO_HYPERLIQUID_INTERVAL: Record<string, string> = {\n PT1M: '1m',\n PT3M: '3m',\n PT5M: '5m',\n PT15M: '15m',\n PT30M: '30m',\n PT1H: '1h',\n PT2H: '2h',\n PT4H: '4h',\n PT8H: '8h',\n PT12H: '12h',\n P1D: '1d',\n P3D: '3d',\n P1W: '1w',\n P1M: '1M',\n};\n\nconst DURATION_TO_PERIOD_IN_SEC: Record<string, number> = {\n PT1M: 60,\n PT3M: 180,\n PT5M: 300,\n PT15M: 900,\n PT30M: 1800,\n PT1H: 3600,\n PT2H: 7200,\n PT4H: 14400,\n PT8H: 28800,\n PT12H: 43200,\n P1D: 86400,\n P3D: 259200,\n P1W: 604800,\n P1M: 2592000,\n};\n\ncreateSeriesProvider<IOHLC>(terminal, {\n tableName: 'ohlc',\n series_id_prefix_parts: ['HYPERLIQUID'],\n reversed: true,\n serviceOptions: { concurrent: 1 },\n queryFn: async function* ({ series_id, ended_at }) {\n const [datasource_id, instType, symbol, duration] = decodePath(series_id);\n const product_id = encodePath(datasource_id, instType, symbol);\n const period_in_sec = DURATION_TO_PERIOD_IN_SEC[duration];\n if (!datasource_id || !instType || !symbol || !duration || !period_in_sec) {\n throw new Error(`Invalid series_id: ${series_id}`);\n }\n if (datasource_id !== 'HYPERLIQUID') {\n throw new Error(`Invalid datasource for series_id: ${series_id}`);\n }\n const coin = symbol?.split('-')?.[0];\n if (!coin) {\n throw new Error(`Invalid product symbol: ${symbol}`);\n }\n const interval = DURATION_TO_HYPERLIQUID_INTERVAL[duration];\n if (!interval) {\n throw new Error(`Unsupported duration: ${duration}`);\n }\n const startTime = 0;\n const res = await getCandleSnapshot({\n req: {\n coin,\n interval,\n startTime,\n endTime: ended_at,\n },\n });\n if (!res || !res.length) {\n return;\n }\n const data = res\n .filter((x) => x.t < ended_at)\n .map(\n (x): IOHLC => ({\n series_id,\n datasource_id,\n product_id,\n duration,\n created_at: formatTime(x.t),\n closed_at: formatTime(x.t + period_in_sec * 1000),\n open: x.o,\n high: x.h,\n low: x.l,\n close: x.c,\n volume: x.v,\n open_interest: '0',\n }),\n )\n .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());\n if (data.length > 0) {\n yield data;\n }\n },\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interest-rate.d.ts","sourceRoot":"","sources":["../../../src/services/markets/interest-rate.ts"],"names":[],"mappings":""}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
3
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
4
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
5
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
6
|
-
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
7
|
-
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
8
|
-
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
9
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
10
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
11
|
-
function fulfill(value) { resume("next", value); }
|
|
12
|
-
function reject(value) { resume("throw", value); }
|
|
13
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
const data_series_1 = require("@yuants/data-series");
|
|
17
|
-
const protocol_1 = require("@yuants/protocol");
|
|
18
|
-
const utils_1 = require("@yuants/utils");
|
|
19
|
-
const public_api_1 = require("../../api/public-api");
|
|
20
|
-
const terminal = protocol_1.Terminal.fromNodeEnv();
|
|
21
|
-
(0, data_series_1.createSeriesProvider)(terminal, {
|
|
22
|
-
tableName: 'interest_rate',
|
|
23
|
-
series_id_prefix_parts: ['HYPERLIQUID', 'PERPETUAL'],
|
|
24
|
-
reversed: true,
|
|
25
|
-
serviceOptions: { concurrent: 1 },
|
|
26
|
-
queryFn: function (_a) {
|
|
27
|
-
return __asyncGenerator(this, arguments, function* ({ series_id, started_at, ended_at }) {
|
|
28
|
-
var _b;
|
|
29
|
-
const start = started_at || 0;
|
|
30
|
-
const end = ended_at || Date.now();
|
|
31
|
-
const [, , instId] = (0, utils_1.decodePath)(series_id);
|
|
32
|
-
const coin = (_b = instId === null || instId === void 0 ? void 0 : instId.split('-')) === null || _b === void 0 ? void 0 : _b[0];
|
|
33
|
-
if (!coin) {
|
|
34
|
-
throw new Error(`Invalid product in series_id: ${series_id}`);
|
|
35
|
-
}
|
|
36
|
-
let current = start;
|
|
37
|
-
while (current <= end) {
|
|
38
|
-
const res = yield __await((0, public_api_1.getHistoricalFundingRates)({ coin, startTime: current, endTime: end }));
|
|
39
|
-
if (!res || res.length === 0) {
|
|
40
|
-
break;
|
|
41
|
-
}
|
|
42
|
-
const filtered = res.filter((v) => v.time >= current && v.time <= end);
|
|
43
|
-
if (!filtered.length) {
|
|
44
|
-
break;
|
|
45
|
-
}
|
|
46
|
-
yield yield __await(filtered.map((v) => ({
|
|
47
|
-
series_id,
|
|
48
|
-
product_id: series_id,
|
|
49
|
-
datasource_id: 'HYPERLIQUID',
|
|
50
|
-
created_at: (0, utils_1.formatTime)(v.time),
|
|
51
|
-
long_rate: `${-parseFloat(v.fundingRate)}`,
|
|
52
|
-
short_rate: `${v.fundingRate}`,
|
|
53
|
-
settlement_price: '',
|
|
54
|
-
})));
|
|
55
|
-
if (res.length < 500) {
|
|
56
|
-
break;
|
|
57
|
-
}
|
|
58
|
-
current = filtered[filtered.length - 1].time + 1;
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
//# sourceMappingURL=interest-rate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"interest-rate.js","sourceRoot":"","sources":["../../../src/services/markets/interest-rate.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AAE,CAAC,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;gBACvE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;oBACrB,MAAM;gBACR,CAAC;gBACD,oBAAM,QAAQ,CAAC,GAAG,CAChB,CAAC,CAAC,EAAiB,EAAE,CAAC,CAAC;oBACrB,SAAS;oBACT,UAAU,EAAE,SAAS;oBACrB,aAAa,EAAE,aAAa;oBAC5B,UAAU,EAAE,IAAA,kBAAU,EAAC,CAAC,CAAC,IAAI,CAAC;oBAC9B,SAAS,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE;oBAC1C,UAAU,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE;oBAC9B,gBAAgB,EAAE,EAAE;iBACrB,CAAC,CACH,CAAA,CAAC;gBACF,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;oBACrB,MAAM;gBACR,CAAC;gBACD,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC","sourcesContent":["import { IInterestRate } from '@yuants/data-interest-rate';\nimport { createSeriesProvider } from '@yuants/data-series';\nimport { Terminal } from '@yuants/protocol';\nimport { decodePath, formatTime } from '@yuants/utils';\nimport { getHistoricalFundingRates } from '../../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\ncreateSeriesProvider<IInterestRate>(terminal, {\n tableName: 'interest_rate',\n series_id_prefix_parts: ['HYPERLIQUID', 'PERPETUAL'],\n reversed: true,\n serviceOptions: { concurrent: 1 },\n queryFn: async function* ({ series_id, started_at, ended_at }) {\n const start = started_at || 0;\n const end = ended_at || Date.now();\n const [, , instId] = decodePath(series_id);\n const coin = instId?.split('-')?.[0];\n if (!coin) {\n throw new Error(`Invalid product in series_id: ${series_id}`);\n }\n let current = start;\n while (current <= end) {\n const res = await getHistoricalFundingRates({ coin, startTime: current, endTime: end });\n if (!res || res.length === 0) {\n break;\n }\n const filtered = res.filter((v) => v.time >= current && v.time <= end);\n if (!filtered.length) {\n break;\n }\n yield filtered.map(\n (v): IInterestRate => ({\n series_id,\n product_id: series_id,\n datasource_id: 'HYPERLIQUID',\n created_at: formatTime(v.time),\n long_rate: `${-parseFloat(v.fundingRate)}`,\n short_rate: `${v.fundingRate}`,\n settlement_price: '',\n }),\n );\n if (res.length < 500) {\n break;\n }\n current = filtered[filtered.length - 1].time + 1;\n }\n },\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ohlc.d.ts","sourceRoot":"","sources":["../../../src/services/markets/ohlc.ts"],"names":[],"mappings":""}
|
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __await = (this && this.__await) || function (v) { return this instanceof __await ? (this.v = v, this) : new __await(v); }
|
|
3
|
-
var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _arguments, generator) {
|
|
4
|
-
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
5
|
-
var g = generator.apply(thisArg, _arguments || []), i, q = [];
|
|
6
|
-
return i = Object.create((typeof AsyncIterator === "function" ? AsyncIterator : Object).prototype), verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
|
|
7
|
-
function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
|
|
8
|
-
function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
|
|
9
|
-
function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
|
|
10
|
-
function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
|
|
11
|
-
function fulfill(value) { resume("next", value); }
|
|
12
|
-
function reject(value) { resume("throw", value); }
|
|
13
|
-
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
|
|
14
|
-
};
|
|
15
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
const data_series_1 = require("@yuants/data-series");
|
|
17
|
-
const protocol_1 = require("@yuants/protocol");
|
|
18
|
-
const utils_1 = require("@yuants/utils");
|
|
19
|
-
const public_api_1 = require("../../api/public-api");
|
|
20
|
-
const terminal = protocol_1.Terminal.fromNodeEnv();
|
|
21
|
-
const DURATION_TO_HYPERLIQUID_INTERVAL = {
|
|
22
|
-
PT1M: '1m',
|
|
23
|
-
PT3M: '3m',
|
|
24
|
-
PT5M: '5m',
|
|
25
|
-
PT15M: '15m',
|
|
26
|
-
PT30M: '30m',
|
|
27
|
-
PT1H: '1h',
|
|
28
|
-
PT2H: '2h',
|
|
29
|
-
PT4H: '4h',
|
|
30
|
-
PT8H: '8h',
|
|
31
|
-
PT12H: '12h',
|
|
32
|
-
P1D: '1d',
|
|
33
|
-
P3D: '3d',
|
|
34
|
-
P1W: '1w',
|
|
35
|
-
P1M: '1M',
|
|
36
|
-
};
|
|
37
|
-
const DURATION_TO_PERIOD_IN_SEC = {
|
|
38
|
-
PT1M: 60,
|
|
39
|
-
PT3M: 180,
|
|
40
|
-
PT5M: 300,
|
|
41
|
-
PT15M: 900,
|
|
42
|
-
PT30M: 1800,
|
|
43
|
-
PT1H: 3600,
|
|
44
|
-
PT2H: 7200,
|
|
45
|
-
PT4H: 14400,
|
|
46
|
-
PT8H: 28800,
|
|
47
|
-
PT12H: 43200,
|
|
48
|
-
P1D: 86400,
|
|
49
|
-
P3D: 259200,
|
|
50
|
-
P1W: 604800,
|
|
51
|
-
P1M: 2592000,
|
|
52
|
-
};
|
|
53
|
-
(0, data_series_1.createSeriesProvider)(terminal, {
|
|
54
|
-
tableName: 'ohlc',
|
|
55
|
-
series_id_prefix_parts: ['HYPERLIQUID'],
|
|
56
|
-
reversed: true,
|
|
57
|
-
serviceOptions: { concurrent: 1 },
|
|
58
|
-
queryFn: function (_a) {
|
|
59
|
-
return __asyncGenerator(this, arguments, function* ({ series_id, ended_at }) {
|
|
60
|
-
var _b;
|
|
61
|
-
const [datasource_id, instType, symbol, duration] = (0, utils_1.decodePath)(series_id);
|
|
62
|
-
const product_id = (0, utils_1.encodePath)(datasource_id, instType, symbol);
|
|
63
|
-
const period_in_sec = DURATION_TO_PERIOD_IN_SEC[duration];
|
|
64
|
-
if (!datasource_id || !instType || !symbol || !duration || !period_in_sec) {
|
|
65
|
-
throw new Error(`Invalid series_id: ${series_id}`);
|
|
66
|
-
}
|
|
67
|
-
if (datasource_id !== 'HYPERLIQUID') {
|
|
68
|
-
throw new Error(`Invalid datasource for series_id: ${series_id}`);
|
|
69
|
-
}
|
|
70
|
-
const coin = (_b = symbol === null || symbol === void 0 ? void 0 : symbol.split('-')) === null || _b === void 0 ? void 0 : _b[0];
|
|
71
|
-
if (!coin) {
|
|
72
|
-
throw new Error(`Invalid product symbol: ${symbol}`);
|
|
73
|
-
}
|
|
74
|
-
const interval = DURATION_TO_HYPERLIQUID_INTERVAL[duration];
|
|
75
|
-
if (!interval) {
|
|
76
|
-
throw new Error(`Unsupported duration: ${duration}`);
|
|
77
|
-
}
|
|
78
|
-
const startTime = 0;
|
|
79
|
-
const res = yield __await((0, public_api_1.getCandleSnapshot)({
|
|
80
|
-
req: {
|
|
81
|
-
coin,
|
|
82
|
-
interval,
|
|
83
|
-
startTime,
|
|
84
|
-
endTime: ended_at,
|
|
85
|
-
},
|
|
86
|
-
}));
|
|
87
|
-
if (!res || !res.length) {
|
|
88
|
-
return yield __await(void 0);
|
|
89
|
-
}
|
|
90
|
-
const data = res
|
|
91
|
-
.filter((x) => x.t < ended_at)
|
|
92
|
-
.map((x) => ({
|
|
93
|
-
series_id,
|
|
94
|
-
datasource_id,
|
|
95
|
-
product_id,
|
|
96
|
-
duration,
|
|
97
|
-
created_at: (0, utils_1.formatTime)(x.t),
|
|
98
|
-
closed_at: (0, utils_1.formatTime)(x.t + period_in_sec * 1000),
|
|
99
|
-
open: x.o,
|
|
100
|
-
high: x.h,
|
|
101
|
-
low: x.l,
|
|
102
|
-
close: x.c,
|
|
103
|
-
volume: x.v,
|
|
104
|
-
open_interest: '0',
|
|
105
|
-
}))
|
|
106
|
-
.sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
|
|
107
|
-
if (data.length > 0) {
|
|
108
|
-
yield yield __await(data);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
},
|
|
112
|
-
});
|
|
113
|
-
//# sourceMappingURL=ohlc.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ohlc.js","sourceRoot":"","sources":["../../../src/services/markets/ohlc.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,qDAA2D;AAC3D,+CAA4C;AAC5C,yCAAmE;AACnE,qDAAyD;AAEzD,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,MAAM,gCAAgC,GAA2B;IAC/D,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,KAAK;IACZ,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;IACT,GAAG,EAAE,IAAI;CACV,CAAC;AAEF,MAAM,yBAAyB,GAA2B;IACxD,IAAI,EAAE,EAAE;IACR,IAAI,EAAE,GAAG;IACT,IAAI,EAAE,GAAG;IACT,KAAK,EAAE,GAAG;IACV,KAAK,EAAE,IAAI;IACX,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI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AI,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBACpB,oBAAM,IAAI,CAAA,CAAC;YACb,CAAC;QACH,CAAC;KAAA;CACF,CAAC,CAAC","sourcesContent":["import { IOHLC } from '@yuants/data-ohlc';\nimport { createSeriesProvider } from '@yuants/data-series';\nimport { Terminal } from '@yuants/protocol';\nimport { decodePath, encodePath, formatTime } from '@yuants/utils';\nimport { getCandleSnapshot } from '../../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst DURATION_TO_HYPERLIQUID_INTERVAL: Record<string, string> = {\n PT1M: '1m',\n PT3M: '3m',\n PT5M: '5m',\n PT15M: '15m',\n PT30M: '30m',\n PT1H: '1h',\n PT2H: '2h',\n PT4H: '4h',\n PT8H: '8h',\n PT12H: '12h',\n P1D: '1d',\n P3D: '3d',\n P1W: '1w',\n P1M: '1M',\n};\n\nconst DURATION_TO_PERIOD_IN_SEC: Record<string, number> = {\n PT1M: 60,\n PT3M: 180,\n PT5M: 300,\n PT15M: 900,\n PT30M: 1800,\n PT1H: 3600,\n PT2H: 7200,\n PT4H: 14400,\n PT8H: 28800,\n PT12H: 43200,\n P1D: 86400,\n P3D: 259200,\n P1W: 604800,\n P1M: 2592000,\n};\n\ncreateSeriesProvider<IOHLC>(terminal, {\n tableName: 'ohlc',\n series_id_prefix_parts: ['HYPERLIQUID'],\n reversed: true,\n serviceOptions: { concurrent: 1 },\n queryFn: async function* ({ series_id, ended_at }) {\n const [datasource_id, instType, symbol, duration] = decodePath(series_id);\n const product_id = encodePath(datasource_id, instType, symbol);\n const period_in_sec = DURATION_TO_PERIOD_IN_SEC[duration];\n if (!datasource_id || !instType || !symbol || !duration || !period_in_sec) {\n throw new Error(`Invalid series_id: ${series_id}`);\n }\n if (datasource_id !== 'HYPERLIQUID') {\n throw new Error(`Invalid datasource for series_id: ${series_id}`);\n }\n const coin = symbol?.split('-')?.[0];\n if (!coin) {\n throw new Error(`Invalid product symbol: ${symbol}`);\n }\n const interval = DURATION_TO_HYPERLIQUID_INTERVAL[duration];\n if (!interval) {\n throw new Error(`Unsupported duration: ${duration}`);\n }\n const startTime = 0;\n const res = await getCandleSnapshot({\n req: {\n coin,\n interval,\n startTime,\n endTime: ended_at,\n },\n });\n if (!res || !res.length) {\n return;\n }\n const data = res\n .filter((x) => x.t < ended_at)\n .map(\n (x): IOHLC => ({\n series_id,\n datasource_id,\n product_id,\n duration,\n created_at: formatTime(x.t),\n closed_at: formatTime(x.t + period_in_sec * 1000),\n open: x.o,\n high: x.h,\n low: x.l,\n close: x.c,\n volume: x.v,\n open_interest: '0',\n }),\n )\n .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());\n if (data.length > 0) {\n yield data;\n }\n },\n});\n"]}
|