Skip to content

Commit

Permalink
Merge pull request #357 from JJ-Cro/testfix
Browse files Browse the repository at this point in the history
v3.10.11: fix() deprecated endpoints (copy trading & unified margin client)
  • Loading branch information
tiagosiebler authored Jun 28, 2024
2 parents 24f9919 + 576cf6b commit 17be240
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 44 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,5 @@ lib
bundleReport.html
.history/
rawReq.ts
localtest.sh

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bybit-api",
"version": "3.10.10",
"version": "3.10.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",
Expand Down Expand Up @@ -80,4 +80,4 @@
"url": "https://github.com/tiagosiebler/bybit-api/issues"
},
"homepage": "https://github.com/tiagosiebler/bybit-api#readme"
}
}
4 changes: 0 additions & 4 deletions src/copy-trading-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,4 @@ export class CopyTradingClient extends BaseRestClient {
getServerTime(): Promise<APIResponseWithTime> {
return this.get('/v2/public/time');
}

getAnnouncements(): Promise<APIResponseWithTime<any[]>> {
return this.get('/v2/public/announcement');
}
}
56 changes: 26 additions & 30 deletions src/unified-margin-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class UnifiedMarginClient extends BaseRestClient {
getOrderBook(
symbol: string,
category: string,
limit?: number
limit?: number,
): Promise<APIResponseV3<any>> {
return this.get('/derivatives/v3/public/order-book/L2', {
category,
Expand All @@ -74,14 +74,14 @@ export class UnifiedMarginClient extends BaseRestClient {
/** Get a symbol price/statistics ticker */
getSymbolTicker(
category: UMCategory,
symbol?: string
symbol?: string,
): Promise<APIResponseV3<any>> {
return this.get('/derivatives/v3/public/tickers', { category, symbol });
}

/** Get trading rules per symbol/contract, incl price/amount/value/leverage filters */
getInstrumentInfo(
params: UMInstrumentInfoRequest
params: UMInstrumentInfoRequest,
): Promise<APIResponseV3<UMPaginatedResult<UMInstrumentInfo>>> {
return this.get('/derivatives/v3/public/instruments-info', params);
}
Expand All @@ -101,18 +101,18 @@ export class UnifiedMarginClient extends BaseRestClient {
* For example, if a request is sent at 12:00 UTC, the funding rate generated earlier that day at 08:00 UTC will be sent.
*/
getFundingRateHistory(
params: UMFundingRateHistoryRequest
params: UMFundingRateHistoryRequest,
): Promise<APIResponseV3<any>> {
return this.get(
'/derivatives/v3/public/funding/history-funding-rate',
params
params,
);
}

/** Get Risk Limit */
getRiskLimit(
category: UMCategory,
symbol: string
symbol: string,
): Promise<APIResponseV3<any>> {
return this.get('/derivatives/v3/public/risk-limit/list', {
category,
Expand All @@ -122,7 +122,7 @@ export class UnifiedMarginClient extends BaseRestClient {

/** Get option delivery price */
getOptionDeliveryPrice(
params: UMOptionDeliveryPriceRequest
params: UMOptionDeliveryPriceRequest,
): Promise<APIResponseV3<any>> {
return this.get('/derivatives/v3/public/delivery-price', params);
}
Expand Down Expand Up @@ -170,7 +170,7 @@ export class UnifiedMarginClient extends BaseRestClient {

/** Query order history. As order creation/cancellation is asynchronous, the data returned from the interface may be delayed. To access order information in real-time, call getActiveOrders() */
getHistoricOrders(
params: UMHistoricOrdersRequest
params: UMHistoricOrdersRequest,
): Promise<APIResponseV3<UMPaginatedResult<UMHistoricOrder>>> {
return this.getPrivate('/unified/v3/private/order/list', params);
}
Expand All @@ -181,7 +181,7 @@ export class UnifiedMarginClient extends BaseRestClient {
*/
batchSubmitOrders(
category: UMCategory,
orders: UMBatchOrder[]
orders: UMBatchOrder[],
): Promise<APIResponseV3<any>> {
return this.postPrivate('/unified/v3/private/order/create-batch', {
category,
Expand All @@ -197,7 +197,7 @@ export class UnifiedMarginClient extends BaseRestClient {
*/
batchReplaceOrders(
category: UMCategory,
orders: UMBatchOrderReplace[]
orders: UMBatchOrderReplace[],
): Promise<APIResponseV3<any>> {
return this.postPrivate('/unified/v3/private/order/replace-batch', {
category,
Expand All @@ -212,7 +212,7 @@ export class UnifiedMarginClient extends BaseRestClient {
*/
batchCancelOrders(
category: UMCategory,
orders: UMBatchOrderCancel[]
orders: UMBatchOrderCancel[],
): Promise<APIResponseV3<any>> {
return this.postPrivate('/unified/v3/private/order/cancel-batch', {
category,
Expand All @@ -226,7 +226,7 @@ export class UnifiedMarginClient extends BaseRestClient {
* If both futures and options orders are in one request, only the orders matching the category will be operated according to the category type.
*/
cancelAllOrders(
params: UMCancelAllOrdersRequest
params: UMCancelAllOrdersRequest,
): Promise<APIResponseV3<any>> {
return this.postPrivate('/unified/v3/private/order/cancel-all', params);
}
Expand All @@ -246,7 +246,7 @@ export class UnifiedMarginClient extends BaseRestClient {
category: UMCategory,
symbol: string,
buyLeverage: number,
sellLeverage: number
sellLeverage: number,
): Promise<APIResponseV3<any>> {
return this.postPrivate('/unified/v3/private/position/set-leverage', {
category,
Expand All @@ -263,7 +263,7 @@ export class UnifiedMarginClient extends BaseRestClient {
setTPSLMode(
category: UMCategory,
symbol: string,
tpSlMode: 1 | 0
tpSlMode: 1 | 0,
): Promise<APIResponseV3<any>> {
return this.postPrivate('/unified/v3/private/position/tpsl/switch-mode', {
category,
Expand All @@ -277,7 +277,7 @@ export class UnifiedMarginClient extends BaseRestClient {
category: UMCategory,
symbol: string,
riskId: number,
positionIdx: number
positionIdx: number,
): Promise<APIResponseV3<any>> {
return this.postPrivate('/unified/v3/private/position/set-risk-limit', {
category,
Expand All @@ -295,7 +295,7 @@ export class UnifiedMarginClient extends BaseRestClient {
setTPSL(params: UMSetTPSLRequest): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/unified/v3/private/position/trading-stop',
params
params,
);
}

Expand All @@ -304,21 +304,21 @@ export class UnifiedMarginClient extends BaseRestClient {
* There might be multiple filled histories for an order.
*/
get7DayTradingHistory(
params: UM7DayTradingHistoryRequest
params: UM7DayTradingHistoryRequest,
): Promise<APIResponseV3<any>> {
return this.getPrivate('/unified/v3/private/execution/list', params);
}

/** Query the settlement history, ranked by time in descending order. */
getOptionsSettlementHistory(
params: UMOptionsSettlementHistoryRequest
params: UMOptionsSettlementHistoryRequest,
): Promise<APIResponseV3<any>> {
return this.getPrivate('/unified/v3/private/delivery-record', params);
}

/** Query session settlement records, only for USDC perpetual */
getUSDCPerpetualSettlementHistory(
params: UMPerpSettlementHistoryRequest
params: UMPerpSettlementHistoryRequest,
): Promise<APIResponseV3<any>> {
return this.getPrivate('/unified/v3/private/settlement-record', params);
}
Expand All @@ -338,17 +338,17 @@ export class UnifiedMarginClient extends BaseRestClient {
*/
upgradeToUnifiedMargin(): Promise<APIResponseV3<any>> {
return this.postPrivate(
'/unified/v3/private/account/upgrade-unified-account'
'/unified/v3/private/account/upgrade-unified-account',
);
}

/** Query trading history */
getTransactionLog(
params: UMTransactionLogRequest
params: UMTransactionLogRequest,
): Promise<APIResponseV3<any>> {
return this.getPrivate(
'/unified/v3/private/account/transaction-log',
params
params,
);
}

Expand All @@ -359,21 +359,21 @@ export class UnifiedMarginClient extends BaseRestClient {

/** Exchange Coins */
getCoinExchangeHistory(
params?: UMExchangeCoinsRequest
params?: UMExchangeCoinsRequest,
): Promise<APIResponseV3<any>> {
return this.getPrivate(
'/asset/v2/private/exchange/exchange-order-all',
params
params,
);
}

/** Get Borrow History */
getBorrowHistory(
params?: UMBorrowHistoryRequest
params?: UMBorrowHistoryRequest,
): Promise<APIResponseV3<any>> {
return this.getPrivate(
'/unified/v3/private/account/borrow-history',
params
params,
);
}

Expand All @@ -393,8 +393,4 @@ export class UnifiedMarginClient extends BaseRestClient {
getServerTime(): Promise<APIResponseWithTime> {
return this.get('/v2/public/time');
}

getAnnouncements(): Promise<APIResponseV3<any>> {
return this.get('/v2/public/announcement');
}
}
4 changes: 0 additions & 4 deletions test/copy-trading/public.read.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,4 @@ describe('Public Copy Trading REST API Endpoints', () => {
it('getServerTime()', async () => {
expect(await api.getServerTime()).toMatchObject(successResponseObject());
});

it('getAnnouncements()', async () => {
expect(await api.getAnnouncements()).toMatchObject(successResponseObject());
});
});
4 changes: 0 additions & 4 deletions test/unified-margin/public.read.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,4 @@ describe('Public Unified Margin REST API Endpoints', () => {
it('getServerTime()', async () => {
expect(await api.getServerTime()).toMatchObject(successResponseObject());
});

it('getAnnouncements()', async () => {
expect(await api.getAnnouncements()).toMatchObject(successResponseObject());
});
});

0 comments on commit 17be240

Please sign in to comment.