@yuants/vendor-huobi 0.18.13 → 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/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/lib/index.d.ts +0 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -1
- package/lib/index.js.map +1 -1
- package/package.json +10 -10
- package/temp/build/typescript/ts_pRZ94LVe.json +1 -1
- package/temp/package-deps.json +4 -5
- package/temp/test/jest/haste-map-fefe7499bc87b2b52172761a7fafd5ee-e0af843dfeade9e9ece596ee0c4ddcd4-4c5295047830cedf09a623a6f26c8535 +0 -0
- package/dist/services/market-data/interest_rate.js +0 -63
- 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 -65
- package/lib/services/market-data/interest_rate.js.map +0 -1
package/temp/package-deps.json
CHANGED
|
@@ -1,26 +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
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
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
21
|
"apps/vendor-huobi/src/services/interest-ledger-service.ts": "496a282904f921d923c866e817e3af8db430101d",
|
|
22
22
|
"apps/vendor-huobi/src/services/interest-rate-service.ts": "3180227cd8fe336e187ad7a90bf3ce1bb7dfc7f7",
|
|
23
|
-
"apps/vendor-huobi/src/services/market-data/interest_rate.ts": "79aa362f9fa90e612f9813d0b45d357b96189f3e",
|
|
24
23
|
"apps/vendor-huobi/src/services/market-data/quote.ts": "2f5883a95b11cf19c1a9a595567f9369b360cccf",
|
|
25
24
|
"apps/vendor-huobi/src/services/ohlc-service.ts": "914f75705e0ad396b537e4b55334419206526160",
|
|
26
25
|
"apps/vendor-huobi/src/services/orders/listOrders.ts": "1cf4621727fb290f8e5fd1439765fd73387bda7a",
|
|
Binary file
|
|
@@ -1,63 +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, newError } from '@yuants/utils';
|
|
17
|
-
import { firstValueFrom, timer } from 'rxjs';
|
|
18
|
-
import { getSwapHistoricalFundingRate } from '../../api/public-api';
|
|
19
|
-
createSeriesProvider(Terminal.fromNodeEnv(), {
|
|
20
|
-
tableName: 'interest_rate',
|
|
21
|
-
series_id_prefix_parts: ['HTX'],
|
|
22
|
-
reversed: true,
|
|
23
|
-
serviceOptions: { concurrent: 10 },
|
|
24
|
-
queryFn: function (_a) {
|
|
25
|
-
return __asyncGenerator(this, arguments, function* ({ series_id, started_at }) {
|
|
26
|
-
const [, instType, contract_code] = decodePath(series_id);
|
|
27
|
-
if (instType === 'SWAP') {
|
|
28
|
-
let current_page = 0;
|
|
29
|
-
let total_page = 1;
|
|
30
|
-
while (true) {
|
|
31
|
-
// 向前翻页,时间降序
|
|
32
|
-
const res = yield __await(getSwapHistoricalFundingRate({
|
|
33
|
-
contract_code: contract_code,
|
|
34
|
-
page_index: current_page,
|
|
35
|
-
}));
|
|
36
|
-
if (res.status !== 'ok') {
|
|
37
|
-
throw `API failed: ${res.status}`;
|
|
38
|
-
}
|
|
39
|
-
if (res.data.data.length === 0)
|
|
40
|
-
break;
|
|
41
|
-
yield yield __await(res.data.data.map((v) => ({
|
|
42
|
-
series_id,
|
|
43
|
-
datasource_id: 'HTX',
|
|
44
|
-
product_id: series_id,
|
|
45
|
-
created_at: formatTime(+v.funding_time),
|
|
46
|
-
long_rate: `${-v.funding_rate}`,
|
|
47
|
-
short_rate: `${v.funding_rate}`,
|
|
48
|
-
settlement_price: '',
|
|
49
|
-
})));
|
|
50
|
-
total_page = res.data.total_page;
|
|
51
|
-
current_page++;
|
|
52
|
-
if (current_page >= total_page)
|
|
53
|
-
break;
|
|
54
|
-
if (+res.data.data[res.data.data.length - 1].funding_time <= started_at)
|
|
55
|
-
break;
|
|
56
|
-
yield __await(firstValueFrom(timer(1000)));
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
throw newError('UNSUPPORTED_INST_TYPE', { instType });
|
|
60
|
-
});
|
|
61
|
-
},
|
|
62
|
-
});
|
|
63
|
-
//# 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;4DAAiB,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,CAAC;gBACxB,IAAI,YAAY,GAAG,CAAC,CAAC;gBACrB,IAAI,UAAU,GAAG,CAAC,CAAC;gBACnB,OAAO,IAAI,EAAE,CAAC;oBACZ,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,CAAC;wBACxB,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,CAAC;oBACpC,CAAC;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;gBACpC,CAAC;YACH,CAAC;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,65 +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 rxjs_1 = require("rxjs");
|
|
20
|
-
const public_api_1 = require("../../api/public-api");
|
|
21
|
-
(0, data_series_1.createSeriesProvider)(protocol_1.Terminal.fromNodeEnv(), {
|
|
22
|
-
tableName: 'interest_rate',
|
|
23
|
-
series_id_prefix_parts: ['HTX'],
|
|
24
|
-
reversed: true,
|
|
25
|
-
serviceOptions: { concurrent: 10 },
|
|
26
|
-
queryFn: function (_a) {
|
|
27
|
-
return __asyncGenerator(this, arguments, function* ({ series_id, started_at }) {
|
|
28
|
-
const [, instType, contract_code] = (0, utils_1.decodePath)(series_id);
|
|
29
|
-
if (instType === 'SWAP') {
|
|
30
|
-
let current_page = 0;
|
|
31
|
-
let total_page = 1;
|
|
32
|
-
while (true) {
|
|
33
|
-
// 向前翻页,时间降序
|
|
34
|
-
const res = yield __await((0, public_api_1.getSwapHistoricalFundingRate)({
|
|
35
|
-
contract_code: contract_code,
|
|
36
|
-
page_index: current_page,
|
|
37
|
-
}));
|
|
38
|
-
if (res.status !== 'ok') {
|
|
39
|
-
throw `API failed: ${res.status}`;
|
|
40
|
-
}
|
|
41
|
-
if (res.data.data.length === 0)
|
|
42
|
-
break;
|
|
43
|
-
yield yield __await(res.data.data.map((v) => ({
|
|
44
|
-
series_id,
|
|
45
|
-
datasource_id: 'HTX',
|
|
46
|
-
product_id: series_id,
|
|
47
|
-
created_at: (0, utils_1.formatTime)(+v.funding_time),
|
|
48
|
-
long_rate: `${-v.funding_rate}`,
|
|
49
|
-
short_rate: `${v.funding_rate}`,
|
|
50
|
-
settlement_price: '',
|
|
51
|
-
})));
|
|
52
|
-
total_page = res.data.total_page;
|
|
53
|
-
current_page++;
|
|
54
|
-
if (current_page >= total_page)
|
|
55
|
-
break;
|
|
56
|
-
if (+res.data.data[res.data.data.length - 1].funding_time <= started_at)
|
|
57
|
-
break;
|
|
58
|
-
yield __await((0, rxjs_1.firstValueFrom)((0, rxjs_1.timer)(1000)));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
throw (0, utils_1.newError)('UNSUPPORTED_INST_TYPE', { instType });
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
//# 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;4DAAiB,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,CAAC;gBACxB,IAAI,YAAY,GAAG,CAAC,CAAC;gBACrB,IAAI,UAAU,GAAG,CAAC,CAAC;gBACnB,OAAO,IAAI,EAAE,CAAC;oBACZ,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,CAAC;wBACxB,MAAM,eAAe,GAAG,CAAC,MAAM,EAAE,CAAC;oBACpC,CAAC;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;gBACpC,CAAC;YACH,CAAC;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"]}
|