@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.
- package/dist/api/private-api.js +8 -0
- package/dist/api/private-api.js.map +1 -1
- package/dist/api/public-api.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/services/accounts/spot.js.map +1 -1
- package/dist/services/accounts/super-margin.js.map +1 -1
- package/dist/services/accounts/swap.js.map +1 -1
- package/dist/services/exchange.js +1 -1
- package/dist/services/exchange.js.map +1 -1
- package/dist/services/interest-ledger-service.js +63 -0
- package/dist/services/interest-ledger-service.js.map +1 -0
- package/dist/services/interest-rate-service.js.map +1 -1
- package/dist/services/market-data/quote.js.map +1 -1
- package/dist/services/ohlc-service.js.map +1 -1
- package/dist/services/orders/listOrders.js +2 -2
- package/dist/services/orders/listOrders.js.map +1 -1
- package/dist/services/orders/submitOrder.js +1 -1
- package/dist/services/orders/submitOrder.js.map +1 -1
- package/dist/services/product.js.map +1 -1
- package/lib/api/private-api.d.ts +61 -32
- package/lib/api/private-api.d.ts.map +1 -1
- package/lib/api/private-api.js +10 -1
- package/lib/api/private-api.js.map +1 -1
- package/lib/api/public-api.d.ts.map +1 -1
- package/lib/api/public-api.js +13 -13
- package/lib/api/public-api.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/services/accounts/spot.js.map +1 -1
- package/lib/services/accounts/super-margin.js.map +1 -1
- package/lib/services/accounts/swap.d.ts.map +1 -1
- package/lib/services/accounts/swap.js.map +1 -1
- package/lib/services/exchange.js +1 -1
- package/lib/services/exchange.js.map +1 -1
- package/lib/services/interest-ledger-service.d.ts +2 -0
- package/lib/services/interest-ledger-service.d.ts.map +1 -0
- package/lib/services/interest-ledger-service.js +65 -0
- package/lib/services/interest-ledger-service.js.map +1 -0
- package/lib/services/interest-rate-service.js.map +1 -1
- package/lib/services/market-data/quote.js.map +1 -1
- package/lib/services/ohlc-service.js.map +1 -1
- package/lib/services/orders/listOrders.d.ts.map +1 -1
- package/lib/services/orders/listOrders.js +2 -2
- package/lib/services/orders/listOrders.js.map +1 -1
- package/lib/services/orders/submitOrder.d.ts.map +1 -1
- package/lib/services/orders/submitOrder.js +1 -1
- package/lib/services/orders/submitOrder.js.map +1 -1
- package/lib/services/product.d.ts.map +1 -1
- package/lib/services/product.js.map +1 -1
- package/lib/tsdoc-metadata.json +1 -1
- package/package.json +43 -43
- package/temp/build/typescript/ts_pRZ94LVe.json +1 -0
- package/temp/package-deps.json +23 -23
- package/temp/test/jest/haste-map-fefe7499bc87b2b52172761a7fafd5ee-e0af843dfeade9e9ece596ee0c4ddcd4-4c5295047830cedf09a623a6f26c8535 +0 -0
- package/temp/vendor-huobi.api.json +18 -2
- package/dist/services/market-data/interest_rate.js +0 -62
- package/dist/services/market-data/interest_rate.js.map +0 -1
- package/lib/services/market-data/interest_rate.d.ts +0 -2
- package/lib/services/market-data/interest_rate.d.ts.map +0 -1
- package/lib/services/market-data/interest_rate.js +0 -64
- package/lib/services/market-data/interest_rate.js.map +0 -1
package/temp/package-deps.json
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
{
|
|
2
|
-
"apps/vendor-huobi/CHANGELOG.json": "
|
|
3
|
-
"apps/vendor-huobi/CHANGELOG.md": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
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": "
|
|
32
|
-
"libraries/protocol/temp/package-deps.json": "
|
|
33
|
-
"libraries/data-account/temp/package-deps.json": "
|
|
34
|
-
"libraries/data-order/temp/package-deps.json": "
|
|
35
|
-
"libraries/data-ohlc/temp/package-deps.json": "
|
|
36
|
-
"libraries/transfer/temp/package-deps.json": "
|
|
37
|
-
"libraries/utils/temp/package-deps.json": "
|
|
38
|
-
"libraries/cache/temp/package-deps.json": "
|
|
39
|
-
"libraries/sql/temp/package-deps.json": "
|
|
40
|
-
"libraries/data-product/temp/package-deps.json": "
|
|
41
|
-
"libraries/data-series/temp/package-deps.json": "
|
|
42
|
-
"libraries/data-interest-rate/temp/package-deps.json": "
|
|
43
|
-
"libraries/data-quote/temp/package-deps.json": "
|
|
44
|
-
"libraries/exchange/temp/package-deps.json": "
|
|
45
|
-
"libraries/extension/temp/package-deps.json": "
|
|
46
|
-
"tools/toolkit/temp/package-deps.json": "
|
|
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
|
}
|
|
Binary file
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"metadata": {
|
|
3
3
|
"toolPackage": "@microsoft/api-extractor",
|
|
4
|
-
"toolVersion": "7.
|
|
5
|
-
"schemaVersion":
|
|
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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C;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 +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,QAA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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"]}
|