@yuants/vendor-gate 0.6.8 → 0.6.10

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.
Files changed (53) hide show
  1. package/dist/api/http-client.js.map +1 -1
  2. package/dist/api/private-api.js +6 -0
  3. package/dist/api/private-api.js.map +1 -1
  4. package/dist/api/rate-limiter.js.map +1 -1
  5. package/dist/index.js +1 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/services/accounts/unified.js.map +1 -1
  8. package/dist/services/default-credential.js.map +1 -1
  9. package/dist/services/interest-ledger-service.js +34 -0
  10. package/dist/services/interest-ledger-service.js.map +1 -0
  11. package/dist/services/markets/quote.js.map +1 -1
  12. package/dist/services/ohlc-service.js.map +1 -1
  13. package/dist/services/orders/cancelOrder.js.map +1 -1
  14. package/dist/services/orders/listOrders.js.map +1 -1
  15. package/dist/services/orders/submitOrder.js.map +1 -1
  16. package/dist/services/quotes.js +1 -1
  17. package/dist/services/quotes.js.map +1 -1
  18. package/lib/api/http-client.d.ts +2 -2
  19. package/lib/api/http-client.d.ts.map +1 -1
  20. package/lib/api/http-client.js.map +1 -1
  21. package/lib/api/private-api.d.ts +24 -1
  22. package/lib/api/private-api.d.ts.map +1 -1
  23. package/lib/api/private-api.js +8 -1
  24. package/lib/api/private-api.js.map +1 -1
  25. package/lib/api/public-api.d.ts +1 -8
  26. package/lib/api/public-api.d.ts.map +1 -1
  27. package/lib/api/rate-limiter.js.map +1 -1
  28. package/lib/index.d.ts +1 -0
  29. package/lib/index.d.ts.map +1 -1
  30. package/lib/index.js +1 -0
  31. package/lib/index.js.map +1 -1
  32. package/lib/services/accounts/profile.d.ts.map +1 -1
  33. package/lib/services/accounts/unified.d.ts.map +1 -1
  34. package/lib/services/accounts/unified.js.map +1 -1
  35. package/lib/services/default-credential.js.map +1 -1
  36. package/lib/services/interest-ledger-service.d.ts +2 -0
  37. package/lib/services/interest-ledger-service.d.ts.map +1 -0
  38. package/lib/services/interest-ledger-service.js +36 -0
  39. package/lib/services/interest-ledger-service.js.map +1 -0
  40. package/lib/services/markets/quote.js.map +1 -1
  41. package/lib/services/ohlc-service.js.map +1 -1
  42. package/lib/services/orders/cancelOrder.js.map +1 -1
  43. package/lib/services/orders/listOrders.d.ts.map +1 -1
  44. package/lib/services/orders/listOrders.js.map +1 -1
  45. package/lib/services/orders/submitOrder.js.map +1 -1
  46. package/lib/services/quotes.js +1 -1
  47. package/lib/services/quotes.js.map +1 -1
  48. package/lib/tsdoc-metadata.json +1 -1
  49. package/package.json +43 -43
  50. package/temp/build/typescript/ts_Eujh_fX2.json +1 -0
  51. package/temp/package-deps.json +23 -22
  52. package/temp/test/jest/haste-map-ac984f375ffe2771b37aa116ca7fe6f5-87fb4bb14df3d29fb61369ce8cbe1fe1-6499ab22de0ac9ce813ded0e96430273 +0 -0
  53. package/temp/vendor-gate.api.json +18 -2
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getUnifiedTransferable = exports.postWalletTransfer = exports.getSpotAccounts = exports.getWithdrawalHistory = exports.getDepositHistory = exports.getSubAccountList = exports.getDepositAddress = exports.postWithdrawals = exports.deleteFutureOrders = exports.postFutureOrders = exports.getFuturesAccounts = exports.getFuturesOrders = exports.getFuturePositions = exports.getUnifiedAccounts = exports.getAccountDetail = void 0;
3
+ exports.getFutureAccountsBook = exports.getUnifiedTransferable = exports.postWalletTransfer = exports.getSpotAccounts = exports.getWithdrawalHistory = exports.getDepositHistory = exports.getSubAccountList = exports.getDepositAddress = exports.postWithdrawals = exports.deleteFutureOrders = exports.postFutureOrders = exports.getFuturesAccounts = exports.getFuturesOrders = exports.getFuturePositions = exports.getUnifiedAccounts = exports.getAccountDetail = void 0;
4
4
  const http_client_1 = require("./http-client");
5
5
  const callPrivate = (credential, method, path, params) => (0, http_client_1.requestPrivate)(credential, method, path, params);
6
6
  /**
@@ -128,4 +128,11 @@ exports.postWalletTransfer = postWalletTransfer;
128
128
  */
129
129
  const getUnifiedTransferable = (credential, params) => callPrivate(credential, 'GET', `/unified/transferable`, params);
130
130
  exports.getUnifiedTransferable = getUnifiedTransferable;
131
+ /**
132
+ * 查询合约账户变更历史
133
+ *
134
+ * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E8%B4%A6%E6%88%B7%E5%8F%98%E6%9B%B4%E5%8E%86%E5%8F%B2
135
+ */
136
+ const getFutureAccountsBook = (credential, params) => callPrivate(credential, 'GET', `/futures/${params.settle}/account_book`, params);
137
+ exports.getFutureAccountsBook = getFutureAccountsBook;
131
138
  //# sourceMappingURL=private-api.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"private-api.js","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":";;;AACA,+CAA+C;AAI/C,MAAM,WAAW,GAAG,CAClB,UAAuB,EACvB,MAAkB,EAClB,IAAY,EACZ,MAAmB,EACnB,EAAE,CAAC,IAAA,4BAAc,EAAY,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAEjE;;;;GAIG;AACI,MAAM,gBAAgB,GAAG,CAC9B,UAAuB,EAStB,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,iBAAiB,CAAC,CAAC;AAV3C,QAAA,gBAAgB,oBAU2B;AAExD;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAChC,UAAuB,EACvB,MAA8B,EAoC7B,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAtCrD,QAAA,kBAAkB,sBAsCmC;AAElE;;;;GAIG;AACI,MAAM,kBAAkB,GAAG,CAChC,UAAuB,EACvB,cAAsB,EACtB,MAA+D,EAmB/D,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,YAAY,cAAc,YAAY,EAAE,MAAM,CAAC,CAAC;AAtBvE,QA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AACI,MAAM,iBAAiB,GAAG,CAC/B,UAAuB,EACvB,MAEC,EAYD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,eAAe,EAAE,MAAM,CAAC,CAAC;AAhBhD,QAAA,iBAAiB,qBAgB+B;AAE7D;;;;;;GAMG;AACI,MAAM,iBAAiB,GAAG,CAC/B,UAAuB,EACvB,MAMC,EAcD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,kBAAkB,EAAE,MAAM,CAAC,CAAC;AAtBnD,QAAA,iBAAiB,qBAsBkC;AAEhE;;;;;;GAMG;AACI,MAAM,oBAAoB,GAAG,CAClC,UAAuB,EACvB,MAMC,EAcD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,CAAC,CAAC;AAtBtD,QAAA,oBAAoB,wBAsBkC;AAEnE;;;;GAIG;AACI,MAAM,eAAe,GAAG,CAC7B,UAAuB,EACvB,MAEC,EAQD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAZjD,QAAA,eAAe,mBAYkC;AAE9D;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,CAChC,UAAuB,EACvB,MAOC,EAGA,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAZtD,QAAA,kBAAkB,sBAYoC;AAEnE;;;;GAIG;AACI,MAAM,sBAAsB,GAAG,CACpC,UAAuB,EACvB,MAEC,EAIA,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,CAAC,CAAC;AARzD,QAAA,sBAAsB,0BAQmC","sourcesContent":["import type { GateParams, HttpMethod, IGateCredential } from './http-client';\nimport { requestPrivate } from './http-client';\n\nexport type ICredential = IGateCredential;\n\nconst callPrivate = <TResponse>(\n credential: ICredential,\n method: HttpMethod,\n path: string,\n params?: GateParams,\n) => requestPrivate<TResponse>(credential, method, path, params);\n\n/**\n * 获取用户账户信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AF\n */\nexport const getAccountDetail = (\n credential: ICredential,\n): Promise<{\n user_id: number;\n ip_whitelist: string[];\n currency_pairs: string[];\n key: {\n mode: number;\n };\n tier: number;\n}> => callPrivate(credential, 'GET', '/account/detail');\n\n/**\n * 获取统一账户信息\n *\n * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%BB%9F%E4%B8%80%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AF\n */\nexport const getUnifiedAccounts = (\n credential: ICredential,\n params?: { currency?: string },\n): Promise<{\n user_id: string;\n refresh_time: number;\n locket: boolean;\n balances: Record<\n string,\n {\n available: string;\n freeze: string;\n borrowed: string;\n negative_liab: string;\n futures_pos_liab: string;\n equity: string;\n total_freeze: string;\n total_liab: string;\n spot_in_use: string;\n cross_balance: string;\n iso_balance: string;\n funding: string;\n }\n >;\n total: string;\n borrowed: string;\n total_initial_margin: string;\n total_margin_balance: string;\n total_maintenance_margin: string;\n total_initial_margin_rate: string;\n total_maintenance_margin_rate: string;\n total_avail_margin: string;\n unified_account_total: string;\n unified_account_total_liab: string;\n unified_account_total_equity: string;\n leverage: string;\n spot_order_loss: string;\n spot_hedge: boolean;\n}> => callPrivate(credential, 'GET', '/unified/accounts', params);\n\n/**\n * 获取用户仓位列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E4%BB%93%E4%BD%8D%E5%88%97%E8%A1%A8\n */\nexport const getFuturePositions = (\n credential: ICredential,\n quote_currency: string,\n params?: { holding?: boolean; limit?: number; offset?: number },\n): Promise<\n {\n user: number;\n contract: string;\n size: number;\n leverage: string;\n risk_limit: string;\n leverage_max: string;\n maintenance_rate: string;\n value: string;\n margin: string;\n entry_price: string;\n mark_price: string;\n unrealised_pnl: string;\n realised_pnl: string;\n mode: string;\n liq_price: string;\n }[]\n> => callPrivate(credential, 'GET', `/futures/${quote_currency}/positions`, params);\n\n/**\n * 查询合约订单列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8\n */\nexport const getFuturesOrders = (\n credential: ICredential,\n settle: string,\n params: {\n contract?: string;\n status: string;\n limit?: number;\n offset?: number;\n last_id?: number;\n },\n): Promise<\n {\n id: string;\n contract: string;\n create_time: number;\n size: number;\n price: string;\n is_close: boolean;\n fill_price: string;\n left?: number;\n status?: string;\n text: string;\n }[]\n> => callPrivate(credential, 'GET', `/futures/${settle}/orders`, params);\n\n/**\n * 获取合约账号\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%90%88%E7%BA%A6%E8%B4%A6%E5%8F%B7\n */\nexport const getFuturesAccounts = (\n credential: ICredential,\n settle: string,\n): Promise<{\n user: number;\n currency: string;\n total: string;\n unrealised_pnl: string;\n position_margin: string;\n order_margin: string;\n available: string;\n point: string;\n bonus: string;\n in_dual_mode: boolean;\n enable_evolved_classic: boolean;\n history: {\n dnw: string;\n pnl: string;\n fee: string;\n refr: string;\n fund: string;\n point_dnw: string;\n point_fee: string;\n point_refr: string;\n bonus_dnw: string;\n bonus_offset: string;\n };\n}> => callPrivate(credential, 'GET', `/futures/${settle}/accounts`);\n\n/**\n * 合约交易下单\n *\n * 下单时指定的是合约张数 size ,而非币的数量,每一张合约对应的币的数量是合约详情接口里返回的 quanto_multiplier\n *\n * 0 成交的订单在撤单 10 分钟之后无法再获取到,会提到订单不存在\n *\n * 设置 reduce_only 为 true 可以防止在减仓的时候穿仓\n *\n * 单仓模式下,如果需要平仓,需要设置 size 为 0 ,close 为 true\n *\n * 双仓模式下,平仓需要使用 auto_size 来设置平仓方向,并同时设置 reduce_only 为 true,size 为 0\n *\n * 设置 stp_act 决定使用限制用户自成交的策略,详细用法参考body参数stp_act\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E4%B8%8B%E5%8D%95\n */\nexport const postFutureOrders = (\n credential: ICredential,\n settle: string,\n params: {\n contract: string;\n size: number;\n iceberg?: number;\n price?: string;\n close?: boolean;\n reduce_only?: boolean;\n tif?: string;\n text?: string;\n auto_size?: string;\n stp_act?: string;\n },\n): Promise<{\n label?: string;\n message?: string;\n detail?: string;\n id: number;\n user: number;\n contract: string;\n create_time: number;\n size: number;\n iceberg: number;\n left: number;\n price: string;\n fill_price: string;\n mkfr: string;\n tkfr: string;\n tif: string;\n refu: number;\n is_reduce_only: boolean;\n is_close: boolean;\n is_liq: boolean;\n text: string;\n status: string;\n finish_time: number;\n finish_as: string;\n stp_id: number;\n stp_act: string;\n amend_text: string;\n}> => callPrivate(credential, 'POST', `/futures/${settle}/orders`, params);\n\n/**\n * 撤销单个订单\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%92%A4%E9%94%80%E5%8D%95%E4%B8%AA%E8%AE%A2%E5%8D%95-2\n */\nexport const deleteFutureOrders = (credential: ICredential, settle: string, order_id: string): Promise<{}> =>\n callPrivate(credential, 'DELETE', `/futures/${settle}/orders/${order_id}`);\n\n/**\n * 提现\n *\n * POST /withdrawals\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%8F%90%E7%8E%B0\n */\nexport const postWithdrawals = (\n credential: ICredential,\n params: {\n withdraw_order_id?: string;\n amount: string;\n currency: string;\n address?: string;\n memo?: string;\n chain: string;\n },\n): Promise<{\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n}> => callPrivate(credential, 'POST', '/withdrawals', params);\n\n/**\n * 获取币种充值地址\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80\n */\nexport const getDepositAddress = (\n credential: ICredential,\n params: {\n currency: string;\n },\n): Promise<{\n currency: string;\n address: string;\n multichain_addresses: {\n chain: string;\n address: string;\n payment_id: string;\n payment_name: string;\n obtain_failed: boolean;\n }[];\n}> => callPrivate(credential, 'GET', '/wallet/deposit_address', params);\n\n/**\n * 创建新的子账户\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84%E5%AD%90%E8%B4%A6%E6%88%B7\n */\nexport const getSubAccountList = (\n credential: ICredential,\n params?: {\n type?: string;\n },\n): Promise<\n {\n remark: string;\n login_name: string;\n password: string;\n email: string;\n state: number;\n type: number;\n user_id: number;\n create_time: number;\n }[]\n> => callPrivate(credential, 'GET', '/sub_accounts', params);\n\n/**\n * 获取充值记录\n *\n * 记录查询时间范围不允许超过 30 天\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%85%85%E5%80%BC%E8%AE%B0%E5%BD%95\n */\nexport const getDepositHistory = (\n credential: ICredential,\n params?: {\n currency?: string;\n from?: number;\n to?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<\n {\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n }[]\n> => callPrivate(credential, 'GET', '/wallet/deposits', params);\n\n/**\n * 获取提现记录\n *\n * 记录查询时间范围不允许超过 30 天\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80\n */\nexport const getWithdrawalHistory = (\n credential: ICredential,\n params?: {\n currency?: string;\n from?: number;\n to?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<\n {\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n }[]\n> => callPrivate(credential, 'GET', '/wallet/withdrawals', params);\n\n/**\n * 获取现货交易账户列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%8E%B0%E8%B4%A7%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E5%88%97%E8%A1%A8\n */\nexport const getSpotAccounts = (\n credential: ICredential,\n params?: {\n currency?: string;\n },\n): Promise<\n {\n currency: string;\n available: string;\n locked: string;\n update_id: string;\n }[]\n> => callPrivate(credential, 'GET', '/spot/accounts', params);\n\n/**\n * 交易账户互转\n *\n * POST /wallet/transfers\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E4%BA%92%E8%BD%AC\n */\nexport const postWalletTransfer = (\n credential: ICredential,\n params: {\n currency: string;\n from: string;\n to: string;\n amount: string;\n currency_pair?: string;\n settle?: string;\n },\n): Promise<{\n tx_id: string;\n}> => callPrivate(credential, 'POST', '/wallet/transfers', params);\n\n/**\n * 获取统一账户最多可转出\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E7%BB%9F%E4%B8%80%E8%B4%A6%E6%88%B7%E6%9C%80%E5%A4%9A%E5%8F%AF%E8%BD%AC%E5%87%BA\n */\nexport const getUnifiedTransferable = (\n credential: ICredential,\n params: {\n currency: string;\n },\n): Promise<{\n currency: string;\n amount: string;\n}> => callPrivate(credential, 'GET', `/unified/transferable`, params);\n"]}
1
+ {"version":3,"file":"private-api.js","sourceRoot":"","sources":["../../src/api/private-api.ts"],"names":[],"mappings":";;;AACA,+CAA+C;AAI/C,MAAM,WAAW,GAAG,CAClB,UAAuB,EACvB,MAAkB,E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AAe,GAAG,CAC7B,UAAuB,EACvB,MAEC,EAQD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,gBAAgB,EAAE,MAAM,CAAC,CAAC;AAZjD,QAAA,eAAe,mBAYkC;AAE9D;;;;;;GAMG;AACI,MAAM,kBAAkB,GAAG,CAChC,UAAuB,EACvB,MAOC,EAGA,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,CAAC,CAAC;AAZtD,QAAA,kBAAkB,sBAYoC;AAEnE;;;;GAIG;AACI,MAAM,sBAAsB,GAAG,CACpC,UAAuB,EACvB,MAEC,EAIA,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,CAAC,CAAC;AARzD,QAAA,sBAAsB,0BAQmC;AAEtE;;;;GAIG;AACI,MAAM,qBAAqB,GAAG,CACnC,UAAuB,EACvB,MAQC,EAYD,EAAE,CAAC,WAAW,CAAC,UAAU,EAAE,KAAK,EAAE,YAAY,MAAM,CAAC,MAAM,eAAe,EAAE,MAAM,CAAC,CAAC;AAtBzE,QAAA,qBAAqB,yBAsBoD","sourcesContent":["import type { GateParams, HttpMethod, IGateCredential } from './http-client';\nimport { requestPrivate } from './http-client';\n\nexport type ICredential = IGateCredential;\n\nconst callPrivate = <TResponse>(\n credential: ICredential,\n method: HttpMethod,\n path: string,\n params?: GateParams,\n) => requestPrivate<TResponse>(credential, method, path, params);\n\n/**\n * 获取用户账户信息\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AF\n */\nexport const getAccountDetail = (\n credential: ICredential,\n): Promise<{\n user_id: number;\n ip_whitelist: string[];\n currency_pairs: string[];\n key: {\n mode: number;\n };\n tier: number;\n}> => callPrivate(credential, 'GET', '/account/detail');\n\n/**\n * 获取统一账户信息\n *\n * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%BB%9F%E4%B8%80%E8%B4%A6%E6%88%B7%E4%BF%A1%E6%81%AF\n */\nexport const getUnifiedAccounts = (\n credential: ICredential,\n params?: { currency?: string },\n): Promise<{\n user_id: string;\n refresh_time: number;\n locket: boolean;\n balances: Record<\n string,\n {\n available: string;\n freeze: string;\n borrowed: string;\n negative_liab: string;\n futures_pos_liab: string;\n equity: string;\n total_freeze: string;\n total_liab: string;\n spot_in_use: string;\n cross_balance: string;\n iso_balance: string;\n funding: string;\n }\n >;\n total: string;\n borrowed: string;\n total_initial_margin: string;\n total_margin_balance: string;\n total_maintenance_margin: string;\n total_initial_margin_rate: string;\n total_maintenance_margin_rate: string;\n total_avail_margin: string;\n unified_account_total: string;\n unified_account_total_liab: string;\n unified_account_total_equity: string;\n leverage: string;\n spot_order_loss: string;\n spot_hedge: boolean;\n}> => callPrivate(credential, 'GET', '/unified/accounts', params);\n\n/**\n * 获取用户仓位列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%94%A8%E6%88%B7%E4%BB%93%E4%BD%8D%E5%88%97%E8%A1%A8\n */\nexport const getFuturePositions = (\n credential: ICredential,\n quote_currency: string,\n params?: { holding?: boolean; limit?: number; offset?: number },\n): Promise<\n {\n user: number;\n contract: string;\n size: number;\n leverage: string;\n risk_limit: string;\n leverage_max: string;\n maintenance_rate: string;\n value: string;\n margin: string;\n entry_price: string;\n mark_price: string;\n unrealised_pnl: string;\n realised_pnl: string;\n mode: string;\n liq_price: string;\n }[]\n> => callPrivate(credential, 'GET', `/futures/${quote_currency}/positions`, params);\n\n/**\n * 查询合约订单列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8\n */\nexport const getFuturesOrders = (\n credential: ICredential,\n settle: string,\n params: {\n contract?: string;\n status: string;\n limit?: number;\n offset?: number;\n last_id?: number;\n },\n): Promise<\n {\n id: string;\n contract: string;\n create_time: number;\n size: number;\n price: string;\n is_close: boolean;\n fill_price: string;\n left?: number;\n status?: string;\n text: string;\n }[]\n> => callPrivate(credential, 'GET', `/futures/${settle}/orders`, params);\n\n/**\n * 获取合约账号\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%90%88%E7%BA%A6%E8%B4%A6%E5%8F%B7\n */\nexport const getFuturesAccounts = (\n credential: ICredential,\n settle: string,\n): Promise<{\n user: number;\n currency: string;\n total: string;\n unrealised_pnl: string;\n position_margin: string;\n order_margin: string;\n available: string;\n point: string;\n bonus: string;\n in_dual_mode: boolean;\n enable_evolved_classic: boolean;\n history: {\n dnw: string;\n pnl: string;\n fee: string;\n refr: string;\n fund: string;\n point_dnw: string;\n point_fee: string;\n point_refr: string;\n bonus_dnw: string;\n bonus_offset: string;\n };\n}> => callPrivate(credential, 'GET', `/futures/${settle}/accounts`);\n\n/**\n * 合约交易下单\n *\n * 下单时指定的是合约张数 size ,而非币的数量,每一张合约对应的币的数量是合约详情接口里返回的 quanto_multiplier\n *\n * 0 成交的订单在撤单 10 分钟之后无法再获取到,会提到订单不存在\n *\n * 设置 reduce_only 为 true 可以防止在减仓的时候穿仓\n *\n * 单仓模式下,如果需要平仓,需要设置 size 为 0 ,close 为 true\n *\n * 双仓模式下,平仓需要使用 auto_size 来设置平仓方向,并同时设置 reduce_only 为 true,size 为 0\n *\n * 设置 stp_act 决定使用限制用户自成交的策略,详细用法参考body参数stp_act\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%90%88%E7%BA%A6%E4%BA%A4%E6%98%93%E4%B8%8B%E5%8D%95\n */\nexport const postFutureOrders = (\n credential: ICredential,\n settle: string,\n params: {\n contract: string;\n size: number;\n iceberg?: number;\n price?: string;\n close?: boolean;\n reduce_only?: boolean;\n tif?: string;\n text?: string;\n auto_size?: string;\n stp_act?: string;\n },\n): Promise<{\n label?: string;\n message?: string;\n detail?: string;\n id: number;\n user: number;\n contract: string;\n create_time: number;\n size: number;\n iceberg: number;\n left: number;\n price: string;\n fill_price: string;\n mkfr: string;\n tkfr: string;\n tif: string;\n refu: number;\n is_reduce_only: boolean;\n is_close: boolean;\n is_liq: boolean;\n text: string;\n status: string;\n finish_time: number;\n finish_as: string;\n stp_id: number;\n stp_act: string;\n amend_text: string;\n}> => callPrivate(credential, 'POST', `/futures/${settle}/orders`, params);\n\n/**\n * 撤销单个订单\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%92%A4%E9%94%80%E5%8D%95%E4%B8%AA%E8%AE%A2%E5%8D%95-2\n */\nexport const deleteFutureOrders = (credential: ICredential, settle: string, order_id: string): Promise<{}> =>\n callPrivate(credential, 'DELETE', `/futures/${settle}/orders/${order_id}`);\n\n/**\n * 提现\n *\n * POST /withdrawals\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%8F%90%E7%8E%B0\n */\nexport const postWithdrawals = (\n credential: ICredential,\n params: {\n withdraw_order_id?: string;\n amount: string;\n currency: string;\n address?: string;\n memo?: string;\n chain: string;\n },\n): Promise<{\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n}> => callPrivate(credential, 'POST', '/withdrawals', params);\n\n/**\n * 获取币种充值地址\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80\n */\nexport const getDepositAddress = (\n credential: ICredential,\n params: {\n currency: string;\n },\n): Promise<{\n currency: string;\n address: string;\n multichain_addresses: {\n chain: string;\n address: string;\n payment_id: string;\n payment_name: string;\n obtain_failed: boolean;\n }[];\n}> => callPrivate(credential, 'GET', '/wallet/deposit_address', params);\n\n/**\n * 创建新的子账户\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E5%88%9B%E5%BB%BA%E6%96%B0%E7%9A%84%E5%AD%90%E8%B4%A6%E6%88%B7\n */\nexport const getSubAccountList = (\n credential: ICredential,\n params?: {\n type?: string;\n },\n): Promise<\n {\n remark: string;\n login_name: string;\n password: string;\n email: string;\n state: number;\n type: number;\n user_id: number;\n create_time: number;\n }[]\n> => callPrivate(credential, 'GET', '/sub_accounts', params);\n\n/**\n * 获取充值记录\n *\n * 记录查询时间范围不允许超过 30 天\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%85%85%E5%80%BC%E8%AE%B0%E5%BD%95\n */\nexport const getDepositHistory = (\n credential: ICredential,\n params?: {\n currency?: string;\n from?: number;\n to?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<\n {\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n }[]\n> => callPrivate(credential, 'GET', '/wallet/deposits', params);\n\n/**\n * 获取提现记录\n *\n * 记录查询时间范围不允许超过 30 天\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E5%B8%81%E7%A7%8D%E5%85%85%E5%80%BC%E5%9C%B0%E5%9D%80\n */\nexport const getWithdrawalHistory = (\n credential: ICredential,\n params?: {\n currency?: string;\n from?: number;\n to?: number;\n limit?: number;\n offset?: number;\n },\n): Promise<\n {\n id: string;\n txid: string;\n withdraw_order_id: string;\n timestamp: number;\n amount: string;\n currency: string;\n address: string;\n memo: string;\n status: string;\n chain: string;\n }[]\n> => callPrivate(credential, 'GET', '/wallet/withdrawals', params);\n\n/**\n * 获取现货交易账户列表\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E8%8E%B7%E5%8F%96%E7%8E%B0%E8%B4%A7%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E5%88%97%E8%A1%A8\n */\nexport const getSpotAccounts = (\n credential: ICredential,\n params?: {\n currency?: string;\n },\n): Promise<\n {\n currency: string;\n available: string;\n locked: string;\n update_id: string;\n }[]\n> => callPrivate(credential, 'GET', '/spot/accounts', params);\n\n/**\n * 交易账户互转\n *\n * POST /wallet/transfers\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E4%BA%A4%E6%98%93%E8%B4%A6%E6%88%B7%E4%BA%92%E8%BD%AC\n */\nexport const postWalletTransfer = (\n credential: ICredential,\n params: {\n currency: string;\n from: string;\n to: string;\n amount: string;\n currency_pair?: string;\n settle?: string;\n },\n): Promise<{\n tx_id: string;\n}> => callPrivate(credential, 'POST', '/wallet/transfers', params);\n\n/**\n * 获取统一账户最多可转出\n *\n * https://www.gate.io/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E7%BB%9F%E4%B8%80%E8%B4%A6%E6%88%B7%E6%9C%80%E5%A4%9A%E5%8F%AF%E8%BD%AC%E5%87%BA\n */\nexport const getUnifiedTransferable = (\n credential: ICredential,\n params: {\n currency: string;\n },\n): Promise<{\n currency: string;\n amount: string;\n}> => callPrivate(credential, 'GET', `/unified/transferable`, params);\n\n/**\n * 查询合约账户变更历史\n *\n * https://www.gate.com/docs/developers/apiv4/zh_CN/#%E6%9F%A5%E8%AF%A2%E5%90%88%E7%BA%A6%E8%B4%A6%E6%88%B7%E5%8F%98%E6%9B%B4%E5%8E%86%E5%8F%B2\n */\nexport const getFutureAccountsBook = (\n credential: ICredential,\n params: {\n settle: string;\n contract?: string;\n limit?: number;\n offset?: number;\n from?: number;\n to?: number;\n type?: string; // | 'dnw' | 'pnl' | 'fee' | 'refr' | 'fund' | 'point_dnw' | 'point_fee' | 'point_refr' | 'bonus_offset'\n },\n): Promise<\n {\n time: number;\n change: string;\n balance: string;\n text: string;\n type: string;\n contract: string;\n trade_id: string;\n id: string;\n }[]\n> => callPrivate(credential, 'GET', `/futures/${params.settle}/account_book`, params);\n"]}
@@ -110,14 +110,7 @@ export declare const getSpotCandlesticks: (params: {
110
110
  * [t, v, c, h, l, o]
111
111
  * - t: Unix second
112
112
  */
113
- [
114
- string,
115
- string,
116
- string,
117
- string,
118
- string,
119
- string
120
- ]>>;
113
+ [string, string, string, string, string, string]>>;
121
114
  /**
122
115
  * 查询合约市场深度信息
123
116
  *
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../../src/api/public-api.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,WACtB,MAAM,WACL;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,KAC3C,QACD;IACE,MAAM,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,uBAAuB,EAAE,MAAM,CAAC;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,OAAO,CAAC;IACtB,eAAe,EAAE,MAAM,CAAC;IACxB,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,YA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AEY,QAAA,WAAW,GAAG,IAAI,WAAW,EAAE,CAAC","sourcesContent":["import { Subject, Subscription, filter, mergeMap, timer } from 'rxjs';\n\ntype QueueTask = {\n execute: () => Promise<unknown>;\n resolve: (value: unknown) => void;\n reject: (error: unknown) => void;\n};\n\ninterface IRateLimitChannel {\n queue: QueueTask[];\n limit: number;\n subject: Subject<QueueTask>;\n queueSubscription: Subscription;\n timerSubscription: Subscription;\n activeCount: number;\n}\n\nexport class RateLimiter {\n private channels = new Map<string, IRateLimitChannel>();\n\n schedule<T>(key: string, limit: number, periodMs: number, execute: () => Promise<T>): Promise<T> {\n if (!Number.isFinite(limit) || limit <= 0) {\n return execute();\n }\n const channel = this.ensureChannel(key, limit, periodMs);\n\n return new Promise<T>((resolve, reject) => {\n channel.queue.push({\n execute,\n resolve: (value) => resolve(value as T),\n reject,\n });\n });\n }\n\n private ensureChannel(key: string, limit: number, periodMs: number): IRateLimitChannel {\n if (this.channels.has(key)) {\n return this.channels.get(key)!;\n }\n const subject = new Subject<QueueTask>();\n const channel: IRateLimitChannel = {\n queue: [],\n limit,\n subject,\n queueSubscription: subject.subscribe((task) => {\n channel.activeCount++;\n task\n .execute()\n .then((value) => task.resolve(value))\n .catch((error) => task.reject(error))\n .finally(() => {\n channel.activeCount--;\n if (channel.queue.length === 0 && channel.activeCount === 0) {\n this.disposeChannel(key);\n }\n });\n }),\n timerSubscription: timer(0, periodMs)\n .pipe(\n filter(() => channel.queue.length > 0),\n mergeMap(() => channel.queue.splice(0, channel.limit)),\n )\n .subscribe(subject),\n activeCount: 0,\n };\n\n this.channels.set(key, channel);\n return channel;\n }\n\n private disposeChannel(key: string) {\n const channel = this.channels.get(key);\n if (!channel) return;\n channel.queueSubscription.unsubscribe();\n channel.timerSubscription.unsubscribe();\n channel.subject.complete();\n this.channels.delete(key);\n }\n}\n\nexport const rateLimiter = new RateLimiter();\n"]}
1
+ {"version":3,"file":"rate-limiter.js","sourceRoot":"","sources":["../../src/api/rate-limiter.ts"],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,WAAW,EAAE,CAAC","sourcesContent":["import { Subject, Subscription, filter, mergeMap, timer } from 'rxjs';\n\ntype QueueTask = {\n execute: () => Promise<unknown>;\n resolve: (value: unknown) => void;\n reject: (error: unknown) => void;\n};\n\ninterface IRateLimitChannel {\n queue: QueueTask[];\n limit: number;\n subject: Subject<QueueTask>;\n queueSubscription: Subscription;\n timerSubscription: Subscription;\n activeCount: number;\n}\n\nexport class RateLimiter {\n private channels = new Map<string, IRateLimitChannel>();\n\n schedule<T>(key: string, limit: number, periodMs: number, execute: () => Promise<T>): Promise<T> {\n if (!Number.isFinite(limit) || limit <= 0) {\n return execute();\n }\n const channel = this.ensureChannel(key, limit, periodMs);\n\n return new Promise<T>((resolve, reject) => {\n channel.queue.push({\n execute,\n resolve: (value) => resolve(value as T),\n reject,\n });\n });\n }\n\n private ensureChannel(key: string, limit: number, periodMs: number): IRateLimitChannel {\n if (this.channels.has(key)) {\n return this.channels.get(key)!;\n }\n const subject = new Subject<QueueTask>();\n const channel: IRateLimitChannel = {\n queue: [],\n limit,\n subject,\n queueSubscription: subject.subscribe((task) => {\n channel.activeCount++;\n task\n .execute()\n .then((value) => task.resolve(value))\n .catch((error) => task.reject(error))\n .finally(() => {\n channel.activeCount--;\n if (channel.queue.length === 0 && channel.activeCount === 0) {\n this.disposeChannel(key);\n }\n });\n }),\n timerSubscription: timer(0, periodMs)\n .pipe(\n filter(() => channel.queue.length > 0),\n mergeMap(() => channel.queue.splice(0, channel.limit)),\n )\n .subscribe(subject),\n activeCount: 0,\n };\n\n this.channels.set(key, channel);\n return channel;\n }\n\n private disposeChannel(key: string) {\n const channel = this.channels.get(key);\n if (!channel) return;\n channel.queueSubscription.unsubscribe();\n channel.timerSubscription.unsubscribe();\n channel.subject.complete();\n this.channels.delete(key);\n }\n}\n\nexport const rateLimiter = new RateLimiter();\n"]}
package/lib/index.d.ts CHANGED
@@ -6,4 +6,5 @@ import './services/quotes';
6
6
  import './services/transfer';
7
7
  import './services/ohlc-service';
8
8
  import './services/interest-rate-service';
9
+ import './services/interest-ledger-service';
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,kCAAkC,CAAC;AAC1C,OAAO,4BAA4B,CAAC;AACpC,OAAO,0BAA0B,CAAC;AAClC,OAAO,mBAAmB,CAAC;AAC3B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,yBAAyB,CAAC;AACjC,OAAO,kCAAkC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,OAAO,kCAAkC,CAAC;AAC1C,OAAO,4BAA4B,CAAC;AACpC,OAAO,0BAA0B,CAAC;AAClC,OAAO,mBAAmB,CAAC;AAC3B,OAAO,qBAAqB,CAAC;AAC7B,OAAO,yBAAyB,CAAC;AACjC,OAAO,kCAAkC,CAAC;AAC1C,OAAO,oCAAoC,CAAC"}
package/lib/index.js CHANGED
@@ -8,4 +8,5 @@ require("./services/quotes");
8
8
  require("./services/transfer");
9
9
  require("./services/ohlc-service");
10
10
  require("./services/interest-rate-service");
11
+ require("./services/interest-ledger-service");
11
12
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,+BAA6B;AAC7B,4CAA0C;AAC1C,sCAAoC;AACpC,oCAAkC;AAClC,6BAA2B;AAC3B,+BAA6B;AAC7B,mCAAiC;AACjC,4CAA0C","sourcesContent":["import './services/exchange';\nimport './services/markets/interest-rate';\nimport './services/markets/product';\nimport './services/markets/quote';\nimport './services/quotes';\nimport './services/transfer';\nimport './services/ohlc-service';\nimport './services/interest-rate-service';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;AAAA,+BAA6B;AAC7B,4CAA0C;AAC1C,sCAAoC;AACpC,oCAAkC;AAClC,6BAA2B;AAC3B,+BAA6B;AAC7B,mCAAiC;AACjC,4CAA0C;AAC1C,8CAA4C","sourcesContent":["import './services/exchange';\nimport './services/markets/interest-rate';\nimport './services/markets/product';\nimport './services/markets/quote';\nimport './services/quotes';\nimport './services/transfer';\nimport './services/ohlc-service';\nimport './services/interest-rate-service';\nimport './services/interest-ledger-service';\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../src/services/accounts/profile.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEtE,eAAO,MAAM,eAAe,eAAsB,WAAW,KAAG,QAAQ,MAAM,CAI7E,CAAC"}
1
+ {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../../src/services/accounts/profile.ts"],"names":[],"mappings":"AACA,OAAO,EAAoB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEtE,eAAO,MAAM,eAAe,GAAU,YAAY,WAAW,KAAG,OAAO,CAAC,MAAM,CAI7E,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"unified.d.ts","sourceRoot":"","sources":["../../../src/services/accounts/unified.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAA0C,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAuC5F,eAAO,MAAM,qBAAqB,eAAsB,WAAW,yBAsClE,CAAC"}
1
+ {"version":3,"file":"unified.d.ts","sourceRoot":"","sources":["../../../src/services/accounts/unified.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAExE,OAAO,EAA0C,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAuC5F,eAAO,MAAM,qBAAqB,GAAU,YAAY,WAAW,y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YACH,CAAC,CAAC,MAAM,CAAC,CAAA,MAAA,cAAc,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,KAAK,aAAa,CAAC,0CAAE,IAAI,KAAI,CAAC,CAAC,CAAC;QACjG,6BAA6B;QAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,CAAA,MAAA,QAAQ,CAAC,QAAQ,CAAC,0CAAE,SAAS,KAAI,CAAC,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,MAAM,CAAC,CAAA,MAAA,QAAQ,CAAC,QAAQ,CAAC,0CAAE,SAAS,KAAI,CAAC,CAAC,CAAC;QAC/D,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAC7C,OAAO,IAAA,+BAAgB,EAAC;YACtB,aAAa,EAAE,MAAM;YACrB,WAAW,EAAE,QAAQ;YACrB,UAAU,EAAE,IAAA,kBAAU,EAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC;YAC1D,MAAM;YACN,WAAW;YACX,cAAc;SACf,CAAC,CAAC;IACL,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAqB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAE/C,OAAO,CAAC,GAAG,eAAe,EAAE,GAAG,aAAa,CAAC,CAAC;AAChD,CAAC,CAAC;AAtCW,QAAA,qBAAqB,yBAsChC","sourcesContent":["import { makeSpotPosition, type IPosition } from '@yuants/data-account';\nimport { encodePath } from '@yuants/utils';\nimport { getFuturePositions, getUnifiedAccounts, ICredential } from '../../api/private-api';\nimport { getSpotTickers } from '../../api/public-api';\n\nconst loadFuturePositions = async (credential: ICredential): Promise<IPosition[]> => {\n const positions: IPosition[] = [];\n const positionsRes = await getFuturePositions(credential, 'usdt');\n\n for (const position of Array.isArray(positionsRes) ? positionsRes : []) {\n if (!(Math.abs(position.size) > 0)) continue;\n\n const product_id = encodePath('GATE', 'FUTURE', position.contract);\n const volume = Math.abs(position.size);\n const closable_price = Number(position.mark_price);\n const valuation = volume * closable_price;\n positions.push({\n datasource_id: 'GATE',\n position_id: `${position.contract}-${position.leverage}-${position.mode}`,\n product_id,\n direction:\n position.mode === 'dual_long'\n ? 'LONG'\n : position.mode === 'dual_short'\n ? 'SHORT'\n : position.size > 0\n ? 'LONG'\n : 'SHORT',\n volume,\n free_volume: Math.abs(position.size),\n position_price: Number(position.entry_price),\n closable_price,\n floating_profit: Number(position.unrealised_pnl),\n liquidation_price: position.liq_price,\n valuation,\n });\n }\n\n return positions;\n};\n\nexport const getUnifiedAccountInfo = async (credential: ICredential) => {\n const [futurePositions, unifiedAccount, spotTickers] = await Promise.all([\n loadFuturePositions(credential),\n getUnifiedAccounts(credential, {}),\n getSpotTickers({}),\n ]);\n\n const balances = unifiedAccount?.balances ?? {};\n const spotTickerList = Array.isArray(spotTickers) ? spotTickers : [];\n const spotPositions: IPosition[] = Object.keys(balances)\n .map((currency) => {\n let currency_pair = `${currency}_USDT`;\n if (currency === 'SOL2') {\n currency_pair = 'SOL_USDT';\n }\n if (currency === 'GTSOL') {\n currency_pair = 'SOL_USDT';\n }\n const closable_price =\n currency === 'USDT'\n ? 1\n : Number(spotTickerList.find((ticker) => ticker.currency_pair === currency_pair)?.last || 0);\n // TODO: 根据账户模式调整 volume 计算方式\n const volume = Number(balances[currency]?.available || 0);\n const free_volume = Number(balances[currency]?.available || 0);\n if (Math.abs(volume) === 0) return undefined;\n return makeSpotPosition({\n datasource_id: 'GATE',\n position_id: currency,\n product_id: encodePath('GATE', 'SPOT', currency + '_USDT'),\n volume,\n free_volume,\n closable_price,\n });\n })\n .filter((item): item is IPosition => !!item);\n\n return [...futurePositions, ...spotPositions];\n};\n"]}
1
+ {"version":3,"file":"unified.js","sourceRoot":"","sources":["../../../src/services/accounts/unified.ts"],"names":[],"mappings":";;;AAAA,uDAAwE;AACxE,yCAA2C;AAC3C,uDAA4F;A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AK,aAAa,CAAC,0CAAE,IAAI,KAAI,CAAC,CAAC,CAAC;QACjG,6BAA6B;QAC7B,MAAM,MAAM,GAAG,MAAM,CAAC,CAAA,MAAA,QAAQ,CAAC,QAAQ,CAAC,0CAAE,SAAS,KAAI,CAAC,CAAC,CAAC;QAC1D,MAAM,WAAW,GAAG,MAAM,CAAC,CAAA,MAAA,QAAQ,CAAC,QAAQ,CAAC,0CAAE,SAAS,KAAI,CAAC,CAAC,CAAC;QAC/D,IAAI,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAC7C,OAAO,IAAA,+BAAgB,EAAC;YACtB,aAAa,EAAE,MAAM;YACrB,WAAW,EAAE,QAAQ;YACrB,UAAU,EAAE,IAAA,kBAAU,EAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC;YAC1D,MAAM;YACN,WAAW;YACX,cAAc;SACf,CAAC,CAAC;IACL,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAqB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAE/C,OAAO,CAAC,GAAG,eAAe,EAAE,GAAG,aAAa,CAAC,CAAC;AAChD,CAAC,CAAC;AAtCW,QAAA,qBAAqB,yBAsChC","sourcesContent":["import { makeSpotPosition, type IPosition } from '@yuants/data-account';\nimport { encodePath } from '@yuants/utils';\nimport { getFuturePositions, getUnifiedAccounts, ICredential } from '../../api/private-api';\nimport { getSpotTickers } from '../../api/public-api';\n\nconst loadFuturePositions = async (credential: ICredential): Promise<IPosition[]> => {\n const positions: IPosition[] = [];\n const positionsRes = await getFuturePositions(credential, 'usdt');\n\n for (const position of Array.isArray(positionsRes) ? positionsRes : []) {\n if (!(Math.abs(position.size) > 0)) continue;\n\n const product_id = encodePath('GATE', 'FUTURE', position.contract);\n const volume = Math.abs(position.size);\n const closable_price = Number(position.mark_price);\n const valuation = volume * closable_price;\n positions.push({\n datasource_id: 'GATE',\n position_id: `${position.contract}-${position.leverage}-${position.mode}`,\n product_id,\n direction:\n position.mode === 'dual_long'\n ? 'LONG'\n : position.mode === 'dual_short'\n ? 'SHORT'\n : position.size > 0\n ? 'LONG'\n : 'SHORT',\n volume,\n free_volume: Math.abs(position.size),\n position_price: Number(position.entry_price),\n closable_price,\n floating_profit: Number(position.unrealised_pnl),\n liquidation_price: position.liq_price,\n valuation,\n });\n }\n\n return positions;\n};\n\nexport const getUnifiedAccountInfo = async (credential: ICredential) => {\n const [futurePositions, unifiedAccount, spotTickers] = await Promise.all([\n loadFuturePositions(credential),\n getUnifiedAccounts(credential, {}),\n getSpotTickers({}),\n ]);\n\n const balances = unifiedAccount?.balances ?? {};\n const spotTickerList = Array.isArray(spotTickers) ? spotTickers : [];\n const spotPositions: IPosition[] = Object.keys(balances)\n .map((currency) => {\n let currency_pair = `${currency}_USDT`;\n if (currency === 'SOL2') {\n currency_pair = 'SOL_USDT';\n }\n if (currency === 'GTSOL') {\n currency_pair = 'SOL_USDT';\n }\n const closable_price =\n currency === 'USDT'\n ? 1\n : Number(spotTickerList.find((ticker) => ticker.currency_pair === currency_pair)?.last || 0);\n // TODO: 根据账户模式调整 volume 计算方式\n const volume = Number(balances[currency]?.available || 0);\n const free_volume = Number(balances[currency]?.available || 0);\n if (Math.abs(volume) === 0) return undefined;\n return makeSpotPosition({\n datasource_id: 'GATE',\n position_id: currency,\n product_id: encodePath('GATE', 'SPOT', currency + '_USDT'),\n volume,\n free_volume,\n closable_price,\n });\n })\n .filter((item): item is IPosition => !!item);\n\n return [...futurePositions, ...spotPositions];\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"default-credential.js","sourceRoot":"","sources":["../../src/services/default-credential.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAG3C,IAAI,MAAM,GAAG,KAAK,CAAC;AAEZ,MAAM,oBAAoB,GAAG,GAAuB,EAAE;IAC3D,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IAC1C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IAC1C,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE;QAC9B,IAAI,CAAC,MAAM,EAAE;YACX,OAAO,CAAC,IAAI,CACV,IAAA,kBAAU,EAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EACtB,0EAA0E,CAC3E,CAAC;YACF,MAAM,GAAG,IAAI,CAAC;SACf;QACD,OAAO,IAAI,CAAC;KACb;IACD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AACpC,CAAC,CAAC;AAdW,QAAA,oBAAoB,wBAc/B","sourcesContent":["import { formatTime } from '@yuants/utils';\nimport { ICredential } from '../api/private-api';\n\nlet warned = false;\n\nexport const getDefaultCredential = (): ICredential | null => {\n const access_key = process.env.ACCESS_KEY;\n const secret_key = process.env.SECRET_KEY;\n if (!access_key || !secret_key) {\n if (!warned) {\n console.warn(\n formatTime(Date.now()),\n 'Missing ACCESS_KEY or SECRET_KEY, skip registering Gate default services',\n );\n warned = true;\n }\n return null;\n }\n return { access_key, secret_key };\n};\n"]}
1
+ {"version":3,"file":"default-credential.js","sourceRoot":"","sources":["../../src/services/default-credential.ts"],"names":[],"mappings":";;;AAAA,yCAA2C;AAG3C,IAAI,MAAM,GAAG,KAAK,CAAC;AAEZ,MAAM,oBAAoB,GAAG,GAAuB,EAAE;IAC3D,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IAC1C,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC;IAC1C,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE,CAAC;QAC/B,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,OAAO,CAAC,IAAI,CACV,IAAA,kBAAU,EAAC,IAAI,CAAC,GAAG,EAAE,CAAC,EACtB,0EAA0E,CAC3E,CAAC;YACF,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC;AACpC,CAAC,CAAC;AAdW,QAAA,oBAAoB,wBAc/B","sourcesContent":["import { formatTime } from '@yuants/utils';\nimport { ICredential } from '../api/private-api';\n\nlet warned = false;\n\nexport const getDefaultCredential = (): ICredential | null => {\n const access_key = process.env.ACCESS_KEY;\n const secret_key = process.env.SECRET_KEY;\n if (!access_key || !secret_key) {\n if (!warned) {\n console.warn(\n formatTime(Date.now()),\n 'Missing ACCESS_KEY or SECRET_KEY, skip registering Gate default services',\n );\n warned = true;\n }\n return null;\n }\n return { access_key, secret_key };\n};\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=interest-ledger-service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interest-ledger-service.d.ts","sourceRoot":"","sources":["../../src/services/interest-ledger-service.ts"],"names":[],"mappings":""}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const protocol_1 = require("@yuants/protocol");
4
+ const utils_1 = require("@yuants/utils");
5
+ const exchange_1 = require("@yuants/exchange");
6
+ const private_api_1 = require("../api/private-api");
7
+ const terminal = protocol_1.Terminal.fromNodeEnv();
8
+ const WINDOW_MS = 10 * 24 * 3600000;
9
+ const fetchInterestRateLedgerBackward = async (req) => {
10
+ const params = {
11
+ settle: 'usdt',
12
+ to: ~~(req.time / 1000),
13
+ from: ~~((req.time - WINDOW_MS) / 1000),
14
+ limit: 100,
15
+ type: req.ledger_type,
16
+ };
17
+ const res = await (0, private_api_1.getFutureAccountsBook)(req.credential.payload, params);
18
+ return (res !== null && res !== void 0 ? res : [])
19
+ .map((v) => {
20
+ const ms = Number(v.time * 1000);
21
+ return {
22
+ id: v.id,
23
+ product_id: (0, utils_1.encodePath)('GATE', 'FUTURE', v.contract),
24
+ amount: v.change,
25
+ account_id: req.account_id,
26
+ currency: 'USDT',
27
+ created_at: (0, utils_1.formatTime)(ms),
28
+ };
29
+ })
30
+ .filter((x) => Date.parse(x.created_at) <= req.time);
31
+ };
32
+ (0, exchange_1.provideInterestLedgerService)(terminal, {
33
+ direction: 'backward',
34
+ type: 'GATE',
35
+ }, fetchInterestRateLedgerBackward);
36
+ //# sourceMappingURL=interest-ledger-service.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"interest-ledger-service.js","sourceRoot":"","sources":["../../src/services/interest-ledger-service.ts"],"names":[],"mappings":";;AACA,+CAA4C;AAC5C,yCAAuD;AACvD,+CAAgE;AAChE,oDAA2D;AAO3D,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,MAAM,SAAS,GAAG,EAAE,GAAG,EAAE,GAAG,OAAQ,CAAC;AAErC,MAAM,+BAA+B,GAAG,KAAK,EAAE,GAK9C,EAA8B,EAAE;IAC/B,MAAM,MAAM,GAAG;QACb,MAAM,EAAE,MAAM;QACd,EAAE,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;QACvB,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC;QACvC,KAAK,EAAE,GAAG;QACV,IAAI,EAAE,GAAG,CAAC,WAAW;KACtB,CAAC;IACF,MAAM,GAAG,GAAG,MAAM,IAAA,mCAAqB,EAAC,GAAG,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACxE,OAAO,CAAC,GAAG,aAAH,GAAG,cAAH,GAAG,GAAI,EAAE,CAAC;SACf,GAAG,CAAC,CAAC,CAAC,EAAmB,EAAE;QAC1B,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC;QACjC,OAAO;YACL,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,UAAU,EAAE,IAAA,kBAAU,EAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC;YACpD,MAAM,EAAE,CAAC,CAAC,MAAM;YAChB,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,QAAQ,EAAE,MAAM;YAChB,UAAU,EAAE,IAAA,kBAAU,EAAC,EAAE,CAAC;SACR,CAAC;IACvB,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,UAAW,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,CAAC;AAC1D,CAAC,CAAC;AAEF,IAAA,uCAA4B,EAC1B,QAAQ,EACR;IACE,SAAS,EAAE,UAAU;IACrB,IAAI,EAAE,MAAM;CACb,EACD,+BAA+B,CAChC,CAAC","sourcesContent":["import { IInterestLedger } from '@yuants/data-interest-rate';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath, formatTime } from '@yuants/utils';\nimport { provideInterestLedgerService } from '@yuants/exchange';\nimport { getFutureAccountsBook } from '../api/private-api';\n\ninterface IExchangeCredential {\n type: string;\n payload: any;\n}\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst WINDOW_MS = 10 * 24 * 3600_000;\n\nconst fetchInterestRateLedgerBackward = async (req: {\n credential: IExchangeCredential;\n account_id: string;\n time: number;\n ledger_type: string;\n}): Promise<IInterestLedger[]> => {\n const params = {\n settle: 'usdt',\n to: ~~(req.time / 1000),\n from: ~~((req.time - WINDOW_MS) / 1000),\n limit: 100,\n type: req.ledger_type,\n };\n const res = await getFutureAccountsBook(req.credential.payload, params);\n return (res ?? [])\n .map((v): IInterestLedger => {\n const ms = Number(v.time * 1000);\n return {\n id: v.id,\n product_id: encodePath('GATE', 'FUTURE', v.contract),\n amount: v.change,\n account_id: req.account_id,\n currency: 'USDT',\n created_at: formatTime(ms),\n } as IInterestLedger;\n })\n .filter((x) => Date.parse(x.created_at!) <= req.time);\n};\n\nprovideInterestLedgerService(\n terminal,\n {\n direction: 'backward',\n type: 'GATE',\n },\n fetchInterestRateLedgerBackward,\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"quote.js","sourceRoot":"","sources":["../../../src/services/markets/quote.ts"],"names":[],"mappings":";;AAAA,mDAAkE;AAClE,+CAA4C;AAC5C,qCAAyC;AACzC,yCAAuD;AACvD,+BAcc;AACd,qDAA8F;AAE9F,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,eAAe;AACf,MAAM,oBAAoB,GAAG,IAAA,YAAK,EAAC,GAAG,EAAE,CAAC,IAAA,gCAAmB,EAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAC5E,IAAA,aAAM,EAAC,EAAE,KAAK,EAAE,OAAQ,EAAE,CAAC,EAC3B,IAAA,YAAK,EAAC,EAAE,KAAK,EAAE,KAAM,EAAE,CAAC,EACxB,IAAA,kBAAW,EAAC,CAAC,CAAC,CACf,CAAC;AAEF,qBAAqB;AACrB,MAAM,iBAAiB,GAAG,IAAA,YAAK,EAAC,GAAG,EAAE,CAAC,IAAA,8BAAiB,EAAC,MAAM,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CACvE,IAAA,eAAQ,EAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,EAC9B,IAAA,UAAG,EACD,CAAC,MAAM,EAAmB,EAAE,CAAC,CAAC;IAC5B,aAAa,EAAE,MAAM;IACrB,UAAU,EAAE,IAAA,kBAAU,EAAC,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC,IAAI;IACvB,SAAS,EAAE,MAAM,CAAC,UAAU;IAC5B,SAAS,EAAE,MAAM,CAAC,WAAW;IAC7B,+DAA+D;IAC/D,oDAAoD;IACpD,UAAU,EAAE,GAAG;IACf,UAAU,EAAE,GAAG;IACf,kCAAkC;IAClC,aAAa,EAAE,MAAM,CAAC,UAAU;IAChC,2CAA2C;IAC3C,kBAAkB,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CACH,IAAA,iCAAoB,EAAC,QAAQ,CAAC,WAAW,CAAC,EAC1C,IAAA,gBAAU,EAAC;QACT,QAAQ;QACR,aAAa,EAAE,IAAI;QACnB,SAAS,EAAE,OAAO;QAClB,YAAY,EAAE,CAAC,eAAe,EAAE,YAAY,CAAC;KAC9C,CAAC,CACH;SACA,SAAS,EAAE,CAAC;CAChB","sourcesContent":["import { IQuote, setMetricsQuoteState } from '@yuants/data-quote';\nimport { Terminal } from '@yuants/protocol';\nimport { writeToSQL } from '@yuants/sql';\nimport { decodePath, encodePath } from '@yuants/utils';\nimport {\n catchError,\n defer,\n EMPTY,\n filter,\n groupBy,\n map,\n merge,\n mergeMap,\n repeat,\n retry,\n scan,\n share,\n shareReplay,\n} from 'rxjs';\nimport { getFuturesContracts, getFuturesTickers, getSpotTickers } from '../../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\n// 获取所有USDT永续合约\nconst usdtFutureContracts$ = defer(() => getFuturesContracts('usdt', {})).pipe(\n repeat({ delay: 3600_000 }),\n retry({ delay: 60_000 }),\n shareReplay(1),\n);\n\n// 从tickers获取价格和交易量数据\nconst quoteFromTickers$ = defer(() => getFuturesTickers('usdt', {})).pipe(\n mergeMap((tickers) => tickers),\n map(\n (ticker): Partial<IQuote> => ({\n datasource_id: 'GATE',\n product_id: encodePath('GATE', 'FUTURE', ticker.contract),\n last_price: ticker.last,\n ask_price: ticker.lowest_ask,\n bid_price: ticker.highest_bid,\n // GATE API doesn't provide bid/ask volumes in tickers endpoint\n // We'll need to use order book for that if required\n ask_volume: '0',\n bid_volume: '0',\n // total_size is the open interest\n open_interest: ticker.total_size,\n // funding_rate is the current funding rate\n interest_rate_long: ticker.funding_rate ? `${-parseFloat(ticker.funding_rate)}` : undefined,\n interest_rate_short: ticker.funding_rate,\n }),\n ),\n repeat({ delay: 5000 }),\n retry({ delay: 1000 }),\n);\n\n// 从现货tickers获取价格和交易量数据\nconst quoteFromSpotTickers$ = defer(() => getSpotTickers({})).pipe(\n mergeMap((tickers) => tickers),\n map(\n (ticker): Partial<IQuote> => ({\n datasource_id: 'GATE',\n product_id: encodePath('GATE', 'SPOT', ticker.currency_pair),\n last_price: ticker.last,\n ask_price: ticker.lowest_ask,\n bid_price: ticker.highest_bid,\n ask_volume: ticker.lowest_size ?? '0',\n bid_volume: ticker.highest_size ?? '0',\n // 现货没有持仓量的概念,设置为0\n open_interest: '0',\n }),\n ),\n repeat({ delay: 5000 }),\n retry({ delay: 1000 }),\n);\n\nconst quoteSources$ = [quoteFromTickers$, quoteFromSpotTickers$];\n\nconst quote$ = defer(() =>\n merge(\n ...quoteSources$.map((x$) =>\n defer(() => x$).pipe(\n // 防止单个流关闭导致整体关闭\n catchError(() => EMPTY),\n ),\n ),\n ),\n).pipe(\n groupBy((x) => encodePath(x.datasource_id, x.product_id)),\n mergeMap((group$) => {\n return group$.pipe(\n //\n scan((acc, cur) => Object.assign(acc, cur), {} as Partial<IQuote>),\n );\n }),\n share(),\n);\n\n// 写入数据库\nif (process.env.WRITE_QUOTE_TO_SQL === 'true') {\n terminal.channel.publishChannel('quote', { pattern: `^GATE/` }, (channel_id) => {\n const [datasource_id, product_id] = decodePath(channel_id);\n if (!datasource_id) {\n throw 'datasource_id is required';\n }\n if (!product_id) {\n throw 'product_id is required';\n }\n return quote$.pipe(filter((x) => x.product_id === product_id));\n });\n quote$\n .pipe(\n setMetricsQuoteState(terminal.terminal_id),\n writeToSQL({\n terminal,\n writeInterval: 1000,\n tableName: 'quote',\n conflictKeys: ['datasource_id', 'product_id'],\n }),\n )\n .subscribe();\n}\n"]}
1
+ {"version":3,"file":"quote.js","sourceRoot":"","sources":["../../../src/services/markets/quote.ts"],"names":[],"mappings":";;AAAA,mDAAkE;AAClE,+CAA4C;AAC5C,qCAAyC;AACzC,yCAAuD;AACvD,+BAcc;AACd,qDAA8F;AAE9F,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,eAAe;AACf,MAAM,oBAAoB,G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data-quote';\nimport { Terminal } from '@yuants/protocol';\nimport { writeToSQL } from '@yuants/sql';\nimport { decodePath, encodePath } from '@yuants/utils';\nimport {\n catchError,\n defer,\n EMPTY,\n filter,\n groupBy,\n map,\n merge,\n mergeMap,\n repeat,\n retry,\n scan,\n share,\n shareReplay,\n} from 'rxjs';\nimport { getFuturesContracts, getFuturesTickers, getSpotTickers } from '../../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\n// 获取所有USDT永续合约\nconst usdtFutureContracts$ = defer(() => getFuturesContracts('usdt', {})).pipe(\n repeat({ delay: 3600_000 }),\n retry({ delay: 60_000 }),\n shareReplay(1),\n);\n\n// 从tickers获取价格和交易量数据\nconst quoteFromTickers$ = defer(() => getFuturesTickers('usdt', {})).pipe(\n mergeMap((tickers) => tickers),\n map(\n (ticker): Partial<IQuote> => ({\n datasource_id: 'GATE',\n product_id: encodePath('GATE', 'FUTURE', ticker.contract),\n last_price: ticker.last,\n ask_price: ticker.lowest_ask,\n bid_price: ticker.highest_bid,\n // GATE API doesn't provide bid/ask volumes in tickers endpoint\n // We'll need to use order book for that if required\n ask_volume: '0',\n bid_volume: '0',\n // total_size is the open interest\n open_interest: ticker.total_size,\n // funding_rate is the current funding rate\n interest_rate_long: ticker.funding_rate ? `${-parseFloat(ticker.funding_rate)}` : undefined,\n interest_rate_short: ticker.funding_rate,\n }),\n ),\n repeat({ delay: 5000 }),\n retry({ delay: 1000 }),\n);\n\n// 从现货tickers获取价格和交易量数据\nconst quoteFromSpotTickers$ = defer(() => getSpotTickers({})).pipe(\n mergeMap((tickers) => tickers),\n map(\n (ticker): Partial<IQuote> => ({\n datasource_id: 'GATE',\n product_id: encodePath('GATE', 'SPOT', ticker.currency_pair),\n last_price: ticker.last,\n ask_price: ticker.lowest_ask,\n bid_price: ticker.highest_bid,\n ask_volume: ticker.lowest_size ?? '0',\n bid_volume: ticker.highest_size ?? '0',\n // 现货没有持仓量的概念,设置为0\n open_interest: '0',\n }),\n ),\n repeat({ delay: 5000 }),\n retry({ delay: 1000 }),\n);\n\nconst quoteSources$ = [quoteFromTickers$, quoteFromSpotTickers$];\n\nconst quote$ = defer(() =>\n merge(\n ...quoteSources$.map((x$) =>\n defer(() => x$).pipe(\n // 防止单个流关闭导致整体关闭\n catchError(() => EMPTY),\n ),\n ),\n ),\n).pipe(\n groupBy((x) => encodePath(x.datasource_id, x.product_id)),\n mergeMap((group$) => {\n return group$.pipe(\n //\n scan((acc, cur) => Object.assign(acc, cur), {} as Partial<IQuote>),\n );\n }),\n share(),\n);\n\n// 写入数据库\nif (process.env.WRITE_QUOTE_TO_SQL === 'true') {\n terminal.channel.publishChannel('quote', { pattern: `^GATE/` }, (channel_id) => {\n const [datasource_id, product_id] = decodePath(channel_id);\n if (!datasource_id) {\n throw 'datasource_id is required';\n }\n if (!product_id) {\n throw 'product_id is required';\n }\n return quote$.pipe(filter((x) => x.product_id === product_id));\n });\n quote$\n .pipe(\n setMetricsQuoteState(terminal.terminal_id),\n writeToSQL({\n terminal,\n writeInterval: 1000,\n tableName: 'quote',\n conflictKeys: ['datasource_id', 'product_id'],\n }),\n )\n .subscribe();\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ohlc-service.js","sourceRoot":"","sources":["../../src/services/ohlc-service.ts"],"names":[],"mappings":";;AACA,+CAAsD;AACtD,+CAA6D;AAC7D,yCAAgF;AAChF,kDAAgF;AAEhF,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,MAAM,sBAAsB,GAAoB;IAC9C,qBAAqB,EAAE,GAAG;IAC1B,4BAA4B,EAAE,KAAK;CACpC,CAAC;AAEF,MAAM,yBAAyB,GAA2B;IACxD,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,KAAK,EAAE,KAAK;IACZ,KAAK,EAAE,KAAK;IACZ,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,IAAI,EAAE,IAAI;IACV,GAAG,EAAE,IAAI;IACT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C,GAAG,eAAe,CAAC,GAAG,CAAC,CAAC;QAC/B,OAAO;YACL,SAAS,EAAE,GAAG,CAAC,SAAS;YACxB,aAAa,EAAE,MAAM;YACrB,UAAU,EAAE,GAAG,CAAC,UAAU;YAC1B,QAAQ,EAAE,GAAG,CAAC,QAAQ;YACtB,UAAU,EAAE,IAAA,kBAAU,EAAC,CAAC,CAAC,GAAG,CAAC;YAC7B,SAAS,EAAE,IAAA,kBAAU,EAAC,CAAC,CAAC,GAAG,GAAG,MAAM,CAAC;YACrC,IAAI,EAAE,CAAC,CAAC,CAAC;YACT,IAAI,EAAE,CAAC,CAAC,CAAC;YACT,GAAG,EAAE,CAAC,CAAC,CAAC;YACR,KAAK,EAAE,CAAC,CAAC,CAAC;YACV,MAAM,EAAE,CAAC,CAAC,CAAC;YACX,aAAa,EAAE,GAAG;SACnB,CAAC;IACJ,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,UAAU,CAAC,GAAG,SAAS,CAAC,CAAC;AACzD,CAAC,CAAC;AAEF,IAAA,6BAAkB,EAChB,QAAQ,EACR;IACE,iBAAiB,EAAE,cAAc;IACjC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC;IACrD,SAAS,EAAE,UAAU;CACtB,EACD,wBAAwB,EACxB,sBAAsB,CACvB,CAAC;AAEF,IAAA,6BAAkB,EAChB,QAAQ,EACR;IACE,iBAAiB,EAAE,YAAY;IAC/B,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC;IACrD,SAAS,EAAE,UAAU;CACtB,EACD,qBAAqB,EACrB,sBAAsB,CACvB,CAAC","sourcesContent":["import { IOHLC } from '@yuants/data-ohlc';\nimport { provideOHLCService } from '@yuants/exchange';\nimport { IServiceOptions, Terminal } from '@yuants/protocol';\nimport { convertDurationToOffset, decodePath, formatTime } from '@yuants/utils';\nimport { getFuturesCandlesticks, getSpotCandlesticks } from '../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst INGEST_SERVICE_OPTIONS: IServiceOptions = {\n egress_token_capacity: 200,\n egress_token_refill_interval: 10000,\n};\n\nconst DURATION_TO_GATE_INTERVAL: Record<string, string> = {\n PT1M: '1m',\n PT5M: '5m',\n PT15M: '15m',\n PT30M: '30m',\n PT1H: '1h',\n PT4H: '4h',\n PT8H: '8h',\n P1D: '1d',\n P1W: '1w',\n};\n\nconst normalizeCandle = (\n raw:\n | { t: number; o: string; h: string; l: string; c: string; v: string }\n | [string, string, string, string, string, string],\n): { tMs: number; o: string; h: string; l: string; c: string; v: string } => {\n if (Array.isArray(raw)) {\n const t = Number(raw[0]);\n const tMs = t < 1e12 ? t * 1000 : t;\n const volume = raw[1];\n const close = raw[2];\n const high = raw[3];\n const low = raw[4];\n const open = raw[5];\n return { tMs, o: open, h: high, l: low, c: close, v: volume };\n }\n const t = Number(raw.t);\n const tMs = t < 1e12 ? t * 1000 : t;\n return { tMs, o: raw.o, h: raw.h, l: raw.l, c: raw.c, v: raw.v };\n};\n\nconst fetchFuturesOHLCBackward = async (req: {\n product_id: string;\n duration: string;\n time: number;\n series_id: string;\n}): Promise<IOHLC[]> => {\n const [, instType, contract] = decodePath(req.product_id);\n if (instType !== 'FUTURE' || !contract) throw new Error(`Unsupported product_id: ${req.product_id}`);\n\n const interval = DURATION_TO_GATE_INTERVAL[req.duration];\n if (!interval) throw new Error(`Unsupported duration: ${req.duration}`);\n\n const offset = convertDurationToOffset(req.duration);\n const endedAtMs = req.time;\n const to = Math.floor(endedAtMs / 1000);\n\n const rows = await getFuturesCandlesticks('usdt', {\n contract,\n interval,\n to,\n limit: 1000,\n });\n\n return (rows ?? [])\n .map((raw): IOHLC => {\n const k = normalizeCandle(raw);\n return {\n series_id: req.series_id,\n datasource_id: 'GATE',\n product_id: req.product_id,\n duration: req.duration,\n created_at: formatTime(k.tMs),\n closed_at: formatTime(k.tMs + offset),\n open: k.o,\n high: k.h,\n low: k.l,\n close: k.c,\n volume: k.v,\n open_interest: '0',\n };\n })\n .filter((x) => Date.parse(x.created_at) < endedAtMs);\n};\n\nconst fetchSpotOHLCBackward = async (req: {\n product_id: string;\n duration: string;\n time: number;\n series_id: string;\n}): Promise<IOHLC[]> => {\n const [, instType, currency_pair] = decodePath(req.product_id);\n if (instType !== 'SPOT' || !currency_pair) throw new Error(`Unsupported product_id: ${req.product_id}`);\n\n const interval = DURATION_TO_GATE_INTERVAL[req.duration];\n if (!interval) throw new Error(`Unsupported duration: ${req.duration}`);\n\n const offset = convertDurationToOffset(req.duration);\n const endedAtMs = req.time;\n const to = Math.floor(endedAtMs / 1000);\n\n const rows = await getSpotCandlesticks({\n currency_pair,\n interval,\n to,\n limit: 1000,\n });\n\n return (rows ?? [])\n .map((raw): IOHLC => {\n const k = normalizeCandle(raw);\n return {\n series_id: req.series_id,\n datasource_id: 'GATE',\n product_id: req.product_id,\n duration: req.duration,\n created_at: formatTime(k.tMs),\n closed_at: formatTime(k.tMs + offset),\n open: k.o,\n high: k.h,\n low: k.l,\n close: k.c,\n volume: k.v,\n open_interest: '0',\n };\n })\n .filter((x) => Date.parse(x.created_at) < endedAtMs);\n};\n\nprovideOHLCService(\n terminal,\n {\n product_id_prefix: 'GATE/FUTURE/',\n duration_list: Object.keys(DURATION_TO_GATE_INTERVAL),\n direction: 'backward',\n },\n fetchFuturesOHLCBackward,\n INGEST_SERVICE_OPTIONS,\n);\n\nprovideOHLCService(\n terminal,\n {\n product_id_prefix: 'GATE/SPOT/',\n duration_list: Object.keys(DURATION_TO_GATE_INTERVAL),\n direction: 'backward',\n },\n fetchSpotOHLCBackward,\n INGEST_SERVICE_OPTIONS,\n);\n"]}
1
+ {"version":3,"file":"ohlc-service.js","sourceRoot":"","sources":["../../src/services/ohlc-service.ts"],"names":[],"mappings":";;AACA,+CAAsD;AACtD,+CAA6D;AAC7D,yCAAgF;AAChF,kDAAgF;AAEhF,MAAM,QAAQ,GAAG,mBA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AEF,IAAA,6BAAkB,EAChB,QAAQ,EACR;IACE,iBAAiB,EAAE,YAAY;IAC/B,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,yBAAyB,CAAC;IACrD,SAAS,EAAE,UAAU;CACtB,EACD,qBAAqB,EACrB,sBAAsB,CACvB,CAAC","sourcesContent":["import { IOHLC } from '@yuants/data-ohlc';\nimport { provideOHLCService } from '@yuants/exchange';\nimport { IServiceOptions, Terminal } from '@yuants/protocol';\nimport { convertDurationToOffset, decodePath, formatTime } from '@yuants/utils';\nimport { getFuturesCandlesticks, getSpotCandlesticks } from '../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nconst INGEST_SERVICE_OPTIONS: IServiceOptions = {\n egress_token_capacity: 200,\n egress_token_refill_interval: 10000,\n};\n\nconst DURATION_TO_GATE_INTERVAL: Record<string, string> = {\n PT1M: '1m',\n PT5M: '5m',\n PT15M: '15m',\n PT30M: '30m',\n PT1H: '1h',\n PT4H: '4h',\n PT8H: '8h',\n P1D: '1d',\n P1W: '1w',\n};\n\nconst normalizeCandle = (\n raw:\n | { t: number; o: string; h: string; l: string; c: string; v: string }\n | [string, string, string, string, string, string],\n): { tMs: number; o: string; h: string; l: string; c: string; v: string } => {\n if (Array.isArray(raw)) {\n const t = Number(raw[0]);\n const tMs = t < 1e12 ? t * 1000 : t;\n const volume = raw[1];\n const close = raw[2];\n const high = raw[3];\n const low = raw[4];\n const open = raw[5];\n return { tMs, o: open, h: high, l: low, c: close, v: volume };\n }\n const t = Number(raw.t);\n const tMs = t < 1e12 ? t * 1000 : t;\n return { tMs, o: raw.o, h: raw.h, l: raw.l, c: raw.c, v: raw.v };\n};\n\nconst fetchFuturesOHLCBackward = async (req: {\n product_id: string;\n duration: string;\n time: number;\n series_id: string;\n}): Promise<IOHLC[]> => {\n const [, instType, contract] = decodePath(req.product_id);\n if (instType !== 'FUTURE' || !contract) throw new Error(`Unsupported product_id: ${req.product_id}`);\n\n const interval = DURATION_TO_GATE_INTERVAL[req.duration];\n if (!interval) throw new Error(`Unsupported duration: ${req.duration}`);\n\n const offset = convertDurationToOffset(req.duration);\n const endedAtMs = req.time;\n const to = Math.floor(endedAtMs / 1000);\n\n const rows = await getFuturesCandlesticks('usdt', {\n contract,\n interval,\n to,\n limit: 1000,\n });\n\n return (rows ?? [])\n .map((raw): IOHLC => {\n const k = normalizeCandle(raw);\n return {\n series_id: req.series_id,\n datasource_id: 'GATE',\n product_id: req.product_id,\n duration: req.duration,\n created_at: formatTime(k.tMs),\n closed_at: formatTime(k.tMs + offset),\n open: k.o,\n high: k.h,\n low: k.l,\n close: k.c,\n volume: k.v,\n open_interest: '0',\n };\n })\n .filter((x) => Date.parse(x.created_at) < endedAtMs);\n};\n\nconst fetchSpotOHLCBackward = async (req: {\n product_id: string;\n duration: string;\n time: number;\n series_id: string;\n}): Promise<IOHLC[]> => {\n const [, instType, currency_pair] = decodePath(req.product_id);\n if (instType !== 'SPOT' || !currency_pair) throw new Error(`Unsupported product_id: ${req.product_id}`);\n\n const interval = DURATION_TO_GATE_INTERVAL[req.duration];\n if (!interval) throw new Error(`Unsupported duration: ${req.duration}`);\n\n const offset = convertDurationToOffset(req.duration);\n const endedAtMs = req.time;\n const to = Math.floor(endedAtMs / 1000);\n\n const rows = await getSpotCandlesticks({\n currency_pair,\n interval,\n to,\n limit: 1000,\n });\n\n return (rows ?? [])\n .map((raw): IOHLC => {\n const k = normalizeCandle(raw);\n return {\n series_id: req.series_id,\n datasource_id: 'GATE',\n product_id: req.product_id,\n duration: req.duration,\n created_at: formatTime(k.tMs),\n closed_at: formatTime(k.tMs + offset),\n open: k.o,\n high: k.h,\n low: k.l,\n close: k.c,\n volume: k.v,\n open_interest: '0',\n };\n })\n .filter((x) => Date.parse(x.created_at) < endedAtMs);\n};\n\nprovideOHLCService(\n terminal,\n {\n product_id_prefix: 'GATE/FUTURE/',\n duration_list: Object.keys(DURATION_TO_GATE_INTERVAL),\n direction: 'backward',\n },\n fetchFuturesOHLCBackward,\n INGEST_SERVICE_OPTIONS,\n);\n\nprovideOHLCService(\n terminal,\n {\n product_id_prefix: 'GATE/SPOT/',\n duration_list: Object.keys(DURATION_TO_GATE_INTERVAL),\n direction: 'backward',\n },\n fetchSpotOHLCBackward,\n INGEST_SERVICE_OPTIONS,\n);\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"cancelOrder.js","sourceRoot":"","sources":["../../../src/services/orders/cancelOrder.ts"],"names":[],"mappings":";;;AACA,uDAAwE;AACxE,yCAA2C;AAEpC,MAAM,WAAW,GAA6C,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE;IAC/F,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;QACnB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;KACrC;IACD,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,IAAA,kBAAU,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,IAAI,KAAK,QAAQ,EAAE;QACrB,MAAM,IAAA,gCAAkB,EAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;KAC9D;IACD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAC9C,CAAC,CAAC;AATW,QAAA,WAAW,eAStB","sourcesContent":["import { IActionHandlerOfCancelOrder } from '@yuants/data-order';\nimport { deleteFutureOrders, ICredential } from '../../api/private-api';\nimport { decodePath } from '@yuants/utils';\n\nexport const cancelOrder: IActionHandlerOfCancelOrder<ICredential> = async (credential, order) => {\n if (!order.order_id) {\n throw new Error('Missing order_id');\n }\n const [, TYPE] = decodePath(order.product_id);\n if (TYPE === 'FUTURE') {\n await deleteFutureOrders(credential, 'usdt', order.order_id);\n }\n throw new Error('Product type not support');\n};\n"]}
1
+ {"version":3,"file":"cancelOrder.js","sourceRoot":"","sources":["../../../src/services/orders/cancelOrder.ts"],"names":[],"mappings":";;;AACA,uDAAwE;AACxE,yCAA2C;AAEpC,MAAM,WAAW,GAA6C,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,EAAE;IAC/F,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACtC,CAAC;IACD,MAAM,CAAC,EAAE,IAAI,CAAC,GAAG,IAAA,kBAAU,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IAC9C,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,MAAM,IAAA,gCAAkB,EAAC,UAAU,EAAE,MAAM,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC/D,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAC9C,CAAC,CAAC;AATW,QAAA,WAAW,eAStB","sourcesContent":["import { IActionHandlerOfCancelOrder } from '@yuants/data-order';\nimport { deleteFutureOrders, ICredential } from '../../api/private-api';\nimport { decodePath } from '@yuants/utils';\n\nexport const cancelOrder: IActionHandlerOfCancelOrder<ICredential> = async (credential, order) => {\n if (!order.order_id) {\n throw new Error('Missing order_id');\n }\n const [, TYPE] = decodePath(order.product_id);\n if (TYPE === 'FUTURE') {\n await deleteFutureOrders(credential, 'usdt', order.order_id);\n }\n throw new Error('Product type not support');\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"listOrders.d.ts","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAoB,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAatE,eAAO,MAAM,UAAU,eAAsB,WAAW,sBAsBvD,CAAC;AAEF,eAAO,MAAM,oBAAoB,eACnB,WAAW,cACX,MAAM,KACjB,QAAQ,MAAM,EAAE,CAWlB,CAAC"}
1
+ {"version":3,"file":"listOrders.d.ts","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":"AAAA,OAA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UAAU,CAAC,CAAC;QAC5C,OAAO,MAAM,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,KAAK,UAAU,CAAC,CAAC;KAClE;IACD,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC;AAdW,QAAA,oBAAoB,wBAc/B","sourcesContent":["import { IOrder } from '@yuants/data-order';\nimport { getFuturesOrders, ICredential } from '../../api/private-api';\nimport { decodePath, newError } from '@yuants/utils';\n\ntype OrderDirection = 'OPEN_LONG' | 'OPEN_SHORT' | 'CLOSE_LONG' | 'CLOSE_SHORT';\n\nconst resolveOrderDirection = (order: { size: number; is_close: boolean }): OrderDirection => {\n const isLong = order.size > 0;\n if (order.is_close) {\n return isLong ? 'CLOSE_SHORT' : 'CLOSE_LONG';\n }\n return isLong ? 'OPEN_LONG' : 'OPEN_SHORT';\n};\n\nexport const listOrders = async (credential: ICredential) => {\n const orders = await getFuturesOrders(credential, 'usdt', { status: 'open' });\n if (Array.isArray(orders) === false) throw newError('InvalidResponse', { orders });\n return orders.map((order): IOrder => {\n const volume = Math.abs(order.size);\n const leftVolume = typeof order.left === 'number' ? Math.abs(order.left) : undefined;\n const traded_volume = leftVolume !== undefined ? Math.max(volume - leftVolume, 0) : undefined;\n const price = Number(order.price);\n const traded_price = Number(order.fill_price);\n return {\n order_id: `${order.id}`,\n account_id: '',\n product_id: order.contract,\n order_direction: resolveOrderDirection(order),\n volume,\n price: Number.isFinite(price) ? price : undefined,\n submit_at: order.create_time * 1000,\n traded_volume,\n traded_price: Number.isFinite(traded_price) ? traded_price : undefined,\n order_status: order.status,\n };\n });\n};\n\nexport const getOrdersByProductId = async function (\n credential: ICredential,\n product_id: string,\n): Promise<IOrder[]> {\n const [_, instType] = decodePath(product_id); // GATE/FUTURE/ADAUSDT\n // if (instType === 'SPOT') {\n // const orders = await listSpotOrders(credential);\n // return orders.filter((order) => order.product_id === product_id);\n // }\n if (instType === 'FUTURE') {\n const orders = await listOrders(credential);\n return orders.filter((order) => order.product_id === product_id);\n }\n throw new Error(`Unsupported instType: ${instType}`);\n};\n"]}
1
+ {"version":3,"file":"listOrders.js","sourceRoot":"","sources":["../../../src/services/orders/listOrders.ts"],"names":[],"mappings":";;;AACA,uDAAsE;AACtE,yCAAqD;AAIrD,MAAM,qBAAqB,GAAG,CAAC,KAA0C,EAAkB,EAAE;IAC3F,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,GAAG,CAAC,CAAC;IAC9B,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;QACnB,OAAO,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,YAAY,CAAC;IAC/C,CAAC;IACD,OAAO,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,YAAY,CAAC;AAC7C,CAAC,CAAC;AAEK,MAAM,UAAU,GAAG,KAAK,EAAE,UAAuB,EAAE,EAAE;IAC1D,MAAM,MAAM,GAAG,MAAM,IAAA,8BAAgB,EAAC,UAAU,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9E,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK;QAAE,MAAM,IAAA,gBAAQ,EAAC,iBAAiB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IACnF,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAU,EAAE;QAClC,MAAM,MAAM,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,MAAM,UAAU,GAAG,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACrF,MAAM,aAAa,GAAG,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,G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AM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAC;AACvD,CAAC,CAAC;AAdW,QAAA,oBAAoB,wBAc/B","sourcesContent":["import { IOrder } from '@yuants/data-order';\nimport { getFuturesOrders, ICredential } from '../../api/private-api';\nimport { decodePath, newError } from '@yuants/utils';\n\ntype OrderDirection = 'OPEN_LONG' | 'OPEN_SHORT' | 'CLOSE_LONG' | 'CLOSE_SHORT';\n\nconst resolveOrderDirection = (order: { size: number; is_close: boolean }): OrderDirection => {\n const isLong = order.size > 0;\n if (order.is_close) {\n return isLong ? 'CLOSE_SHORT' : 'CLOSE_LONG';\n }\n return isLong ? 'OPEN_LONG' : 'OPEN_SHORT';\n};\n\nexport const listOrders = async (credential: ICredential) => {\n const orders = await getFuturesOrders(credential, 'usdt', { status: 'open' });\n if (Array.isArray(orders) === false) throw newError('InvalidResponse', { orders });\n return orders.map((order): IOrder => {\n const volume = Math.abs(order.size);\n const leftVolume = typeof order.left === 'number' ? Math.abs(order.left) : undefined;\n const traded_volume = leftVolume !== undefined ? Math.max(volume - leftVolume, 0) : undefined;\n const price = Number(order.price);\n const traded_price = Number(order.fill_price);\n return {\n order_id: `${order.id}`,\n account_id: '',\n product_id: order.contract,\n order_direction: resolveOrderDirection(order),\n volume,\n price: Number.isFinite(price) ? price : undefined,\n submit_at: order.create_time * 1000,\n traded_volume,\n traded_price: Number.isFinite(traded_price) ? traded_price : undefined,\n order_status: order.status,\n };\n });\n};\n\nexport const getOrdersByProductId = async function (\n credential: ICredential,\n product_id: string,\n): Promise<IOrder[]> {\n const [_, instType] = decodePath(product_id); // GATE/FUTURE/ADAUSDT\n // if (instType === 'SPOT') {\n // const orders = await listSpotOrders(credential);\n // return orders.filter((order) => order.product_id === product_id);\n // }\n if (instType === 'FUTURE') {\n const orders = await listOrders(credential);\n return orders.filter((order) => order.product_id === product_id);\n }\n throw new Error(`Unsupported instType: ${instType}`);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"submit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T,KAAK,CAAC,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;IACjG,IAAI,KAAK,KAAK,SAAS,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;KACrD;IACD,MAAM,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,GAAG,IAAA,kBAAU,EAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACxD,IAAI,IAAI,KAAK,QAAQ,EAAE;QACrB,MAAM,GAAG,GAAG,MAAM,IAAA,8BAAgB,EAAC,UAAU,EAAE,MAAM,EAAE;YACrD,QAAQ;YACR,IAAI;YACJ,KAAK;YACL,GAAG;YACH,WAAW;SACZ,CAAC,CAAC;QAEH,IAAI,GAAG,CAAC,KAAK,EAAE;YACb,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClF,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;SACzB;QACD,OAAO;YACL,QAAQ,EAAE,GAAG,GAAG,CAAC,EAAE,EAAE;SACtB,CAAC;KACH;IACD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAC9C,CAAC,CAAC;AAnCW,QAAA,WAAW,eAmCtB","sourcesContent":["import { IActionHandlerOfSubmitOrder } from '@yuants/data-order';\nimport { ICredential, postFutureOrders } from '../../api/private-api';\nimport { decodePath } from '@yuants/utils';\n\nconst resolveSizeSign = (order_direction?: string): number => {\n switch (order_direction) {\n case 'OPEN_LONG':\n case 'CLOSE_SHORT':\n return 1;\n case 'OPEN_SHORT':\n case 'CLOSE_LONG':\n return -1;\n default:\n throw new Error(`Unsupported order_direction: ${order_direction}`);\n }\n};\n\nconst resolveTif = (order_type?: string): string => {\n if (order_type === 'MARKET') return 'ioc';\n if (order_type === 'LIMIT' || order_type === 'MAKER') return 'gtc';\n throw new Error(`Unsupported order_type: ${order_type}`);\n};\n\nexport const submitOrder: IActionHandlerOfSubmitOrder<ICredential> = async (credential, order) => {\n if (!order.product_id) {\n throw new Error('Missing product_id');\n }\n if (!order.volume || order.volume <= 0) {\n throw new Error('Invalid order volume');\n }\n\n const size = order.volume * resolveSizeSign(order.order_direction);\n const tif = resolveTif(order.order_type);\n const reduce_only = order.order_direction === 'CLOSE_LONG' || order.order_direction === 'CLOSE_SHORT';\n const price =\n order.order_type === 'MARKET' ? '0' : order.price !== undefined ? `${order.price}` : undefined;\n if (price === undefined) {\n throw new Error('Limit/Maker order requires price');\n }\n const [, TYPE, contract] = decodePath(order.product_id);\n if (TYPE === 'FUTURE') {\n const res = await postFutureOrders(credential, 'usdt', {\n contract,\n size,\n price,\n tif,\n reduce_only,\n });\n\n if (res.label) {\n const detail = [res.label, res.message, res.detail].filter((v) => !!v).join(': ');\n throw new Error(detail);\n }\n return {\n order_id: `${res.id}`,\n };\n }\n throw new Error('Product type not support');\n};\n"]}
1
+ {"version":3,"file":"submitOrder.js","sourceRoot":"","sources":["../../../src/services/orders/submitOrder.ts"],"names":[],"mappings":";;;AACA,uDAAsE;AACtE,yCAA2C;AAE3C,MAAM,eAAe,GAAG,CAAC,eAAwB,EAAU,EAAE;IAC3D,QAAQ,eAAe,EAAE,CAAC;QACxB,KAAK,WAAW,CAAC;QACjB,KAAK,aAAa;YAChB,OAAO,CAAC,CAAC;QACX,KAAK,YAAY,CAAC;QAClB,KAAK,YAAY;YACf,OAAO,CAAC,CAAC,CAAC;QACZ;YACE,MAAM,IAAI,KAAK,CAAC,gCAAgC,eAAe,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC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,KAAK,CAAC,UAAU,CAAC,CAAC;IACxD,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,MAAM,GAAG,GAAG,MAAM,IAAA,8BAAgB,EAAC,UAAU,EAAE,MAAM,EAAE;YACrD,QAAQ;YACR,IAAI;YACJ,KAAK;YACL,GAAG;YACH,WAAW;SACZ,CAAC,CAAC;QAEH,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;YACd,MAAM,MAAM,GAAG,CAAC,GAAG,CAAC,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YAClF,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC1B,CAAC;QACD,OAAO;YACL,QAAQ,EAAE,GAAG,GAAG,CAAC,EAAE,EAAE;SACtB,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAC9C,CAAC,CAAC;AAnCW,QAAA,WAAW,eAmCtB","sourcesContent":["import { IActionHandlerOfSubmitOrder } from '@yuants/data-order';\nimport { ICredential, postFutureOrders } from '../../api/private-api';\nimport { decodePath } from '@yuants/utils';\n\nconst resolveSizeSign = (order_direction?: string): number => {\n switch (order_direction) {\n case 'OPEN_LONG':\n case 'CLOSE_SHORT':\n return 1;\n case 'OPEN_SHORT':\n case 'CLOSE_LONG':\n return -1;\n default:\n throw new Error(`Unsupported order_direction: ${order_direction}`);\n }\n};\n\nconst resolveTif = (order_type?: string): string => {\n if (order_type === 'MARKET') return 'ioc';\n if (order_type === 'LIMIT' || order_type === 'MAKER') return 'gtc';\n throw new Error(`Unsupported order_type: ${order_type}`);\n};\n\nexport const submitOrder: IActionHandlerOfSubmitOrder<ICredential> = async (credential, order) => {\n if (!order.product_id) {\n throw new Error('Missing product_id');\n }\n if (!order.volume || order.volume <= 0) {\n throw new Error('Invalid order volume');\n }\n\n const size = order.volume * resolveSizeSign(order.order_direction);\n const tif = resolveTif(order.order_type);\n const reduce_only = order.order_direction === 'CLOSE_LONG' || order.order_direction === 'CLOSE_SHORT';\n const price =\n order.order_type === 'MARKET' ? '0' : order.price !== undefined ? `${order.price}` : undefined;\n if (price === undefined) {\n throw new Error('Limit/Maker order requires price');\n }\n const [, TYPE, contract] = decodePath(order.product_id);\n if (TYPE === 'FUTURE') {\n const res = await postFutureOrders(credential, 'usdt', {\n contract,\n size,\n price,\n tif,\n reduce_only,\n });\n\n if (res.label) {\n const detail = [res.label, res.message, res.detail].filter((v) => !!v).join(': ');\n throw new Error(detail);\n }\n return {\n order_id: `${res.id}`,\n };\n }\n throw new Error('Product type not support');\n};\n"]}
@@ -19,7 +19,7 @@ const terminal = protocol_1.Terminal.fromNodeEnv();
19
19
  const res = await (0, public_api_1.getFuturesTickers)('usdt', {});
20
20
  return res.map((ticker) => ({
21
21
  product_id: (0, utils_1.encodePath)('GATE', 'FUTURE', ticker.contract),
22
- updated_at: Date.now(),
22
+ updated_at: Date.now(), // ISSUE: API 未返回服务器时间
23
23
  last_price: ticker.last,
24
24
  ask_price: ticker.lowest_ask,
25
25
  bid_price: ticker.highest_bid,
@@ -1 +1 @@
1
- {"version":3,"file":"quotes.js","sourceRoot":"","sources":["../../src/services/quotes.ts"],"names":[],"mappings":";;AAAA,+CAAuD;AACvD,+CAA4C;AAC5C,yCAA2C;AAC3C,kDAAsE;AAEtE,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,EAAE,CAAC;AAExC,IAAA,8BAAmB,EACjB,QAAQ,EACR;IACE,iBAAiB,EAAE,cAAc;IACjC,MAAM,EAAE;QACN,YAAY;QACZ,WAAW;QACX,WAAW;QACX,eAAe;QACf,oBAAoB;QACpB,qBAAqB;KACtB;CACF,EACD,KAAK,IAAI,EAAE;IACT,MAAM,GAAG,GAAG,MAAM,IAAA,8BAAiB,EAAC,MAAM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,YAAY,mCAAI,GAAG;YACtC,kBAAkB;YAClB,aAAa,EAAE,GAAG;SACnB,CAAC,CAAA;KAAA,CAAC,CAAC;AACN,CAAC,CACF,CAAC","sourcesContent":["import { provideQuoteService } from '@yuants/exchange';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { getFuturesTickers, getSpotTickers } from '../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'GATE/FUTURE/',\n fields: [\n 'last_price',\n 'ask_price',\n 'bid_price',\n 'open_interest',\n 'interest_rate_long',\n 'interest_rate_short',\n ],\n },\n async () => {\n const res = await getFuturesTickers('usdt', {});\n return res.map((ticker) => ({\n product_id: encodePath('GATE', 'FUTURE', ticker.contract),\n updated_at: Date.now(), // ISSUE: API 未返回服务器时间\n last_price: ticker.last,\n ask_price: ticker.lowest_ask,\n bid_price: ticker.highest_bid,\n // total_size is the open interest\n open_interest: ticker.total_size,\n // funding_rate is the current funding rate\n interest_rate_long: `${-Number(ticker.funding_rate)}`,\n interest_rate_short: ticker.funding_rate,\n }));\n },\n);\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'GATE/SPOT/',\n fields: ['last_price', 'ask_price', 'ask_volume', 'bid_price', 'bid_volume', 'open_interest'],\n },\n async () => {\n const res = await getSpotTickers({});\n return res.map((ticker) => ({\n product_id: encodePath('GATE', 'SPOT', ticker.currency_pair),\n updated_at: Date.now(),\n last_price: ticker.last,\n ask_price: ticker.lowest_ask,\n bid_price: ticker.highest_bid,\n ask_volume: ticker.lowest_size ?? '0',\n bid_volume: ticker.highest_size ?? '0',\n // 现货没有持仓量的概念,设置为0\n open_interest: '0',\n }));\n },\n);\n"]}
1
+ {"version":3,"file":"quotes.js","sourceRoot":"","sources":["../../src/services/quotes.ts"],"names":[],"mappings":";;AAAA,+CAAuD;AACvD,+CAA4C;AAC5C,yCAA2C;AAC3C,kDAAsE;AAEtE,MAAM,QAA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,EAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,aAAa,CAAC;YAC5D,UAAU,EAAE,IAAI,CAAC,GAAG,EAAE;YACtB,UAAU,EAAE,MAAM,CAAC,IAAI;YACvB,SAAS,EAAE,MAAM,CAAC,UAAU;YAC5B,SAAS,EAAE,MAAM,CAAC,WAAW;YAC7B,UAAU,EAAE,MAAA,MAAM,CAAC,WAAW,mCAAI,GAAG;YACrC,UAAU,EAAE,MAAA,MAAM,CAAC,YAAY,mCAAI,GAAG;YACtC,kBAAkB;YAClB,aAAa,EAAE,GAAG;SACnB,CAAC,CAAA;KAAA,CAAC,CAAC;AACN,CAAC,CACF,CAAC","sourcesContent":["import { provideQuoteService } from '@yuants/exchange';\nimport { Terminal } from '@yuants/protocol';\nimport { encodePath } from '@yuants/utils';\nimport { getFuturesTickers, getSpotTickers } from '../api/public-api';\n\nconst terminal = Terminal.fromNodeEnv();\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'GATE/FUTURE/',\n fields: [\n 'last_price',\n 'ask_price',\n 'bid_price',\n 'open_interest',\n 'interest_rate_long',\n 'interest_rate_short',\n ],\n },\n async () => {\n const res = await getFuturesTickers('usdt', {});\n return res.map((ticker) => ({\n product_id: encodePath('GATE', 'FUTURE', ticker.contract),\n updated_at: Date.now(), // ISSUE: API 未返回服务器时间\n last_price: ticker.last,\n ask_price: ticker.lowest_ask,\n bid_price: ticker.highest_bid,\n // total_size is the open interest\n open_interest: ticker.total_size,\n // funding_rate is the current funding rate\n interest_rate_long: `${-Number(ticker.funding_rate)}`,\n interest_rate_short: ticker.funding_rate,\n }));\n },\n);\n\nprovideQuoteService(\n terminal,\n {\n product_id_prefix: 'GATE/SPOT/',\n fields: ['last_price', 'ask_price', 'ask_volume', 'bid_price', 'bid_volume', 'open_interest'],\n },\n async () => {\n const res = await getSpotTickers({});\n return res.map((ticker) => ({\n product_id: encodePath('GATE', 'SPOT', ticker.currency_pair),\n updated_at: Date.now(),\n last_price: ticker.last,\n ask_price: ticker.lowest_ask,\n bid_price: ticker.highest_bid,\n ask_volume: ticker.lowest_size ?? '0',\n bid_volume: ticker.highest_size ?? '0',\n // 现货没有持仓量的概念,设置为0\n open_interest: '0',\n }));\n },\n);\n"]}
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.30.1"
8
+ "packageVersion": "7.55.2"
9
9
  }
10
10
  ]
11
11
  }
package/package.json CHANGED
@@ -1,44 +1,44 @@
1
1
  {
2
- "name": "@yuants/vendor-gate",
3
- "version": "0.6.8",
4
- "main": "lib/index.js",
5
- "files": [
6
- "lib",
7
- "dist",
8
- "temp"
9
- ],
10
- "dependencies": {
11
- "@yuants/cache": "0.3.11",
12
- "@yuants/protocol": "0.54.0",
13
- "@yuants/transfer": "0.2.47",
14
- "@yuants/data-account": "0.11.7",
15
- "@yuants/data-order": "0.7.8",
16
- "@yuants/data-ohlc": "0.6.3",
17
- "@yuants/sql": "0.9.38",
18
- "@yuants/data-product": "0.5.8",
19
- "@yuants/utils": "0.19.3",
20
- "@yuants/data-series": "0.3.60",
21
- "@yuants/data-interest-rate": "0.2.6",
22
- "@yuants/exchange": "0.8.9",
23
- "@yuants/data-quote": "0.4.7",
24
- "rxjs": "~7.5.6"
25
- },
26
- "devDependencies": {
27
- "@microsoft/api-extractor": "~7.30.0",
28
- "@rushstack/heft": "~0.47.5",
29
- "@rushstack/heft-jest-plugin": "~0.16.8",
30
- "@rushstack/heft-node-rig": "~1.10.7",
31
- "@types/heft-jest": "1.0.3",
32
- "@types/node": "22",
33
- "@yuants/extension": "0.2.39",
34
- "@yuants/tool-kit": "0.2.1",
35
- "typescript": "~4.7.4"
36
- },
37
- "publishConfig": {
38
- "registry": "https://registry.npmjs.org",
39
- "access": "public"
40
- },
41
- "scripts": {
42
- "build": "heft test --clean && api-extractor run --local && yuan-toolkit post-build"
43
- }
44
- }
2
+ "name": "@yuants/vendor-gate",
3
+ "version": "0.6.10",
4
+ "main": "lib/index.js",
5
+ "files": [
6
+ "lib",
7
+ "dist",
8
+ "temp"
9
+ ],
10
+ "dependencies": {
11
+ "rxjs": "~7.5.6",
12
+ "@yuants/cache": "0.3.12",
13
+ "@yuants/transfer": "0.2.48",
14
+ "@yuants/data-order": "0.7.9",
15
+ "@yuants/protocol": "0.54.1",
16
+ "@yuants/data-account": "0.11.8",
17
+ "@yuants/data-ohlc": "0.6.4",
18
+ "@yuants/sql": "0.9.39",
19
+ "@yuants/data-product": "0.5.9",
20
+ "@yuants/utils": "0.19.4",
21
+ "@yuants/data-interest-rate": "0.2.8",
22
+ "@yuants/data-series": "0.3.61",
23
+ "@yuants/exchange": "0.8.11",
24
+ "@yuants/data-quote": "0.4.8"
25
+ },
26
+ "devDependencies": {
27
+ "@microsoft/api-extractor": "~7.55.2",
28
+ "@rushstack/heft": "~1.1.7",
29
+ "@rushstack/heft-jest-plugin": "~1.1.7",
30
+ "@rushstack/heft-node-rig": "~2.11.12",
31
+ "@types/heft-jest": "1.0.6",
32
+ "@types/node": "24",
33
+ "typescript": "~5.9.3",
34
+ "@yuants/extension": "0.2.40",
35
+ "@yuants/tool-kit": "0.2.2"
36
+ },
37
+ "publishConfig": {
38
+ "registry": "https://registry.npmjs.org",
39
+ "access": "public"
40
+ },
41
+ "scripts": {
42
+ "build": "heft test --clean && api-extractor run --local --config ./config/api-extractor.json && yuan-toolkit post-build"
43
+ }
44
+ }