diff --git a/examples/apidoc/V5/Trade/pre-check-order.js b/examples/apidoc/V5/Trade/pre-check-order.js new file mode 100644 index 0000000..4bd1147 --- /dev/null +++ b/examples/apidoc/V5/Trade/pre-check-order.js @@ -0,0 +1,24 @@ +const { RestClientV5 } = require('bybit-api'); + +const client = new RestClientV5({ + testnet: true, + key: 'apikey', + secret: 'apisecret', +}); + +// Submit a market order +client + .preCheckOrder({ + category: 'spot', + symbol: 'BTCUSDT', + side: 'Buy', + orderType: 'Limit', + qty: '0.01', + price: '28000', + }) + .then((response) => { + console.log('Market order result', response); + }) + .catch((error) => { + console.error('Market order error', error); + }); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index ded9e86..fe35dc9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "bybit-api", - "version": "4.1.10", + "version": "4.1.11", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "bybit-api", - "version": "4.1.10", + "version": "4.1.11", "license": "MIT", "dependencies": { "axios": "^1.7.9", diff --git a/package.json b/package.json index e31ecf0..e2923e6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bybit-api", - "version": "4.1.10", + "version": "4.1.11", "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 84503e7..7930bf6 100644 --- a/src/rest-client-v5.ts +++ b/src/rest-client-v5.ts @@ -176,6 +176,7 @@ import { P2PUserPaymentV5, PositionInfoParamsV5, PositionV5, + PreCheckOrderResultV5, PreUpgradeOptionsDelivery, PreUpgradeTransaction, PreUpgradeUSDCSessionSettlement, @@ -926,6 +927,20 @@ export class RestClientV5 extends BaseRestClient { return this.postPrivate('/v5/order/disconnected-cancel-all', params); } + /** + * Pre-check order to calculate changes in IMR and MMR before placing an order + * + * This endpoint supports orders with category = inverse, linear, option. + * Only Cross Margin mode and Portfolio Margin mode are supported, isolated margin mode is not supported. + * category = inverse is not supported in Cross Margin mode. + * Conditional order is not supported. + */ + preCheckOrder( + params: OrderParamsV5, + ): Promise> { + return this.postPrivate('/v5/order/pre-check', params); + } + /** * ****** Position APIs diff --git a/src/types/request/v5-asset.ts b/src/types/request/v5-asset.ts index 7a0475c..e561ecd 100644 --- a/src/types/request/v5-asset.ts +++ b/src/types/request/v5-asset.ts @@ -87,6 +87,8 @@ export interface GetAllowedDepositCoinInfoParamsV5 { } export interface GetDepositRecordParamsV5 { + id?: string; + txID?: string; coin?: string; startTime?: number; endTime?: number; @@ -95,6 +97,8 @@ export interface GetDepositRecordParamsV5 { } export interface GetSubAccountDepositRecordParamsV5 { + id?: string; + txID?: string; subMemberId: string; coin?: string; startTime?: number; diff --git a/src/types/request/v5-broker.ts b/src/types/request/v5-broker.ts index b604655..2ad6ead 100644 --- a/src/types/request/v5-broker.ts +++ b/src/types/request/v5-broker.ts @@ -8,6 +8,8 @@ export interface GetExchangeBrokerEarningsParamsV5 { } export interface GetBrokerSubAccountDepositsV5 { + id?: string; + txID?: string; subMemberId?: string; coin?: string; startTime?: number; diff --git a/src/types/response/v5-asset.ts b/src/types/response/v5-asset.ts index e5aa629..3d0dafc 100644 --- a/src/types/response/v5-asset.ts +++ b/src/types/response/v5-asset.ts @@ -103,6 +103,7 @@ export interface AllowedDepositCoinInfoV5 { } export interface DepositRecordV5 { + id: string; coin: string; chain: string; amount: string; @@ -161,6 +162,7 @@ export interface CoinInfoV5 { chainWithdraw: string; withdrawPercentageFee: string; contractAddress: string; + safeConfirmNumber: string; }[]; } diff --git a/src/types/response/v5-broker.ts b/src/types/response/v5-broker.ts index 488ba4c..d0480ca 100644 --- a/src/types/response/v5-broker.ts +++ b/src/types/response/v5-broker.ts @@ -43,6 +43,7 @@ export interface ExchangeBrokerAccountInfoV5 { } export interface ExchangeBrokerSubAccountDepositRecordV5 { + id: string; subMemberId: string; coin: string; chain: string; diff --git a/src/types/response/v5-trade.ts b/src/types/response/v5-trade.ts index 08c4c92..e6b04c0 100644 --- a/src/types/response/v5-trade.ts +++ b/src/types/response/v5-trade.ts @@ -109,3 +109,12 @@ export interface SpotBorrowCheckResultV5 { spotMaxTradeAmount: string; borrowCoin: string; } + +export interface PreCheckOrderResultV5 { + orderId: string; + orderLinkId: string; + preImrE4: number; // Initial margin rate before checking (in basis points) + preMmrE4: number; // Maintenance margin rate before checking (in basis points) + postImrE4: number; // Initial margin rate after checking (in basis points) + postMmrE4: number; // Maintenance margin rate after checking (in basis points) +}