diff --git a/examples/apidoc/V5/Account/batch-set-collateral-coin.js b/examples/apidoc/V5/Account/batch-set-collateral-coin.js new file mode 100644 index 0000000..187b3bb --- /dev/null +++ b/examples/apidoc/V5/Account/batch-set-collateral-coin.js @@ -0,0 +1,27 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .batchSetCollateralCoin({ + request: [ + { + coin: 'BTC', + collateralSwitch: 'ON', + }, + { + coin: 'ETH', + collateralSwitch: 'OFF', + }, + ], + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Account/get-borrow-history.js b/examples/apidoc/V5/Account/get-borrow-history.js new file mode 100644 index 0000000..08c29c1 --- /dev/null +++ b/examples/apidoc/V5/Account/get-borrow-history.js @@ -0,0 +1,22 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getBorrowHistory({ + currency: 'USDT', + startTime: 1670601600000, + endTime: 1673203200000, + limit: 30, + cursor: 'nextPageCursorToken', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Account/get-dcp-info.js b/examples/apidoc/V5/Account/get-dcp-info.js new file mode 100644 index 0000000..0d46100 --- /dev/null +++ b/examples/apidoc/V5/Account/get-dcp-info.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getDCPInfo() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Account/get-smp-group-id.js b/examples/apidoc/V5/Account/get-smp-group-id.js new file mode 100644 index 0000000..38b6ff2 --- /dev/null +++ b/examples/apidoc/V5/Account/get-smp-group-id.js @@ -0,0 +1,16 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSMPGroup() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Account/repay-liability.js b/examples/apidoc/V5/Account/repay-liability.js new file mode 100644 index 0000000..6037a8e --- /dev/null +++ b/examples/apidoc/V5/Account/repay-liability.js @@ -0,0 +1,18 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .repayLiability({ + coin: 'USDT', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Account/set-collateral-coin.js b/examples/apidoc/V5/Account/set-collateral-coin.js new file mode 100644 index 0000000..414770d --- /dev/null +++ b/examples/apidoc/V5/Account/set-collateral-coin.js @@ -0,0 +1,19 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .setCollateralCoin({ + coin: 'BTC', + collateralSwitch: 'ON', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Account/set-spot-hedging.js b/examples/apidoc/V5/Account/set-spot-hedging.js new file mode 100644 index 0000000..605e3f5 --- /dev/null +++ b/examples/apidoc/V5/Account/set-spot-hedging.js @@ -0,0 +1,18 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .setSpotHedging({ + setHedgingMode: 'ON' | 'OFF', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Asset/get-exchange-entity-list.js b/examples/apidoc/V5/Asset/get-exchange-entity-list.js new file mode 100644 index 0000000..6083229 --- /dev/null +++ b/examples/apidoc/V5/Asset/get-exchange-entity-list.js @@ -0,0 +1,18 @@ +// https://api.bybit.com/v5/asset/withdraw/vasp/list + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getExchangeEntities() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Broker/get-exchange-broker-account-info.js b/examples/apidoc/V5/Broker/get-exchange-broker-account-info.js new file mode 100644 index 0000000..60bdaea --- /dev/null +++ b/examples/apidoc/V5/Broker/get-exchange-broker-account-info.js @@ -0,0 +1,18 @@ +// https://api.bybit.com/v5/broker/account-info + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getExchangeBrokerAccountInfo() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Broker/get-exchange-broker-earning.js b/examples/apidoc/V5/Broker/get-exchange-broker-earning.js new file mode 100644 index 0000000..3e4543b --- /dev/null +++ b/examples/apidoc/V5/Broker/get-exchange-broker-earning.js @@ -0,0 +1,23 @@ +// https://api.bybit.com/v5/broker/earnings-info + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getExchangeBrokerEarnings({ + bizType: 'SPOT', + begin: '20231201', + end: '20231207', + limit: 1000, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Broker/get-subaccount-deposit-records.js b/examples/apidoc/V5/Broker/get-subaccount-deposit-records.js new file mode 100644 index 0000000..83c8bf3 --- /dev/null +++ b/examples/apidoc/V5/Broker/get-subaccount-deposit-records.js @@ -0,0 +1,20 @@ +// https://api.bybit.com/v5/broker/asset/query-sub-member-deposit-record + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getBrokerSubAccountDeposits({ + limit: 50, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/bind-or-unbind-uid.js b/examples/apidoc/V5/Institutional-Loan/bind-or-unbind-uid.js new file mode 100644 index 0000000..2ebd1ac --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/bind-or-unbind-uid.js @@ -0,0 +1,21 @@ +// https://api.bybit.com/v5/ins-loan/association-uid + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .bindOrUnbindUID({ + uid: 'yourUID', + operate: '0', // 0 for bind, 1 for unbind + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/get-LTV.js b/examples/apidoc/V5/Institutional-Loan/get-LTV.js new file mode 100644 index 0000000..cdd54a9 --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/get-LTV.js @@ -0,0 +1,18 @@ +// https://api.bybit.com/v5/ins-loan/ltv-convert + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getInstitutionalLendingLTVWithLadderConversionRate() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/get-loan-orders.js b/examples/apidoc/V5/Institutional-Loan/get-loan-orders.js new file mode 100644 index 0000000..da81dd4 --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/get-loan-orders.js @@ -0,0 +1,20 @@ +// https://api.bybit.com/v5/ins-loan/loan-order + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getInstitutionalLendingLoanOrders({ + limit: 10, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/get-margin-coin-info.js b/examples/apidoc/V5/Institutional-Loan/get-margin-coin-info.js new file mode 100644 index 0000000..da8f636 --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/get-margin-coin-info.js @@ -0,0 +1,20 @@ +// https://api.bybit.com/v5/ins-loan/ensure-tokens-convert + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getInstitutionalLendingMarginCoinInfoWithConversionRate({ + productId: '81', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/get-product-info.js b/examples/apidoc/V5/Institutional-Loan/get-product-info.js new file mode 100644 index 0000000..154934f --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/get-product-info.js @@ -0,0 +1,20 @@ +// https://api.bybit.com/v5/ins-loan/product-infos + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getInstitutionalLendingProductInfo({ + productId: '91', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Institutional-Loan/get-repayment-orders.js b/examples/apidoc/V5/Institutional-Loan/get-repayment-orders.js new file mode 100644 index 0000000..c63b8ab --- /dev/null +++ b/examples/apidoc/V5/Institutional-Loan/get-repayment-orders.js @@ -0,0 +1,20 @@ +// https://api.bybit.com/v5/ins-loan/repaid-history + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getInstitutionalLendingRepayOrders({ + limit: 100, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-Bybit-server-time.js b/examples/apidoc/V5/Market/get-Bybit-server-time.js new file mode 100644 index 0000000..2b1139d --- /dev/null +++ b/examples/apidoc/V5/Market/get-Bybit-server-time.js @@ -0,0 +1,14 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getServerTime() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Market/get-long-short-ratio.js b/examples/apidoc/V5/Market/get-long-short-ratio.js new file mode 100644 index 0000000..0e96a5f --- /dev/null +++ b/examples/apidoc/V5/Market/get-long-short-ratio.js @@ -0,0 +1,19 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, +}); + +client + .getLongShortRatio({ + category: 'linear', + symbol: 'BTCUSDT', + period: '1h', + limit: 100, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-status-and-leverage.js b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-status-and-leverage.js new file mode 100644 index 0000000..457da1e --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-status-and-leverage.js @@ -0,0 +1,18 @@ +// https://api.bybit.com/v5/spot-margin-trade/state + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSpotMarginState() + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-vip-margin-data.js b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-vip-margin-data.js new file mode 100644 index 0000000..94d467c --- /dev/null +++ b/examples/apidoc/V5/Spot-Margin-Trade-(UTA)/get-vip-margin-data.js @@ -0,0 +1,21 @@ +// https://api.bybit.com/v5/spot-margin-trade/data + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getVIPMarginData({ + vipLevel: 'No VIP', + currency: 'BTC', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Trade/confirm-new-risk-limit.js b/examples/apidoc/V5/Trade/confirm-new-risk-limit.js new file mode 100644 index 0000000..8cca9d3 --- /dev/null +++ b/examples/apidoc/V5/Trade/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/Trade/get-move-position-history.js b/examples/apidoc/V5/Trade/get-move-position-history.js new file mode 100644 index 0000000..a346dbc --- /dev/null +++ b/examples/apidoc/V5/Trade/get-move-position-history.js @@ -0,0 +1,23 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getMovePositionHistory({ + category: 'linear', + symbol: 'BTCUSDT', + startTime: 1670601600000, + endTime: 1671206400000, + status: 'Filled', + limit: '50', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/Trade/move-position.js b/examples/apidoc/V5/Trade/move-position.js new file mode 100644 index 0000000..98eb8b6 --- /dev/null +++ b/examples/apidoc/V5/Trade/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: 'UTA12345', + toUid: 'UTA67890', + list: [ + { + category: 'linear', + symbol: 'BTCUSDT', + price: '50000', + side: 'Sell', + qty: '1', + }, + ], + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/User/delete-sub-uid.js b/examples/apidoc/V5/User/delete-sub-uid.js new file mode 100644 index 0000000..1dcb574 --- /dev/null +++ b/examples/apidoc/V5/User/delete-sub-uid.js @@ -0,0 +1,20 @@ +// https://api.bybit.com/v5/user/del-submember + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .deleteSubMember({ + subMemberId: 'subUID', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/User/get-sub-all-api-keys.js b/examples/apidoc/V5/User/get-sub-all-api-keys.js new file mode 100644 index 0000000..f029e70 --- /dev/null +++ b/examples/apidoc/V5/User/get-sub-all-api-keys.js @@ -0,0 +1,21 @@ +// https://api.bybit.com/v5/user/sub-apikeys + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getSubAccountAllApiKeys({ + subMemberId: 'subUID', + limit: 20, + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/examples/apidoc/V5/User/get-uid-wallet-type.js b/examples/apidoc/V5/User/get-uid-wallet-type.js new file mode 100644 index 0000000..42713d0 --- /dev/null +++ b/examples/apidoc/V5/User/get-uid-wallet-type.js @@ -0,0 +1,20 @@ +// https://api.bybit.com/v5/user/get-member-type + +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +client + .getUIDWalletType({ + memberIds: 'subUID1,subUID2', + }) + .then((response) => { + console.log(response); + }) + .catch((error) => { + console.error(error); + }); diff --git a/package-lock.json b/package-lock.json index d4b5697..92e6a3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "3.10.6", + "version": "3.10.8", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "3.10.6", + "version": "3.10.8", "license": "MIT", "dependencies": { "axios": "^1.6.6", diff --git a/package.json b/package.json index 79f3623..ad9d3b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "3.10.6", + "version": "3.10.8", "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 4e9f37f..90205f9 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -9,6 +9,7 @@ import { AccountTypeV5, AddOrReduceMarginParamsV5, AddOrReduceMarginResultV5, + AffiliateUserInfoV5, AllCoinsBalanceV5, AllowedDepositCoinInfoV5, AmendOrderParamsV5, @@ -33,12 +34,14 @@ import { CoinGreeksV5, CoinInfoV5, CollateralInfoV5, + ConfirmNewRiskLimitParamsV5, CreateSubApiKeyParamsV5, CreateSubApiKeyResultV5, CreateSubMemberParamsV5, CreateSubMemberResultV5, CursorListV5, CursorRowsV5, + DCPInfoV5, DeleteSubMemberParamsV5, DeliveryPriceV5, DeliveryRecordV5, @@ -54,6 +57,7 @@ import { GetAllowedDepositCoinInfoParamsV5, GetAssetInfoParamsV5, GetBorrowHistoryParamsV5, + GetClassicTransactionLogsParamsV5, GetClosedPnLParamsV5, GetCoinExchangeRecordParamsV5, GetDeliveryPriceParamsV5, @@ -71,6 +75,7 @@ import { GetKlineParamsV5, GetLongShortRatioParamsV5, GetMarkPriceKlineParamsV5, + GetMovePositionHistoryParamsV5, GetOpenInterestParamsV5, GetOptionDeliveryPriceParamsV5, GetOrderbookParamsV5, @@ -87,6 +92,7 @@ import { GetTickersParamsV5, GetTransactionLogParamsV5, GetUniversalTransferRecordsParamsV5, + GetVIPMarginDataParamsV5, GetWalletBalanceParamsV5, GetWithdrawalRecordsParamsV5, HistoricalVolatilityV5, @@ -99,6 +105,9 @@ import { LongShortRatioV5, MMPModifyParamsV5, MMPStateV5, + MovePositionHistoryV5, + MovePositionParamsV5, + MovePositionResultV5, OHLCKlineV5, OHLCVKlineV5, OpenInterestResponseV5, @@ -127,6 +136,7 @@ import { SettlementRecordV5, SpotBorrowCheckResultV5, SpotLeveragedTokenOrderHistoryV5, + SpotMarginStateV5, SubAccountAllApiKeysResultV5, SubMemberV5, SwitchIsolatedMarginParamsV5, @@ -141,9 +151,16 @@ import { UniversalTransferRecordV5, UpdateApiKeyParamsV5, UpdateApiKeyResultV5, + VIPMarginDataV5, + VaspEntityV5, WalletBalanceV5, WithdrawParamsV5, WithdrawalRecordV5, + GetBrokerSubAccountDepositsV5, + GetExchangeBrokerEarningsParamsV5, + ExchangeBrokerAccountInfoV5, + ExchangeBrokerEarningResultV5, + ExchangeBrokerSubAccountDepositRecordV5, } from './types'; import { REST_CLIENT_TYPE_ENUM } from './util'; @@ -700,6 +717,55 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/position/closed-pnl', params); } + /** + * Move positions between sub-master, master-sub, or sub-sub UIDs. + * + * Unified account covers: USDT perpetual / USDC contract / Spot / Option + * + * INFO + * The endpoint can only be called by master UID api key + * UIDs must be the same master-sub account relationship + * The trades generated from move-position endpoint will not be displayed in the Recent Trade (Rest API & Websocket) + * There is no trading fee + * fromUid and toUid both should be Unified trading accounts, and they need to be one-way mode when moving the positions + * Please note that once executed, you will get execType=MovePosition entry from Get Trade History, Get Closed Pnl, and stream from Execution. + */ + movePosition( + params: MovePositionParamsV5, + ): Promise> { + return this.postPrivate('/v5/position/move-positions', params); + } + + /** + * Query moved position data by master UID api key. + * + * Unified account covers: USDT perpetual / USDC contract / Spot / Option + */ + getMovePositionHistory(params: GetMovePositionHistoryParamsV5): Promise< + APIResponseV3WithTime<{ + list: MovePositionHistoryV5[]; + nextPageCursor: string; + }> + > { + return this.getPrivate('/v5/position/move-history', params); + } + + /** + * Confirm new risk limit. + * + * It is only applicable when the user is marked as only reducing positions (please see the isReduceOnly field in the Get Position Info interface). + * After the user actively adjusts the risk level, this interface is called to try to calculate the adjusted risk level, and if it passes (retCode=0), + * the system will remove the position reduceOnly mark. You are recommended to call Get Position Info to check isReduceOnly field. + * + * Unified account covers: USDT perpetual / USDC contract / Inverse contract + * Classic account covers: USDT perpetual / Inverse contract + */ + confirmNewRiskLimit( + params: ConfirmNewRiskLimitParamsV5, + ): Promise> { + return this.postPrivate('/v5/position/confirm-pending-mmr', params); + } + /** * ****** Pre-upgrade APIs @@ -862,6 +928,30 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/account/transaction-log', params); } + /** + * Query transaction logs in the derivatives wallet (classic account), and inverse derivatives wallet (upgraded to UTA). + * + * API key permission: "Contract - Position" + */ + getClassicTransactionLogs( + params?: GetClassicTransactionLogsParamsV5, + ): Promise< + APIResponseV3WithTime<{ list: TransactionLogV5[]; nextPageCursor: string }> + > { + return this.getPrivate('/v5/account/contract-transaction-log', params); + } + + /** + * Query the SMP group ID of self match prevention. + */ + getSMPGroup(): Promise< + APIResponseV3WithTime<{ + smpGroup: number; + }> + > { + return this.getPrivate('/v5/account/smp-group'); + } + /** * Default is regular margin mode. * @@ -877,6 +967,19 @@ export class RestClientV5 extends BaseRestClient { }); } + /** + * Turn on/off Spot hedging feature in Portfolio margin for Unified account. + * + * INFO + * Only unified account is applicable + * Only portfolio margin mode is applicable + */ + setSpotHedging(params: { + setHedgingMode: 'ON' | 'OFF'; + }): Promise> { + return this.postPrivate('/v5/account/set-hedging-mode', params); + } + /** * Configure Market Maker Protection (MMP) */ @@ -900,6 +1003,19 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/account/mmp-state', { baseCoin }); } + /** + * Query the DCP configuration of the account's contracts (USDT perpetual, USDC perpetual and USDC Futures) / spot / options. + * + * Only the configured main / sub account can query information from this API. Calling this API by an account always returns empty. + * + * INFO + * support linear contract (USDT, USDC Perp & USDC Futures) / Spot / Options only + * Unified account only + */ + getDCPInfo(): Promise> { + return this.getPrivate('/v5/account/query-dcp-info'); + } + /** * ****** Asset APIs @@ -1234,6 +1350,17 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/asset/withdraw/withdrawable-amount', params); } + /** + * Get Exchange Entity List. + * + * This endpoint is particularly used for kyc=KOR users. When withdraw funds, you need to fill entity id. + */ + getExchangeEntities(): Promise< + APIResponseV3WithTime<{ vasp: VaspEntityV5[] }> + > { + return this.getPrivate('/v5/asset/withdraw/vasp/list'); + } + /** * Withdraw assets from the SPOT account. * @@ -1302,9 +1429,7 @@ export class RestClientV5 extends BaseRestClient { */ getSubAccountAllApiKeys( params: GetSubAccountAllApiKeysParamsV5, - ): Promise< - APIResponseV3WithTime - > { + ): Promise> { return this.getPrivate('/v5/user/sub-apikeys', params); } @@ -1331,6 +1456,17 @@ export class RestClientV5 extends BaseRestClient { return this.getPrivate('/v5/user/query-api'); } + getUIDWalletType(params: { memberIds: string }): Promise< + APIResponseV3WithTime<{ + accounts: { + uid: string; + accountType: string[]; + }[]; + }> + > { + return this.getPrivate('/v5/user/query-api', params); + } + /** * Modify the settings of a master API key. Use the API key pending to be modified to call the endpoint. Use master user's API key only. * @@ -1380,11 +1516,10 @@ export class RestClientV5 extends BaseRestClient { * * DANGER: BE CAREFUL! The sub API key used to call this interface will be invalid immediately. */ - deleteSubApiKey(params?: { apikey?: string; }): Promise> { - return this.postPrivate( - '/v5/user/delete-sub-api', - params, - ); + deleteSubApiKey(params?: { + apikey?: string; + }): Promise> { + return this.postPrivate('/v5/user/delete-sub-api', params); } /** @@ -1400,6 +1535,22 @@ export class RestClientV5 extends BaseRestClient { return this.postPrivate('/v5/user/del-submember', params); } + /** + * Get Affiliate User Info. + * + * This API is used for affiliate to get their users information. + * + * TIP + * Use master UID only + * The api key can only have "Affiliate" permission + * The transaction volume and deposit amount are the total amount of the user done on Bybit, and have nothing to do with commission settlement. Any transaction volume data related to commission settlement is subject to the Affiliate Portal. + */ + getAffiliateUserInfo(params: { + uid: string; + }): Promise> { + return this.getPrivate('/v5/user/aff-customer-info', params); + } + /** * ****** Spot Leverage Token APIs @@ -1459,6 +1610,20 @@ export class RestClientV5 extends BaseRestClient { * */ + /** + * Get VIP Margin Data. + * + * This margin data is for Unified account in particular. + * + * INFO + * Do not need authentication + */ + getVIPMarginData( + params?: GetVIPMarginDataParamsV5, + ): Promise> { + return this.get('/v5/spot-margin-trade/data', params); + } + /** * Turn spot margin trade on / off in your UTA account. * @@ -1481,6 +1646,15 @@ export class RestClientV5 extends BaseRestClient { return this.postPrivate('/v5/spot-margin-trade/set-leverage', { leverage }); } + /** + * Query the Spot margin status and leverage of Unified account. + * + * Covers: Margin trade (Unified Account) + */ + getSpotMarginState(): Promise> { + return this.getPrivate('/v5/spot-margin-trade/state'); + } + /** * ****** Spot Margin Trade APIs (Normal) @@ -1729,4 +1903,78 @@ export class RestClientV5 extends BaseRestClient { > { return this.getPrivate('/v5/ins-loan/ltv-convert'); } + + /** + * Bind or unbind UID for the institutional loan product. + * + * INFO + * Risk unit designated UID cannot be unbound + * This endpoint can only be called by uids in the risk unit list + * The UID must be upgraded to UTA Pro if you try to bind it. + * When the API is operated through the API Key of any UID in the risk unit, the UID is bound or unbound in the risk unit. + */ + bindOrUnbindUID(params: { uid: string; operate: '0' | '1' }): Promise< + APIResponseV3WithTime<{ + uid: string; + operate: '0' | '1'; + }> + > { + return this.postPrivate('/v5/ins-loan/association-uid', params); + } + + /** + * + ****** Broker + * + */ + + /** + * Get Exchange Broker Earning. + * + * INFO + * Use exchange broker master account to query + * The data can support up to past 1 months until T-1. To extract data from over a month ago, please contact your Relationship Manager + * begin & end are either entered at the same time or not entered, and latest 7 days data are returned by default + * API rate limit: 10 req / sec + */ + getExchangeBrokerEarnings( + params?: GetExchangeBrokerEarningsParamsV5, + ): Promise> { + return this.getPrivate('/v5/broker/earnings-info', params); + } + + /** + * Get Exchange Broker Account Info. + * + * INFO + * Use exchange broker master account to query + * API rate limit: 10 req / sec + */ + getExchangeBrokerAccountInfo(): Promise< + APIResponseV3WithTime + > { + return this.getPrivate('/v5/broker/account-info'); + } + + /** + * Get Sub Account Deposit Records. + * + * Exchange broker can query subaccount's deposit records by main UID's API key without specifying uid. + * + * API rate limit: 300 req / min + * + * TIP + * endTime - startTime should be less than 30 days. Queries for the last 30 days worth of records by default. + */ + getBrokerSubAccountDeposits(params?: GetBrokerSubAccountDepositsV5): Promise< + APIResponseV3WithTime<{ + rows: ExchangeBrokerSubAccountDepositRecordV5[]; + nextPageCursor: string; + }> + > { + return this.getPrivate( + '/v5/broker/asset/query-sub-member-deposit-record', + params, + ); + } } diff --git a/src/types/request/index.ts b/src/types/request/index.ts index be15ddc..4c8cfdc 100644 --- a/src/types/request/index.ts +++ b/src/types/request/index.ts @@ -16,3 +16,4 @@ export * from './v5-pre-upgrade'; export * from './v5-trade'; export * from './v5-user'; export * from './v5-spot-leverage-token'; +export * from './v5-broker'; diff --git a/src/types/request/v5-account.ts b/src/types/request/v5-account.ts index 38f3159..bb39048 100644 --- a/src/types/request/v5-account.ts +++ b/src/types/request/v5-account.ts @@ -47,3 +47,13 @@ export interface SetCollateralCoinParamsV5 { coin: string; collateralSwitch: 'ON' | 'OFF'; } + +export interface GetClassicTransactionLogsParamsV5 { + currency?: string; + baseCoin?: string; + type?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; +} diff --git a/src/types/request/v5-broker.ts b/src/types/request/v5-broker.ts new file mode 100644 index 0000000..adcd2b8 --- /dev/null +++ b/src/types/request/v5-broker.ts @@ -0,0 +1,17 @@ +export interface GetExchangeBrokerEarningsParamsV5 { + bizType?: 'SPOT' | 'DERIVATIVES' | 'OPTIONS'; + begin?: string; + end?: string; + uid?: string; + limit?: number; + cursor?: string; +} + +export interface GetBrokerSubAccountDepositsV5 { + subMemberId?: string; + coin?: string; + startTime?: number; + endTime?: number; + limit?: number; + cursor?: string; +} diff --git a/src/types/request/v5-position.ts b/src/types/request/v5-position.ts index 160ee34..6f1dac0 100644 --- a/src/types/request/v5-position.ts +++ b/src/types/request/v5-position.ts @@ -105,3 +105,31 @@ export interface GetClosedPnLParamsV5 { limit?: number; cursor?: string; } + +export interface MovePositionParamsV5 { + fromUid: string; + toUid: string; + list: { + category: 'linear' | 'spot' | 'option'; + symbol: string; + price: string; + side: 'Buy' | 'Sell'; + qty: string; + }[]; +} + +export interface GetMovePositionHistoryParamsV5 { + category?: 'linear' | 'spot' | 'option'; + symbol?: string; + startTime?: number; + endTime?: number; + status?: 'Processing' | 'Filled' | 'Rejected'; + blockTradeId?: string; + limit?: string; + cursor?: string; +} + +export interface ConfirmNewRiskLimitParamsV5 { + category: 'linear' | 'inverse'; + symbol: string; +} diff --git a/src/types/request/v5-spot-leverage-token.ts b/src/types/request/v5-spot-leverage-token.ts index b60e306..6691dc0 100644 --- a/src/types/request/v5-spot-leverage-token.ts +++ b/src/types/request/v5-spot-leverage-token.ts @@ -21,3 +21,8 @@ export interface GetSpotLeveragedTokenOrderHistoryParamsV5 { ltOrderType?: LTOrderTypeV5; serialNo?: string; } + +export interface GetVIPMarginDataParamsV5 { + vipLevel?: string; + currency?: string; +} diff --git a/src/types/response/index.ts b/src/types/response/index.ts index 47736f8..30233d0 100644 --- a/src/types/response/index.ts +++ b/src/types/response/index.ts @@ -11,3 +11,4 @@ export * from './v5-position'; export * from './v5-trade'; export * from './v5-user'; export * from './v5-spot-leverage-token'; +export * from './v5-broker'; diff --git a/src/types/response/v5-account.ts b/src/types/response/v5-account.ts index 8650413..bd155f2 100644 --- a/src/types/response/v5-account.ts +++ b/src/types/response/v5-account.ts @@ -125,3 +125,11 @@ export interface RepayLiabilityResultV5 { coin: string; repaymentQty: string; } + +export interface DCPInfoV5 { + product: 'SPOT' | 'DERIVATIVES' | 'OPTIONS'; + dcpStatus: 'ON'; + timeWindow: string; +} + + diff --git a/src/types/response/v5-asset.ts b/src/types/response/v5-asset.ts index 04a7b71..fe578b4 100644 --- a/src/types/response/v5-asset.ts +++ b/src/types/response/v5-asset.ts @@ -168,3 +168,9 @@ export interface WithdrawalRecordV5 { createTime: string; updateTime: string; } + + +export interface VaspEntityV5 { + vaspEntityId: string; + vaspName: string; +} \ No newline at end of file diff --git a/src/types/response/v5-broker.ts b/src/types/response/v5-broker.ts new file mode 100644 index 0000000..176895c --- /dev/null +++ b/src/types/response/v5-broker.ts @@ -0,0 +1,59 @@ +interface EarningDetailV5 { + userId: string; + bizType: 'SPOT' | 'DERIVATIVES' | 'OPTIONS'; + symbol: string; + coin: string; + earning: string; + markupEarning: string; + baseFeeEarning: string; + orderId: string; + execTime: string; +} + +interface TotalEarningCategoryV5 { + coin: string; + earning: string; +} + +export interface ExchangeBrokerEarningResultV5 { + totalEarningCat: { + spot: TotalEarningCategoryV5[]; + derivatives: TotalEarningCategoryV5[]; + options: TotalEarningCategoryV5[]; + total: TotalEarningCategoryV5[]; + }; + details: EarningDetailV5[]; + nextPageCursor: string; +} + +export interface ExchangeBrokerAccountInfoV5 { + subAcctQty: string; + maxSubAcctQty: string; + baseFeeRebateRate: { + spot: string; + derivatives: string; + }; + markupFeeRebateRate: { + spot: string; + derivatives: string; + }; + ts: string; +} + +export interface ExchangeBrokerSubAccountDepositRecordV5 { + subMemberId: string; + coin: string; + chain: string; + amount: string; + txID: string; + status: number; + toAddress: string; + tag: string; + depositFee: string; + successAt: string; + confirmations: string; + txIndex: string; + blockHash: string; + batchReleaseLimit: string; + depositType: string; +} diff --git a/src/types/response/v5-position.ts b/src/types/response/v5-position.ts index 6c66be1..7293bcc 100644 --- a/src/types/response/v5-position.ts +++ b/src/types/response/v5-position.ts @@ -129,3 +129,28 @@ export interface ClosedPnLV5 { createdTime: string; updatedTime: string; } + +export interface MovePositionResultV5 { + blockTradeId: string; + status: 'Processing' | 'Rejected'; + rejectParty: '' | 'Taker' | 'Maker' | 'bybit'; +} + +export interface MovePositionHistoryV5 { + blockTradeId: string; + category: 'linear' | 'spot' | 'option'; + orderId: string; + userId: number; + symbol: string; + side: 'Buy' | 'Sell'; + price: string; + qty: string; + execFee: string; + status: 'Processing' | 'Filled' | 'Rejected'; + execId: string; + resultCode: number; + resultMessage: string; + createdAt: number; + updatedAt: number; + rejectParty: '' | 'Taker' | 'Maker' | 'bybit'; +} diff --git a/src/types/response/v5-spot-leverage-token.ts b/src/types/response/v5-spot-leverage-token.ts index 7bda8cc..2c1dd94 100644 --- a/src/types/response/v5-spot-leverage-token.ts +++ b/src/types/response/v5-spot-leverage-token.ts @@ -68,3 +68,24 @@ export interface SpotLeveragedTokenOrderHistoryV5 { valueCoin: string; serialNo: string; } + +export interface VIPMarginDataV5 { + vipCoinList: { + list: { + borrowable: boolean; + collateralRatio: string; + currency: string; + hourlyBorrowRate: string; + liquidationOrder: string; + marginCollateral: boolean; + maxBorrowingAmount: string; + }[]; + vipLevel: string; + }[]; +} + +export interface SpotMarginStateV5 { + spotLeverage: string; + spotMarginMode: '1' | '0'; + effectiveLeverage: string; +} diff --git a/src/types/response/v5-user.ts b/src/types/response/v5-user.ts index e9f8dae..3bdc5b1 100644 --- a/src/types/response/v5-user.ts +++ b/src/types/response/v5-user.ts @@ -76,3 +76,21 @@ export interface SubAccountAllApiKeysResultV5 { }[], nextPageCursor: string; } + + +export interface AffiliateUserInfoV5 { + uid: string; + vipLevel: string; + takerVol30Day: string; + makerVol30Day: string; + tradeVol30Day: string; + depositAmount30Day: string; + takerVol365Day: string; + makerVol365Day: string; + tradeVol365Day: string; + depositAmount365Day: string; + totalWalletBalance: '1' | '2' | '3' | '4'; + depositUpdateTime: string; + volUpdateTime: string; + KycLevel: 0 | 1 | 2; +} \ No newline at end of file