@yuants/vendor-huobi 0.15.16 → 0.16.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 CHANGED
@@ -1,4 +1,5 @@
1
1
  import './services/exchange';
2
2
  import './services/market-data/interest_rate';
3
3
  import './services/market-data/quote';
4
+ import './services/quotes';
4
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,sCAAsC,CAAC;AAC9C,OAAO,8BAA8B,CAAC","sourcesContent":["import './services/exchange';\nimport './services/market-data/interest_rate';\nimport './services/market-data/quote';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,sCAAsC,CAAC;AAC9C,OAAO,8BAA8B,CAAC;AACtC,OAAO,mBAAmB,CAAC","sourcesContent":["import './services/exchange';\nimport './services/market-data/interest_rate';\nimport './services/market-data/quote';\nimport './services/quotes';\n"]}
@@ -0,0 +1,84 @@
1
+ import { provideQuoteService } from '@yuants/exchange';
2
+ import { Terminal } from '@yuants/protocol';
3
+ import { encodePath, formatTime } from '@yuants/utils';
4
+ import { getSpotMarketTickers, getSwapBatchFundingRate, getSwapMarketBbo, getSwapMarketTrade, getSwapOpenInterest, } from '../api/public-api';
5
+ const terminal = Terminal.fromNodeEnv();
6
+ provideQuoteService(terminal, {
7
+ product_id_prefix: 'HTX/SWAP/',
8
+ fields: ['ask_price', 'ask_volume', 'bid_price', 'bid_volume'],
9
+ }, async () => {
10
+ var _a;
11
+ const res = await getSwapMarketBbo({});
12
+ const updated_at = Date.now();
13
+ return ((_a = res.ticks) !== null && _a !== void 0 ? _a : []).map((tick) => {
14
+ const [ask_price = '', ask_volume = ''] = tick.ask || [];
15
+ const [bid_price = '', bid_volume = ''] = tick.bid || [];
16
+ return {
17
+ product_id: encodePath('HTX', 'SWAP', tick.contract_code),
18
+ updated_at,
19
+ ask_price: `${ask_price}`,
20
+ ask_volume: `${ask_volume}`,
21
+ bid_price: `${bid_price}`,
22
+ bid_volume: `${bid_volume}`,
23
+ };
24
+ });
25
+ });
26
+ provideQuoteService(terminal, {
27
+ product_id_prefix: 'HTX/SWAP/',
28
+ fields: ['last_price'],
29
+ }, async () => {
30
+ var _a, _b;
31
+ const res = await getSwapMarketTrade({});
32
+ const updated_at = Date.now();
33
+ return ((_b = (_a = res.tick) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : []).map((tick) => ({
34
+ product_id: encodePath('HTX', 'SWAP', tick.contract_code),
35
+ updated_at,
36
+ last_price: `${tick.price}`,
37
+ }));
38
+ });
39
+ provideQuoteService(terminal, {
40
+ product_id_prefix: 'HTX/SWAP/',
41
+ fields: ['interest_rate_long', 'interest_rate_short', 'interest_rate_next_settled_at'],
42
+ }, async (req) => {
43
+ var _a;
44
+ const res = await getSwapBatchFundingRate({});
45
+ const updated_at = Date.now();
46
+ return ((_a = res.data) !== null && _a !== void 0 ? _a : []).map((tick) => ({
47
+ product_id: encodePath('HTX', 'SWAP', tick.contract_code),
48
+ updated_at,
49
+ interest_rate_long: `${-Number(tick.funding_rate)}`,
50
+ interest_rate_short: `${Number(tick.funding_rate)}`,
51
+ interest_rate_next_settled_at: formatTime(+tick.funding_time),
52
+ }));
53
+ });
54
+ provideQuoteService(terminal, {
55
+ product_id_prefix: 'HTX/SWAP/',
56
+ fields: ['open_interest'],
57
+ }, async (req) => {
58
+ var _a;
59
+ const res = await getSwapOpenInterest({});
60
+ const updated_at = Date.now();
61
+ return ((_a = res.data) !== null && _a !== void 0 ? _a : []).map((tick) => ({
62
+ product_id: encodePath('HTX', 'SWAP', tick.contract_code),
63
+ updated_at,
64
+ open_interest: `${tick.volume}`,
65
+ }));
66
+ });
67
+ provideQuoteService(terminal, {
68
+ product_id_prefix: 'HTX/SPOT/',
69
+ fields: ['last_price', 'ask_price', 'ask_volume', 'bid_price', 'bid_volume'],
70
+ }, async () => {
71
+ var _a;
72
+ const res = await getSpotMarketTickers();
73
+ const updated_at = Date.now();
74
+ return ((_a = res.data) !== null && _a !== void 0 ? _a : []).map((tick) => ({
75
+ product_id: encodePath('HTX', 'SPOT', tick.symbol),
76
+ updated_at,
77
+ ask_price: `${tick.ask}`,
78
+ bid_price: `${tick.bid}`,
79
+ ask_volume: `${tick.askSize}`,
80
+ bid_volume: `${tick.bidSize}`,
81
+ last_price: `${tick.close}`,
82
+ }));
83
+ });
84
+ //# sourceMappingURL=quotes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quotes.js","sourceRoot":"","sources":["../../src/services/quotes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EACL,oBAAoB,EACpB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,mBAAmB,CAAC;AAE3B,MAAM,QAAQ,GAAG,QAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,mBAAmB,CACjB,QAAQ,EACR;IACE,iBAAiB,EAAE,WAAW;IAC9B,MAAM,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,CAAC;CAC/D,EACD,KAAK,IAAI,EAAE;;IACT,MAAM,GAAG,GAAG,MAAM,gBAAgB,CAAC,EAAE,CAAC,CAAC;IACvC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC9B,OAAO,CAAC,MAAA,GAAG,CAAC,KAAK,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAC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YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,WAAW,EAAE,YAAY,CAAC;CAC7E,EACD,KAAK,IAAI,EAAE;;IACT,MAAM,GAAG,GAAG,MAAM,oBAAoB,EAAE,CAAC;IACzC,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IAC9B,OAAO,CAAC,MAAA,GAAG,CAAC,IAAI,mCAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACrC,UAAU,EAAE,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;QAClD,UAAU;QACV,SAAS,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;QACxB,SAAS,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;QACxB,UAAU,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE;QAC7B,UAAU,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE;QAC7B,UAAU,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE;KAC5B,CAAC,CAAC,CAAC;AACN,CAAC,CACF,CAAC","sourcesContent":["import { provideQuoteService } from '@yuants/exchange';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport {\n getSpotMarketTickers,\n getSwapBatchFundingRate,\n getSwapMarketBbo,\n getSwapMarketTrade,\n getSwapOpenInterest,\n} from '../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'HTX/SWAP/',\n fields: ['ask_price', 'ask_volume', 'bid_price', 'bid_volume'],\n },\n async () => {\n const res = await getSwapMarketBbo({});\n const updated_at = Date.now();\n return (res.ticks ?? []).map((tick) => {\n const [ask_price = '', ask_volume = ''] = tick.ask || [];\n const [bid_price = '', bid_volume = ''] = tick.bid || [];\n return {\n product_id: encodePath('HTX', 'SWAP', tick.contract_code),\n updated_at,\n ask_price: `${ask_price}`,\n ask_volume: `${ask_volume}`,\n bid_price: `${bid_price}`,\n bid_volume: `${bid_volume}`,\n };\n });\n },\n);\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'HTX/SWAP/',\n fields: ['last_price'],\n },\n async () => {\n const res = await getSwapMarketTrade({});\n const updated_at = Date.now();\n return (res.tick?.data ?? []).map((tick) => ({\n product_id: encodePath('HTX', 'SWAP', tick.contract_code),\n updated_at,\n last_price: `${tick.price}`,\n }));\n },\n);\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'HTX/SWAP/',\n fields: ['interest_rate_long', 'interest_rate_short', 'interest_rate_next_settled_at'],\n },\n async (req) => {\n const res = await getSwapBatchFundingRate({});\n const updated_at = Date.now();\n return (res.data ?? []).map((tick) => ({\n product_id: encodePath('HTX', 'SWAP', tick.contract_code),\n updated_at,\n interest_rate_long: `${-Number(tick.funding_rate)}`,\n interest_rate_short: `${Number(tick.funding_rate)}`,\n interest_rate_next_settled_at: formatTime(+tick.funding_time),\n }));\n },\n);\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'HTX/SWAP/',\n fields: ['open_interest'],\n },\n async (req) => {\n const res = await getSwapOpenInterest({});\n const updated_at = Date.now();\n return (res.data ?? []).map((tick) => ({\n product_id: encodePath('HTX', 'SWAP', tick.contract_code),\n updated_at,\n open_interest: `${tick.volume}`,\n }));\n },\n);\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'HTX/SPOT/',\n fields: ['last_price', 'ask_price', 'ask_volume', 'bid_price', 'bid_volume'],\n },\n async () => {\n const res = await getSpotMarketTickers();\n const updated_at = Date.now();\n return (res.data ?? []).map((tick) => ({\n product_id: encodePath('HTX', 'SPOT', tick.symbol),\n updated_at,\n ask_price: `${tick.ask}`,\n bid_price: `${tick.bid}`,\n ask_volume: `${tick.askSize}`,\n bid_volume: `${tick.bidSize}`,\n last_price: `${tick.close}`,\n }));\n },\n);\n"]}
package/lib/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import './services/exchange';
2
2
  import './services/market-data/interest_rate';
3
3
  import './services/market-data/quote';
4
+ import './services/quotes';
4
5
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,sCAAsC,CAAC;AAC9C,OAAO,8BAA8B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,sCAAsC,CAAC;AAC9C,OAAO,8BAA8B,CAAC;AACtC,OAAO,mBAAmB,CAAC"}
package/lib/index.js CHANGED
@@ -3,4 +3,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("./services/exchange");
4
4
  require("./services/market-data/interest_rate");
5
5
  require("./services/market-data/quote");
6
+ require("./services/quotes");
6
7
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,+BAA6B;AAC7B,gDAA8C;AAC9C,wCAAsC","sourcesContent":["import './services/exchange';\nimport './services/market-data/interest_rate';\nimport './services/market-data/quote';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,+BAA6B;AAC7B,gDAA8C;AAC9C,wCAAsC;AACtC,6BAA2B","sourcesContent":["import './services/exchange';\nimport './services/market-data/interest_rate';\nimport './services/market-data/quote';\nimport './services/quotes';\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=quotes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quotes.d.ts","sourceRoot":"","sources":["../../src/services/quotes.ts"],"names":[],"mappings":""}
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const exchange_1 = require("@yuants/exchange");
4
+ const protocol_1 = require("@yuants/protocol");
5
+ const utils_1 = require("@yuants/utils");
6
+ const public_api_1 = require("../api/public-api");
7
+ const terminal = protocol_1.Terminal.fromNodeEnv();
8
+ (0, exchange_1.provideQuoteService)(terminal, {
9
+ product_id_prefix: 'HTX/SWAP/',
10
+ fields: ['ask_price', 'ask_volume', 'bid_price', 'bid_volume'],
11
+ }, async () => {
12
+ var _a;
13
+ const res = await (0, public_api_1.getSwapMarketBbo)({});
14
+ const updated_at = Date.now();
15
+ return ((_a = res.ticks) !== null && _a !== void 0 ? _a : []).map((tick) => {
16
+ const [ask_price = '', ask_volume = ''] = tick.ask || [];
17
+ const [bid_price = '', bid_volume = ''] = tick.bid || [];
18
+ return {
19
+ product_id: (0, utils_1.encodePath)('HTX', 'SWAP', tick.contract_code),
20
+ updated_at,
21
+ ask_price: `${ask_price}`,
22
+ ask_volume: `${ask_volume}`,
23
+ bid_price: `${bid_price}`,
24
+ bid_volume: `${bid_volume}`,
25
+ };
26
+ });
27
+ });
28
+ (0, exchange_1.provideQuoteService)(terminal, {
29
+ product_id_prefix: 'HTX/SWAP/',
30
+ fields: ['last_price'],
31
+ }, async () => {
32
+ var _a, _b;
33
+ const res = await (0, public_api_1.getSwapMarketTrade)({});
34
+ const updated_at = Date.now();
35
+ return ((_b = (_a = res.tick) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : []).map((tick) => ({
36
+ product_id: (0, utils_1.encodePath)('HTX', 'SWAP', tick.contract_code),
37
+ updated_at,
38
+ last_price: `${tick.price}`,
39
+ }));
40
+ });
41
+ (0, exchange_1.provideQuoteService)(terminal, {
42
+ product_id_prefix: 'HTX/SWAP/',
43
+ fields: ['interest_rate_long', 'interest_rate_short', 'interest_rate_next_settled_at'],
44
+ }, async (req) => {
45
+ var _a;
46
+ const res = await (0, public_api_1.getSwapBatchFundingRate)({});
47
+ const updated_at = Date.now();
48
+ return ((_a = res.data) !== null && _a !== void 0 ? _a : []).map((tick) => ({
49
+ product_id: (0, utils_1.encodePath)('HTX', 'SWAP', tick.contract_code),
50
+ updated_at,
51
+ interest_rate_long: `${-Number(tick.funding_rate)}`,
52
+ interest_rate_short: `${Number(tick.funding_rate)}`,
53
+ interest_rate_next_settled_at: (0, utils_1.formatTime)(+tick.funding_time),
54
+ }));
55
+ });
56
+ (0, exchange_1.provideQuoteService)(terminal, {
57
+ product_id_prefix: 'HTX/SWAP/',
58
+ fields: ['open_interest'],
59
+ }, async (req) => {
60
+ var _a;
61
+ const res = await (0, public_api_1.getSwapOpenInterest)({});
62
+ const updated_at = Date.now();
63
+ return ((_a = res.data) !== null && _a !== void 0 ? _a : []).map((tick) => ({
64
+ product_id: (0, utils_1.encodePath)('HTX', 'SWAP', tick.contract_code),
65
+ updated_at,
66
+ open_interest: `${tick.volume}`,
67
+ }));
68
+ });
69
+ (0, exchange_1.provideQuoteService)(terminal, {
70
+ product_id_prefix: 'HTX/SPOT/',
71
+ fields: ['last_price', 'ask_price', 'ask_volume', 'bid_price', 'bid_volume'],
72
+ }, async () => {
73
+ var _a;
74
+ const res = await (0, public_api_1.getSpotMarketTickers)();
75
+ const updated_at = Date.now();
76
+ return ((_a = res.data) !== null && _a !== void 0 ? _a : []).map((tick) => ({
77
+ product_id: (0, utils_1.encodePath)('HTX', 'SPOT', tick.symbol),
78
+ updated_at,
79
+ ask_price: `${tick.ask}`,
80
+ bid_price: `${tick.bid}`,
81
+ ask_volume: `${tick.askSize}`,
82
+ bid_volume: `${tick.bidSize}`,
83
+ last_price: `${tick.close}`,
84
+ }));
85
+ });
86
+ //# sourceMappingURL=quotes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quotes.js","sourceRoot":"","sources":["../../src/services/quotes.ts"],"names":[],"mappings":";;AAAA,+CAAuD;AACvD,+CAA4C;AAC5C,yCAAuD;AACvD,kDAM2B;AAE3B,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,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';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport {\n getSpotMarketTickers,\n getSwapBatchFundingRate,\n getSwapMarketBbo,\n getSwapMarketTrade,\n getSwapOpenInterest,\n} from '../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'HTX/SWAP/',\n fields: ['ask_price', 'ask_volume', 'bid_price', 'bid_volume'],\n },\n async () => {\n const res = await getSwapMarketBbo({});\n const updated_at = Date.now();\n return (res.ticks ?? []).map((tick) => {\n const [ask_price = '', ask_volume = ''] = tick.ask || [];\n const [bid_price = '', bid_volume = ''] = tick.bid || [];\n return {\n product_id: encodePath('HTX', 'SWAP', tick.contract_code),\n updated_at,\n ask_price: `${ask_price}`,\n ask_volume: `${ask_volume}`,\n bid_price: `${bid_price}`,\n bid_volume: `${bid_volume}`,\n };\n });\n },\n);\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'HTX/SWAP/',\n fields: ['last_price'],\n },\n async () => {\n const res = await getSwapMarketTrade({});\n const updated_at = Date.now();\n return (res.tick?.data ?? []).map((tick) => ({\n product_id: encodePath('HTX', 'SWAP', tick.contract_code),\n updated_at,\n last_price: `${tick.price}`,\n }));\n },\n);\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'HTX/SWAP/',\n fields: ['interest_rate_long', 'interest_rate_short', 'interest_rate_next_settled_at'],\n },\n async (req) => {\n const res = await getSwapBatchFundingRate({});\n const updated_at = Date.now();\n return (res.data ?? []).map((tick) => ({\n product_id: encodePath('HTX', 'SWAP', tick.contract_code),\n updated_at,\n interest_rate_long: `${-Number(tick.funding_rate)}`,\n interest_rate_short: `${Number(tick.funding_rate)}`,\n interest_rate_next_settled_at: formatTime(+tick.funding_time),\n }));\n },\n);\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'HTX/SWAP/',\n fields: ['open_interest'],\n },\n async (req) => {\n const res = await getSwapOpenInterest({});\n const updated_at = Date.now();\n return (res.data ?? []).map((tick) => ({\n product_id: encodePath('HTX', 'SWAP', tick.contract_code),\n updated_at,\n open_interest: `${tick.volume}`,\n }));\n },\n);\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'HTX/SPOT/',\n fields: ['last_price', 'ask_price', 'ask_volume', 'bid_price', 'bid_volume'],\n },\n async () => {\n const res = await getSpotMarketTickers();\n const updated_at = Date.now();\n return (res.data ?? []).map((tick) => ({\n product_id: encodePath('HTX', 'SPOT', tick.symbol),\n updated_at,\n ask_price: `${tick.ask}`,\n bid_price: `${tick.bid}`,\n ask_volume: `${tick.askSize}`,\n bid_volume: `${tick.bidSize}`,\n last_price: `${tick.close}`,\n }));\n },\n);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuants/vendor-huobi",
3
- "version": "0.15.16",
3
+ "version": "0.16.0",
4
4
  "main": "lib/index.js",
5
5
  "files": [
6
6
  "dist",
@@ -1,19 +1,19 @@
1
1
  {
2
- "apps/vendor-huobi/CHANGELOG.json": "c683eeee2f9fbfd995f615f13c252b777ee8ea69",
3
- "apps/vendor-huobi/CHANGELOG.md": "d3b765a48f4555de4630fd70f28d26f69aaa0fc9",
2
+ "apps/vendor-huobi/CHANGELOG.json": "d7bb6eb74c962585fae85ac4169da5b165bd95d8",
3
+ "apps/vendor-huobi/CHANGELOG.md": "ff639e3a38beab822e0bb79cf7a15147c3cb2fa4",
4
4
  "apps/vendor-huobi/README.md": "d7bf0149513114eab5500a6b5c9e7cba10565572",
5
5
  "apps/vendor-huobi/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": "d259e04c0d61188aa7e2b73d7d1482da754ca333",
10
+ "apps/vendor-huobi/package.json": "f528db64d53f3049d21d814ee07fe026c4ef8320",
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": "6c9422f767b120a5ab45d65f2e38243a3a4851f5",
15
15
  "apps/vendor-huobi/src/api/public-api.ts": "c8c6c380118d1282d16a3b5342060f3f82ed14af",
16
- "apps/vendor-huobi/src/index.ts": "b0fa28ef4e008320564a0ddc789104f398160a0a",
16
+ "apps/vendor-huobi/src/index.ts": "d3979bbfa38c0b88be8854dbdea2d7833c89ec9c",
17
17
  "apps/vendor-huobi/src/services/accounts/spot.ts": "9b214135dd375822ea5ef03c0fee108873ccc264",
18
18
  "apps/vendor-huobi/src/services/accounts/super-margin.ts": "ff885947334f43085aacb6e8c37b997afee2b7f6",
19
19
  "apps/vendor-huobi/src/services/accounts/swap.ts": "91ef044f09ed3dddd7b0d32116a16c78f74ba9be",
@@ -23,6 +23,7 @@
23
23
  "apps/vendor-huobi/src/services/orders/listOrders.ts": "1cf4621727fb290f8e5fd1439765fd73387bda7a",
24
24
  "apps/vendor-huobi/src/services/orders/submitOrder.ts": "876e70b541246b5fb5b50957880a6ae17179cf0b",
25
25
  "apps/vendor-huobi/src/services/product.ts": "096feb6e1348910242e814ca45848afa3b5bff98",
26
+ "apps/vendor-huobi/src/services/quotes.ts": "a99185c9d2e95da220919deef49357ec6280ee78",
26
27
  "apps/vendor-huobi/src/services/uid.ts": "b71c27a6a0debdd9365dea35306f4763327aca2f",
27
28
  "apps/vendor-huobi/tsconfig.json": "81da8f78196974b5d15da0edb6b2d9f48641063c",
28
29
  "apps/vendor-huobi/.rush/temp/shrinkwrap-deps.json": "3099afcf246e8bc9ff02db11dd7b34b8bd1e72d9",