@yuants/vendor-huobi 0.15.4 → 0.15.6
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/public-api.js +7 -0
- package/dist/api/public-api.js.map +1 -1
- package/dist/services/accounts/spot.js +17 -11
- package/dist/services/accounts/spot.js.map +1 -1
- package/dist/services/accounts/super-margin.js +18 -44
- package/dist/services/accounts/super-margin.js.map +1 -1
- package/dist/services/accounts/swap.js +20 -11
- package/dist/services/accounts/swap.js.map +1 -1
- package/dist/services/market-data/quote.js +21 -3
- package/dist/services/market-data/quote.js.map +1 -1
- package/dist/services/orders/submitOrder.js +5 -7
- package/dist/services/orders/submitOrder.js.map +1 -1
- package/dist/services/product.js +2 -4
- package/dist/services/product.js.map +1 -1
- package/lib/api/public-api.d.ts +24 -0
- package/lib/api/public-api.d.ts.map +1 -1
- package/lib/api/public-api.js +9 -1
- package/lib/api/public-api.js.map +1 -1
- package/lib/services/accounts/spot.d.ts.map +1 -1
- package/lib/services/accounts/spot.js +17 -11
- package/lib/services/accounts/spot.js.map +1 -1
- package/lib/services/accounts/super-margin.d.ts.map +1 -1
- package/lib/services/accounts/super-margin.js +17 -43
- 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 +19 -10
- package/lib/services/accounts/swap.js.map +1 -1
- package/lib/services/market-data/quote.d.ts +2 -1
- package/lib/services/market-data/quote.d.ts.map +1 -1
- package/lib/services/market-data/quote.js +20 -1
- package/lib/services/market-data/quote.js.map +1 -1
- package/lib/services/orders/submitOrder.d.ts.map +1 -1
- package/lib/services/orders/submitOrder.js +4 -6
- package/lib/services/orders/submitOrder.js.map +1 -1
- package/lib/services/product.d.ts +1 -1
- package/lib/services/product.d.ts.map +1 -1
- package/lib/services/product.js +2 -4
- package/lib/services/product.js.map +1 -1
- package/package.json +3 -3
- package/temp/package-deps.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submitOrder.js","sourceRoot":"","sources":["../../../src/services/orders/submitOrder.ts"],"names":[],"mappings":";;;AACA,yCAA8E;AAC9E
|
|
1
|
+
{"version":3,"file":"submitOrder.js","sourceRoot":"","sources":["../../../src/services/orders/submitOrder.ts"],"names":[],"mappings":";;;AACA,yCAA8E;AAC9E,uDAO+B;AAC/B,qDAAmD;AACnD,wCAA0C;AAC1C,gCAAoD;AAEpD;;GAEG;AACH,KAAK,UAAU,eAAe,CAAC,KAAa,EAAE,UAAuB;;IACnE,SAAS;IACT,MAAM,YAAY,GAAG,MAAM,IAAA,sCAAwB,EAAC,UAAU,CAAC,CAAC;IAChE,MAAM,qBAAqB,GAAG,MAAM,CAAC,WAAW,CAC9C,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAC9D,CAAC;IAEF,MAAM,UAAU,GAAG,MAAA,qBAAqB,CAAC,KAAK,CAAC,UAAU,CAAC,mCAAI,EAAE,CAAC;IACjE,MAAM,MAAM,GAAG;QACb,aAAa,EAAE,KAAK,CAAC,UAAU;QAC/B,aAAa,EAAE,MAAM;QACrB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,MAAM,EACJ,KAAK,CAAC,eAAe,KAAK,WAAW,IAAI,KAAK,CAAC,eAAe,KAAK,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;QACpG,SAAS,EACP,KAAK,CAAC,eAAe,KAAK,WAAW,IAAI,KAAK,CAAC,eAAe,KAAK,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM;QACnG,kCAAkC;QAClC,UAAU;QACV,gBAAgB,EAAE,KAAK,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC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nG,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,IAAA,kBAAU,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAClD,IAAI,QAAQ,KAAK,MAAM,EAAE;QACvB,OAAO,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;KAC3C;IACD,IAAI,QAAQ,KAAK,cAAc,EAAE;QAC/B,OAAO,sBAAsB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;KAClD;IACD,MAAM,IAAA,gBAAQ,EAAC,uBAAuB,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;AACpE,CAAC,CAAC;AATW,QAAA,WAAW,eAStB","sourcesContent":["import { IOrder } from '@yuants/data-order';\nimport { decodePath, formatTime, newError, roundToStep } from '@yuants/utils';\nimport {\n ICredential,\n getCrossMarginLoanInfo,\n getSpotAccountBalance,\n getSwapCrossPositionInfo,\n postSpotOrder,\n postSwapOrder,\n} from '../../api/private-api';\nimport { getSpotTick } from '../../api/public-api';\nimport { productCache } from '../product';\nimport { superMarginAccountUidCache } from '../uid';\n\n/**\n * 处理 swap 账户订单提交\n */\nasync function handleSwapOrder(order: IOrder, credential: ICredential): Promise<{ order_id: string }> {\n // 获取仓位信息\n const positionInfo = await getSwapCrossPositionInfo(credential);\n const mapContractCodeToRate = Object.fromEntries(\n positionInfo.data.map((v) => [v.contract_code, v.lever_rate]),\n );\n\n const lever_rate = mapContractCodeToRate[order.product_id] ?? 20;\n const params = {\n contract_code: order.product_id,\n contract_type: 'swap',\n price: order.price,\n volume: order.volume,\n offset:\n order.order_direction === 'OPEN_LONG' || order.order_direction === 'OPEN_SHORT' ? 'open' : 'close',\n direction:\n order.order_direction === 'OPEN_LONG' || order.order_direction === 'CLOSE_SHORT' ? 'buy' : 'sell',\n // dynamically adjust the leverage\n lever_rate,\n order_price_type: order.order_type === 'MARKET' ? 'market' : 'limit',\n };\n\n const result = await postSwapOrder(credential, params);\n console.info(formatTime(Date.now()), 'SubmitOrder', JSON.stringify(result), JSON.stringify(params));\n\n if (result.status !== 'ok') {\n throw new Error(`Failed to submit swap order: status=${result.status}`);\n }\n return { order_id: result.data.order_id_str };\n}\n\n/**\n * 处理 super-margin 账户订单提交\n */\nasync function handleSuperMarginOrder(order: IOrder, credential: ICredential): Promise<{ order_id: string }> {\n // 获取可贷款金额\n const superMarginAccountUid = await superMarginAccountUidCache.query(JSON.stringify(credential));\n if (!superMarginAccountUid) throw new Error('Super margin account UID not found');\n const loanInfo = await getCrossMarginLoanInfo(credential);\n const usdtLoanable = loanInfo.data.find((v) => v.currency === 'usdt');\n if (!usdtLoanable) throw new Error('USDT loanable amount not found');\n const loanable = +usdtLoanable['loanable-amt'];\n\n // 获取账户余额, 产品信息和价格\n const [balanceRes, theProduct, priceRes] = await Promise.all([\n getSpotAccountBalance(credential, superMarginAccountUid),\n productCache.query(order.product_id),\n getSpotTick({ symbol: order.product_id }),\n ]);\n\n const balance = balanceRes.data.list\n .filter((v) => v.currency === 'usdt' && v.type === 'trade')\n .reduce((acc, cur) => acc + +cur.balance, 0);\n\n if (!theProduct) throw newError('HUOBI_SUBMIT_ORDER_PRODUCT_NOT_FOUND', { product_id: order.product_id });\n\n const price = priceRes.tick.close;\n const borrow_amount =\n order.order_direction === 'OPEN_LONG' || order.order_direction === 'CLOSE_SHORT'\n ? Math.max(Math.min(loanable, order.volume * price - balance), 0)\n : undefined;\n\n const params = {\n symbol: order.product_id,\n 'account-id': '' + superMarginAccountUid,\n amount:\n '' +\n (order.order_direction === 'OPEN_LONG' || order.order_direction === 'CLOSE_SHORT'\n ? roundToStep(order.volume * price, theProduct?.volume_step!)\n : order.volume),\n 'borrow-amount': '' + borrow_amount,\n type: `${\n order.order_direction === 'OPEN_LONG' || order.order_direction === 'CLOSE_SHORT' ? 'buy' : 'sell'\n }-${'LIMIT' === order.order_type ? 'limit' : 'market'}`,\n 'trade-purpose':\n order.order_direction === 'OPEN_LONG' || order.order_direction === 'CLOSE_SHORT'\n ? '1' // auto borrow\n : '2', // auto repay\n price: order.order_type === 'MARKET' ? undefined : '' + order.price,\n source: 'super-margin-api',\n };\n\n const result = await postSpotOrder(credential, params);\n console.info(formatTime(Date.now()), 'SubmitOrder', JSON.stringify(result), JSON.stringify(params));\n\n if (result.success === false) {\n throw new Error(`Failed to submit super margin order: code=${result.code} message=${result.message}`);\n }\n\n return { order_id: result.data.orderId.toString() };\n}\n\nexport const submitOrder = (credential: ICredential, order: IOrder): Promise<{ order_id: string }> => {\n const [, instType] = decodePath(order.product_id);\n if (instType === 'SWAP') {\n return handleSwapOrder(order, credential);\n }\n if (instType === 'SUPER-MARGIN') {\n return handleSuperMarginOrder(order, credential);\n }\n throw newError('UNSUPPORTED_INST_TYPE', { order_type: instType });\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { IProduct } from '@yuants/data-product';
|
|
2
2
|
export declare const listProducts: () => Promise<IProduct[]>;
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const productCache: import("@yuants/cache").ICache<IProduct>;
|
|
4
4
|
//# sourceMappingURL=product.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product.d.ts","sourceRoot":"","sources":["../../src/services/product.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"product.d.ts","sourceRoot":"","sources":["../../src/services/product.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAoFpE,eAAO,MAAM,YAAY,QAAa,QAAQ,QAAQ,EAAE,CAGvD,CAAC;AAEF,eAAO,MAAM,YAAY,0CAA+B,CAAC"}
|
package/lib/services/product.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.productCache = exports.listProducts = void 0;
|
|
4
4
|
const data_product_1 = require("@yuants/data-product");
|
|
5
5
|
const protocol_1 = require("@yuants/protocol");
|
|
6
6
|
const utils_1 = require("@yuants/utils");
|
|
@@ -78,7 +78,5 @@ const listProducts = async () => {
|
|
|
78
78
|
return [...swapProducts, ...spotProducts];
|
|
79
79
|
};
|
|
80
80
|
exports.listProducts = listProducts;
|
|
81
|
-
exports.
|
|
82
|
-
auto_refresh_interval: 3600000,
|
|
83
|
-
});
|
|
81
|
+
exports.productCache = (0, data_product_1.createProductCache)(terminal);
|
|
84
82
|
//# sourceMappingURL=product.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product.js","sourceRoot":"","sources":["../../src/services/product.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"product.js","sourceRoot":"","sources":["../../src/services/product.ts"],"names":[],"mappings":";;;AAAA,uDAAoE;AACpE,+CAA4C;AAC5C,yCAA2C;AAC3C,kDAA0G;AAE1G,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,kDAAkD;AAClD,MAAM,gBAAgB,GAAG,KAAK,IAAyB,EAAE;;IACvD,MAAM,QAAQ,GAAe,EAAE,CAAC;IAEhC,sEAAsE;IACtE,MAAM,CAAC,WAAW,EAAE,aAAa,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;QACrD,IAAA,wCAA2B,GAAE;QAC7B,IAAA,qCAAwB,GAAE;KAC3B,CAAC,CAAC;IAEH,KAAK,MAAM,MAAM,IAAI,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,IAAI,KAAI,EAAE,EAAE;QAC5C,IAAI,MAAM,CAAC,eAAe,KAAK,CAAC;YAAE,SAAS,CAAC,gCAAgC;QAE5E,MAAM,WAAW,GAAG,MAAA,aAAa,aAAb,aAAa,uBAAb,aAAa,CAAE,IAAI,CACpC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,KAAK,MAAM,CAAC,aAAa,CAAC,0CACpD,IAAI,CAAC,M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AAU,EAAC,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;YAChD,aAAa,EAAE,MAAM,CAAC,EAAE;YACxB,cAAc,EAAE,MAAM,CAAC,EAAE;YACzB,WAAW,EAAE,CAAC;YACd,UAAU,EAAE,CAAC,GAAG,EAAE,IAAI,MAAM,CAAC,GAAG;YAChC,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,MAAM,CAAC,GAAG;YACjC,IAAI,EAAE,EAAE;YACR,gBAAgB,EAAE,EAAE;YACpB,WAAW,EAAE,CAAC;YACd,gBAAgB,EAAE,CAAC;YACnB,iBAAiB,EAAE,CAAC;YACpB,YAAY,EAAE,CAAC;YACf,UAAU,EAAE,CAAC;YACb,UAAU,EAAE,IAAI;YAChB,WAAW,EAAE,KAAK;YAClB,SAAS,EAAE,YAAY;YACvB,gBAAgB,EAAE,IAAI;SACvB,CAAC,CAAC;KACJ;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC;AAEK,MAAM,YAAY,GAAG,KAAK,IAAyB,EAAE;IAC1D,MAAM,CAAC,YAAY,EAAE,YAAY,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,CAAC,gBAAgB,EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC,CAAC;IACjG,OAAO,CAAC,GAAG,YAAY,EAAE,GAAG,YAAY,CAAC,CAAC;AAC5C,CAAC,CAAC;AAHW,QAAA,YAAY,gBAGvB;AAEW,QAAA,YAAY,GAAG,IAAA,iCAAkB,EAAC,QAAQ,CAAC,CAAC","sourcesContent":["import { createProductCache, IProduct } from '@yuants/data-product';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { getPerpetualContractSymbols, getSpotSymbols, getSwapCrossLadderMargin } from '../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\n// Provide QueryProducts service for swap products\nconst listSwapProducts = async (): Promise<IProduct[]> => {\n const products: IProduct[] = [];\n\n // Get perpetual contract products and cross leverage data in parallel\n const [swapSymbols, crossLeverage] = await Promise.all([\n getPerpetualContractSymbols(),\n getSwapCrossLadderMargin(),\n ]);\n\n for (const symbol of swapSymbols?.data || []) {\n if (symbol.contract_status !== 1) continue; // Only include active contracts\n\n const maxLeverage = crossLeverage?.data\n .find((x) => x.contract_code === symbol.contract_code)\n ?.list.reduce((acc, cur) => Math.max(acc, cur.lever_rate), 1);\n\n products.push({\n datasource_id: 'HTX',\n product_id: encodePath('HTX', 'SWAP', symbol.contract_code),\n base_currency: symbol.symbol,\n quote_currency: 'USDT',\n value_scale: symbol.contract_size,\n price_step: symbol.price_tick,\n volume_step: 1,\n name: '',\n value_scale_unit: '',\n margin_rate: 1 / (maxLeverage || 1),\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: true,\n market_id: 'HTX',\n no_interest_rate: false,\n });\n }\n\n return products;\n};\n\n// Provide QueryProducts service for spot products\nconst listSpotProducts = async (): Promise<IProduct[]> => {\n const products: IProduct[] = [];\n\n // Get spot products\n const spotSymbols = await getSpotSymbols();\n\n for (const symbol of spotSymbols?.data || []) {\n if (symbol.state !== 'online') continue; // Only include online symbols\n\n products.push({\n datasource_id: 'HTX',\n product_id: encodePath('HTX', 'SPOT', symbol.sc),\n base_currency: symbol.bc,\n quote_currency: symbol.qc,\n value_scale: 1,\n price_step: 1 / 10 ** symbol.tpp,\n volume_step: 1 / 10 ** symbol.tap,\n name: '',\n value_scale_unit: '',\n margin_rate: 1,\n value_based_cost: 0,\n volume_based_cost: 0,\n max_position: 0,\n max_volume: 0,\n allow_long: true,\n allow_short: false,\n market_id: 'HUOBI/SPOT',\n no_interest_rate: true,\n });\n }\n\n return products;\n};\n\nexport const listProducts = async (): Promise<IProduct[]> => {\n const [swapProducts, spotProducts] = await Promise.all([listSwapProducts(), listSpotProducts()]);\n return [...swapProducts, ...spotProducts];\n};\n\nexport const productCache = createProductCache(terminal);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuants/vendor-huobi",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.6",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"@yuants/utils": "0.14.0",
|
|
16
16
|
"@yuants/cache": "0.3.3",
|
|
17
17
|
"@yuants/sql": "0.9.30",
|
|
18
|
-
"@yuants/data-product": "0.
|
|
18
|
+
"@yuants/data-product": "0.5.0",
|
|
19
19
|
"@yuants/data-series": "0.3.51",
|
|
20
20
|
"@yuants/data-interest-rate": "0.1.48",
|
|
21
21
|
"@yuants/data-quote": "0.2.43",
|
|
22
|
-
"@yuants/exchange": "0.
|
|
22
|
+
"@yuants/exchange": "0.3.0",
|
|
23
23
|
"rxjs": "~7.5.6"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
package/temp/package-deps.json
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
{
|
|
2
|
-
"apps/vendor-huobi/CHANGELOG.json": "
|
|
3
|
-
"apps/vendor-huobi/CHANGELOG.md": "
|
|
2
|
+
"apps/vendor-huobi/CHANGELOG.json": "dea8e654de3b203a5540faf20f4bf2ee89c46d89",
|
|
3
|
+
"apps/vendor-huobi/CHANGELOG.md": "28dd0136ddbbb0ad8eeefc84cbd07c4f7bb514fc",
|
|
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": "
|
|
10
|
+
"apps/vendor-huobi/package.json": "89a7c6204961c1a5f1d9afb143110edecfc902e0",
|
|
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": "644260e6709841ade74d43b6df6dd3eda42d36d9",
|
|
15
|
-
"apps/vendor-huobi/src/api/public-api.ts": "
|
|
15
|
+
"apps/vendor-huobi/src/api/public-api.ts": "c8c6c380118d1282d16a3b5342060f3f82ed14af",
|
|
16
16
|
"apps/vendor-huobi/src/index.ts": "b0fa28ef4e008320564a0ddc789104f398160a0a",
|
|
17
|
-
"apps/vendor-huobi/src/services/accounts/spot.ts": "
|
|
18
|
-
"apps/vendor-huobi/src/services/accounts/super-margin.ts": "
|
|
19
|
-
"apps/vendor-huobi/src/services/accounts/swap.ts": "
|
|
17
|
+
"apps/vendor-huobi/src/services/accounts/spot.ts": "9b214135dd375822ea5ef03c0fee108873ccc264",
|
|
18
|
+
"apps/vendor-huobi/src/services/accounts/super-margin.ts": "ff885947334f43085aacb6e8c37b997afee2b7f6",
|
|
19
|
+
"apps/vendor-huobi/src/services/accounts/swap.ts": "c847a74dba98f0c043a8fcb74b4d057da089df62",
|
|
20
20
|
"apps/vendor-huobi/src/services/exchange.ts": "6fed94206a22c43d3c6890cf52ff054a24d98d82",
|
|
21
21
|
"apps/vendor-huobi/src/services/market-data/interest_rate.ts": "79aa362f9fa90e612f9813d0b45d357b96189f3e",
|
|
22
|
-
"apps/vendor-huobi/src/services/market-data/quote.ts": "
|
|
22
|
+
"apps/vendor-huobi/src/services/market-data/quote.ts": "254f73d682ea7b9ac3300808e98db89c7935a0a9",
|
|
23
23
|
"apps/vendor-huobi/src/services/orders/listOrders.ts": "1cf4621727fb290f8e5fd1439765fd73387bda7a",
|
|
24
|
-
"apps/vendor-huobi/src/services/orders/submitOrder.ts": "
|
|
25
|
-
"apps/vendor-huobi/src/services/product.ts": "
|
|
24
|
+
"apps/vendor-huobi/src/services/orders/submitOrder.ts": "7699595d28a0533d0e017414218a01b9a8c9d565",
|
|
25
|
+
"apps/vendor-huobi/src/services/product.ts": "314f35055876a1d581c8bb8daf80aba04bd163bb",
|
|
26
26
|
"apps/vendor-huobi/src/services/uid.ts": "b71c27a6a0debdd9365dea35306f4763327aca2f",
|
|
27
27
|
"apps/vendor-huobi/tsconfig.json": "81da8f78196974b5d15da0edb6b2d9f48641063c",
|
|
28
28
|
"apps/vendor-huobi/.rush/temp/shrinkwrap-deps.json": "3099afcf246e8bc9ff02db11dd7b34b8bd1e72d9",
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
"libraries/utils/temp/package-deps.json": "6d58e9b325e8d16de8a878c32010f626b12a01da",
|
|
34
34
|
"libraries/cache/temp/package-deps.json": "a4afa15e6462983f9d3735d31dc1ed8a683fb4dc",
|
|
35
35
|
"libraries/sql/temp/package-deps.json": "4a9a7ec55f04b20459e664e81e76fa74b6c77b39",
|
|
36
|
-
"libraries/data-product/temp/package-deps.json": "
|
|
36
|
+
"libraries/data-product/temp/package-deps.json": "a03f08f30800d5fb52c5d019bda4f8e7ec04e344",
|
|
37
37
|
"libraries/data-series/temp/package-deps.json": "c89ebffe302757903aa54eff78f76cb855486b8c",
|
|
38
38
|
"libraries/data-interest-rate/temp/package-deps.json": "cef1e1cb0116ad593c24635684e0cbf03488d67c",
|
|
39
39
|
"libraries/data-quote/temp/package-deps.json": "34d079eab44d2bf65e07b112ac2099c6e92a015e",
|
|
40
|
-
"libraries/exchange/temp/package-deps.json": "
|
|
40
|
+
"libraries/exchange/temp/package-deps.json": "81cd228057e0c05ac9f39d4d22b19a59e9a4792f",
|
|
41
41
|
"libraries/extension/temp/package-deps.json": "9569c553c2f9a7d50b70d8f101fc2d3825aaccb9",
|
|
42
42
|
"tools/toolkit/temp/package-deps.json": "23e053490eb8feade23e4d45de4e54883e322711"
|
|
43
43
|
}
|