@yuants/vendor-huobi 0.18.2 → 0.18.3

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.
@@ -1 +1 @@
1
- {"version":3,"file":"private-api.js","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAOrE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAgB,EAAE;IACpD,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAW;QACnC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAW;KACpC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,UAAuB,EACvB,MAAc,EACd,IAAY,EACZ,QAAgB,EAChB,MAAY,EACZ,EAAE;IACF,MAAM,aAAa,GAAG,eACpB,UAAU,CAAC,UACb,4DAA4D,kBAAkB,CAC5E,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACvC,GACC,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,SAAS;QACtC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;aACvB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;aAClC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;aACtC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;aAC5B,IAAI,CAAC,GAAG,CAAC,EAAE;QAChB,CAAC,CAAC,EACN,EAA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;;;;;GAMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,UAAuB,EACvB,MAA4B,EAY3B,EAAE;IACH,OAAO,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;AAC9F,CAAC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,UAAuB,EAQtB,EAAE;IACH,OAAO,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,+CAA+C,EAAE,cAAc,CAAC,CAAC;AAC5G,CAAC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,UAAuB,EACvB,MAAgC,EAQ/B,EAAE;IACH,OAAO,cAAc,CACnB,UAAU,EACV,MAAM,EACN,8CAA8C,EAC9C,cAAc,EACd,MAAM,CACP,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,UAAuB,EACvB,MAGC,EAkCA,EAAE;IACH,OAAO,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;AAChG,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UAAuB,EACvB,MASC,EAmBA,EAAE;IACH,OAAO,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;AAC3F,CAAC,CAAC","sourcesContent":["import { encodeBase64, formatTime, HmacSHA256 } from '@yuants/utils';\n\nexport interface ICredential {\n access_key: string;\n secret_key: string;\n}\n\nexport const getDefaultCredential = (): ICredential => {\n return {\n access_key: process.env.ACCESS_KEY!,\n secret_key: process.env.SECRET_KEY!,\n };\n};\n\nexport const privateRequest = async (\n credential: ICredential,\n method: string,\n path: string,\n api_root: string,\n params?: any,\n) => {\n const requestParams = `AccessKeyId=${\n credential.access_key\n }&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=${encodeURIComponent(\n new Date().toISOString().split('.')[0],\n )}${\n method === 'GET' && params !== undefined\n ? `&${Object.entries(params)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}=${v}`)\n .join('&')}`\n : ''\n }`;\n\n const body = method === 'GET' ? '' : JSON.stringify(params);\n\n const requestString = `${method}\\n${api_root}\\n${path}\\n${requestParams}`;\n\n const str = encodeBase64(\n await HmacSHA256(\n new TextEncoder().encode(requestString),\n new TextEncoder().encode(credential.secret_key),\n ),\n );\n\n const url = new URL(`https://${api_root}${path}?${requestParams}&Signature=${encodeURIComponent(str)}`);\n // url.searchParams.sort();\n console.info(formatTime(Date.now()), method, url.href, body);\n const res = await fetch(url.href, {\n method,\n headers: { 'Content-Type': 'application/json' },\n body: body || undefined,\n });\n\n const retStr = await res.text();\n console.info(formatTime(Date.now()), 'PrivateResponse', url.toString(), res.status);\n try {\n return JSON.parse(retStr);\n } catch (e) {\n console.error(formatTime(Date.now()), 'huobiRequestFailed', path, JSON.stringify(params), retStr);\n throw e;\n }\n};\n\n/**\n * 获取账户信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec40743-7773-11ed-9966-0242ac110003\n */\nexport const getAccount = (\n credential: ICredential,\n): Promise<{\n status: string;\n data: {\n id: number;\n type: string;\n state: string;\n subtype: string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v1/account/accounts', 'api.huobi.pro');\n};\n\n/**\n * 获取用户ID\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec491c9-7773-11ed-9966-0242ac110003\n */\nexport const getUid = (credential: ICredential): Promise<{ data: number; code: number }> => {\n return privateRequest(credential, 'GET', '/v2/user/uid', 'api.huobi.pro');\n};\n\n/**\n * 获取统一账户信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=10000073-77b7-11ed-9966-0242ac110003\n */\nexport const getUnifiedAccountInfo = (\n credential: ICredential,\n): Promise<{\n status: string;\n code: number;\n msg: string;\n data: {\n margin_asset: string;\n margin_balance: number;\n cross_margin_static: number;\n cross_profit_unreal: number;\n withdraw_available: number;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/linear-swap-api/v3/unified_account_info', 'api.hbdm.com');\n};\n\n/**\n * 获取合约持仓信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb74963-77b5-11ed-9966-0242ac110003\n */\nexport const getSwapCrossPositionInfo = (\n credential: ICredential,\n params?: {\n contract_code?: string;\n pair?: string;\n contract_type: string;\n },\n): Promise<{\n status: string;\n ts: number;\n data: {\n symbol: string;\n contract_code: string;\n volume: number;\n available: number;\n frozen: number;\n cost_open: number;\n cost_hold: number;\n profit_unreal: number;\n profit_rate: number;\n lever_rate: number;\n position_margin: number;\n direction: string;\n profit: number;\n last_price: number;\n margin_asset: string;\n margin_mode: string;\n margin_account: string;\n contract_type: string;\n pair: string;\n business_type: string;\n position_mode: string;\n adl_risk_percent: string;\n liquidation_price?: number;\n }[];\n}> => {\n return privateRequest(\n credential,\n 'POST',\n '/linear-swap-api/v1/swap_cross_position_info',\n 'api.hbdm.com',\n params,\n );\n};\n\n/**\n * 获取合约挂单\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb784d4-77b5-11ed-9966-0242ac110003\n */\nexport const getSwapOpenOrders = (\n credential: ICredential,\n params?: {\n contract_code?: string;\n pair?: string;\n page_index?: number;\n page_size?: number;\n sort_by?: string;\n trade_type?: string;\n },\n): Promise<{\n status: string;\n data: {\n orders: {\n order_id_str: string;\n contract_code: string;\n order_price_type: string;\n direction: string;\n offset: string;\n volume: number;\n created_at: number;\n price: number;\n trade_volume: number;\n }[];\n };\n}> => {\n return privateRequest(\n credential,\n 'POST',\n '/linear-swap-api/v1/swap_cross_openorders',\n 'api.hbdm.com',\n params,\n );\n};\n\n/**\n * 获取现货账户余额\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec40922-7773-11ed-9966-0242ac110003\n */\nexport const getSpotAccountBalance = (\n credential: ICredential,\n account_uid: number,\n): Promise<{\n status: string;\n data: {\n list: {\n currency: string;\n balance: string;\n type: string;\n }[];\n };\n}> => {\n return privateRequest(credential, 'GET', `/v1/account/accounts/${account_uid}/balance`, 'api.huobi.pro');\n};\n\n/**\n * 获取杠杆借贷信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41863-7773-11ed-9966-0242ac110003\n */\nexport const getCrossMarginLoanInfo = (\n credential: ICredential,\n): Promise<{\n status: string;\n code: number;\n data: {\n currency: string;\n 'loanable-amt': string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v1/cross-margin/loan-info', 'api.huobi.pro');\n};\n\n/**\n * 现货下单\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=10000065-77b7-11ed-9966-0242ac110003\n */\nexport const postSpotOrder = (\n credential: ICredential,\n params: {\n symbol: string;\n 'account-id': string;\n amount: string;\n market_amount?: string;\n 'borrow-amount'?: string;\n type: string;\n 'trade-purpose': string;\n price?: string;\n source: string;\n 'client-order-id'?: string;\n },\n): Promise<{ success: boolean; code: number; message: string; data: { orderId: number } }> => {\n return privateRequest(credential, 'POST', `/v1/order/auto/place`, 'api.huobi.pro', params);\n};\n\n/**\n * 合约下单\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb77159-77b5-11ed-9966-0242ac110003\n */\nexport const postSwapOrder = (\n credential: ICredential,\n params: {\n contract_code: string;\n contract_type: string;\n price?: number;\n volume: number;\n offset: string;\n direction: string;\n lever_rate: number;\n order_price_type: string;\n channel_code?: string;\n },\n): Promise<{ status: string; ts: number; data: { order_id: number; order_id_str: string } }> => {\n return privateRequest(credential, 'POST', '/linear-swap-api/v1/swap_cross_order', 'api.hbdm.com', params);\n};\n\n/**\n * 获取现货存款地址\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec45fb7-7773-11ed-9966-0242ac110003\n */\nexport const getSpotAccountDepositAddresses = (\n credential: ICredential,\n params: { currency: string },\n): Promise<{\n code: number;\n message: string;\n data: {\n currency: string;\n chain: string;\n address: string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', `/v2/account/deposit/address`, 'api.huobi.pro', params);\n};\n\n/**\n * 获取账户流水\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec4610b-7773-11ed-9966-0242ac110003\n */\nexport const getAccountLedger = (\n credential: ICredential,\n params: { accountId: string; currency: string },\n): Promise<{\n status: string;\n data: {\n transactTime: number;\n transactAmt: number;\n }[];\n}> => {\n return privateRequest(credential, 'GET', `/v2/account/ledger`, 'api.huobi.pro', params);\n};\n\n/**\n * 超级杠杆转出\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41ff0-7773-11ed-9966-0242ac110003\n */\nexport const postSuperMarginAccountTransferOut = (\n credential: ICredential,\n params: {\n currency: string;\n amount: string;\n },\n): Promise<{ status: string; data: number }> => {\n return privateRequest(credential, 'POST', `/v1/cross-margin/transfer-out`, 'api.huobi.pro', params);\n};\n\n/**\n * 超级杠杆转入\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41f0e-7773-11ed-9966-0242ac110003\n */\nexport const postSuperMarginAccountTransferIn = (\n credential: ICredential,\n params: {\n currency: string;\n amount: string;\n },\n): Promise<{ status: string; data: number }> => {\n return privateRequest(credential, 'POST', `/v1/cross-margin/transfer-in`, 'api.huobi.pro', params);\n};\n\n/**\n * 现货账户转账\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=10000095-77b7-11ed-9966-0242ac110003\n */\nexport const postSpotAccountTransfer = (\n credential: ICredential,\n params: {\n from: string;\n to: string;\n currency: string;\n amount: number;\n 'margin-account': string;\n },\n): Promise<{ success: boolean; data: number; code: number; message: string }> => {\n return privateRequest(credential, 'POST', `/v2/account/transfer`, 'api.huobi.pro', params);\n};\n\n/**\n * 借贷\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41b5d-7773-11ed-9966-0242ac110003\n */\nexport const postBorrow = (\n credential: ICredential,\n params: { currency: string; amount: string },\n): Promise<{\n status: string;\n data: number;\n}> => {\n return privateRequest(credential, 'POST', `/v1/cross-margin/orders`, 'api.huobi.pro', params);\n};\n\n/**\n * 提现\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec42cfd-7773-11ed-9966-0242ac110003\n */\nexport const postWithdraw = (\n credential: ICredential,\n params: {\n address: string;\n amount: string;\n currency: string;\n fee: string;\n chain: string;\n },\n): Promise<{\n status: string;\n data: number;\n}> => {\n return privateRequest(credential, 'POST', `/v1/dw/withdraw/api/create`, 'api.huobi.pro', params);\n};\n\n/**\n * 获取充提历史\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec44f99-7773-11ed-9966-0242ac110003\n */\nexport const getDepositWithdrawHistory = (\n credential: ICredential,\n params: {\n currency: string;\n type: string;\n from?: string;\n size?: string;\n direct?: string;\n },\n): Promise<{\n status: string;\n 'error-code': string;\n 'error-msg': string;\n data: {\n id: number;\n type: string;\n currency: string;\n 'tx-hash': string;\n chain: string;\n amount: string;\n address: string;\n 'address-tag': string;\n fee: string;\n state: string;\n 'create-at': number;\n 'update-at': number;\n }[];\n}> => {\n return privateRequest(credential, 'GET', `/v1/query/deposit-withdraw`, 'api.huobi.pro', params);\n};\n\n/**\n * 资产划转(母子用户之间)\n *\n * 接口权限: 交易\n *\n * 限频: 2次/2s\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec45d8e-7773-11ed-9966-0242ac110003\n */\nexport const postSubUserTransfer = (\n credential: ICredential,\n params: {\n 'sub-uid': number;\n currency: string;\n amount: number;\n 'client-order-id'?: string;\n type: string;\n },\n): Promise<{\n data: number;\n status: string;\n}> => {\n return privateRequest(credential, 'POST', '/v1/subuser/transfer', 'api.huobi.pro', params);\n};\n\n/**\n * 获取子用户列表\n *\n * 接口权限: 读取\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec48f09-7773-11ed-9966-0242ac110003\n */\nexport const getSubUserList = (\n credential: ICredential,\n params?: { fromId?: number },\n): Promise<{\n code: number;\n message?: string;\n data: {\n uid: number;\n userState: string;\n subUserName: string;\n note: string;\n }[];\n nextId?: number;\n ok: boolean;\n}> => {\n return privateRequest(credential, 'GET', `/v2/sub-user/user-list`, 'api.huobi.pro', params);\n};\n\n/**\n * 账户类型查询\n *\n * 是否验签: 是\n *\n * 接口权限: 读取\n *\n * 限频: 每个UID 3秒最多 144 次请求(交易接口3秒最多 72 次请求,查询接口3秒最多 72 次请求) (该UID的所有币种和不同到期日的合约的所有私有接口共享该限制) 。\n *\n * 接口描述: 此接口用于客户查询的账号类型,当前U本位合约有统一账户和非统一账户(全仓逐仓账户)类型。统一账户类型资产放在USDT一个账户上,全仓逐仓账户类型资产放在不同的币对。\n * 统一账户类型为最新升级的,当前不支持API下单。若需要用用API下单请切换账户类型为非统一账户。\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb71825-77b5-11ed-9966-0242ac110003\n */\nexport const getSwapUnifiedAccountType = (\n credential: ICredential,\n): Promise<{\n code: number;\n msg: string;\n ts: number;\n data: {\n account_type: number;\n };\n}> => {\n return privateRequest(credential, 'GET', '/linear-swap-api/v3/swap_unified_account_type', 'api.hbdm.com');\n};\n\n/**\n * 账户类型更改接口\n *\n * 是否验签: 是\n *\n * 接口权限: 交易\n *\n * 限频: 每个UID 3秒最多 144 次请求(交易接口3秒最多 72 次请求,查询接口3秒最多 72 次请求) (该UID的所有币种和不同到期日的合约的所有私有接口共享该限制) 。\n *\n * 接口描述: 调用该接口前需要保证U本位合约无持仓和挂单,当由非统一账户(全仓逐仓账户)变为统一账户还需将资产从逐仓账户划转到全仓账户。\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb7196b-77b5-11ed-9966-0242ac110003\n */\nexport const postSwapSwitchAccountType = (\n credential: ICredential,\n params: { account_type: number },\n): Promise<{\n code: number;\n msg: string;\n ts: number;\n data: {\n account_type: number;\n };\n}> => {\n return privateRequest(\n credential,\n 'POST',\n '/linear-swap-api/v3/swap_switch_account_type',\n 'api.hbdm.com',\n params,\n );\n};\n\n/**\n * APIv2币链参考信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec478f0-7773-11ed-9966-0242ac110003\n */\nexport const getV2ReferenceCurrencies = (\n credential: ICredential,\n params: {\n currency?: string;\n authorizedUser?: string;\n },\n): Promise<{\n code: number;\n data: {\n currency: string;\n assetType: number;\n chains: {\n chain: string;\n displayName: string;\n fullName: string;\n baseChain?: string;\n baseChainProtocol?: string;\n isDynamic?: boolean;\n numOfConfirmations: number;\n numOfFastConfirmations: number;\n depositStatus: string;\n minDepositAmt: string;\n withdrawStatus: string;\n minWithdrawAmt: string;\n withdrawPrecision: number;\n maxWithdrawAmt: string;\n withdrawQuotaPerDay: string;\n withdrawQuotaPerYear: null;\n withdrawQuotaTotal: null;\n withdrawFeeType: string;\n transactFeeWithdraw?: string;\n addrWithTag: boolean;\n addrDepositTag: boolean;\n minTransactFeeWithdraw?: string;\n transactFeeRateWithdraw?: string;\n maxTransactFeeWithdraw?: string;\n }[];\n instStatus: string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v2/reference/currencies', 'api.huobi.pro', params);\n};\n\n/**\n * 获取账户历史\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41049-7773-11ed-9966-0242ac110003\n */\nexport const getAccountHistory = (\n credential: ICredential,\n params: {\n 'account-id': string;\n currency?: string;\n 'transact-types'?: number;\n 'start-time'?: number;\n 'end-time'?: number;\n sort?: 'asc' | 'desc';\n size?: number;\n 'from-id'?: number;\n },\n): Promise<{\n // code: number;\n 'transact-amt': string;\n 'avail-balance': string;\n 'acct-balance': string;\n 'transact-time': string;\n 'record-id': string;\n status: string;\n data: {\n 'account-id': string;\n currency: string;\n 'record-id': string;\n 'transact-amt': string;\n 'transact-type': string;\n 'avail-balance': string;\n 'acct-balance': string;\n 'transact-time': string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v1/account/history', 'api.huobi.pro', params);\n};\n"]}
1
+ {"version":3,"file":"private-api.js","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAOrE,MAAM,CAAC,MAAM,oBAAoB,GAAG,GAAgB,EAAE;IACpD,OAAO;QACL,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAW;QACnC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,UAAW;KACpC,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,UAAuB,EACvB,MAAc,EACd,IAAY,EACZ,QAAgB,EAChB,MAAY,EACZ,EAAE;IACF,MAAM,aAAa,GAAG,eACpB,UAAU,CAAC,UACb,4DAA4D,kBAAkB,CAC5E,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CACvC,GACC,MAAM,KAAK,KAAK,IAAI,MAAM,KAAK,SAAS;QACtC,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;aACvB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC;aAClC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC;aACtC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;aAC5B,IAAI,CAAC,GAAG,CAAC,EAAE;QAChB,CAAC,CAAC,EACN,EAAE,CAA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AMG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,CAC5B,UAAuB,EACvB,MAA4B,EAY3B,EAAE;IACH,OAAO,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,wBAAwB,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;AAC9F,CAAC,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,UAAuB,EAQtB,EAAE;IACH,OAAO,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,+CAA+C,EAAE,cAAc,CAAC,CAAC;AAC5G,CAAC,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,UAAuB,EACvB,MAAgC,EAQ/B,EAAE;IACH,OAAO,cAAc,CACnB,UAAU,EACV,MAAM,EACN,8CAA8C,EAC9C,cAAc,EACd,MAAM,CACP,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACtC,UAAuB,EACvB,MAGC,EAkCA,EAAE;IACH,OAAO,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;AAChG,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,UAAuB,EACvB,MASC,EAmBA,EAAE;IACH,OAAO,cAAc,CAAC,UAAU,EAAE,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;AAC3F,CAAC,CAAC","sourcesContent":["import { encodeBase64, formatTime, HmacSHA256 } from '@yuants/utils';\n\nexport interface ICredential {\n access_key: string;\n secret_key: string;\n}\n\nexport const getDefaultCredential = (): ICredential => {\n return {\n access_key: process.env.ACCESS_KEY!,\n secret_key: process.env.SECRET_KEY!,\n };\n};\n\nexport const privateRequest = async (\n credential: ICredential,\n method: string,\n path: string,\n api_root: string,\n params?: any,\n) => {\n const requestParams = `AccessKeyId=${\n credential.access_key\n }&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=${encodeURIComponent(\n new Date().toISOString().split('.')[0],\n )}${\n method === 'GET' && params !== undefined\n ? `&${Object.entries(params)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}=${v}`)\n .join('&')}`\n : ''\n }`;\n\n const body = method === 'GET' ? '' : JSON.stringify(params);\n\n const requestString = `${method}\\n${api_root}\\n${path}\\n${requestParams}`;\n\n const str = encodeBase64(\n await HmacSHA256(\n new TextEncoder().encode(requestString),\n new TextEncoder().encode(credential.secret_key),\n ),\n );\n\n const url = new URL(`https://${api_root}${path}?${requestParams}&Signature=${encodeURIComponent(str)}`);\n // url.searchParams.sort();\n console.info(formatTime(Date.now()), method, url.href, body);\n const res = await fetch(url.href, {\n method,\n headers: { 'Content-Type': 'application/json' },\n body: body || undefined,\n });\n\n const retStr = await res.text();\n console.info(formatTime(Date.now()), 'PrivateResponse', url.toString(), res.status);\n try {\n return JSON.parse(retStr);\n } catch (e) {\n console.error(formatTime(Date.now()), 'huobiRequestFailed', path, JSON.stringify(params), retStr);\n throw e;\n }\n};\n\n/**\n * 获取账户信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec40743-7773-11ed-9966-0242ac110003\n */\nexport const getAccount = (\n credential: ICredential,\n): Promise<{\n status: string;\n data: {\n id: number;\n type: string;\n state: string;\n subtype: string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v1/account/accounts', 'api.huobi.pro');\n};\n\n/**\n * 获取用户ID\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec491c9-7773-11ed-9966-0242ac110003\n */\nexport const getUid = (credential: ICredential): Promise<{ data: number; code: number }> => {\n return privateRequest(credential, 'GET', '/v2/user/uid', 'api.huobi.pro');\n};\n\n/**\n * 获取统一账户信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=10000073-77b7-11ed-9966-0242ac110003\n */\nexport const getUnifiedAccountInfo = (\n credential: ICredential,\n): Promise<{\n status: string;\n code: number;\n msg: string;\n data: {\n margin_asset: string;\n margin_balance: number;\n margin_static: number;\n cross_margin_static: number;\n cross_profit_unreal: number;\n withdraw_available: number;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/linear-swap-api/v3/unified_account_info', 'api.hbdm.com');\n};\n\n/**\n * 获取合约持仓信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb74963-77b5-11ed-9966-0242ac110003\n */\nexport const getSwapCrossPositionInfo = (\n credential: ICredential,\n params?: {\n contract_code?: string;\n pair?: string;\n contract_type: string;\n },\n): Promise<{\n status: string;\n ts: number;\n data: {\n symbol: string;\n contract_code: string;\n volume: number;\n available: number;\n frozen: number;\n cost_open: number;\n cost_hold: number;\n profit_unreal: number;\n profit_rate: number;\n lever_rate: number;\n position_margin: number;\n direction: string;\n profit: number;\n last_price: number;\n margin_asset: string;\n margin_mode: string;\n margin_account: string;\n contract_type: string;\n pair: string;\n business_type: string;\n position_mode: string;\n adl_risk_percent: string;\n liquidation_price?: number;\n }[];\n}> => {\n return privateRequest(\n credential,\n 'POST',\n '/linear-swap-api/v1/swap_cross_position_info',\n 'api.hbdm.com',\n params,\n );\n};\n\n/**\n * 获取合约挂单\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb784d4-77b5-11ed-9966-0242ac110003\n */\nexport const getSwapOpenOrders = (\n credential: ICredential,\n params?: {\n contract_code?: string;\n pair?: string;\n page_index?: number;\n page_size?: number;\n sort_by?: string;\n trade_type?: string;\n },\n): Promise<{\n status: string;\n data: {\n orders: {\n order_id_str: string;\n contract_code: string;\n order_price_type: string;\n direction: string;\n offset: string;\n volume: number;\n created_at: number;\n price: number;\n trade_volume: number;\n }[];\n };\n}> => {\n return privateRequest(\n credential,\n 'POST',\n '/linear-swap-api/v1/swap_cross_openorders',\n 'api.hbdm.com',\n params,\n );\n};\n\n/**\n * 获取现货账户余额\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec40922-7773-11ed-9966-0242ac110003\n */\nexport const getSpotAccountBalance = (\n credential: ICredential,\n account_uid: number,\n): Promise<{\n status: string;\n data: {\n list: {\n currency: string;\n balance: string;\n type: string;\n }[];\n };\n}> => {\n return privateRequest(credential, 'GET', `/v1/account/accounts/${account_uid}/balance`, 'api.huobi.pro');\n};\n\n/**\n * 获取杠杆借贷信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41863-7773-11ed-9966-0242ac110003\n */\nexport const getCrossMarginLoanInfo = (\n credential: ICredential,\n): Promise<{\n status: string;\n code: number;\n data: {\n currency: string;\n 'loanable-amt': string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v1/cross-margin/loan-info', 'api.huobi.pro');\n};\n\n/**\n * 现货下单\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=10000065-77b7-11ed-9966-0242ac110003\n */\nexport const postSpotOrder = (\n credential: ICredential,\n params: {\n symbol: string;\n 'account-id': string;\n amount: string;\n market_amount?: string;\n 'borrow-amount'?: string;\n type: string;\n 'trade-purpose': string;\n price?: string;\n source: string;\n 'client-order-id'?: string;\n },\n): Promise<{ success: boolean; code: number; message: string; data: { orderId: number } }> => {\n return privateRequest(credential, 'POST', `/v1/order/auto/place`, 'api.huobi.pro', params);\n};\n\n/**\n * 合约下单\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb77159-77b5-11ed-9966-0242ac110003\n */\nexport const postSwapOrder = (\n credential: ICredential,\n params: {\n contract_code: string;\n contract_type: string;\n price?: number;\n volume: number;\n offset: string;\n direction: string;\n lever_rate: number;\n order_price_type: string;\n channel_code?: string;\n },\n): Promise<{ status: string; ts: number; data: { order_id: number; order_id_str: string } }> => {\n return privateRequest(credential, 'POST', '/linear-swap-api/v1/swap_cross_order', 'api.hbdm.com', params);\n};\n\n/**\n * 获取现货存款地址\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec45fb7-7773-11ed-9966-0242ac110003\n */\nexport const getSpotAccountDepositAddresses = (\n credential: ICredential,\n params: { currency: string },\n): Promise<{\n code: number;\n message: string;\n data: {\n currency: string;\n chain: string;\n address: string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', `/v2/account/deposit/address`, 'api.huobi.pro', params);\n};\n\n/**\n * 获取账户流水\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec4610b-7773-11ed-9966-0242ac110003\n */\nexport const getAccountLedger = (\n credential: ICredential,\n params: { accountId: string; currency: string },\n): Promise<{\n status: string;\n data: {\n transactTime: number;\n transactAmt: number;\n }[];\n}> => {\n return privateRequest(credential, 'GET', `/v2/account/ledger`, 'api.huobi.pro', params);\n};\n\n/**\n * 超级杠杆转出\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41ff0-7773-11ed-9966-0242ac110003\n */\nexport const postSuperMarginAccountTransferOut = (\n credential: ICredential,\n params: {\n currency: string;\n amount: string;\n },\n): Promise<{ status: string; data: number }> => {\n return privateRequest(credential, 'POST', `/v1/cross-margin/transfer-out`, 'api.huobi.pro', params);\n};\n\n/**\n * 超级杠杆转入\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41f0e-7773-11ed-9966-0242ac110003\n */\nexport const postSuperMarginAccountTransferIn = (\n credential: ICredential,\n params: {\n currency: string;\n amount: string;\n },\n): Promise<{ status: string; data: number }> => {\n return privateRequest(credential, 'POST', `/v1/cross-margin/transfer-in`, 'api.huobi.pro', params);\n};\n\n/**\n * 现货账户转账\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=10000095-77b7-11ed-9966-0242ac110003\n */\nexport const postSpotAccountTransfer = (\n credential: ICredential,\n params: {\n from: string;\n to: string;\n currency: string;\n amount: number;\n 'margin-account': string;\n },\n): Promise<{ success: boolean; data: number; code: number; message: string }> => {\n return privateRequest(credential, 'POST', `/v2/account/transfer`, 'api.huobi.pro', params);\n};\n\n/**\n * 借贷\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41b5d-7773-11ed-9966-0242ac110003\n */\nexport const postBorrow = (\n credential: ICredential,\n params: { currency: string; amount: string },\n): Promise<{\n status: string;\n data: number;\n}> => {\n return privateRequest(credential, 'POST', `/v1/cross-margin/orders`, 'api.huobi.pro', params);\n};\n\n/**\n * 提现\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec42cfd-7773-11ed-9966-0242ac110003\n */\nexport const postWithdraw = (\n credential: ICredential,\n params: {\n address: string;\n amount: string;\n currency: string;\n fee: string;\n chain: string;\n },\n): Promise<{\n status: string;\n data: number;\n}> => {\n return privateRequest(credential, 'POST', `/v1/dw/withdraw/api/create`, 'api.huobi.pro', params);\n};\n\n/**\n * 获取充提历史\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec44f99-7773-11ed-9966-0242ac110003\n */\nexport const getDepositWithdrawHistory = (\n credential: ICredential,\n params: {\n currency: string;\n type: string;\n from?: string;\n size?: string;\n direct?: string;\n },\n): Promise<{\n status: string;\n 'error-code': string;\n 'error-msg': string;\n data: {\n id: number;\n type: string;\n currency: string;\n 'tx-hash': string;\n chain: string;\n amount: string;\n address: string;\n 'address-tag': string;\n fee: string;\n state: string;\n 'create-at': number;\n 'update-at': number;\n }[];\n}> => {\n return privateRequest(credential, 'GET', `/v1/query/deposit-withdraw`, 'api.huobi.pro', params);\n};\n\n/**\n * 资产划转(母子用户之间)\n *\n * 接口权限: 交易\n *\n * 限频: 2次/2s\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec45d8e-7773-11ed-9966-0242ac110003\n */\nexport const postSubUserTransfer = (\n credential: ICredential,\n params: {\n 'sub-uid': number;\n currency: string;\n amount: number;\n 'client-order-id'?: string;\n type: string;\n },\n): Promise<{\n data: number;\n status: string;\n}> => {\n return privateRequest(credential, 'POST', '/v1/subuser/transfer', 'api.huobi.pro', params);\n};\n\n/**\n * 获取子用户列表\n *\n * 接口权限: 读取\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec48f09-7773-11ed-9966-0242ac110003\n */\nexport const getSubUserList = (\n credential: ICredential,\n params?: { fromId?: number },\n): Promise<{\n code: number;\n message?: string;\n data: {\n uid: number;\n userState: string;\n subUserName: string;\n note: string;\n }[];\n nextId?: number;\n ok: boolean;\n}> => {\n return privateRequest(credential, 'GET', `/v2/sub-user/user-list`, 'api.huobi.pro', params);\n};\n\n/**\n * 账户类型查询\n *\n * 是否验签: 是\n *\n * 接口权限: 读取\n *\n * 限频: 每个UID 3秒最多 144 次请求(交易接口3秒最多 72 次请求,查询接口3秒最多 72 次请求) (该UID的所有币种和不同到期日的合约的所有私有接口共享该限制) 。\n *\n * 接口描述: 此接口用于客户查询的账号类型,当前U本位合约有统一账户和非统一账户(全仓逐仓账户)类型。统一账户类型资产放在USDT一个账户上,全仓逐仓账户类型资产放在不同的币对。\n * 统一账户类型为最新升级的,当前不支持API下单。若需要用用API下单请切换账户类型为非统一账户。\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb71825-77b5-11ed-9966-0242ac110003\n */\nexport const getSwapUnifiedAccountType = (\n credential: ICredential,\n): Promise<{\n code: number;\n msg: string;\n ts: number;\n data: {\n account_type: number;\n };\n}> => {\n return privateRequest(credential, 'GET', '/linear-swap-api/v3/swap_unified_account_type', 'api.hbdm.com');\n};\n\n/**\n * 账户类型更改接口\n *\n * 是否验签: 是\n *\n * 接口权限: 交易\n *\n * 限频: 每个UID 3秒最多 144 次请求(交易接口3秒最多 72 次请求,查询接口3秒最多 72 次请求) (该UID的所有币种和不同到期日的合约的所有私有接口共享该限制) 。\n *\n * 接口描述: 调用该接口前需要保证U本位合约无持仓和挂单,当由非统一账户(全仓逐仓账户)变为统一账户还需将资产从逐仓账户划转到全仓账户。\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb7196b-77b5-11ed-9966-0242ac110003\n */\nexport const postSwapSwitchAccountType = (\n credential: ICredential,\n params: { account_type: number },\n): Promise<{\n code: number;\n msg: string;\n ts: number;\n data: {\n account_type: number;\n };\n}> => {\n return privateRequest(\n credential,\n 'POST',\n '/linear-swap-api/v3/swap_switch_account_type',\n 'api.hbdm.com',\n params,\n );\n};\n\n/**\n * APIv2币链参考信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec478f0-7773-11ed-9966-0242ac110003\n */\nexport const getV2ReferenceCurrencies = (\n credential: ICredential,\n params: {\n currency?: string;\n authorizedUser?: string;\n },\n): Promise<{\n code: number;\n data: {\n currency: string;\n assetType: number;\n chains: {\n chain: string;\n displayName: string;\n fullName: string;\n baseChain?: string;\n baseChainProtocol?: string;\n isDynamic?: boolean;\n numOfConfirmations: number;\n numOfFastConfirmations: number;\n depositStatus: string;\n minDepositAmt: string;\n withdrawStatus: string;\n minWithdrawAmt: string;\n withdrawPrecision: number;\n maxWithdrawAmt: string;\n withdrawQuotaPerDay: string;\n withdrawQuotaPerYear: null;\n withdrawQuotaTotal: null;\n withdrawFeeType: string;\n transactFeeWithdraw?: string;\n addrWithTag: boolean;\n addrDepositTag: boolean;\n minTransactFeeWithdraw?: string;\n transactFeeRateWithdraw?: string;\n maxTransactFeeWithdraw?: string;\n }[];\n instStatus: string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v2/reference/currencies', 'api.huobi.pro', params);\n};\n\n/**\n * 获取账户历史\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41049-7773-11ed-9966-0242ac110003\n */\nexport const getAccountHistory = (\n credential: ICredential,\n params: {\n 'account-id': string;\n currency?: string;\n 'transact-types'?: number;\n 'start-time'?: number;\n 'end-time'?: number;\n sort?: 'asc' | 'desc';\n size?: number;\n 'from-id'?: number;\n },\n): Promise<{\n // code: number;\n 'transact-amt': string;\n 'avail-balance': string;\n 'acct-balance': string;\n 'transact-time': string;\n 'record-id': string;\n status: string;\n data: {\n 'account-id': string;\n currency: string;\n 'record-id': string;\n 'transact-amt': string;\n 'transact-type': string;\n 'avail-balance': string;\n 'acct-balance': string;\n 'transact-time': string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v1/account/history', 'api.huobi.pro', params);\n};\n"]}
@@ -14,10 +14,10 @@ export const getSwapAccountInfo = async (credential) => {
14
14
  if (v.margin_balance === 0)
15
15
  continue;
16
16
  positions.push(makeSpotPosition({
17
- position_id: encodePath('HTX', 'SWAP-MARGIN', v.margin_asset),
17
+ position_id: encodePath('HTX', 'SWAP-ASSET', v.margin_asset),
18
18
  datasource_id: 'HTX',
19
- product_id: encodePath('HTX', 'SWAP-MARGIN', v.margin_asset),
20
- volume: +v.margin_balance,
19
+ product_id: encodePath('HTX', 'SWAP-ASSET', v.margin_asset),
20
+ volume: +v.margin_static,
21
21
  free_volume: +v.withdraw_available,
22
22
  closable_price: usdAssets.has(v.margin_asset) ? 1 : 0,
23
23
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"swap.js","sourceRoot":"","sources":["../../../src/services/accounts/swap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAe,MAAM,uBAAuB,CAAC;AACrG,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAuB,EAAwB,EAAE;IACxF,MAAM,SAAS,GAAgB,EAAE,CAAC;IAClC,UAAU;IACV,MAAM,OAAO,GAAG,MAAM,qBAAqB,CAAC,UAAU,CAAC,CAAC;IACxD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;KACvD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C,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;YACnD,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,WAAW,EAAE,CAAC,CAAC,SAAS;YACxB,cAAc,EAAE,CAAC,CAAC,SAAS;YAC3B,cAAc,EAAE,CAAC,CAAC,UAAU;YAC5B,eAAe,EAAE,CAAC,CAAC,aAAa;YAChC,iBAAiB,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,SAAS;YAC7E,SAAS;SACV,CAAC,CAAC;KACJ;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { IPosition, makeSpotPosition } from '@yuants/data-account';\nimport { encodePath } from '@yuants/utils';\nimport { getSwapCrossPositionInfo, getUnifiedAccountInfo, ICredential } from '../../api/private-api';\nimport { productCache } from '../product';\n\nconst usdAssets = new Set(['USDT', 'USDC', 'USDD']);\n\nexport const getSwapAccountInfo = async (credential: ICredential): Promise<IPosition[]> => {\n const positions: IPosition[] = [];\n // balance\n const balance = await getUnifiedAccountInfo(credential);\n if (!balance.data) {\n throw new Error('Failed to get unified account info');\n }\n\n for (const v of balance.data || []) {\n if (v.margin_balance === 0) continue;\n positions.push(\n makeSpotPosition({\n position_id: encodePath('HTX', 'SWAP-MARGIN', v.margin_asset),\n datasource_id: 'HTX',\n product_id: encodePath('HTX', 'SWAP-MARGIN', v.margin_asset),\n volume: +v.margin_balance,\n free_volume: +v.withdraw_available,\n closable_price: usdAssets.has(v.margin_asset) ? 1 : 0,\n }),\n );\n }\n\n // positions\n const positionsRes = await getSwapCrossPositionInfo(credential);\n for (const v of positionsRes.data || []) {\n const product_id = encodePath('HTX', 'SWAP', v.contract_code);\n const theProduct = await productCache.query(product_id);\n const valuation = v.volume * v.last_price * (theProduct?.value_scale || 1);\n positions.push({\n position_id: `${product_id}/${v.contract_type}/${v.direction}/${v.margin_mode}`,\n datasource_id: 'HTX',\n product_id,\n direction: v.direction === 'buy' ? 'LONG' : 'SHORT',\n volume: v.volume,\n free_volume: v.available,\n position_price: v.cost_hold,\n closable_price: v.last_price,\n floating_profit: v.profit_unreal,\n liquidation_price: v.liquidation_price ? `${v.liquidation_price}` : undefined,\n valuation,\n });\n }\n\n return positions;\n};\n"]}
1
+ {"version":3,"file":"swap.js","sourceRoot":"","sources":["../../../src/services/accounts/swap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,wBAAwB,EAAE,qBAAqB,EAAe,MAAM,uBAAuB,CAAC;AACrG,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAEpD,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAuB,EAAwB,EAAE;IACxF,MAAM,SAAS,GAAgB,EAAE,CAAC;IAClC,UAAU;IACV,MAAM,OAAO,GAAG,MAAM,qBAAqB,CAAC,UAAU,CAAC,CAAC;IACxD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;KACvD;IAED,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,IAAI,EAAE,EAAE;QAClC,IAAI,CAAC,CAAC,cAAc,KAAK,CAAC;YAAE,SAAS;QACrC,SAAS,CAAC,IAAI,CACZ,gBAAgB,CAAC;YACf,WAAW,EAAE,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,CAAC;YAC5D,aAAa,EAAE,KAAK;YACpB,UAAU,EAAE,UAAU,CAAC,KAAK,EAAE,YAAY,EAAE,CAAC,CAAC,YAAY,C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E,CAAC,CAAC,CAAC,SAAS;YAC7E,SAAS;SACV,CAAC,CAAC;KACJ;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC","sourcesContent":["import { IPosition, makeSpotPosition } from '@yuants/data-account';\nimport { encodePath } from '@yuants/utils';\nimport { getSwapCrossPositionInfo, getUnifiedAccountInfo, ICredential } from '../../api/private-api';\nimport { productCache } from '../product';\n\nconst usdAssets = new Set(['USDT', 'USDC', 'USDD']);\n\nexport const getSwapAccountInfo = async (credential: ICredential): Promise<IPosition[]> => {\n const positions: IPosition[] = [];\n // balance\n const balance = await getUnifiedAccountInfo(credential);\n if (!balance.data) {\n throw new Error('Failed to get unified account info');\n }\n\n for (const v of balance.data || []) {\n if (v.margin_balance === 0) continue;\n positions.push(\n makeSpotPosition({\n position_id: encodePath('HTX', 'SWAP-ASSET', v.margin_asset),\n datasource_id: 'HTX',\n product_id: encodePath('HTX', 'SWAP-ASSET', v.margin_asset),\n volume: +v.margin_static,\n free_volume: +v.withdraw_available,\n closable_price: usdAssets.has(v.margin_asset) ? 1 : 0,\n }),\n );\n }\n\n // positions\n const positionsRes = await getSwapCrossPositionInfo(credential);\n for (const v of positionsRes.data || []) {\n const product_id = encodePath('HTX', 'SWAP', v.contract_code);\n const theProduct = await productCache.query(product_id);\n const valuation = v.volume * v.last_price * (theProduct?.value_scale || 1);\n positions.push({\n position_id: `${product_id}/${v.contract_type}/${v.direction}/${v.margin_mode}`,\n datasource_id: 'HTX',\n product_id,\n direction: v.direction === 'buy' ? 'LONG' : 'SHORT',\n volume: v.volume,\n free_volume: v.available,\n position_price: v.cost_hold,\n closable_price: v.last_price,\n floating_profit: v.profit_unreal,\n liquidation_price: v.liquidation_price ? `${v.liquidation_price}` : undefined,\n valuation,\n });\n }\n\n return positions;\n};\n"]}
@@ -11,8 +11,8 @@ async function handleSwapOrder(order, credential) {
11
11
  // 获取仓位信息
12
12
  const positionInfo = await getSwapCrossPositionInfo(credential);
13
13
  const mapContractCodeToRate = Object.fromEntries(positionInfo.data.map((v) => [v.contract_code, v.lever_rate]));
14
- const lever_rate = (_a = mapContractCodeToRate[order.product_id]) !== null && _a !== void 0 ? _a : 20;
15
14
  const [, instType, contractCode] = decodePath(order.product_id);
15
+ const lever_rate = (_a = mapContractCodeToRate[contractCode]) !== null && _a !== void 0 ? _a : 20;
16
16
  const params = {
17
17
  contract_code: contractCode,
18
18
  contract_type: 'swap',
@@ -28,7 +28,7 @@ async function handleSwapOrder(order, credential) {
28
28
  const result = await postSwapOrder(credential, params);
29
29
  console.info(formatTime(Date.now()), 'SubmitOrder', JSON.stringify(result), JSON.stringify(params));
30
30
  if (result.status !== 'ok') {
31
- throw new Error(`Failed to submit swap order: status=${result.status}`);
31
+ throw newError(`HTX_SUBMIT_ORDER_FAILED`, { result });
32
32
  }
33
33
  return { order_id: result.data.order_id_str };
34
34
  }
@@ -1 +1 @@
1
- {"version":3,"file":"submitOrder.js","sourceRoot":"","sources":["../../../src/services/orders/submitOrder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAEL,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,EACb,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,QAAQ,CAAC;AAEpD;;GAEG;AACH,KAAK,UAAU,eAAe,CAAC,KAAa,EAAE,UAAuB;;IACnE,SAAS;IACT,MAAM,YAAY,GAAG,MAAM,wBAAwB,CAAC,UAAU,CAAC,CAAC;IAChE,MAAM,qBAAqB,GAAG,MAAM,CAAC,WAAW,CAC9C,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC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QAAQ,EAAE,CAAC,CAAC;AACpE,CAAC,CAAC","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 [, instType, contractCode] = decodePath(order.product_id);\n const params = {\n contract_code: contractCode,\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 channel_code: process.env.BROKER_ID,\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 const [, instType, contractCode] = decodePath(order.product_id);\n\n // 获取账户余额, 产品信息和价格\n const [balanceRes, theProduct, priceRes] = await Promise.all([\n getSpotAccountBalance(credential, superMarginAccountUid),\n productCache.query(order.product_id),\n getSpotTick({ symbol: contractCode }),\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: contractCode,\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 'client-order-id': process.env.BROKER_ID,\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
+ {"version":3,"file":"submitOrder.js","sourceRoot":"","sources":["../../../src/services/orders/submitOrder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC9E,OAAO,EAEL,sBAAsB,EACtB,qBAAqB,EACrB,wBAAwB,EACxB,aAAa,EACb,aAAa,GACd,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,0BAA0B,EAAE,MAAM,QAAQ,CAAC;AAEpD;;GAEG;AACH,KAAK,UAAU,eAAe,CAAC,KAAa,EAAE,UAAuB;;IACnE,SAAS;IACT,MAAM,YAAY,GAAG,MAAM,wBAAwB,CAAC,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,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,GAAG,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,MAAA,qBAAqB,CAAC,YAAY,CAAC,mCAAI,EAAE,CAAC;IAC7D,MAAM,MAAM,GAAG;QACb,aAAa,EAAE,YAAY;QAC3B,aAAa,EAAE,MAAM;QACrB,KAAK,EAAE,KAAK,CAAC,KAA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E,MAAM,CAAC,CAAC;IACvD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpG,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,6CAA6C,MAAM,CAAC,IAAI,YAAY,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;KACvG;IAED,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;AACtD,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,UAAuB,EAAE,KAAa,EAAiC,EAAE;IACnG,MAAM,CAAC,EAAE,QAAQ,CAAC,GAAG,UAAU,CAAC,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,QAAQ,CAAC,uBAAuB,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;AACpE,CAAC,CAAC","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 [, instType, contractCode] = decodePath(order.product_id);\n const lever_rate = mapContractCodeToRate[contractCode] ?? 20;\n const params = {\n contract_code: contractCode,\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 channel_code: process.env.BROKER_ID,\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 newError(`HTX_SUBMIT_ORDER_FAILED`, { result });\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 const [, instType, contractCode] = decodePath(order.product_id);\n\n // 获取账户余额, 产品信息和价格\n const [balanceRes, theProduct, priceRes] = await Promise.all([\n getSpotAccountBalance(credential, superMarginAccountUid),\n productCache.query(order.product_id),\n getSpotTick({ symbol: contractCode }),\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: contractCode,\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 'client-order-id': process.env.BROKER_ID,\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"]}
@@ -39,6 +39,7 @@ export declare const getUnifiedAccountInfo: (credential: ICredential) => Promise
39
39
  data: {
40
40
  margin_asset: string;
41
41
  margin_balance: number;
42
+ margin_static: number;
42
43
  cross_margin_static: number;
43
44
  cross_profit_unreal: number;
44
45
  withdraw_available: number;
@@ -1 +1 @@
1
- {"version":3,"file":"private-api.d.ts","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,oBAAoB,QAAO,WAKvC,CAAC;AAEF,eAAO,MAAM,cAAc,eACb,WAAW,UACf,MAAM,QACR,MAAM,YACF,MAAM,WACP,GAAG,iBA4Cb,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,UAAU,eACT,WAAW,KACtB,QAAQ;IACT,QAAQ,MAAM,CAAC;IACf,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;KACjB,EAAE,CAAC;CACL,CAEA,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,MAAM,eAAgB,WAAW,KAAG,QAAQ;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAEtF,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,eACpB,WAAW,KACtB,QAAQ;IACT,QAAQ,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE;QACJ,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;QACvB,mBAAmB,EAAE,MAAM,CAAC;QAC5B,mBAAmB,EAAE,MAAM,CAAC;QAC5B,kBAAkB,EAAE,MAAM,CAAC;KAC5B,EAAE,CAAC;CACL,CAEA,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,wBAAwB,eACvB,WAAW,WACd;IACP,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IAC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uB,EAQtB,EAAE;IACH,OAAO,IAAA,sBAAc,EAAC,UAAU,EAAE,KAAK,EAAE,+CAA+C,EAAE,cAAc,CAAC,CAAC;AAC5G,CAAC,CAAC;AAXW,QAAA,yBAAyB,6BAWpC;AAEF;;;;;;;;;;;;GAYG;AACI,MAAM,yBAAyB,GAAG,CACvC,UAAuB,EACvB,MAAgC,EAQ/B,EAAE;IACH,OAAO,IAAA,sBAAc,EACnB,UAAU,EACV,MAAM,EACN,8CAA8C,EAC9C,cAAc,EACd,MAAM,CACP,CAAC;AACJ,CAAC,CAAC;AAlBW,QAAA,yBAAyB,6BAkBpC;AAEF;;;;GAIG;AACI,MAAM,wBAAwB,GAAG,CACtC,UAAuB,EACvB,MAGC,EAkCA,EAAE;IACH,OAAO,IAAA,sBAAc,EAAC,UAAU,EAAE,KAAK,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;AAChG,CAAC,CAAC;AAzCW,QAAA,wBAAwB,4BAyCnC;AAEF;;;;GAIG;AACI,MAAM,iBAAiB,GAAG,CAC/B,UAAuB,EACvB,MASC,EAmBA,EAAE;IACH,OAAO,IAAA,sBAAc,EAAC,UAAU,EAAE,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;AAC3F,CAAC,CAAC;AAhCW,QAAA,iBAAiB,qBAgC5B","sourcesContent":["import { encodeBase64, formatTime, HmacSHA256 } from '@yuants/utils';\n\nexport interface ICredential {\n access_key: string;\n secret_key: string;\n}\n\nexport const getDefaultCredential = (): ICredential => {\n return {\n access_key: process.env.ACCESS_KEY!,\n secret_key: process.env.SECRET_KEY!,\n };\n};\n\nexport const privateRequest = async (\n credential: ICredential,\n method: string,\n path: string,\n api_root: string,\n params?: any,\n) => {\n const requestParams = `AccessKeyId=${\n credential.access_key\n }&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=${encodeURIComponent(\n new Date().toISOString().split('.')[0],\n )}${\n method === 'GET' && params !== undefined\n ? `&${Object.entries(params)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}=${v}`)\n .join('&')}`\n : ''\n }`;\n\n const body = method === 'GET' ? '' : JSON.stringify(params);\n\n const requestString = `${method}\\n${api_root}\\n${path}\\n${requestParams}`;\n\n const str = encodeBase64(\n await HmacSHA256(\n new TextEncoder().encode(requestString),\n new TextEncoder().encode(credential.secret_key),\n ),\n );\n\n const url = new URL(`https://${api_root}${path}?${requestParams}&Signature=${encodeURIComponent(str)}`);\n // url.searchParams.sort();\n console.info(formatTime(Date.now()), method, url.href, body);\n const res = await fetch(url.href, {\n method,\n headers: { 'Content-Type': 'application/json' },\n body: body || undefined,\n });\n\n const retStr = await res.text();\n console.info(formatTime(Date.now()), 'PrivateResponse', url.toString(), res.status);\n try {\n return JSON.parse(retStr);\n } catch (e) {\n console.error(formatTime(Date.now()), 'huobiRequestFailed', path, JSON.stringify(params), retStr);\n throw e;\n }\n};\n\n/**\n * 获取账户信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec40743-7773-11ed-9966-0242ac110003\n */\nexport const getAccount = (\n credential: ICredential,\n): Promise<{\n status: string;\n data: {\n id: number;\n type: string;\n state: string;\n subtype: string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v1/account/accounts', 'api.huobi.pro');\n};\n\n/**\n * 获取用户ID\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec491c9-7773-11ed-9966-0242ac110003\n */\nexport const getUid = (credential: ICredential): Promise<{ data: number; code: number }> => {\n return privateRequest(credential, 'GET', '/v2/user/uid', 'api.huobi.pro');\n};\n\n/**\n * 获取统一账户信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=10000073-77b7-11ed-9966-0242ac110003\n */\nexport const getUnifiedAccountInfo = (\n credential: ICredential,\n): Promise<{\n status: string;\n code: number;\n msg: string;\n data: {\n margin_asset: string;\n margin_balance: number;\n cross_margin_static: number;\n cross_profit_unreal: number;\n withdraw_available: number;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/linear-swap-api/v3/unified_account_info', 'api.hbdm.com');\n};\n\n/**\n * 获取合约持仓信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb74963-77b5-11ed-9966-0242ac110003\n */\nexport const getSwapCrossPositionInfo = (\n credential: ICredential,\n params?: {\n contract_code?: string;\n pair?: string;\n contract_type: string;\n },\n): Promise<{\n status: string;\n ts: number;\n data: {\n symbol: string;\n contract_code: string;\n volume: number;\n available: number;\n frozen: number;\n cost_open: number;\n cost_hold: number;\n profit_unreal: number;\n profit_rate: number;\n lever_rate: number;\n position_margin: number;\n direction: string;\n profit: number;\n last_price: number;\n margin_asset: string;\n margin_mode: string;\n margin_account: string;\n contract_type: string;\n pair: string;\n business_type: string;\n position_mode: string;\n adl_risk_percent: string;\n liquidation_price?: number;\n }[];\n}> => {\n return privateRequest(\n credential,\n 'POST',\n '/linear-swap-api/v1/swap_cross_position_info',\n 'api.hbdm.com',\n params,\n );\n};\n\n/**\n * 获取合约挂单\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb784d4-77b5-11ed-9966-0242ac110003\n */\nexport const getSwapOpenOrders = (\n credential: ICredential,\n params?: {\n contract_code?: string;\n pair?: string;\n page_index?: number;\n page_size?: number;\n sort_by?: string;\n trade_type?: string;\n },\n): Promise<{\n status: string;\n data: {\n orders: {\n order_id_str: string;\n contract_code: string;\n order_price_type: string;\n direction: string;\n offset: string;\n volume: number;\n created_at: number;\n price: number;\n trade_volume: number;\n }[];\n };\n}> => {\n return privateRequest(\n credential,\n 'POST',\n '/linear-swap-api/v1/swap_cross_openorders',\n 'api.hbdm.com',\n params,\n );\n};\n\n/**\n * 获取现货账户余额\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec40922-7773-11ed-9966-0242ac110003\n */\nexport const getSpotAccountBalance = (\n credential: ICredential,\n account_uid: number,\n): Promise<{\n status: string;\n data: {\n list: {\n currency: string;\n balance: string;\n type: string;\n }[];\n };\n}> => {\n return privateRequest(credential, 'GET', `/v1/account/accounts/${account_uid}/balance`, 'api.huobi.pro');\n};\n\n/**\n * 获取杠杆借贷信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41863-7773-11ed-9966-0242ac110003\n */\nexport const getCrossMarginLoanInfo = (\n credential: ICredential,\n): Promise<{\n status: string;\n code: number;\n data: {\n currency: string;\n 'loanable-amt': string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v1/cross-margin/loan-info', 'api.huobi.pro');\n};\n\n/**\n * 现货下单\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=10000065-77b7-11ed-9966-0242ac110003\n */\nexport const postSpotOrder = (\n credential: ICredential,\n params: {\n symbol: string;\n 'account-id': string;\n amount: string;\n market_amount?: string;\n 'borrow-amount'?: string;\n type: string;\n 'trade-purpose': string;\n price?: string;\n source: string;\n 'client-order-id'?: string;\n },\n): Promise<{ success: boolean; code: number; message: string; data: { orderId: number } }> => {\n return privateRequest(credential, 'POST', `/v1/order/auto/place`, 'api.huobi.pro', params);\n};\n\n/**\n * 合约下单\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb77159-77b5-11ed-9966-0242ac110003\n */\nexport const postSwapOrder = (\n credential: ICredential,\n params: {\n contract_code: string;\n contract_type: string;\n price?: number;\n volume: number;\n offset: string;\n direction: string;\n lever_rate: number;\n order_price_type: string;\n channel_code?: string;\n },\n): Promise<{ status: string; ts: number; data: { order_id: number; order_id_str: string } }> => {\n return privateRequest(credential, 'POST', '/linear-swap-api/v1/swap_cross_order', 'api.hbdm.com', params);\n};\n\n/**\n * 获取现货存款地址\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec45fb7-7773-11ed-9966-0242ac110003\n */\nexport const getSpotAccountDepositAddresses = (\n credential: ICredential,\n params: { currency: string },\n): Promise<{\n code: number;\n message: string;\n data: {\n currency: string;\n chain: string;\n address: string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', `/v2/account/deposit/address`, 'api.huobi.pro', params);\n};\n\n/**\n * 获取账户流水\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec4610b-7773-11ed-9966-0242ac110003\n */\nexport const getAccountLedger = (\n credential: ICredential,\n params: { accountId: string; currency: string },\n): Promise<{\n status: string;\n data: {\n transactTime: number;\n transactAmt: number;\n }[];\n}> => {\n return privateRequest(credential, 'GET', `/v2/account/ledger`, 'api.huobi.pro', params);\n};\n\n/**\n * 超级杠杆转出\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41ff0-7773-11ed-9966-0242ac110003\n */\nexport const postSuperMarginAccountTransferOut = (\n credential: ICredential,\n params: {\n currency: string;\n amount: string;\n },\n): Promise<{ status: string; data: number }> => {\n return privateRequest(credential, 'POST', `/v1/cross-margin/transfer-out`, 'api.huobi.pro', params);\n};\n\n/**\n * 超级杠杆转入\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41f0e-7773-11ed-9966-0242ac110003\n */\nexport const postSuperMarginAccountTransferIn = (\n credential: ICredential,\n params: {\n currency: string;\n amount: string;\n },\n): Promise<{ status: string; data: number }> => {\n return privateRequest(credential, 'POST', `/v1/cross-margin/transfer-in`, 'api.huobi.pro', params);\n};\n\n/**\n * 现货账户转账\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=10000095-77b7-11ed-9966-0242ac110003\n */\nexport const postSpotAccountTransfer = (\n credential: ICredential,\n params: {\n from: string;\n to: string;\n currency: string;\n amount: number;\n 'margin-account': string;\n },\n): Promise<{ success: boolean; data: number; code: number; message: string }> => {\n return privateRequest(credential, 'POST', `/v2/account/transfer`, 'api.huobi.pro', params);\n};\n\n/**\n * 借贷\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41b5d-7773-11ed-9966-0242ac110003\n */\nexport const postBorrow = (\n credential: ICredential,\n params: { currency: string; amount: string },\n): Promise<{\n status: string;\n data: number;\n}> => {\n return privateRequest(credential, 'POST', `/v1/cross-margin/orders`, 'api.huobi.pro', params);\n};\n\n/**\n * 提现\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec42cfd-7773-11ed-9966-0242ac110003\n */\nexport const postWithdraw = (\n credential: ICredential,\n params: {\n address: string;\n amount: string;\n currency: string;\n fee: string;\n chain: string;\n },\n): Promise<{\n status: string;\n data: number;\n}> => {\n return privateRequest(credential, 'POST', `/v1/dw/withdraw/api/create`, 'api.huobi.pro', params);\n};\n\n/**\n * 获取充提历史\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec44f99-7773-11ed-9966-0242ac110003\n */\nexport const getDepositWithdrawHistory = (\n credential: ICredential,\n params: {\n currency: string;\n type: string;\n from?: string;\n size?: string;\n direct?: string;\n },\n): Promise<{\n status: string;\n 'error-code': string;\n 'error-msg': string;\n data: {\n id: number;\n type: string;\n currency: string;\n 'tx-hash': string;\n chain: string;\n amount: string;\n address: string;\n 'address-tag': string;\n fee: string;\n state: string;\n 'create-at': number;\n 'update-at': number;\n }[];\n}> => {\n return privateRequest(credential, 'GET', `/v1/query/deposit-withdraw`, 'api.huobi.pro', params);\n};\n\n/**\n * 资产划转(母子用户之间)\n *\n * 接口权限: 交易\n *\n * 限频: 2次/2s\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec45d8e-7773-11ed-9966-0242ac110003\n */\nexport const postSubUserTransfer = (\n credential: ICredential,\n params: {\n 'sub-uid': number;\n currency: string;\n amount: number;\n 'client-order-id'?: string;\n type: string;\n },\n): Promise<{\n data: number;\n status: string;\n}> => {\n return privateRequest(credential, 'POST', '/v1/subuser/transfer', 'api.huobi.pro', params);\n};\n\n/**\n * 获取子用户列表\n *\n * 接口权限: 读取\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec48f09-7773-11ed-9966-0242ac110003\n */\nexport const getSubUserList = (\n credential: ICredential,\n params?: { fromId?: number },\n): Promise<{\n code: number;\n message?: string;\n data: {\n uid: number;\n userState: string;\n subUserName: string;\n note: string;\n }[];\n nextId?: number;\n ok: boolean;\n}> => {\n return privateRequest(credential, 'GET', `/v2/sub-user/user-list`, 'api.huobi.pro', params);\n};\n\n/**\n * 账户类型查询\n *\n * 是否验签: 是\n *\n * 接口权限: 读取\n *\n * 限频: 每个UID 3秒最多 144 次请求(交易接口3秒最多 72 次请求,查询接口3秒最多 72 次请求) (该UID的所有币种和不同到期日的合约的所有私有接口共享该限制) 。\n *\n * 接口描述: 此接口用于客户查询的账号类型,当前U本位合约有统一账户和非统一账户(全仓逐仓账户)类型。统一账户类型资产放在USDT一个账户上,全仓逐仓账户类型资产放在不同的币对。\n * 统一账户类型为最新升级的,当前不支持API下单。若需要用用API下单请切换账户类型为非统一账户。\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb71825-77b5-11ed-9966-0242ac110003\n */\nexport const getSwapUnifiedAccountType = (\n credential: ICredential,\n): Promise<{\n code: number;\n msg: string;\n ts: number;\n data: {\n account_type: number;\n };\n}> => {\n return privateRequest(credential, 'GET', '/linear-swap-api/v3/swap_unified_account_type', 'api.hbdm.com');\n};\n\n/**\n * 账户类型更改接口\n *\n * 是否验签: 是\n *\n * 接口权限: 交易\n *\n * 限频: 每个UID 3秒最多 144 次请求(交易接口3秒最多 72 次请求,查询接口3秒最多 72 次请求) (该UID的所有币种和不同到期日的合约的所有私有接口共享该限制) 。\n *\n * 接口描述: 调用该接口前需要保证U本位合约无持仓和挂单,当由非统一账户(全仓逐仓账户)变为统一账户还需将资产从逐仓账户划转到全仓账户。\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb7196b-77b5-11ed-9966-0242ac110003\n */\nexport const postSwapSwitchAccountType = (\n credential: ICredential,\n params: { account_type: number },\n): Promise<{\n code: number;\n msg: string;\n ts: number;\n data: {\n account_type: number;\n };\n}> => {\n return privateRequest(\n credential,\n 'POST',\n '/linear-swap-api/v3/swap_switch_account_type',\n 'api.hbdm.com',\n params,\n );\n};\n\n/**\n * APIv2币链参考信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec478f0-7773-11ed-9966-0242ac110003\n */\nexport const getV2ReferenceCurrencies = (\n credential: ICredential,\n params: {\n currency?: string;\n authorizedUser?: string;\n },\n): Promise<{\n code: number;\n data: {\n currency: string;\n assetType: number;\n chains: {\n chain: string;\n displayName: string;\n fullName: string;\n baseChain?: string;\n baseChainProtocol?: string;\n isDynamic?: boolean;\n numOfConfirmations: number;\n numOfFastConfirmations: number;\n depositStatus: string;\n minDepositAmt: string;\n withdrawStatus: string;\n minWithdrawAmt: string;\n withdrawPrecision: number;\n maxWithdrawAmt: string;\n withdrawQuotaPerDay: string;\n withdrawQuotaPerYear: null;\n withdrawQuotaTotal: null;\n withdrawFeeType: string;\n transactFeeWithdraw?: string;\n addrWithTag: boolean;\n addrDepositTag: boolean;\n minTransactFeeWithdraw?: string;\n transactFeeRateWithdraw?: string;\n maxTransactFeeWithdraw?: string;\n }[];\n instStatus: string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v2/reference/currencies', 'api.huobi.pro', params);\n};\n\n/**\n * 获取账户历史\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41049-7773-11ed-9966-0242ac110003\n */\nexport const getAccountHistory = (\n credential: ICredential,\n params: {\n 'account-id': string;\n currency?: string;\n 'transact-types'?: number;\n 'start-time'?: number;\n 'end-time'?: number;\n sort?: 'asc' | 'desc';\n size?: number;\n 'from-id'?: number;\n },\n): Promise<{\n // code: number;\n 'transact-amt': string;\n 'avail-balance': string;\n 'acct-balance': string;\n 'transact-time': string;\n 'record-id': string;\n status: string;\n data: {\n 'account-id': string;\n currency: string;\n 'record-id': string;\n 'transact-amt': string;\n 'transact-type': string;\n 'avail-balance': string;\n 'acct-balance': string;\n 'transact-time': string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v1/account/history', 'api.huobi.pro', params);\n};\n"]}
1
+ {"version":3,"file":"private-api.js","sourceRoot":"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MASC,EAmBA,EAAE;IACH,OAAO,IAAA,sBAAc,EAAC,UAAU,EAAE,KAAK,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;AAC3F,CAAC,CAAC;AAhCW,QAAA,iBAAiB,qBAgC5B","sourcesContent":["import { encodeBase64, formatTime, HmacSHA256 } from '@yuants/utils';\n\nexport interface ICredential {\n access_key: string;\n secret_key: string;\n}\n\nexport const getDefaultCredential = (): ICredential => {\n return {\n access_key: process.env.ACCESS_KEY!,\n secret_key: process.env.SECRET_KEY!,\n };\n};\n\nexport const privateRequest = async (\n credential: ICredential,\n method: string,\n path: string,\n api_root: string,\n params?: any,\n) => {\n const requestParams = `AccessKeyId=${\n credential.access_key\n }&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=${encodeURIComponent(\n new Date().toISOString().split('.')[0],\n )}${\n method === 'GET' && params !== undefined\n ? `&${Object.entries(params)\n .filter(([, v]) => v !== undefined)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}=${v}`)\n .join('&')}`\n : ''\n }`;\n\n const body = method === 'GET' ? '' : JSON.stringify(params);\n\n const requestString = `${method}\\n${api_root}\\n${path}\\n${requestParams}`;\n\n const str = encodeBase64(\n await HmacSHA256(\n new TextEncoder().encode(requestString),\n new TextEncoder().encode(credential.secret_key),\n ),\n );\n\n const url = new URL(`https://${api_root}${path}?${requestParams}&Signature=${encodeURIComponent(str)}`);\n // url.searchParams.sort();\n console.info(formatTime(Date.now()), method, url.href, body);\n const res = await fetch(url.href, {\n method,\n headers: { 'Content-Type': 'application/json' },\n body: body || undefined,\n });\n\n const retStr = await res.text();\n console.info(formatTime(Date.now()), 'PrivateResponse', url.toString(), res.status);\n try {\n return JSON.parse(retStr);\n } catch (e) {\n console.error(formatTime(Date.now()), 'huobiRequestFailed', path, JSON.stringify(params), retStr);\n throw e;\n }\n};\n\n/**\n * 获取账户信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec40743-7773-11ed-9966-0242ac110003\n */\nexport const getAccount = (\n credential: ICredential,\n): Promise<{\n status: string;\n data: {\n id: number;\n type: string;\n state: string;\n subtype: string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v1/account/accounts', 'api.huobi.pro');\n};\n\n/**\n * 获取用户ID\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec491c9-7773-11ed-9966-0242ac110003\n */\nexport const getUid = (credential: ICredential): Promise<{ data: number; code: number }> => {\n return privateRequest(credential, 'GET', '/v2/user/uid', 'api.huobi.pro');\n};\n\n/**\n * 获取统一账户信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=10000073-77b7-11ed-9966-0242ac110003\n */\nexport const getUnifiedAccountInfo = (\n credential: ICredential,\n): Promise<{\n status: string;\n code: number;\n msg: string;\n data: {\n margin_asset: string;\n margin_balance: number;\n margin_static: number;\n cross_margin_static: number;\n cross_profit_unreal: number;\n withdraw_available: number;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/linear-swap-api/v3/unified_account_info', 'api.hbdm.com');\n};\n\n/**\n * 获取合约持仓信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb74963-77b5-11ed-9966-0242ac110003\n */\nexport const getSwapCrossPositionInfo = (\n credential: ICredential,\n params?: {\n contract_code?: string;\n pair?: string;\n contract_type: string;\n },\n): Promise<{\n status: string;\n ts: number;\n data: {\n symbol: string;\n contract_code: string;\n volume: number;\n available: number;\n frozen: number;\n cost_open: number;\n cost_hold: number;\n profit_unreal: number;\n profit_rate: number;\n lever_rate: number;\n position_margin: number;\n direction: string;\n profit: number;\n last_price: number;\n margin_asset: string;\n margin_mode: string;\n margin_account: string;\n contract_type: string;\n pair: string;\n business_type: string;\n position_mode: string;\n adl_risk_percent: string;\n liquidation_price?: number;\n }[];\n}> => {\n return privateRequest(\n credential,\n 'POST',\n '/linear-swap-api/v1/swap_cross_position_info',\n 'api.hbdm.com',\n params,\n );\n};\n\n/**\n * 获取合约挂单\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb784d4-77b5-11ed-9966-0242ac110003\n */\nexport const getSwapOpenOrders = (\n credential: ICredential,\n params?: {\n contract_code?: string;\n pair?: string;\n page_index?: number;\n page_size?: number;\n sort_by?: string;\n trade_type?: string;\n },\n): Promise<{\n status: string;\n data: {\n orders: {\n order_id_str: string;\n contract_code: string;\n order_price_type: string;\n direction: string;\n offset: string;\n volume: number;\n created_at: number;\n price: number;\n trade_volume: number;\n }[];\n };\n}> => {\n return privateRequest(\n credential,\n 'POST',\n '/linear-swap-api/v1/swap_cross_openorders',\n 'api.hbdm.com',\n params,\n );\n};\n\n/**\n * 获取现货账户余额\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec40922-7773-11ed-9966-0242ac110003\n */\nexport const getSpotAccountBalance = (\n credential: ICredential,\n account_uid: number,\n): Promise<{\n status: string;\n data: {\n list: {\n currency: string;\n balance: string;\n type: string;\n }[];\n };\n}> => {\n return privateRequest(credential, 'GET', `/v1/account/accounts/${account_uid}/balance`, 'api.huobi.pro');\n};\n\n/**\n * 获取杠杆借贷信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41863-7773-11ed-9966-0242ac110003\n */\nexport const getCrossMarginLoanInfo = (\n credential: ICredential,\n): Promise<{\n status: string;\n code: number;\n data: {\n currency: string;\n 'loanable-amt': string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v1/cross-margin/loan-info', 'api.huobi.pro');\n};\n\n/**\n * 现货下单\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=10000065-77b7-11ed-9966-0242ac110003\n */\nexport const postSpotOrder = (\n credential: ICredential,\n params: {\n symbol: string;\n 'account-id': string;\n amount: string;\n market_amount?: string;\n 'borrow-amount'?: string;\n type: string;\n 'trade-purpose': string;\n price?: string;\n source: string;\n 'client-order-id'?: string;\n },\n): Promise<{ success: boolean; code: number; message: string; data: { orderId: number } }> => {\n return privateRequest(credential, 'POST', `/v1/order/auto/place`, 'api.huobi.pro', params);\n};\n\n/**\n * 合约下单\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb77159-77b5-11ed-9966-0242ac110003\n */\nexport const postSwapOrder = (\n credential: ICredential,\n params: {\n contract_code: string;\n contract_type: string;\n price?: number;\n volume: number;\n offset: string;\n direction: string;\n lever_rate: number;\n order_price_type: string;\n channel_code?: string;\n },\n): Promise<{ status: string; ts: number; data: { order_id: number; order_id_str: string } }> => {\n return privateRequest(credential, 'POST', '/linear-swap-api/v1/swap_cross_order', 'api.hbdm.com', params);\n};\n\n/**\n * 获取现货存款地址\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec45fb7-7773-11ed-9966-0242ac110003\n */\nexport const getSpotAccountDepositAddresses = (\n credential: ICredential,\n params: { currency: string },\n): Promise<{\n code: number;\n message: string;\n data: {\n currency: string;\n chain: string;\n address: string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', `/v2/account/deposit/address`, 'api.huobi.pro', params);\n};\n\n/**\n * 获取账户流水\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec4610b-7773-11ed-9966-0242ac110003\n */\nexport const getAccountLedger = (\n credential: ICredential,\n params: { accountId: string; currency: string },\n): Promise<{\n status: string;\n data: {\n transactTime: number;\n transactAmt: number;\n }[];\n}> => {\n return privateRequest(credential, 'GET', `/v2/account/ledger`, 'api.huobi.pro', params);\n};\n\n/**\n * 超级杠杆转出\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41ff0-7773-11ed-9966-0242ac110003\n */\nexport const postSuperMarginAccountTransferOut = (\n credential: ICredential,\n params: {\n currency: string;\n amount: string;\n },\n): Promise<{ status: string; data: number }> => {\n return privateRequest(credential, 'POST', `/v1/cross-margin/transfer-out`, 'api.huobi.pro', params);\n};\n\n/**\n * 超级杠杆转入\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41f0e-7773-11ed-9966-0242ac110003\n */\nexport const postSuperMarginAccountTransferIn = (\n credential: ICredential,\n params: {\n currency: string;\n amount: string;\n },\n): Promise<{ status: string; data: number }> => {\n return privateRequest(credential, 'POST', `/v1/cross-margin/transfer-in`, 'api.huobi.pro', params);\n};\n\n/**\n * 现货账户转账\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=10000095-77b7-11ed-9966-0242ac110003\n */\nexport const postSpotAccountTransfer = (\n credential: ICredential,\n params: {\n from: string;\n to: string;\n currency: string;\n amount: number;\n 'margin-account': string;\n },\n): Promise<{ success: boolean; data: number; code: number; message: string }> => {\n return privateRequest(credential, 'POST', `/v2/account/transfer`, 'api.huobi.pro', params);\n};\n\n/**\n * 借贷\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41b5d-7773-11ed-9966-0242ac110003\n */\nexport const postBorrow = (\n credential: ICredential,\n params: { currency: string; amount: string },\n): Promise<{\n status: string;\n data: number;\n}> => {\n return privateRequest(credential, 'POST', `/v1/cross-margin/orders`, 'api.huobi.pro', params);\n};\n\n/**\n * 提现\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec42cfd-7773-11ed-9966-0242ac110003\n */\nexport const postWithdraw = (\n credential: ICredential,\n params: {\n address: string;\n amount: string;\n currency: string;\n fee: string;\n chain: string;\n },\n): Promise<{\n status: string;\n data: number;\n}> => {\n return privateRequest(credential, 'POST', `/v1/dw/withdraw/api/create`, 'api.huobi.pro', params);\n};\n\n/**\n * 获取充提历史\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec44f99-7773-11ed-9966-0242ac110003\n */\nexport const getDepositWithdrawHistory = (\n credential: ICredential,\n params: {\n currency: string;\n type: string;\n from?: string;\n size?: string;\n direct?: string;\n },\n): Promise<{\n status: string;\n 'error-code': string;\n 'error-msg': string;\n data: {\n id: number;\n type: string;\n currency: string;\n 'tx-hash': string;\n chain: string;\n amount: string;\n address: string;\n 'address-tag': string;\n fee: string;\n state: string;\n 'create-at': number;\n 'update-at': number;\n }[];\n}> => {\n return privateRequest(credential, 'GET', `/v1/query/deposit-withdraw`, 'api.huobi.pro', params);\n};\n\n/**\n * 资产划转(母子用户之间)\n *\n * 接口权限: 交易\n *\n * 限频: 2次/2s\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec45d8e-7773-11ed-9966-0242ac110003\n */\nexport const postSubUserTransfer = (\n credential: ICredential,\n params: {\n 'sub-uid': number;\n currency: string;\n amount: number;\n 'client-order-id'?: string;\n type: string;\n },\n): Promise<{\n data: number;\n status: string;\n}> => {\n return privateRequest(credential, 'POST', '/v1/subuser/transfer', 'api.huobi.pro', params);\n};\n\n/**\n * 获取子用户列表\n *\n * 接口权限: 读取\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec48f09-7773-11ed-9966-0242ac110003\n */\nexport const getSubUserList = (\n credential: ICredential,\n params?: { fromId?: number },\n): Promise<{\n code: number;\n message?: string;\n data: {\n uid: number;\n userState: string;\n subUserName: string;\n note: string;\n }[];\n nextId?: number;\n ok: boolean;\n}> => {\n return privateRequest(credential, 'GET', `/v2/sub-user/user-list`, 'api.huobi.pro', params);\n};\n\n/**\n * 账户类型查询\n *\n * 是否验签: 是\n *\n * 接口权限: 读取\n *\n * 限频: 每个UID 3秒最多 144 次请求(交易接口3秒最多 72 次请求,查询接口3秒最多 72 次请求) (该UID的所有币种和不同到期日的合约的所有私有接口共享该限制) 。\n *\n * 接口描述: 此接口用于客户查询的账号类型,当前U本位合约有统一账户和非统一账户(全仓逐仓账户)类型。统一账户类型资产放在USDT一个账户上,全仓逐仓账户类型资产放在不同的币对。\n * 统一账户类型为最新升级的,当前不支持API下单。若需要用用API下单请切换账户类型为非统一账户。\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb71825-77b5-11ed-9966-0242ac110003\n */\nexport const getSwapUnifiedAccountType = (\n credential: ICredential,\n): Promise<{\n code: number;\n msg: string;\n ts: number;\n data: {\n account_type: number;\n };\n}> => {\n return privateRequest(credential, 'GET', '/linear-swap-api/v3/swap_unified_account_type', 'api.hbdm.com');\n};\n\n/**\n * 账户类型更改接口\n *\n * 是否验签: 是\n *\n * 接口权限: 交易\n *\n * 限频: 每个UID 3秒最多 144 次请求(交易接口3秒最多 72 次请求,查询接口3秒最多 72 次请求) (该UID的所有币种和不同到期日的合约的所有私有接口共享该限制) 。\n *\n * 接口描述: 调用该接口前需要保证U本位合约无持仓和挂单,当由非统一账户(全仓逐仓账户)变为统一账户还需将资产从逐仓账户划转到全仓账户。\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=8cb7196b-77b5-11ed-9966-0242ac110003\n */\nexport const postSwapSwitchAccountType = (\n credential: ICredential,\n params: { account_type: number },\n): Promise<{\n code: number;\n msg: string;\n ts: number;\n data: {\n account_type: number;\n };\n}> => {\n return privateRequest(\n credential,\n 'POST',\n '/linear-swap-api/v3/swap_switch_account_type',\n 'api.hbdm.com',\n params,\n );\n};\n\n/**\n * APIv2币链参考信息\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec478f0-7773-11ed-9966-0242ac110003\n */\nexport const getV2ReferenceCurrencies = (\n credential: ICredential,\n params: {\n currency?: string;\n authorizedUser?: string;\n },\n): Promise<{\n code: number;\n data: {\n currency: string;\n assetType: number;\n chains: {\n chain: string;\n displayName: string;\n fullName: string;\n baseChain?: string;\n baseChainProtocol?: string;\n isDynamic?: boolean;\n numOfConfirmations: number;\n numOfFastConfirmations: number;\n depositStatus: string;\n minDepositAmt: string;\n withdrawStatus: string;\n minWithdrawAmt: string;\n withdrawPrecision: number;\n maxWithdrawAmt: string;\n withdrawQuotaPerDay: string;\n withdrawQuotaPerYear: null;\n withdrawQuotaTotal: null;\n withdrawFeeType: string;\n transactFeeWithdraw?: string;\n addrWithTag: boolean;\n addrDepositTag: boolean;\n minTransactFeeWithdraw?: string;\n transactFeeRateWithdraw?: string;\n maxTransactFeeWithdraw?: string;\n }[];\n instStatus: string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v2/reference/currencies', 'api.huobi.pro', params);\n};\n\n/**\n * 获取账户历史\n *\n * https://www.htx.com/zh-cn/opend/newApiPages/?id=7ec41049-7773-11ed-9966-0242ac110003\n */\nexport const getAccountHistory = (\n credential: ICredential,\n params: {\n 'account-id': string;\n currency?: string;\n 'transact-types'?: number;\n 'start-time'?: number;\n 'end-time'?: number;\n sort?: 'asc' | 'desc';\n size?: number;\n 'from-id'?: number;\n },\n): Promise<{\n // code: number;\n 'transact-amt': string;\n 'avail-balance': string;\n 'acct-balance': string;\n 'transact-time': string;\n 'record-id': string;\n status: string;\n data: {\n 'account-id': string;\n currency: string;\n 'record-id': string;\n 'transact-amt': string;\n 'transact-type': string;\n 'avail-balance': string;\n 'acct-balance': string;\n 'transact-time': string;\n }[];\n}> => {\n return privateRequest(credential, 'GET', '/v1/account/history', 'api.huobi.pro', params);\n};\n"]}
@@ -17,10 +17,10 @@ const getSwapAccountInfo = async (credential) => {
17
17
  if (v.margin_balance === 0)
18
18
  continue;
19
19
  positions.push((0, data_account_1.makeSpotPosition)({
20
- position_id: (0, utils_1.encodePath)('HTX', 'SWAP-MARGIN', v.margin_asset),
20
+ position_id: (0, utils_1.encodePath)('HTX', 'SWAP-ASSET', v.margin_asset),
21
21
  datasource_id: 'HTX',
22
- product_id: (0, utils_1.encodePath)('HTX', 'SWAP-MARGIN', v.margin_asset),
23
- volume: +v.margin_balance,
22
+ product_id: (0, utils_1.encodePath)('HTX', 'SWAP-ASSET', v.margin_asset),
23
+ volume: +v.margin_static,
24
24
  free_volume: +v.withdraw_available,
25
25
  closable_price: usdAssets.has(v.margin_asset) ? 1 : 0,
26
26
  }));
@@ -1 +1 @@
1
- {"version":3,"file":"swap.js","sourceRoot":"","sources":["../../../src/services/accounts/swap.ts"],"names":[],"mappings":";;;AAAA,uDAAmE;AACnE,yCAA2C;AAC3C,uDAAqG;AACrG,wCAA0C;AAE1C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,M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G,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,UAAU,GAAG,CAAC,CAAA,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAE,WAAW,KAAI,CAAC,CAAC,CAAC;QAC3E,SAAS,CAAC,IAAI,CAAC;YACb,WAAW,EAAE,GAAG,UAAU,IAAI,CAAC,CAAC,aAAa,IAAI,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,WAAW,EAAE;YAC/E,aAAa,EAAE,KAAK;YACpB,UAAU;YACV,SAAS,EAAE,CAAC,CAAC,SAAS,KAAK,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO;YACnD,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,WAAW,EAAE,CAAC,CAAC,SAAS;YACxB,cAAc,EAAE,CAAC,CAAC,SAAS;YAC3B,cAAc,EAAE,CAAC,CAAC,UAAU;YAC5B,eAAe,EAAE,CAAC,CAAC,aAAa;YAChC,iBAAiB,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,SAAS;YAC7E,SAAS;SACV,CAAC,CAAC;KACJ;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AA5CW,QAAA,kBAAkB,sBA4C7B","sourcesContent":["import { IPosition, makeSpotPosition } from '@yuants/data-account';\nimport { encodePath } from '@yuants/utils';\nimport { getSwapCrossPositionInfo, getUnifiedAccountInfo, ICredential } from '../../api/private-api';\nimport { productCache } from '../product';\n\nconst usdAssets = new Set(['USDT', 'USDC', 'USDD']);\n\nexport const getSwapAccountInfo = async (credential: ICredential): Promise<IPosition[]> => {\n const positions: IPosition[] = [];\n // balance\n const balance = await getUnifiedAccountInfo(credential);\n if (!balance.data) {\n throw new Error('Failed to get unified account info');\n }\n\n for (const v of balance.data || []) {\n if (v.margin_balance === 0) continue;\n positions.push(\n makeSpotPosition({\n position_id: encodePath('HTX', 'SWAP-MARGIN', v.margin_asset),\n datasource_id: 'HTX',\n product_id: encodePath('HTX', 'SWAP-MARGIN', v.margin_asset),\n volume: +v.margin_balance,\n free_volume: +v.withdraw_available,\n closable_price: usdAssets.has(v.margin_asset) ? 1 : 0,\n }),\n );\n }\n\n // positions\n const positionsRes = await getSwapCrossPositionInfo(credential);\n for (const v of positionsRes.data || []) {\n const product_id = encodePath('HTX', 'SWAP', v.contract_code);\n const theProduct = await productCache.query(product_id);\n const valuation = v.volume * v.last_price * (theProduct?.value_scale || 1);\n positions.push({\n position_id: `${product_id}/${v.contract_type}/${v.direction}/${v.margin_mode}`,\n datasource_id: 'HTX',\n product_id,\n direction: v.direction === 'buy' ? 'LONG' : 'SHORT',\n volume: v.volume,\n free_volume: v.available,\n position_price: v.cost_hold,\n closable_price: v.last_price,\n floating_profit: v.profit_unreal,\n liquidation_price: v.liquidation_price ? `${v.liquidation_price}` : undefined,\n valuation,\n });\n }\n\n return positions;\n};\n"]}
1
+ {"version":3,"file":"swap.js","sourceRoot":"","sources":["../../../src/services/accounts/swap.ts"],"names":[],"mappings":";;;AAAA,uDAAmE;AACnE,yCAA2C;AAC3C,uDAAqG;AACrG,wCAA0C;AAE1C,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;AAE7C,MAAM,kBAAkB,GAAG,KAAK,EAAE,UAAuB,EAAwB,EAAE;IACxF,MAAM,SAAS,GAAgB,EAAE,CAAC;IAClC,UAAU;IACV,MAAM,OAAO,GAAG,MAAM,IAAA,mCAAqB,EAAC,UAAU,CAAC,CAAC;IACxD,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;KACvD;IAED,KAAK,MAAM,CAAC,IAAI,OAAO,CAAC,IAAI,IAAI,EAAE,EAAE;QAClC,IAAI,CAAC,CAAC,cAAc,KAAK,CAAC;YAAE,SAAS;QACrC,SAAS,CAAC,I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YAChB,WAAW,EAAE,CAAC,CAAC,SAAS;YACxB,cAAc,EAAE,CAAC,CAAC,SAAS;YAC3B,cAAc,EAAE,CAAC,CAAC,UAAU;YAC5B,eAAe,EAAE,CAAC,CAAC,aAAa;YAChC,iBAAiB,EAAE,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,SAAS;YAC7E,SAAS;SACV,CAAC,CAAC;KACJ;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AA5CW,QAAA,kBAAkB,sBA4C7B","sourcesContent":["import { IPosition, makeSpotPosition } from '@yuants/data-account';\nimport { encodePath } from '@yuants/utils';\nimport { getSwapCrossPositionInfo, getUnifiedAccountInfo, ICredential } from '../../api/private-api';\nimport { productCache } from '../product';\n\nconst usdAssets = new Set(['USDT', 'USDC', 'USDD']);\n\nexport const getSwapAccountInfo = async (credential: ICredential): Promise<IPosition[]> => {\n const positions: IPosition[] = [];\n // balance\n const balance = await getUnifiedAccountInfo(credential);\n if (!balance.data) {\n throw new Error('Failed to get unified account info');\n }\n\n for (const v of balance.data || []) {\n if (v.margin_balance === 0) continue;\n positions.push(\n makeSpotPosition({\n position_id: encodePath('HTX', 'SWAP-ASSET', v.margin_asset),\n datasource_id: 'HTX',\n product_id: encodePath('HTX', 'SWAP-ASSET', v.margin_asset),\n volume: +v.margin_static,\n free_volume: +v.withdraw_available,\n closable_price: usdAssets.has(v.margin_asset) ? 1 : 0,\n }),\n );\n }\n\n // positions\n const positionsRes = await getSwapCrossPositionInfo(credential);\n for (const v of positionsRes.data || []) {\n const product_id = encodePath('HTX', 'SWAP', v.contract_code);\n const theProduct = await productCache.query(product_id);\n const valuation = v.volume * v.last_price * (theProduct?.value_scale || 1);\n positions.push({\n position_id: `${product_id}/${v.contract_type}/${v.direction}/${v.margin_mode}`,\n datasource_id: 'HTX',\n product_id,\n direction: v.direction === 'buy' ? 'LONG' : 'SHORT',\n volume: v.volume,\n free_volume: v.available,\n position_price: v.cost_hold,\n closable_price: v.last_price,\n floating_profit: v.profit_unreal,\n liquidation_price: v.liquidation_price ? `${v.liquidation_price}` : undefined,\n valuation,\n });\n }\n\n return positions;\n};\n"]}
@@ -14,8 +14,8 @@ async function handleSwapOrder(order, credential) {
14
14
  // 获取仓位信息
15
15
  const positionInfo = await (0, private_api_1.getSwapCrossPositionInfo)(credential);
16
16
  const mapContractCodeToRate = Object.fromEntries(positionInfo.data.map((v) => [v.contract_code, v.lever_rate]));
17
- const lever_rate = (_a = mapContractCodeToRate[order.product_id]) !== null && _a !== void 0 ? _a : 20;
18
17
  const [, instType, contractCode] = (0, utils_1.decodePath)(order.product_id);
18
+ const lever_rate = (_a = mapContractCodeToRate[contractCode]) !== null && _a !== void 0 ? _a : 20;
19
19
  const params = {
20
20
  contract_code: contractCode,
21
21
  contract_type: 'swap',
@@ -31,7 +31,7 @@ async function handleSwapOrder(order, credential) {
31
31
  const result = await (0, private_api_1.postSwapOrder)(credential, params);
32
32
  console.info((0, utils_1.formatTime)(Date.now()), 'SubmitOrder', JSON.stringify(result), JSON.stringify(params));
33
33
  if (result.status !== 'ok') {
34
- throw new Error(`Failed to submit swap order: status=${result.status}`);
34
+ throw (0, utils_1.newError)(`HTX_SUBMIT_ORDER_FAILED`, { result });
35
35
  }
36
36
  return { order_id: result.data.order_id_str };
37
37
  }
@@ -1 +1 @@
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,I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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 [, instType, contractCode] = decodePath(order.product_id);\n const params = {\n contract_code: contractCode,\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 channel_code: process.env.BROKER_ID,\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 const [, instType, contractCode] = decodePath(order.product_id);\n\n // 获取账户余额, 产品信息和价格\n const [balanceRes, theProduct, priceRes] = await Promise.all([\n getSpotAccountBalance(credential, superMarginAccountUid),\n productCache.query(order.product_id),\n getSpotTick({ symbol: contractCode }),\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: contractCode,\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 'client-order-id': process.env.BROKER_ID,\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
+ {"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,CAAC,EAAE,QAAQ,EAAE,YAAY,CAAC,GAAG,IAAA,kBAAU,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAChE,MAAM,UAAU,GAAG,MAAA,qBAAqB,CAAC,YAAY,CAAC,mCAAI,EAAE,CAAC;IAC7D,MAAM,MAAM,GAAG;QACb,aAAa,EAAE,YAAY;QAC3B,aAAa,EAAE,MAAM;QACrB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,MAAM,EACJ,KAAK,CAAC,eAAe,KAAK,WA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C,CAAC;IACvD,OAAO,CAAC,IAAI,CAAC,IAAA,kBAAU,EAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EAAE,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC;IAEpG,IAAI,MAAM,CAAC,OAAO,KAAK,KAAK,EAAE;QAC5B,MAAM,IAAI,KAAK,CAAC,6CAA6C,MAAM,CAAC,IAAI,YAAY,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;KACvG;IAED,OAAO,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC;AACtD,CAAC;AAEM,MAAM,WAAW,GAAG,CAAC,UAAuB,EAAE,KAAa,EAAiC,EAAE;IACnG,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 [, instType, contractCode] = decodePath(order.product_id);\n const lever_rate = mapContractCodeToRate[contractCode] ?? 20;\n const params = {\n contract_code: contractCode,\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 channel_code: process.env.BROKER_ID,\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 newError(`HTX_SUBMIT_ORDER_FAILED`, { result });\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 const [, instType, contractCode] = decodePath(order.product_id);\n\n // 获取账户余额, 产品信息和价格\n const [balanceRes, theProduct, priceRes] = await Promise.all([\n getSpotAccountBalance(credential, superMarginAccountUid),\n productCache.query(order.product_id),\n getSpotTick({ symbol: contractCode }),\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: contractCode,\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 'client-order-id': process.env.BROKER_ID,\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yuants/vendor-huobi",
3
- "version": "0.18.2",
3
+ "version": "0.18.3",
4
4
  "main": "lib/index.js",
5
5
  "files": [
6
6
  "dist",
@@ -8,19 +8,19 @@
8
8
  "temp"
9
9
  ],
10
10
  "dependencies": {
11
- "@yuants/protocol": "0.53.5",
12
- "@yuants/data-account": "0.11.2",
13
- "@yuants/data-order": "0.7.3",
14
- "@yuants/data-ohlc": "0.5.1",
15
- "@yuants/transfer": "0.2.42",
16
- "@yuants/utils": "0.17.0",
17
- "@yuants/cache": "0.3.6",
18
- "@yuants/sql": "0.9.33",
19
- "@yuants/data-product": "0.5.3",
20
- "@yuants/data-series": "0.3.55",
21
- "@yuants/data-interest-rate": "0.2.1",
22
- "@yuants/data-quote": "0.4.2",
23
- "@yuants/exchange": "0.8.3",
11
+ "@yuants/protocol": "0.53.6",
12
+ "@yuants/data-account": "0.11.3",
13
+ "@yuants/data-order": "0.7.4",
14
+ "@yuants/data-ohlc": "0.5.2",
15
+ "@yuants/transfer": "0.2.43",
16
+ "@yuants/utils": "0.18.0",
17
+ "@yuants/cache": "0.3.7",
18
+ "@yuants/sql": "0.9.34",
19
+ "@yuants/data-product": "0.5.4",
20
+ "@yuants/data-series": "0.3.56",
21
+ "@yuants/data-interest-rate": "0.2.2",
22
+ "@yuants/data-quote": "0.4.3",
23
+ "@yuants/exchange": "0.8.4",
24
24
  "rxjs": "~7.5.6"
25
25
  },
26
26
  "devDependencies": {
@@ -30,7 +30,7 @@
30
30
  "@rushstack/heft-node-rig": "~1.10.7",
31
31
  "@types/heft-jest": "1.0.3",
32
32
  "@types/node": "22",
33
- "@yuants/extension": "0.2.34",
33
+ "@yuants/extension": "0.2.35",
34
34
  "@yuants/tool-kit": "0.2.1",
35
35
  "typescript": "~4.7.4"
36
36
  },
@@ -1,47 +1,47 @@
1
1
  {
2
- "apps/vendor-huobi/CHANGELOG.json": "d73b95704681b5e91682c4304dcf9db81c5fcdb7",
3
- "apps/vendor-huobi/CHANGELOG.md": "357a327c939469b5c1c8aa79534c8dc95d1d1aac",
2
+ "apps/vendor-huobi/CHANGELOG.json": "3a067914dc6c4903715c1fdd11d6f7b8b61790c9",
3
+ "apps/vendor-huobi/CHANGELOG.md": "6423ae74483cb4262edd8c9a5b8fb2934fd77e41",
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": "8b59c9a85a4c0d637466ae1d77f3bec2c40d1b5c",
10
+ "apps/vendor-huobi/package.json": "40c4ed9a9b56b8335050c3de518be215dff188b0",
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": "8f552b84956a1c65077e194dcf481924204f4662",
14
+ "apps/vendor-huobi/src/api/private-api.ts": "509a56b3501c76813c7cbf8cd3b2b851d5cb5957",
15
15
  "apps/vendor-huobi/src/api/public-api.ts": "730d77c55ae5bf5022c5ccdc964f874131f8b341",
16
16
  "apps/vendor-huobi/src/index.ts": "997283c933e2df8c6d35ce3d2f40d7d0c33c469b",
17
17
  "apps/vendor-huobi/src/services/accounts/spot.ts": "9b214135dd375822ea5ef03c0fee108873ccc264",
18
18
  "apps/vendor-huobi/src/services/accounts/super-margin.ts": "ff885947334f43085aacb6e8c37b997afee2b7f6",
19
- "apps/vendor-huobi/src/services/accounts/swap.ts": "91ef044f09ed3dddd7b0d32116a16c78f74ba9be",
19
+ "apps/vendor-huobi/src/services/accounts/swap.ts": "99ef837adc9c6d47358898c5f869d947e834ae18",
20
20
  "apps/vendor-huobi/src/services/exchange.ts": "6fed94206a22c43d3c6890cf52ff054a24d98d82",
21
21
  "apps/vendor-huobi/src/services/interest-rate-service.ts": "3180227cd8fe336e187ad7a90bf3ce1bb7dfc7f7",
22
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",
26
- "apps/vendor-huobi/src/services/orders/submitOrder.ts": "c6b0625d4922d5188ef042893865e029f5123f24",
26
+ "apps/vendor-huobi/src/services/orders/submitOrder.ts": "fbf9bd1fd423af0937e1bcc057a09bff4dd59c92",
27
27
  "apps/vendor-huobi/src/services/product.ts": "096feb6e1348910242e814ca45848afa3b5bff98",
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
31
  "apps/vendor-huobi/.rush/temp/shrinkwrap-deps.json": "237a816d6e825b5bd2a0fc742f5d055c19e37d3d",
32
- "libraries/protocol/temp/package-deps.json": "359ac43a7382bafa1f91541e084256baec86d40b",
33
- "libraries/data-account/temp/package-deps.json": "a94782e226c47a0f5198a5cca619ae7815055f4a",
34
- "libraries/data-order/temp/package-deps.json": "e89dd8f11cdbe84eb8bdf474105abccdf51abfaa",
35
- "libraries/data-ohlc/temp/package-deps.json": "919692801e80ce34e9af7470712ac4d1c0086af7",
36
- "libraries/transfer/temp/package-deps.json": "266da813de0fc7b8de0acb4f1a561bd5cab7f294",
37
- "libraries/utils/temp/package-deps.json": "acd039ba8f5f93e664764ad2c8474878bd105c3b",
38
- "libraries/cache/temp/package-deps.json": "6f7f290f9a9c2e42e937d8ce3b55a6b541d2e835",
39
- "libraries/sql/temp/package-deps.json": "43f7034c83d7ac4b6c4224b8e916ac39fd78057d",
40
- "libraries/data-product/temp/package-deps.json": "00c23f21d7977f38a942ed06f4812e5ddc2b6248",
41
- "libraries/data-series/temp/package-deps.json": "ba6b4e5b9beec9dbe54fcdc12820d8af70356d50",
42
- "libraries/data-interest-rate/temp/package-deps.json": "5f955d9b9c04936964ba20a37d5e00816fb33f67",
43
- "libraries/data-quote/temp/package-deps.json": "6ee7c2a4c28dd7947039fd9561ff045400848bde",
44
- "libraries/exchange/temp/package-deps.json": "a254260f066adc3e196d020f7eae7354db045404",
45
- "libraries/extension/temp/package-deps.json": "89c372a6eab7dfe766edc0b102492364aa8684fe",
32
+ "libraries/protocol/temp/package-deps.json": "ad2b09da06aa0b6d98e9ca145c3da7c8418f30d1",
33
+ "libraries/data-account/temp/package-deps.json": "ec07276e124d707820e348948c8689cd4b4d5a84",
34
+ "libraries/data-order/temp/package-deps.json": "d2826719d6e1f86ad64cfe6556a0f61352e02897",
35
+ "libraries/data-ohlc/temp/package-deps.json": "f6a0a2248e237fe960daf27c93071ec1c3235fa3",
36
+ "libraries/transfer/temp/package-deps.json": "52cd9bb451ece058b39c7a7b08dd3fef1a57b934",
37
+ "libraries/utils/temp/package-deps.json": "6afd4e6b9f8348c0c24e05f7289101fc6b8fa5a9",
38
+ "libraries/cache/temp/package-deps.json": "8faf993aa54072a8cc7773ca9502618ec1660be1",
39
+ "libraries/sql/temp/package-deps.json": "1fb8bcfa1bd3912150e7567770b065794a3b2138",
40
+ "libraries/data-product/temp/package-deps.json": "77b545e27fbd147bf5fded94beb5baaa33687563",
41
+ "libraries/data-series/temp/package-deps.json": "6744fc1995bb77846daccced427210187b5e774f",
42
+ "libraries/data-interest-rate/temp/package-deps.json": "d1a26e2ed8d3ecd147e0b3a897927720d7760597",
43
+ "libraries/data-quote/temp/package-deps.json": "5aa2671e9a9e7b94827a8891049c4af5eefe757e",
44
+ "libraries/exchange/temp/package-deps.json": "8315951811f0278801081fe8e48ba07213af6816",
45
+ "libraries/extension/temp/package-deps.json": "d0a314f466619661a85b5fa9cc12ffe0b427864b",
46
46
  "tools/toolkit/temp/package-deps.json": "23e053490eb8feade23e4d45de4e54883e322711"
47
47
  }