Merge pull request #454 from JJ-Cro/update13062025
feat(v4.1.11): add preCheckOrder method with corresponding types and example usage, add txId and Id to deposit records
This commit is contained in:
24
examples/apidoc/V5/Trade/pre-check-order.js
Normal file
24
examples/apidoc/V5/Trade/pre-check-order.js
Normal file
@@ -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);
|
||||
});
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -176,6 +176,7 @@ import {
|
||||
P2PUserPaymentV5,
|
||||
PositionInfoParamsV5,
|
||||
PositionV5,
|
||||
PreCheckOrderResultV5,
|
||||
PreUpgradeOptionsDelivery,
|
||||
PreUpgradeTransaction,
|
||||
PreUpgradeUSDCSessionSettlement,
|
||||
@@ -809,7 +810,7 @@ export class RestClientV5 extends BaseRestClient {
|
||||
* The structure of the two lists are completely consistent.
|
||||
*/
|
||||
batchSubmitOrders(
|
||||
category: 'option' | 'linear',
|
||||
category: 'spot' | 'option' | 'linear' | 'inverse',
|
||||
orders: BatchOrderParamsV5[],
|
||||
): Promise<
|
||||
APIResponseV3WithTime<
|
||||
@@ -834,7 +835,7 @@ export class RestClientV5 extends BaseRestClient {
|
||||
* A maximum of 20 orders can be amended per request.
|
||||
*/
|
||||
batchAmendOrders(
|
||||
category: 'option' | 'linear',
|
||||
category: 'spot' | 'option' | 'linear' | 'inverse',
|
||||
orders: BatchAmendOrderParamsV5[],
|
||||
): Promise<
|
||||
APIResponseV3WithTime<
|
||||
@@ -859,7 +860,7 @@ export class RestClientV5 extends BaseRestClient {
|
||||
* You can cancel unfilled or partially filled orders. A maximum of 20 orders can be cancelled per request.
|
||||
*/
|
||||
batchCancelOrders(
|
||||
category: 'option' | 'linear',
|
||||
category: 'spot' | 'option' | 'linear' | 'inverse',
|
||||
orders: BatchCancelOrderParamsV5[],
|
||||
): Promise<
|
||||
APIResponseV3WithTime<
|
||||
@@ -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<APIResponseV3WithTime<PreCheckOrderResultV5>> {
|
||||
return this.postPrivate('/v5/order/pre-check', params);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
****** Position APIs
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -8,6 +8,8 @@ export interface GetExchangeBrokerEarningsParamsV5 {
|
||||
}
|
||||
|
||||
export interface GetBrokerSubAccountDepositsV5 {
|
||||
id?: string;
|
||||
txID?: string;
|
||||
subMemberId?: string;
|
||||
coin?: string;
|
||||
startTime?: number;
|
||||
|
||||
@@ -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;
|
||||
}[];
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ export interface ExchangeBrokerAccountInfoV5 {
|
||||
}
|
||||
|
||||
export interface ExchangeBrokerSubAccountDepositRecordV5 {
|
||||
id: string;
|
||||
subMemberId: string;
|
||||
coin: string;
|
||||
chain: string;
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user