From 20d60da75a6770a1e31cab684f8859d15d4b39b5 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Wed, 31 Aug 2022 18:00:09 +0100 Subject: [PATCH 1/4] update readme --- README.md | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index c451745..98bb8f3 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,15 @@ [![last commit](https://img.shields.io/github/last-commit/tiagosiebler/bybit-api)][1] [![CodeFactor](https://www.codefactor.io/repository/github/tiagosiebler/bybit-api/badge)](https://www.codefactor.io/repository/github/tiagosiebler/bybit-api) +[![connector logo](https://cdn.builder.io/api/v1/image/assets%2Ffddee401a9284ab792b271538c28932d%2F5190c99403ac474699a1959fdee1ab6c?format=webp&width=2000)][1] + [1]: https://www.npmjs.com/package/bybit-api -Node.js connector for the Bybit APIs and WebSockets, with TypeScript & browser support. +Node.js connector for the Bybit APIs and WebSockets: +- TypeScript support (with type declarations for most API requests & responses). +- Integration tests with real API calls validating any changes before they reach npm. +- Robust WebSocket integration with connection heartbeats & automatic reconnection. +- Browser support (via webpack bundle - see "Browser Usage" below). ## Installation `npm install --save bybit-api` @@ -32,6 +38,17 @@ Most methods accept JS objects. These can be populated using parameters specifie - [Bybit API Inverse Futures Documentation](https://bybit-exchange.github.io/docs/inverse_futures/#t-introduction). - [Bybit API Linear Documentation](https://bybit-exchange.github.io/docs/linear/#t-introduction) +## REST Clients +Each REST API category has a dedicated REST client. Here are the REST clients and their API group: +| Class | Description | +|:-----------------------------------------------------: |:------------------------------: | +| [InverseClient](src/inverse-client.ts) | Inverse Perpetual Futures (v2) | +| [LinearClient](src/linear-client.ts) | USDT Perpetual Futures (v2) | +| [InverseFuturesClient](src/inverse-futures-client.ts) | Inverse Futures (v2) | +| [SpotClient](src/spot-client.ts) | Spot Markets | +| USDC Options & Perpetual Contracts | Under Development | +| Derivatives V3 unified margin | Under Development | + ## Structure This project uses typescript. Resources are stored in 3 key structures: - [src](./src) - the whole connector written in typescript From b961b5ab274f3eb2e811aa0bc1f20d5e2de01fa2 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Wed, 31 Aug 2022 18:03:46 +0100 Subject: [PATCH 2/4] readme updates --- README.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 98bb8f3..352e6b5 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ Check out my related projects: - [ftx-api](https://www.npmjs.com/package/ftx-api) - [bybit-api](https://www.npmjs.com/package/bybit-api) - [binance](https://www.npmjs.com/package/binance) + - [okx-api](https://www.npmjs.com/package/okx-api) - Try my misc utilities: - [orderbooks](https://www.npmjs.com/package/orderbooks) - Check out my examples: @@ -50,9 +51,10 @@ Each REST API category has a dedicated REST client. Here are the REST clients an | Derivatives V3 unified margin | Under Development | ## Structure -This project uses typescript. Resources are stored in 3 key structures: -- [src](./src) - the whole connector written in typescript -- [lib](./lib) - the javascript version of the project (compiled from typescript). This should not be edited directly, as it will be overwritten with each release. +The connector is written in TypeScript. A pure JavaScript version can be built using `npm run build`, which is also the version published to [npm](https://www.npmjs.com/package/bybit-api). This connector is fully compatible with both TypeScript and pure JavaScript projects. + +- [src](./src) - the whole connector written in TypeScript +- [lib](./lib) - the JavaScript version of the project (built from TypeScript). This should not be edited directly, as it will be overwritten with each release. - [dist](./dist) - the packed bundle of the project for use in browser environments. - [examples](./examples) - some implementation examples & demonstrations. Contributions are welcome! From a7f2075530afeb188bbf0683befd9f665c446c31 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Wed, 31 Aug 2022 18:07:20 +0100 Subject: [PATCH 3/4] fix test --- test/inverse-futures/private.write.test.ts | 6 +++--- test/inverse/private.write.test.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/inverse-futures/private.write.test.ts b/test/inverse-futures/private.write.test.ts index 257fe36..e57ab37 100644 --- a/test/inverse-futures/private.write.test.ts +++ b/test/inverse-futures/private.write.test.ts @@ -94,7 +94,7 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => { }) ).toMatchObject({ ret_code: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE, - ret_msg: 'order not exists or too late to cancel', + ret_msg: 'Order not exists', }); }); @@ -138,8 +138,8 @@ describe('Private Inverse-Futures REST API POST Endpoints', () => { take_profit: 50000, }) ).toMatchObject({ - ret_code: API_ERROR_CODE.POSITION_STATUS_NOT_NORMAL, - ret_msg: 'position status is not normal', + ret_code: API_ERROR_CODE.POSITION_IDX_NOT_MATCH_POSITION_MODE, + ret_msg: 'position idx not match position mode', }); }); diff --git a/test/inverse/private.write.test.ts b/test/inverse/private.write.test.ts index 4fa1eb0..4a15ed0 100644 --- a/test/inverse/private.write.test.ts +++ b/test/inverse/private.write.test.ts @@ -93,7 +93,7 @@ describe('Private Inverse REST API Endpoints', () => { }) ).toMatchObject({ ret_code: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE, - ret_msg: 'order not exists or too late to cancel', + ret_msg: 'order not exists', }); }); @@ -126,7 +126,7 @@ describe('Private Inverse REST API Endpoints', () => { }) ).toMatchObject({ ret_code: API_ERROR_CODE.POSITION_IS_CROSS_MARGIN, - ret_msg: 'position is in crossMargin', + ret_msg: expect.any(String), }); }); From f022af7b76c2f7df8be97a79b9d1211ff32634c0 Mon Sep 17 00:00:00 2001 From: tiagosiebler Date: Wed, 31 Aug 2022 18:09:22 +0100 Subject: [PATCH 4/4] fix test --- test/inverse/private.write.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/inverse/private.write.test.ts b/test/inverse/private.write.test.ts index 4a15ed0..1271612 100644 --- a/test/inverse/private.write.test.ts +++ b/test/inverse/private.write.test.ts @@ -93,7 +93,7 @@ describe('Private Inverse REST API Endpoints', () => { }) ).toMatchObject({ ret_code: API_ERROR_CODE.ORDER_NOT_FOUND_OR_TOO_LATE, - ret_msg: 'order not exists', + ret_msg: expect.any(String), }); });