diff --git a/examples/apidoc/V5/Position/confirm-new-risk-limit.js b/examples/apidoc/V5/Position/confirm-new-risk-limit.js new file mode 100644 index 0000000..7471014 --- /dev/null +++ b/examples/apidoc/V5/Position/confirm-new-risk-limit.js @@ -0,0 +1,19 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .confirmNewRiskLimit({ + category: 'linear', + symbol: 'BTCUSDT', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Position/get-move-position-history.js b/examples/apidoc/V5/Position/get-move-position-history.js new file mode 100644 index 0000000..2059ec5 --- /dev/null +++ b/examples/apidoc/V5/Position/get-move-position-history.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getMovePositionHistory() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Position/move-position.js b/examples/apidoc/V5/Position/move-position.js new file mode 100644 index 0000000..e57ea77 --- /dev/null +++ b/examples/apidoc/V5/Position/move-position.js @@ -0,0 +1,28 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .movePosition({ + fromUid: '100307601', + toUid: '592324', + list: [ + { + category: 'spot', + symbol: 'BTCUSDT', + price: '100', + side: 'Sell', + qty: '0.01', + }, + ], + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Preupgrade/get-preupgrade-USDC-session-settlement.js b/examples/apidoc/V5/Preupgrade/get-preupgrade-USDC-session-settlement.js new file mode 100644 index 0000000..523b151 --- /dev/null +++ b/examples/apidoc/V5/Preupgrade/get-preupgrade-USDC-session-settlement.js @@ -0,0 +1,20 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getPreUpgradeUSDCSessionSettlement({ + category: 'linear', + symbol: 'ETHPERP', + limit: 1, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Preupgrade/get-preupgrade-closed-pnl.js b/examples/apidoc/V5/Preupgrade/get-preupgrade-closed-pnl.js new file mode 100644 index 0000000..a8eaf76 --- /dev/null +++ b/examples/apidoc/V5/Preupgrade/get-preupgrade-closed-pnl.js @@ -0,0 +1,19 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getPreUpgradeClosedPnl({ + category: 'linear', + symbol: 'BTCUSDT', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Preupgrade/get-preupgrade-option-delivery-record.js b/examples/apidoc/V5/Preupgrade/get-preupgrade-option-delivery-record.js new file mode 100644 index 0000000..44f0624 --- /dev/null +++ b/examples/apidoc/V5/Preupgrade/get-preupgrade-option-delivery-record.js @@ -0,0 +1,18 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getPreUpgradeOptionDeliveryRecord({ + category: 'option', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Preupgrade/get-preupgrade-order-history.js b/examples/apidoc/V5/Preupgrade/get-preupgrade-order-history.js new file mode 100644 index 0000000..4373358 --- /dev/null +++ b/examples/apidoc/V5/Preupgrade/get-preupgrade-order-history.js @@ -0,0 +1,20 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getPreUpgradeOrderHistory({ + category: 'linear', + limit: 1, + orderStatus: 'Filled', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Preupgrade/get-preupgrade-trade-history.js b/examples/apidoc/V5/Preupgrade/get-preupgrade-trade-history.js new file mode 100644 index 0000000..7a29ffd --- /dev/null +++ b/examples/apidoc/V5/Preupgrade/get-preupgrade-trade-history.js @@ -0,0 +1,21 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getPreUpgradeTradeHistory({ + category: 'linear', + limit: 1, + type: 'Funding', + symbol: 'BTCUSDT', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Preupgrade/get-preupgrade-transaction-log.js b/examples/apidoc/V5/Preupgrade/get-preupgrade-transaction-log.js new file mode 100644 index 0000000..54d57bf --- /dev/null +++ b/examples/apidoc/V5/Preupgrade/get-preupgrade-transaction-log.js @@ -0,0 +1,18 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getPreUpgradeTransactionLog({ + category: 'option', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-historical-interest-rate.js b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-historical-interest-rate.js new file mode 100644 index 0000000..b072a69 --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-historical-interest-rate.js @@ -0,0 +1,21 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getHistoricalInterestRate({ + currency: 'USDC', + vipLevel: 'No VIP', + startTime: 1721458800000, + endTime: 1721469600000, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/User/get-sub-uid-list-unlimited.js b/examples/apidoc/V5/User/get-sub-uid-list-unlimited.js new file mode 100644 index 0000000..8b4e2aa --- /dev/null +++ b/examples/apidoc/V5/User/get-sub-uid-list-unlimited.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSubUIDListUnlimited() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/package-lock.json b/package-lock.json index 5ac3fd2..f743907 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "3.10.14", + "version": "3.10.15", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "3.10.14", + "version": "3.10.15", "license": "MIT", "dependencies": { "axios": "^1.6.6", diff --git a/package.json b/package.json index dd3b5ea..d9912f7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "3.10.14", + "version": "3.10.15", "description": "Complete & robust Node.js SDK for Bybit's REST APIs and WebSockets, with TypeScript & strong end to end tests.", "main": "lib/index.js", "types": "lib/index.d.ts", diff --git a/src/rest-client-v5.ts b/src/rest-client-v5.ts index 14a27ad..c446ae4 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -91,8 +91,11 @@ import { GetOptionDeliveryPriceParamsV5, GetOrderbookParamsV5, GetPreUpgradeClosedPnlParamsV5, + GetPreUpgradeOptionDeliveryRecordParamsV5, GetPreUpgradeOrderHistoryParamsV5, GetPreUpgradeTradeHistoryParamsV5, + GetPreUpgradeTransactionLogParamsV5, + GetPreUpgradeUSDCSessionParamsV5, GetPremiumIndexPriceKlineParamsV5, GetPublicTradingHistoryParamsV5, GetRiskLimitParamsV5, @@ -129,6 +132,9 @@ import { OrderbookResponseV5, PositionInfoParamsV5, PositionV5, + PreupgradeOptionsDelivery, + PreupgradeTransactionLog, + PreupgradeUSDCSessionSettlement, PublicTradeV5, PurchaseSpotLeveragedTokenParamsV5, PurchaseSpotLeveragedTokenResultV5, @@ -767,7 +773,7 @@ export class RestClientV5 extends BaseRestClient { * * Unified account covers: USDT perpetual / USDC contract / Spot / Option */ - getMovePositionHistory(params: GetMovePositionHistoryParamsV5): Promise< + getMovePositionHistory(params?: GetMovePositionHistoryParamsV5): Promise< APIResponseV3WithTime<{ list: MovePositionHistoryV5[]; nextPageCursor: string; @@ -838,6 +844,55 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/pre-upgrade/position/closed-pnl', params); } + /** + * Query transaction logs which occurred in the USDC Derivatives wallet before the account was upgraded to a Unified account. + * + * You can get USDC Perpetual, Option records. + * + * INFO + * USDC Perpeual & Option support the recent 6 months data. Please download older data via GUI + */ + getPreUpgradeTransactionLog( + params: GetPreUpgradeTransactionLogParamsV5, + ): Promise< + APIResponseV3WithTime<{ + list: PreupgradeTransactionLog[]; + nextPageCursor: string; + }> + > { + return this.getPrivate('/v5/pre-upgrade/account/transaction-log', params); + } + + /** + * Query delivery records of Option before you upgraded the account to a Unified account, sorted by deliveryTime in descending order. + * + * INFO + * Supports the recent 6 months data. Please download older data via GUI + */ + getPreUpgradeOptionDeliveryRecord( + params: GetPreUpgradeOptionDeliveryRecordParamsV5, + ): Promise< + APIResponseV3WithTime> + > { + return this.getPrivate('/v5/pre-upgrade/asset/delivery-record', params); + } + + /** + * Query session settlement records of USDC perpetual before you upgrade the account to Unified account. + * + * INFO + * USDC Perpetual support the recent 6 months data. Please download older data via GUI + */ + getPreUpgradeUSDCSessionSettlement( + params: GetPreUpgradeUSDCSessionParamsV5, + ): Promise< + APIResponseV3WithTime< + CategoryCursorListV5 + > + > { + return this.getPrivate('/v5/pre-upgrade/asset/settlement-record', params); + } + /** * ****** Account APIs @@ -1512,6 +1567,18 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/user/query-sub-members'); } + getSubUIDListUnlimited(params?: { + pageSize?: string; + nextCursor?: string; + }): Promise< + APIResponseV3WithTime<{ + subMembers: SubMemberV5[]; + nextCursor: string; + }> + > { + return this.getPrivate('/v5/user/submembers', params); + } + /** * Query all api keys information of a sub UID. */ @@ -1712,6 +1779,32 @@ export class RestClientV5 extends BaseRestClient { return this.get('/v5/spot-margin-trade/data', params); } + /** + * Get Historical Interest Rate + * You can query up to six months borrowing interest rate of Margin trading. + * INFO: Need authentication, the api key needs "Spot" permission. Only supports Unified account. + */ + getHistoricalInterestRate(params: { + currency: string; + vipLevel?: string; + startTime?: number; + endTime?: number; + }): Promise< + APIResponseV3WithTime<{ + list: { + timestamp: number; + currency: string; + hourlyBorrowRate: string; + vipLevel: string; + }[]; + }> + > { + return this.getPrivate( + '/v5/spot-margin-trade/interest-rate-history', + params, + ); + } + /** * Turn spot margin trade on / off in your UTA account. * @@ -1766,32 +1859,6 @@ export class RestClientV5 extends BaseRestClient { }); } - /** - * Get Historical Interest Rate - * You can query up to six months borrowing interest rate of Margin trading. - * INFO: Need authentication, the api key needs "Spot" permission. Only supports Unified account. - */ - getHistoricalInterestRate(params: { - currency: string; - vipLevel?: string; - startTime?: number; - endTime?: number; - }): Promise< - APIResponseV3WithTime<{ - list: { - timestamp: number; - currency: string; - hourlyBorrowRate: string; - vipLevel: string; - }[]; - }> - > { - return this.getPrivate( - '/v5/spot-margin-trade/interest-rate-history', - params, - ); - } - /** * Get Borrowable Coin Info */ diff --git a/src/types/request/v5-pre-upgrade.ts b/src/types/request/v5-pre-upgrade.ts index 1cb7201..3cf65ac 100644 --- a/src/types/request/v5-pre-upgrade.ts +++ b/src/types/request/v5-pre-upgrade.ts @@ -35,3 +35,28 @@ export interface GetPreUpgradeClosedPnlParamsV5 { limit?: number; cursor?: string; } + +export interface GetPreUpgradeTransactionLogParamsV5 { + category: 'linear' | 'option'; + baseCoin?: string; + type?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; +} + +export interface GetPreUpgradeOptionDeliveryRecordParamsV5 { + category: 'option'; + symbol?: string; + expDate?: string; + limit?: number; + cursor?: string; +} + +export interface GetPreUpgradeUSDCSessionParamsV5 { + category: 'linear'; + symbol?: string; + limit?: number; + cursor?: string; +} diff --git a/src/types/response/index.ts b/src/types/response/index.ts index 30233d0..7d289b7 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -12,3 +12,4 @@ export * from './v5-trade'; export * from './v5-user'; export * from './v5-spot-leverage-token'; export * from './v5-broker'; +export * from './v5-preupgrade'; diff --git a/src/types/response/v5-asset.ts b/src/types/response/v5-asset.ts index 42d136e..9e58065 100644 --- a/src/types/response/v5-asset.ts +++ b/src/types/response/v5-asset.ts @@ -207,8 +207,6 @@ export interface ConvertQuoteV5 { toAmount: string; expiredTime: string; requestId: string; - paramType: string; - paramValue: string; } export interface ConvertStatusV5 { diff --git a/src/types/response/v5-preupgrade.ts b/src/types/response/v5-preupgrade.ts new file mode 100644 index 0000000..19baf4d --- /dev/null +++ b/src/types/response/v5-preupgrade.ts @@ -0,0 +1,42 @@ +export interface PreupgradeTransactionLog { + symbol: string; + category: string; + side: 'Buy' | 'Sell' | 'None'; + transactionTime: string; + type: string; + qty: string; + size: string; + currency: 'USDC' | 'USDT' | 'BTC' | 'ETH'; + tradePrice: string; + funding: string; + fee: string; + cashFlow: string; + change: string; + cashBalance: string; + feeRate: string; + bonusChange: string; + tradeId: string; + orderId: string; + orderLinkId: string; + } + + export interface PreupgradeOptionsDelivery { + deliveryTime: number; + symbol: string; + side: 'Buy' | 'Sell'; + position: string; + deliveryPrice: string; + strike: string; + fee: string; + deliveryRpl: string; + } + + export interface PreupgradeUSDCSessionSettlement { + symbol: string; + side: 'Buy' | 'Sell'; + size: string; + sessionAvgPrice: string; + markPrice: string; + realisedPnl: string; + createdTime: string; + } \ No newline at end of file diff --git a/src/types/response/v5-user.ts b/src/types/response/v5-user.ts index 3bdc5b1..ea8061e 100644 --- a/src/types/response/v5-user.ts +++ b/src/types/response/v5-user.ts @@ -22,6 +22,7 @@ export interface SubMemberV5 { username: string; memberType: number; status: number; + accountMode: number; remark: string; } export type ApiKeyType = 1 | 2; @@ -73,11 +74,10 @@ export interface SubAccountAllApiKeysResultV5 { readOnly: 0 | 1; deadlineDay?: number; flag: string; - }[], + }[]; nextPageCursor: string; } - export interface AffiliateUserInfoV5 { uid: string; vipLevel: string; @@ -93,4 +93,4 @@ export interface AffiliateUserInfoV5 { depositUpdateTime: string; volUpdateTime: string; KycLevel: 0 | 1 | 2; -} \ No newline at end of file +}