@yuants/vendor-huobi 0.18.12 → 0.19.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 (64) hide show
  1. package/dist/api/private-api.js +8 -0
  2. package/dist/api/private-api.js.map +1 -1
  3. package/dist/api/public-api.js.map +1 -1
  4. package/dist/index.js +1 -1
  5. package/dist/index.js.map +1 -1
  6. package/dist/services/accounts/spot.js.map +1 -1
  7. package/dist/services/accounts/super-margin.js.map +1 -1
  8. package/dist/services/accounts/swap.js.map +1 -1
  9. package/dist/services/exchange.js +1 -1
  10. package/dist/services/exchange.js.map +1 -1
  11. package/dist/services/interest-ledger-service.js +63 -0
  12. package/dist/services/interest-ledger-service.js.map +1 -0
  13. package/dist/services/interest-rate-service.js.map +1 -1
  14. package/dist/services/market-data/quote.js.map +1 -1
  15. package/dist/services/ohlc-service.js.map +1 -1
  16. package/dist/services/orders/listOrders.js +2 -2
  17. package/dist/services/orders/listOrders.js.map +1 -1
  18. package/dist/services/orders/submitOrder.js +1 -1
  19. package/dist/services/orders/submitOrder.js.map +1 -1
  20. package/dist/services/product.js.map +1 -1
  21. package/lib/api/private-api.d.ts +61 -32
  22. package/lib/api/private-api.d.ts.map +1 -1
  23. package/lib/api/private-api.js +10 -1
  24. package/lib/api/private-api.js.map +1 -1
  25. package/lib/api/public-api.d.ts.map +1 -1
  26. package/lib/api/public-api.js +13 -13
  27. package/lib/api/public-api.js.map +1 -1
  28. package/lib/index.d.ts +1 -1
  29. package/lib/index.d.ts.map +1 -1
  30. package/lib/index.js +1 -1
  31. package/lib/index.js.map +1 -1
  32. package/lib/services/accounts/spot.js.map +1 -1
  33. package/lib/services/accounts/super-margin.js.map +1 -1
  34. package/lib/services/accounts/swap.d.ts.map +1 -1
  35. package/lib/services/accounts/swap.js.map +1 -1
  36. package/lib/services/exchange.js +1 -1
  37. package/lib/services/exchange.js.map +1 -1
  38. package/lib/services/interest-ledger-service.d.ts +2 -0
  39. package/lib/services/interest-ledger-service.d.ts.map +1 -0
  40. package/lib/services/interest-ledger-service.js +65 -0
  41. package/lib/services/interest-ledger-service.js.map +1 -0
  42. package/lib/services/interest-rate-service.js.map +1 -1
  43. package/lib/services/market-data/quote.js.map +1 -1
  44. package/lib/services/ohlc-service.js.map +1 -1
  45. package/lib/services/orders/listOrders.d.ts.map +1 -1
  46. package/lib/services/orders/listOrders.js +2 -2
  47. package/lib/services/orders/listOrders.js.map +1 -1
  48. package/lib/services/orders/submitOrder.d.ts.map +1 -1
  49. package/lib/services/orders/submitOrder.js +1 -1
  50. package/lib/services/orders/submitOrder.js.map +1 -1
  51. package/lib/services/product.d.ts.map +1 -1
  52. package/lib/services/product.js.map +1 -1
  53. package/lib/tsdoc-metadata.json +1 -1
  54. package/package.json +43 -43
  55. package/temp/build/typescript/ts_pRZ94LVe.json +1 -0
  56. package/temp/package-deps.json +23 -23
  57. package/temp/test/jest/haste-map-fefe7499bc87b2b52172761a7fafd5ee-e0af843dfeade9e9ece596ee0c4ddcd4-4c5295047830cedf09a623a6f26c8535 +0 -0
  58. package/temp/vendor-huobi.api.json +18 -2
  59. package/dist/services/market-data/interest_rate.js +0 -62
  60. package/dist/services/market-data/interest_rate.js.map +0 -1
  61. package/lib/services/market-data/interest_rate.d.ts +0 -2
  62. package/lib/services/market-data/interest_rate.d.ts.map +0 -1
  63. package/lib/services/market-data/interest_rate.js +0 -64
  64. package/lib/services/market-data/interest_rate.js.map +0 -1
@@ -1,25 +1,25 @@
1
1
  {
2
- "apps/vendor-huobi/CHANGELOG.json": "87f2f98cd1d7b16dc9c100148c642ceebc0c8060",
3
- "apps/vendor-huobi/CHANGELOG.md": "4e5b20b916e51a33fae1f9c411d72731359b0cbc",
2
+ "apps/vendor-huobi/CHANGELOG.json": "3b74de93a46c61ba4187499180375e0eec73d335",
3
+ "apps/vendor-huobi/CHANGELOG.md": "f73eb0a60304b301dbc44ba3359dd66e272dba44",
4
4
  "apps/vendor-huobi/README.md": "d7bf0149513114eab5500a6b5c9e7cba10565572",
5
- "apps/vendor-huobi/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
5
+ "apps/vendor-huobi/config/api-extractor.json": "62f4fd324425b9a235f0c117975967aab09ced0c",
6
6
  "apps/vendor-huobi/config/jest.config.json": "4bb17bde3ee911163a3edb36a6eb71491d80b1bd",
7
7
  "apps/vendor-huobi/config/rig.json": "f6c7b5537dc77a3170ba9f008bae3b6c3ee11956",
8
8
  "apps/vendor-huobi/config/typescript.json": "854907e8a821f2050f6533368db160c649c25348",
9
9
  "apps/vendor-huobi/etc/vendor-huobi.api.md": "dc8cbf2a044a227b30a4ee9701b0c97328244724",
10
- "apps/vendor-huobi/package.json": "04013aa4753ceed7f184c4dda1572f400fd61a4c",
10
+ "apps/vendor-huobi/package.json": "6de43cd3ffe9f0120e54d57a2f1871e74b177715",
11
11
  "apps/vendor-huobi/src/__archived/account-info.ts": "5c325d3bb8839476c11f25693326ce05f3321ebd",
12
12
  "apps/vendor-huobi/src/__archived/api.ts": "8366151dc881b177d0478fb328a601a11e33cd35",
13
13
  "apps/vendor-huobi/src/__archived/transfer.ts": "fd299ad82ff31344460967f2a938b8f36c879259",
14
- "apps/vendor-huobi/src/api/private-api.ts": "62a1b8c67e165bb5d69e083903b5e31d5cae118f",
14
+ "apps/vendor-huobi/src/api/private-api.ts": "22680b405b5eeae0923b9b3c788d16509a37a4e6",
15
15
  "apps/vendor-huobi/src/api/public-api.ts": "7141d4c6369a59b062b2b0e5a475af9abb1ec31b",
16
- "apps/vendor-huobi/src/index.ts": "997283c933e2df8c6d35ce3d2f40d7d0c33c469b",
16
+ "apps/vendor-huobi/src/index.ts": "f0210f9f7be72864c0937dc46f85781e7108bb03",
17
17
  "apps/vendor-huobi/src/services/accounts/spot.ts": "fb2e22203eecce2dbb246a0bf8d8c1caec4c5dff",
18
18
  "apps/vendor-huobi/src/services/accounts/super-margin.ts": "b8a97300664e25f512994813b2175f39a2d76508",
19
19
  "apps/vendor-huobi/src/services/accounts/swap.ts": "7ed0a7a6e927973b1c13dd156cd72607708e818b",
20
20
  "apps/vendor-huobi/src/services/exchange.ts": "6f704961de6dd03b2db3544da6b49c6dd8531f33",
21
+ "apps/vendor-huobi/src/services/interest-ledger-service.ts": "496a282904f921d923c866e817e3af8db430101d",
21
22
  "apps/vendor-huobi/src/services/interest-rate-service.ts": "3180227cd8fe336e187ad7a90bf3ce1bb7dfc7f7",
22
- "apps/vendor-huobi/src/services/market-data/interest_rate.ts": "79aa362f9fa90e612f9813d0b45d357b96189f3e",
23
23
  "apps/vendor-huobi/src/services/market-data/quote.ts": "2f5883a95b11cf19c1a9a595567f9369b360cccf",
24
24
  "apps/vendor-huobi/src/services/ohlc-service.ts": "914f75705e0ad396b537e4b55334419206526160",
25
25
  "apps/vendor-huobi/src/services/orders/listOrders.ts": "1cf4621727fb290f8e5fd1439765fd73387bda7a",
@@ -28,20 +28,20 @@
28
28
  "apps/vendor-huobi/src/services/quotes.ts": "a99185c9d2e95da220919deef49357ec6280ee78",
29
29
  "apps/vendor-huobi/src/services/uid.ts": "b71c27a6a0debdd9365dea35306f4763327aca2f",
30
30
  "apps/vendor-huobi/tsconfig.json": "81da8f78196974b5d15da0edb6b2d9f48641063c",
31
- "apps/vendor-huobi/.rush/temp/shrinkwrap-deps.json": "237a816d6e825b5bd2a0fc742f5d055c19e37d3d",
32
- "libraries/protocol/temp/package-deps.json": "f9ac8a0412f63d53f93ce189a390eab4a74b772b",
33
- "libraries/data-account/temp/package-deps.json": "0b428e3b8643b117276ebe0f29428d5686526d4a",
34
- "libraries/data-order/temp/package-deps.json": "751f5b506c10f57ca17960dd9af22c465c77c6de",
35
- "libraries/data-ohlc/temp/package-deps.json": "d746fd7cc4964310a4f239d6c59538e7562d537a",
36
- "libraries/transfer/temp/package-deps.json": "1475a93c85fc5214e481cd20910740bba1c80812",
37
- "libraries/utils/temp/package-deps.json": "16ee87f512cd903d59f2ce9935be22e5ed6d03a1",
38
- "libraries/cache/temp/package-deps.json": "39ebfb1d8a15e6341c4902a0954985d469597125",
39
- "libraries/sql/temp/package-deps.json": "d1a7297dec9849184bda8843800beae36c6b1f09",
40
- "libraries/data-product/temp/package-deps.json": "0eee98e9df8a5aa401aa1e87cefa141630973535",
41
- "libraries/data-series/temp/package-deps.json": "cc0091507594699dcba5a91b5068259c4776fffe",
42
- "libraries/data-interest-rate/temp/package-deps.json": "4c9d3f2fe8c1f209de2039367832df81a410408b",
43
- "libraries/data-quote/temp/package-deps.json": "ad175d5009b9c8a1a0d590bd8b9f5210e48ef61a",
44
- "libraries/exchange/temp/package-deps.json": "f09d006f65e2a5bb7260affc8b51f2973d47d059",
45
- "libraries/extension/temp/package-deps.json": "85f040a21803ec7d18c2730a13e0a2d79d5245fa",
46
- "tools/toolkit/temp/package-deps.json": "23e053490eb8feade23e4d45de4e54883e322711"
31
+ "apps/vendor-huobi/.rush/temp/shrinkwrap-deps.json": "accad6677b23b3d38174dac43dda1052a7138d68",
32
+ "libraries/protocol/temp/package-deps.json": "1ed7faa57c156fc1b7ff9f13fe5566aacda70447",
33
+ "libraries/data-account/temp/package-deps.json": "9bfd92d0e975a4ad3f2e79ce68233e832865b579",
34
+ "libraries/data-order/temp/package-deps.json": "3495abc01b406b0c63a2725d361512a996a23a79",
35
+ "libraries/data-ohlc/temp/package-deps.json": "4d744c19879a13bbdb1959b5aef0cc1a5da7f726",
36
+ "libraries/transfer/temp/package-deps.json": "56f1b09fff53f23da4c19c0c71307cd636a4421f",
37
+ "libraries/utils/temp/package-deps.json": "018cb7f334c7419da6d55993eec202580b95f794",
38
+ "libraries/cache/temp/package-deps.json": "53c7e65e4fbefc731eef11e41145ecc3b90d9845",
39
+ "libraries/sql/temp/package-deps.json": "88cd4d4a8648dfa8d3aeec991aa734f9ab3374dc",
40
+ "libraries/data-product/temp/package-deps.json": "2b9736cd4a54002df2be4e72f9a4b9641aa71201",
41
+ "libraries/data-series/temp/package-deps.json": "ca8fb8d7fa67d7a77b7254eb785f4aa14c1d928c",
42
+ "libraries/data-interest-rate/temp/package-deps.json": "42fb3cc90524c7bba423d19f038add1ea2d1e4bd",
43
+ "libraries/data-quote/temp/package-deps.json": "ecee1e69820ccb2072ea6977a3971555e9e68e11",
44
+ "libraries/exchange/temp/package-deps.json": "522ed703d78091e161f719f0b0db4666c65316a8",
45
+ "libraries/extension/temp/package-deps.json": "454f577565ee01a0838c468fb1fc59e1f5d5f37c",
46
+ "tools/toolkit/temp/package-deps.json": "580f13201f076fa393117989256a2fee58e354f8"
47
47
  }
@@ -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,62 +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, newError } from '@yuants/utils';
16
- import { firstValueFrom, timer } from 'rxjs';
17
- import { getSwapHistoricalFundingRate } from '../../api/public-api';
18
- createSeriesProvider(Terminal.fromNodeEnv(), {
19
- tableName: 'interest_rate',
20
- series_id_prefix_parts: ['HTX'],
21
- reversed: true,
22
- serviceOptions: { concurrent: 10 },
23
- queryFn: function ({ series_id, started_at }) {
24
- return __asyncGenerator(this, arguments, function* () {
25
- const [, instType, contract_code] = decodePath(series_id);
26
- if (instType === 'SWAP') {
27
- let current_page = 0;
28
- let total_page = 1;
29
- while (true) {
30
- // 向前翻页,时间降序
31
- const res = yield __await(getSwapHistoricalFundingRate({
32
- contract_code: contract_code,
33
- page_index: current_page,
34
- }));
35
- if (res.status !== 'ok') {
36
- throw `API failed: ${res.status}`;
37
- }
38
- if (res.data.data.length === 0)
39
- break;
40
- yield yield __await(res.data.data.map((v) => ({
41
- series_id,
42
- datasource_id: 'HTX',
43
- product_id: series_id,
44
- created_at: formatTime(+v.funding_time),
45
- long_rate: `${-v.funding_rate}`,
46
- short_rate: `${v.funding_rate}`,
47
- settlement_price: '',
48
- })));
49
- total_page = res.data.total_page;
50
- current_page++;
51
- if (current_page >= total_page)
52
- break;
53
- if (+res.data.data[res.data.data.length - 1].funding_time <= started_at)
54
- break;
55
- yield __await(firstValueFrom(timer(1000)));
56
- }
57
- }
58
- throw newError('UNSUPPORTED_INST_TYPE', { instType });
59
- });
60
- },
61
- });
62
- //# sourceMappingURL=interest_rate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interest_rate.js","sourceRoot":"","sources":["../../../src/services/market-data/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,QAAQ,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,sBAAsB,CAAC;AAEpE,oBAAoB,CAAgB,QAAQ,CAAC,WAAW,EAAE,EAAE;IAC1D,SAAS,EAAE,eAAe;IAC1B,sBAAsB,EAAE,CAAC,KAAK,CAAC;IAC/B,QAAQ,EAAE,IAAI;IACd,cAAc,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;IAClC,OAAO,EAAE,UAAiB,EAAE,SAAS,EAAE,UAAU,EAAE;;YACjD,MAAM,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC;YAE1D,IAAI,QAAQ,KAAK,MAAM,EAAE;gBACvB,IAAI,YAAY,GAAG,CAAC,CAAC;gBACrB,IAAI,UAAU,GAAG,CAAC,CAAC;gBACnB,OAAO,IAAI,EAAE;oBACX,YAAY;oBACZ,MAAM,GAAG,GAAG,cAAM,4BAA4B,CAAC;wBAC7C,aAAa,EAAE,aAAa;wBAC5B,UAAU,EAAE,YAAY;qBACzB,CAAC,CAAA,CAAC;oBACH,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI,EAAE;wBACvB,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,CAAC;qBACnC;oBACD,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;wBAAE,MAAM;oBACtC,oBAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACrB,CAAC,CAAC,EAAiB,EAAE,CAAC,CAAC;wBACrB,SAAS;wBACT,aAAa,EAAE,KAAK;wBACpB,UAAU,EAAE,SAAS;wBACrB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;wBACvC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,YAAY,EAAE;wBAC/B,UAAU,EAAE,GAAG,CAAC,CAAC,YAAY,EAAE;wBAC/B,gBAAgB,EAAE,EAAE;qBACrB,CAAC,CACH,CAAA,CAAC;oBACF,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;oBACjC,YAAY,EAAE,CAAC;oBACf,IAAI,YAAY,IAAI,UAAU;wBAAE,MAAM;oBACtC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,UAAU;wBAAE,MAAM;oBAC/E,cAAM,cAAc,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA,CAAC;iBACnC;aACF;YACD,MAAM,QAAQ,CAAC,uBAAuB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QACxD,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, newError } from '@yuants/utils';\nimport { firstValueFrom, timer } from 'rxjs';\nimport { getSwapHistoricalFundingRate } from '../../api/public-api';\n\ncreateSeriesProvider<IInterestRate>(Terminal.fromNodeEnv(), {\n tableName: 'interest_rate',\n series_id_prefix_parts: ['HTX'],\n reversed: true,\n serviceOptions: { concurrent: 10 },\n queryFn: async function* ({ series_id, started_at }) {\n const [, instType, contract_code] = decodePath(series_id);\n\n if (instType === 'SWAP') {\n let current_page = 0;\n let total_page = 1;\n while (true) {\n // 向前翻页,时间降序\n const res = await getSwapHistoricalFundingRate({\n contract_code: contract_code,\n page_index: current_page,\n });\n if (res.status !== 'ok') {\n throw `API failed: ${res.status}`;\n }\n if (res.data.data.length === 0) break;\n yield res.data.data.map(\n (v): IInterestRate => ({\n series_id,\n datasource_id: 'HTX',\n product_id: series_id,\n created_at: formatTime(+v.funding_time),\n long_rate: `${-v.funding_rate}`,\n short_rate: `${v.funding_rate}`,\n settlement_price: '',\n }),\n );\n total_page = res.data.total_page;\n current_page++;\n if (current_page >= total_page) break;\n if (+res.data.data[res.data.data.length - 1].funding_time <= started_at) break;\n await firstValueFrom(timer(1000));\n }\n }\n throw newError('UNSUPPORTED_INST_TYPE', { instType });\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/market-data/interest_rate.ts"],"names":[],"mappings":""}
@@ -1,64 +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 rxjs_1 = require("rxjs");
19
- const public_api_1 = require("../../api/public-api");
20
- (0, data_series_1.createSeriesProvider)(protocol_1.Terminal.fromNodeEnv(), {
21
- tableName: 'interest_rate',
22
- series_id_prefix_parts: ['HTX'],
23
- reversed: true,
24
- serviceOptions: { concurrent: 10 },
25
- queryFn: function ({ series_id, started_at }) {
26
- return __asyncGenerator(this, arguments, function* () {
27
- const [, instType, contract_code] = (0, utils_1.decodePath)(series_id);
28
- if (instType === 'SWAP') {
29
- let current_page = 0;
30
- let total_page = 1;
31
- while (true) {
32
- // 向前翻页,时间降序
33
- const res = yield __await((0, public_api_1.getSwapHistoricalFundingRate)({
34
- contract_code: contract_code,
35
- page_index: current_page,
36
- }));
37
- if (res.status !== 'ok') {
38
- throw `API failed: ${res.status}`;
39
- }
40
- if (res.data.data.length === 0)
41
- break;
42
- yield yield __await(res.data.data.map((v) => ({
43
- series_id,
44
- datasource_id: 'HTX',
45
- product_id: series_id,
46
- created_at: (0, utils_1.formatTime)(+v.funding_time),
47
- long_rate: `${-v.funding_rate}`,
48
- short_rate: `${v.funding_rate}`,
49
- settlement_price: '',
50
- })));
51
- total_page = res.data.total_page;
52
- current_page++;
53
- if (current_page >= total_page)
54
- break;
55
- if (+res.data.data[res.data.data.length - 1].funding_time <= started_at)
56
- break;
57
- yield __await((0, rxjs_1.firstValueFrom)((0, rxjs_1.timer)(1000)));
58
- }
59
- }
60
- throw (0, utils_1.newError)('UNSUPPORTED_INST_TYPE', { instType });
61
- });
62
- },
63
- });
64
- //# sourceMappingURL=interest_rate.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"interest_rate.js","sourceRoot":"","sources":["../../../src/services/market-data/interest_rate.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AACA,qDAA2D;AAC3D,+CAA4C;AAC5C,yCAAiE;AACjE,+BAA6C;AAC7C,qDAAoE;AAEpE,IAAA,kCAAoB,EAAgB,mBAAQ,CAAC,WAAW,EAAE,EAAE;IAC1D,SAAS,EAAE,eAAe;IAC1B,sBAAsB,EAAE,CAAC,KAAK,CAAC;IAC/B,QAAQ,EAAE,IAAI;IACd,cAAc,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;IAClC,OAAO,EAAE,UAAiB,EAAE,SAAS,EAAE,UAAU,EAAE;;YACjD,MAAM,CAAC,EAAE,QAAQ,EAAE,aAAa,CAAC,GAAG,IAAA,kBAAU,EAAC,SAAS,CAAC,CAAC;YAE1D,IAAI,QAAQ,KAAK,MAAM,EAAE;gBACvB,IAAI,YAAY,GAAG,CAAC,CAAC;gBACrB,IAAI,UAAU,GAAG,CAAC,CAAC;gBACnB,OAAO,IAAI,EAAE;oBACX,YAAY;oBACZ,MAAM,GAAG,GAAG,cAAM,IAAA,yCAA4B,EAAC;wBAC7C,aAAa,EAAE,aAAa;wBAC5B,UAAU,EAAE,YAAY;qBACzB,CAAC,CAAA,CAAC;oBACH,IAAI,GAAG,CAAC,MAAM,KAAK,IAAI,EAAE;wBACvB,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,CAAC;qBACnC;oBACD,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,KAAK,CAAC;wBAAE,MAAM;oBACtC,oBAAM,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CACrB,CAAC,CAAC,EAAiB,EAAE,CAAC,CAAC;wBACrB,SAAS;wBACT,aAAa,EAAE,KAAK;wBACpB,UAAU,EAAE,SAAS;wBACrB,UAAU,EAAE,IAAA,kBAAU,EAAC,CAAC,CAAC,CAAC,YAAY,CAAC;wBACvC,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC,YAAY,EAAE;wBAC/B,UAAU,EAAE,GAAG,CAAC,CAAC,YAAY,EAAE;wBAC/B,gBAAgB,EAAE,EAAE;qBACrB,CAAC,CACH,CAAA,CAAC;oBACF,UAAU,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC;oBACjC,YAAY,EAAE,CAAC;oBACf,IAAI,YAAY,IAAI,UAAU;wBAAE,MAAM;oBACtC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,YAAY,IAAI,UAAU;wBAAE,MAAM;oBAC/E,cAAM,IAAA,qBAAc,EAAC,IAAA,YAAK,EAAC,IAAI,CAAC,CAAC,CAAA,CAAC;iBACnC;aACF;YACD,MAAM,IAAA,gBAAQ,EAAC,uBAAuB,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;QACxD,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, newError } from '@yuants/utils';\nimport { firstValueFrom, timer } from 'rxjs';\nimport { getSwapHistoricalFundingRate } from '../../api/public-api';\n\ncreateSeriesProvider<IInterestRate>(Terminal.fromNodeEnv(), {\n tableName: 'interest_rate',\n series_id_prefix_parts: ['HTX'],\n reversed: true,\n serviceOptions: { concurrent: 10 },\n queryFn: async function* ({ series_id, started_at }) {\n const [, instType, contract_code] = decodePath(series_id);\n\n if (instType === 'SWAP') {\n let current_page = 0;\n let total_page = 1;\n while (true) {\n // 向前翻页,时间降序\n const res = await getSwapHistoricalFundingRate({\n contract_code: contract_code,\n page_index: current_page,\n });\n if (res.status !== 'ok') {\n throw `API failed: ${res.status}`;\n }\n if (res.data.data.length === 0) break;\n yield res.data.data.map(\n (v): IInterestRate => ({\n series_id,\n datasource_id: 'HTX',\n product_id: series_id,\n created_at: formatTime(+v.funding_time),\n long_rate: `${-v.funding_rate}`,\n short_rate: `${v.funding_rate}`,\n settlement_price: '',\n }),\n );\n total_page = res.data.total_page;\n current_page++;\n if (current_page >= total_page) break;\n if (+res.data.data[res.data.data.length - 1].funding_time <= started_at) break;\n await firstValueFrom(timer(1000));\n }\n }\n throw newError('UNSUPPORTED_INST_TYPE', { instType });\n },\n});\n"]}