@yuants/vendor-hyperliquid 0.9.9 → 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.
Files changed (90) hide show
  1. package/dist/api/client.js +36 -2
  2. package/dist/api/client.js.map +1 -1
  3. package/dist/api/private-api.js +52 -41
  4. package/dist/api/private-api.js.map +1 -1
  5. package/dist/api/public-api.js +22 -11
  6. package/dist/api/public-api.js.map +1 -1
  7. package/dist/api/rate-limit.js +205 -0
  8. package/dist/api/rate-limit.js.map +1 -0
  9. package/dist/api/rate-limit.test.js +129 -0
  10. package/dist/api/rate-limit.test.js.map +1 -0
  11. package/dist/api/sign.js.map +1 -1
  12. package/dist/api/types.js.map +1 -1
  13. package/dist/index.js +0 -2
  14. package/dist/index.js.map +1 -1
  15. package/dist/services/accounts/spot.js.map +1 -1
  16. package/dist/services/exchange.js.map +1 -1
  17. package/dist/services/markets/quote.js.map +1 -1
  18. package/dist/services/ohlc-service.js.map +1 -1
  19. package/dist/services/orders/cancelOrder.js.map +1 -1
  20. package/dist/services/orders/listOrders.js +2 -2
  21. package/dist/services/orders/listOrders.js.map +1 -1
  22. package/dist/services/orders/modifyOrder.js.map +1 -1
  23. package/dist/services/quotes.js.map +1 -1
  24. package/dist/services/utils.js.map +1 -1
  25. package/lib/api/client.d.ts +1 -1
  26. package/lib/api/client.d.ts.map +1 -1
  27. package/lib/api/client.js +35 -1
  28. package/lib/api/client.js.map +1 -1
  29. package/lib/api/private-api.d.ts +67 -3
  30. package/lib/api/private-api.d.ts.map +1 -1
  31. package/lib/api/private-api.js +59 -43
  32. package/lib/api/private-api.js.map +1 -1
  33. package/lib/api/public-api.d.ts +61 -11
  34. package/lib/api/public-api.d.ts.map +1 -1
  35. package/lib/api/public-api.js +33 -12
  36. package/lib/api/public-api.js.map +1 -1
  37. package/lib/api/rate-limit.d.ts +21 -0
  38. package/lib/api/rate-limit.d.ts.map +1 -0
  39. package/lib/api/rate-limit.js +214 -0
  40. package/lib/api/rate-limit.js.map +1 -0
  41. package/lib/api/rate-limit.test.d.ts +2 -0
  42. package/lib/api/rate-limit.test.d.ts.map +1 -0
  43. package/lib/api/rate-limit.test.js +131 -0
  44. package/lib/api/rate-limit.test.js.map +1 -0
  45. package/lib/api/sign.js +5 -6
  46. package/lib/api/sign.js.map +1 -1
  47. package/lib/api/types.d.ts.map +1 -1
  48. package/lib/api/types.js.map +1 -1
  49. package/lib/index.d.ts +0 -2
  50. package/lib/index.d.ts.map +1 -1
  51. package/lib/index.js +0 -2
  52. package/lib/index.js.map +1 -1
  53. package/lib/services/accounts/perp.d.ts.map +1 -1
  54. package/lib/services/accounts/spot.d.ts.map +1 -1
  55. package/lib/services/accounts/spot.js.map +1 -1
  56. package/lib/services/exchange.js.map +1 -1
  57. package/lib/services/markets/product.d.ts.map +1 -1
  58. package/lib/services/markets/quote.js.map +1 -1
  59. package/lib/services/ohlc-service.js.map +1 -1
  60. package/lib/services/orders/cancelOrder.d.ts.map +1 -1
  61. package/lib/services/orders/cancelOrder.js.map +1 -1
  62. package/lib/services/orders/listOrders.d.ts.map +1 -1
  63. package/lib/services/orders/listOrders.js +2 -2
  64. package/lib/services/orders/listOrders.js.map +1 -1
  65. package/lib/services/orders/modifyOrder.d.ts.map +1 -1
  66. package/lib/services/orders/modifyOrder.js.map +1 -1
  67. package/lib/services/orders/submitOrder.d.ts.map +1 -1
  68. package/lib/services/quotes.js.map +1 -1
  69. package/lib/services/utils.d.ts +2 -2
  70. package/lib/services/utils.d.ts.map +1 -1
  71. package/lib/services/utils.js.map +1 -1
  72. package/lib/tsdoc-metadata.json +1 -1
  73. package/package.json +48 -48
  74. package/temp/build/typescript/ts_HOjXkPSo.json +1 -0
  75. package/temp/package-deps.json +27 -27
  76. package/temp/test/jest/haste-map-1a3370ad4952cc1cbecf8fc42c6e9732-7b2990dcc44090c4eba2c52e971c544c-6a2a6e27ca3579da37751287ea19ab4c +0 -0
  77. package/temp/test/jest/perf-cache-1a3370ad4952cc1cbecf8fc42c6e9732-da39a3ee5e6b4b0d3255bfef95601890 +1 -0
  78. package/temp/vendor-hyperliquid.api.json +18 -2
  79. package/dist/services/markets/interest-rate.js +0 -60
  80. package/dist/services/markets/interest-rate.js.map +0 -1
  81. package/dist/services/markets/ohlc.js +0 -110
  82. package/dist/services/markets/ohlc.js.map +0 -1
  83. package/lib/services/markets/interest-rate.d.ts +0 -2
  84. package/lib/services/markets/interest-rate.d.ts.map +0 -1
  85. package/lib/services/markets/interest-rate.js +0 -62
  86. package/lib/services/markets/interest-rate.js.map +0 -1
  87. package/lib/services/markets/ohlc.d.ts +0 -2
  88. package/lib/services/markets/ohlc.d.ts.map +0 -1
  89. package/lib/services/markets/ohlc.js +0 -112
  90. package/lib/services/markets/ohlc.js.map +0 -1
@@ -1,27 +1,27 @@
1
1
  {
2
2
  "apps/vendor-hyperliquid/AGENTS.md": "f0f3df594ce55fbaf78fb040f2850d1abee3449a",
3
- "apps/vendor-hyperliquid/CHANGELOG.json": "9c47817e764a725985cebf4762e73534227d868f",
4
- "apps/vendor-hyperliquid/CHANGELOG.md": "6d44e3adf8e5f20a98c766e88df8959f479870ea",
5
- "apps/vendor-hyperliquid/SESSION_NOTES.md": "5969eb7dceb736977bf0b36aa24f5cc1f5585656",
6
- "apps/vendor-hyperliquid/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
3
+ "apps/vendor-hyperliquid/CHANGELOG.json": "cc033904ef6eabffc1d47c0b11c1ae35aeb29b0a",
4
+ "apps/vendor-hyperliquid/CHANGELOG.md": "9208e31e8d8bf6bcfe758eb6cd02de118c0c9601",
5
+ "apps/vendor-hyperliquid/SESSION_NOTES.md": "bc090edd4a5471e5d4aebc06c952d07b189cf566",
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": "8738c6b3632b05d9053c5edb435134cdf259b409",
12
- "apps/vendor-hyperliquid/src/api/client.ts": "90eb3b63394c9729cc442e0ee5482bfd494aafdd",
13
- "apps/vendor-hyperliquid/src/api/private-api.ts": "8fd176063af8f345aeab94444850e82979cef680",
14
- "apps/vendor-hyperliquid/src/api/public-api.ts": "fbbb982308eea89a51b93cc21442de6ba45cfd60",
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": "3465b7797a0b49e2b0ff29467220e47bb587dcb6",
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",
@@ -32,20 +32,20 @@
32
32
  "apps/vendor-hyperliquid/src/services/quotes.ts": "d7af1af02965fe4b378a325970816b14822dd10e",
33
33
  "apps/vendor-hyperliquid/src/services/utils.ts": "a115e2f972368033e6eb7325602092dbd448c9c3",
34
34
  "apps/vendor-hyperliquid/tsconfig.json": "fc376462cd03b4f9676999e8b78dd8e7e90bbbd3",
35
- "apps/vendor-hyperliquid/.rush/temp/shrinkwrap-deps.json": "d9e7e51571c2f9512f75f378953ef8175952ed5c",
36
- "libraries/cache/temp/package-deps.json": "39ebfb1d8a15e6341c4902a0954985d469597125",
37
- "libraries/protocol/temp/package-deps.json": "f9ac8a0412f63d53f93ce189a390eab4a74b772b",
38
- "libraries/transfer/temp/package-deps.json": "1475a93c85fc5214e481cd20910740bba1c80812",
39
- "libraries/data-account/temp/package-deps.json": "0b428e3b8643b117276ebe0f29428d5686526d4a",
40
- "libraries/utils/temp/package-deps.json": "16ee87f512cd903d59f2ce9935be22e5ed6d03a1",
41
- "libraries/sql/temp/package-deps.json": "d1a7297dec9849184bda8843800beae36c6b1f09",
42
- "libraries/data-product/temp/package-deps.json": "0eee98e9df8a5aa401aa1e87cefa141630973535",
43
- "libraries/data-interest-rate/temp/package-deps.json": "4c9d3f2fe8c1f209de2039367832df81a410408b",
44
- "libraries/data-order/temp/package-deps.json": "751f5b506c10f57ca17960dd9af22c465c77c6de",
45
- "libraries/data-series/temp/package-deps.json": "cc0091507594699dcba5a91b5068259c4776fffe",
46
- "libraries/data-quote/temp/package-deps.json": "ad175d5009b9c8a1a0d590bd8b9f5210e48ef61a",
47
- "libraries/exchange/temp/package-deps.json": "f09d006f65e2a5bb7260affc8b51f2973d47d059",
48
- "libraries/data-ohlc/temp/package-deps.json": "d746fd7cc4964310a4f239d6c59538e7562d537a",
49
- "libraries/extension/temp/package-deps.json": "85f040a21803ec7d18c2730a13e0a2d79d5245fa",
50
- "tools/toolkit/temp/package-deps.json": "23e053490eb8feade23e4d45de4e54883e322711"
35
+ "apps/vendor-hyperliquid/.rush/temp/shrinkwrap-deps.json": "63fecac6fa117d173c3d7822c3cee7a1cb65c914",
36
+ "libraries/cache/temp/package-deps.json": "53c7e65e4fbefc731eef11e41145ecc3b90d9845",
37
+ "libraries/protocol/temp/package-deps.json": "1ed7faa57c156fc1b7ff9f13fe5566aacda70447",
38
+ "libraries/transfer/temp/package-deps.json": "56f1b09fff53f23da4c19c0c71307cd636a4421f",
39
+ "libraries/data-account/temp/package-deps.json": "9bfd92d0e975a4ad3f2e79ce68233e832865b579",
40
+ "libraries/utils/temp/package-deps.json": "018cb7f334c7419da6d55993eec202580b95f794",
41
+ "libraries/sql/temp/package-deps.json": "88cd4d4a8648dfa8d3aeec991aa734f9ab3374dc",
42
+ "libraries/data-product/temp/package-deps.json": "2b9736cd4a54002df2be4e72f9a4b9641aa71201",
43
+ "libraries/data-interest-rate/temp/package-deps.json": "42fb3cc90524c7bba423d19f038add1ea2d1e4bd",
44
+ "libraries/data-order/temp/package-deps.json": "3495abc01b406b0c63a2725d361512a996a23a79",
45
+ "libraries/data-series/temp/package-deps.json": "ca8fb8d7fa67d7a77b7254eb785f4aa14c1d928c",
46
+ "libraries/data-quote/temp/package-deps.json": "ecee1e69820ccb2072ea6977a3971555e9e68e11",
47
+ "libraries/exchange/temp/package-deps.json": "522ed703d78091e161f719f0b0db4666c65316a8",
48
+ "libraries/data-ohlc/temp/package-deps.json": "4d744c19879a13bbdb1959b5aef0cc1a5da7f726",
49
+ "libraries/extension/temp/package-deps.json": "454f577565ee01a0838c468fb1fc59e1f5d5f37c",
50
+ "tools/toolkit/temp/package-deps.json": "580f13201f076fa393117989256a2fee58e354f8"
51
51
  }
@@ -0,0 +1 @@
1
+ {"/home/runner/work/Yuan/Yuan/apps/vendor-hyperliquid/lib/api/rate-limit.test.js":[1,937]}
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "metadata": {
3
3
  "toolPackage": "@microsoft/api-extractor",
4
- "toolVersion": "7.30.1",
5
- "schemaVersion": 1009,
4
+ "toolVersion": "7.55.2",
5
+ "schemaVersion": 1011,
6
6
  "oldestForwardsCompatibleVersion": 1001,
7
7
  "tsdocConfig": {
8
8
  "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
@@ -114,6 +114,22 @@
114
114
  "tagName": "@virtual",
115
115
  "syntaxKind": "modifier"
116
116
  },
117
+ {
118
+ "tagName": "@jsx",
119
+ "syntaxKind": "block"
120
+ },
121
+ {
122
+ "tagName": "@jsxRuntime",
123
+ "syntaxKind": "block"
124
+ },
125
+ {
126
+ "tagName": "@jsxFrag",
127
+ "syntaxKind": "block"
128
+ },
129
+ {
130
+ "tagName": "@jsxImportSource",
131
+ "syntaxKind": "block"
132
+ },
117
133
  {
118
134
  "tagName": "@betaDocumentation",
119
135
  "syntaxKind": "modifier"
@@ -1,60 +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 = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
6
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
7
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
8
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
9
- function fulfill(value) { resume("next", value); }
10
- function reject(value) { resume("throw", value); }
11
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
12
- };
13
- import { createSeriesProvider } from '@yuants/data-series';
14
- import { Terminal } from '@yuants/protocol';
15
- import { decodePath, formatTime } from '@yuants/utils';
16
- import { getHistoricalFundingRates } from '../../api/public-api';
17
- const terminal = Terminal.fromNodeEnv();
18
- createSeriesProvider(terminal, {
19
- tableName: 'interest_rate',
20
- series_id_prefix_parts: ['HYPERLIQUID', 'PERPETUAL'],
21
- reversed: true,
22
- serviceOptions: { concurrent: 1 },
23
- queryFn: function ({ series_id, started_at, ended_at }) {
24
- var _a;
25
- return __asyncGenerator(this, arguments, function* () {
26
- const start = started_at || 0;
27
- const end = ended_at || Date.now();
28
- const [, , instId] = decodePath(series_id);
29
- const coin = (_a = instId === null || instId === void 0 ? void 0 : instId.split('-')) === null || _a === void 0 ? void 0 : _a[0];
30
- if (!coin) {
31
- throw new Error(`Invalid product in series_id: ${series_id}`);
32
- }
33
- let current = start;
34
- while (current <= end) {
35
- const res = yield __await(getHistoricalFundingRates({ coin, startTime: current, endTime: end }));
36
- if (!res || res.length === 0) {
37
- break;
38
- }
39
- const filtered = res.filter((v) => v.time >= current && v.time <= end);
40
- if (!filtered.length) {
41
- break;
42
- }
43
- yield yield __await(filtered.map((v) => ({
44
- series_id,
45
- product_id: series_id,
46
- datasource_id: 'HYPERLIQUID',
47
- created_at: formatTime(v.time),
48
- long_rate: `${-parseFloat(v.fundingRate)}`,
49
- short_rate: `${v.fundingRate}`,
50
- settlement_price: '',
51
- })));
52
- if (res.length < 500) {
53
- break;
54
- }
55
- current = filtered[filtered.length - 1].time + 1;
56
- }
57
- });
58
- },
59
- });
60
- //# 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,UAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE;;;YAC3D,MAAM,KAAK,GAAG,UAAU,IAAI,CAAC,CAAC;YAC9B,MAAM,GAAG,GAAG,QAAQ,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACnC,MAAM,CAAC,EAAE,AAAD,EAAG,MAAM,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;YAC3C,MAAM,IAAI,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KA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ourcesContent":["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,110 +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 = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
6
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
7
- function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
8
- function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
9
- function fulfill(value) { resume("next", value); }
10
- function reject(value) { resume("throw", value); }
11
- function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
12
- };
13
- import { createSeriesProvider } from '@yuants/data-series';
14
- import { Terminal } from '@yuants/protocol';
15
- import { decodePath, encodePath, formatTime } from '@yuants/utils';
16
- import { getCandleSnapshot } from '../../api/public-api';
17
- const terminal = Terminal.fromNodeEnv();
18
- const DURATION_TO_HYPERLIQUID_INTERVAL = {
19
- PT1M: '1m',
20
- PT3M: '3m',
21
- PT5M: '5m',
22
- PT15M: '15m',
23
- PT30M: '30m',
24
- PT1H: '1h',
25
- PT2H: '2h',
26
- PT4H: '4h',
27
- PT8H: '8h',
28
- PT12H: '12h',
29
- P1D: '1d',
30
- P3D: '3d',
31
- P1W: '1w',
32
- P1M: '1M',
33
- };
34
- const DURATION_TO_PERIOD_IN_SEC = {
35
- PT1M: 60,
36
- PT3M: 180,
37
- PT5M: 300,
38
- PT15M: 900,
39
- PT30M: 1800,
40
- PT1H: 3600,
41
- PT2H: 7200,
42
- PT4H: 14400,
43
- PT8H: 28800,
44
- PT12H: 43200,
45
- P1D: 86400,
46
- P3D: 259200,
47
- P1W: 604800,
48
- P1M: 2592000,
49
- };
50
- createSeriesProvider(terminal, {
51
- tableName: 'ohlc',
52
- series_id_prefix_parts: ['HYPERLIQUID'],
53
- reversed: true,
54
- serviceOptions: { concurrent: 1 },
55
- queryFn: function ({ series_id, ended_at }) {
56
- var _a;
57
- return __asyncGenerator(this, arguments, function* () {
58
- const [datasource_id, instType, symbol, duration] = decodePath(series_id);
59
- const product_id = encodePath(datasource_id, instType, symbol);
60
- const period_in_sec = DURATION_TO_PERIOD_IN_SEC[duration];
61
- if (!datasource_id || !instType || !symbol || !duration || !period_in_sec) {
62
- throw new Error(`Invalid series_id: ${series_id}`);
63
- }
64
- if (datasource_id !== 'HYPERLIQUID') {
65
- throw new Error(`Invalid datasource for series_id: ${series_id}`);
66
- }
67
- const coin = (_a = symbol === null || symbol === void 0 ? void 0 : symbol.split('-')) === null || _a === void 0 ? void 0 : _a[0];
68
- if (!coin) {
69
- throw new Error(`Invalid product symbol: ${symbol}`);
70
- }
71
- const interval = DURATION_TO_HYPERLIQUID_INTERVAL[duration];
72
- if (!interval) {
73
- throw new Error(`Unsupported duration: ${duration}`);
74
- }
75
- const startTime = 0;
76
- const res = yield __await(getCandleSnapshot({
77
- req: {
78
- coin,
79
- interval,
80
- startTime,
81
- endTime: ended_at,
82
- },
83
- }));
84
- if (!res || !res.length) {
85
- return yield __await(void 0);
86
- }
87
- const data = res
88
- .filter((x) => x.t < ended_at)
89
- .map((x) => ({
90
- series_id,
91
- datasource_id,
92
- product_id,
93
- duration,
94
- created_at: formatTime(x.t),
95
- closed_at: formatTime(x.t + period_in_sec * 1000),
96
- open: x.o,
97
- high: x.h,
98
- low: x.l,
99
- close: x.c,
100
- volume: x.v,
101
- open_interest: '0',
102
- }))
103
- .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
104
- if (data.length > 0) {
105
- yield yield __await(data);
106
- }
107
- });
108
- },
109
- });
110
- //# 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,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACnE,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,MA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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;gBACnB,oBAAM,IAAI,CAAA,CAAC;aACZ;;KACF;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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=interest-rate.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interest-rate.d.ts","sourceRoot":"","sources":["../../../src/services/markets/interest-rate.ts"],"names":[],"mappings":""}
@@ -1,62 +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 = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
7
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
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
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const data_series_1 = require("@yuants/data-series");
16
- const protocol_1 = require("@yuants/protocol");
17
- const utils_1 = require("@yuants/utils");
18
- const public_api_1 = require("../../api/public-api");
19
- const terminal = protocol_1.Terminal.fromNodeEnv();
20
- (0, data_series_1.createSeriesProvider)(terminal, {
21
- tableName: 'interest_rate',
22
- series_id_prefix_parts: ['HYPERLIQUID', 'PERPETUAL'],
23
- reversed: true,
24
- serviceOptions: { concurrent: 1 },
25
- queryFn: function ({ series_id, started_at, ended_at }) {
26
- var _a;
27
- return __asyncGenerator(this, arguments, function* () {
28
- const start = started_at || 0;
29
- const end = ended_at || Date.now();
30
- const [, , instId] = (0, utils_1.decodePath)(series_id);
31
- const coin = (_a = instId === null || instId === void 0 ? void 0 : instId.split('-')) === null || _a === void 0 ? void 0 : _a[0];
32
- if (!coin) {
33
- throw new Error(`Invalid product in series_id: ${series_id}`);
34
- }
35
- let current = start;
36
- while (current <= end) {
37
- const res = yield __await((0, public_api_1.getHistoricalFundingRates)({ coin, startTime: current, endTime: end }));
38
- if (!res || res.length === 0) {
39
- break;
40
- }
41
- const filtered = res.filter((v) => v.time >= current && v.time <= end);
42
- if (!filtered.length) {
43
- break;
44
- }
45
- yield yield __await(filtered.map((v) => ({
46
- series_id,
47
- product_id: series_id,
48
- datasource_id: 'HYPERLIQUID',
49
- created_at: (0, utils_1.formatTime)(v.time),
50
- long_rate: `${-parseFloat(v.fundingRate)}`,
51
- short_rate: `${v.fundingRate}`,
52
- settlement_price: '',
53
- })));
54
- if (res.length < 500) {
55
- break;
56
- }
57
- current = filtered[filtered.length - 1].time + 1;
58
- }
59
- });
60
- },
61
- });
62
- //# 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,qDAA2D;AAC3D,+CAA4C;AAC5C,yCAAuD;AACvD,qDAAiE;AAEjE,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,IAAA,kCAAoB,EAAgB,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,UAAiB,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE;;;YAC3D,MAAM,KAAK,GAAG,UAAU,IAAI,CAAC,CAAC;YAC9B,MAAM,GAAG,GAAG,QAAQ,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;YACnC,MAAM,CAAC,EAAE,AAAD,EAAG,MAAM,CAAC,GAAG,IAAA,kBAAU,EAAC,SAAS,CAAC,CAAC;YAC3C,MAAM,IAAI,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,GAAG,CAAC,0CAAG,CAAC,CAAC,CAAC;YACrC,IAAI,CAAC,IAAI,EAAE;gBACT,MAAM,IAAI,KAAK,CAAC,iCAAiC,SAAS,EAAE,CAAC,CAAC;aAC/D;YACD,IAAI,OAAO,GAAG,KAAK,CAAC;YACpB,OAAO,OAAO,IAAI,GAAG,EAAE;gBACrB,MAAM,GAAG,GAAG,cAAM,IAAA,sCAAyB,EAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,CAAA,CAAC;gBACxF,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE;oBAC5B,MAAM;iBACP;gBACD,MAAM,QAAQ,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,IAAI,OAAO,IAAI,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;gBACvE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;oBACpB,MAAM;iBACP;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;oBACpB,MAAM;iBACP;gBACD,OAAO,GAAG,QAAQ,CAAC,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC;aAClD;;KACF;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,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ohlc.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ohlc.d.ts","sourceRoot":"","sources":["../../../src/services/markets/ohlc.ts"],"names":[],"mappings":""}
@@ -1,112 +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 = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
7
- function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
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
- Object.defineProperty(exports, "__esModule", { value: true });
15
- const data_series_1 = require("@yuants/data-series");
16
- const protocol_1 = require("@yuants/protocol");
17
- const utils_1 = require("@yuants/utils");
18
- const public_api_1 = require("../../api/public-api");
19
- const terminal = protocol_1.Terminal.fromNodeEnv();
20
- const DURATION_TO_HYPERLIQUID_INTERVAL = {
21
- PT1M: '1m',
22
- PT3M: '3m',
23
- PT5M: '5m',
24
- PT15M: '15m',
25
- PT30M: '30m',
26
- PT1H: '1h',
27
- PT2H: '2h',
28
- PT4H: '4h',
29
- PT8H: '8h',
30
- PT12H: '12h',
31
- P1D: '1d',
32
- P3D: '3d',
33
- P1W: '1w',
34
- P1M: '1M',
35
- };
36
- const DURATION_TO_PERIOD_IN_SEC = {
37
- PT1M: 60,
38
- PT3M: 180,
39
- PT5M: 300,
40
- PT15M: 900,
41
- PT30M: 1800,
42
- PT1H: 3600,
43
- PT2H: 7200,
44
- PT4H: 14400,
45
- PT8H: 28800,
46
- PT12H: 43200,
47
- P1D: 86400,
48
- P3D: 259200,
49
- P1W: 604800,
50
- P1M: 2592000,
51
- };
52
- (0, data_series_1.createSeriesProvider)(terminal, {
53
- tableName: 'ohlc',
54
- series_id_prefix_parts: ['HYPERLIQUID'],
55
- reversed: true,
56
- serviceOptions: { concurrent: 1 },
57
- queryFn: function ({ series_id, ended_at }) {
58
- var _a;
59
- return __asyncGenerator(this, arguments, function* () {
60
- const [datasource_id, instType, symbol, duration] = (0, utils_1.decodePath)(series_id);
61
- const product_id = (0, utils_1.encodePath)(datasource_id, instType, symbol);
62
- const period_in_sec = DURATION_TO_PERIOD_IN_SEC[duration];
63
- if (!datasource_id || !instType || !symbol || !duration || !period_in_sec) {
64
- throw new Error(`Invalid series_id: ${series_id}`);
65
- }
66
- if (datasource_id !== 'HYPERLIQUID') {
67
- throw new Error(`Invalid datasource for series_id: ${series_id}`);
68
- }
69
- const coin = (_a = symbol === null || symbol === void 0 ? void 0 : symbol.split('-')) === null || _a === void 0 ? void 0 : _a[0];
70
- if (!coin) {
71
- throw new Error(`Invalid product symbol: ${symbol}`);
72
- }
73
- const interval = DURATION_TO_HYPERLIQUID_INTERVAL[duration];
74
- if (!interval) {
75
- throw new Error(`Unsupported duration: ${duration}`);
76
- }
77
- const startTime = 0;
78
- const res = yield __await((0, public_api_1.getCandleSnapshot)({
79
- req: {
80
- coin,
81
- interval,
82
- startTime,
83
- endTime: ended_at,
84
- },
85
- }));
86
- if (!res || !res.length) {
87
- return yield __await(void 0);
88
- }
89
- const data = res
90
- .filter((x) => x.t < ended_at)
91
- .map((x) => ({
92
- series_id,
93
- datasource_id,
94
- product_id,
95
- duration,
96
- created_at: (0, utils_1.formatTime)(x.t),
97
- closed_at: (0, utils_1.formatTime)(x.t + period_in_sec * 1000),
98
- open: x.o,
99
- high: x.h,
100
- low: x.l,
101
- close: x.c,
102
- volume: x.v,
103
- open_interest: '0',
104
- }))
105
- .sort((a, b) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime());
106
- if (data.length > 0) {
107
- yield yield __await(data);
108
- }
109
- });
110
- },
111
- });
112
- //# 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,K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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;gBACnB,oBAAM,IAAI,CAAA,CAAC;aACZ;;KACF;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"]}