diff --git a/doc/rest-client.md b/doc/rest-client.md index 728280f..974a231 100644 --- a/doc/rest-client.md +++ b/doc/rest-client.md @@ -14,13 +14,19 @@ If you only use the [public endpoints](#public-endpoints) you can ommit key and ### Private enpoints #### async placeActiveOrder(params) -[See bybit documentation](https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md#place-active-order) +[See bybit documentation](https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md#place-active-order-v2) #### async getActiveOrder(params) [See bybit documentation](https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md#get-active-order) #### async cancelActiveOrder(params) -[See bybit documentation](https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md#cancel-active-order) +[See bybit documentation](https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md#open-apiordercancelv2post) + +#### async cancelAllActiveOrders(params) +[See bybit documentation](https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md#open-apiordercancelallpost) + +#### async replaceActiveOrder(params) +[See bybit documentation](https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md#open-apiorderreplacepost) #### async placeConditionalOrder(params) [See bybit documentation](https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md#place-conditional-order) @@ -55,7 +61,6 @@ If you only use the [public endpoints](#public-endpoints) you can ommit key and #### async getOrderTradeRecords(params) [See bybit documentation](https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md#get-the-trade-records-of-a-order) - ### Public enpoints #### async getOrderBook(params) @@ -67,10 +72,16 @@ If you only use the [public endpoints](#public-endpoints) you can ommit key and #### async getServerTime() [See bybit documentation](https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md#server-time) +#### async getSymbols() +Returns symbol information (such as tick size & min notional): +[Meeting price restrictions](https://github.com/bybit-exchange/bybit-official-api-docs/blob/master/en/rest_api.md#price-price) + +[See bybit documentation](https://bybit-exchange.github.io/bybit-official-api-docs/en/index.html#operation/query_symbol) + #### async getTimeOffset() Returns the time offset in ms to the server time retrieved by [`async getServerTime`](#async-getservertime). -If positive the time on the server is ahead of the clients time, if negative the time on the server is behind the clients time. +If positive the time on the server is ahead of the clients time, if negative the time on the server is behind the clients time. ## Example diff --git a/lib/rest-client.js b/lib/rest-client.js index 242287c..eac39c6 100644 --- a/lib/rest-client.js +++ b/lib/rest-client.js @@ -19,7 +19,7 @@ module.exports = class RestClient { if(params.order_type === 'Limit') assert(params.price, 'Parameter price is required for limit orders'); - return await this.request.post('/open-api/order/create', params); + return await this.request.post('/v2/private/order/create', params); } async getActiveOrder(params) { @@ -28,9 +28,24 @@ module.exports = class RestClient { async cancelActiveOrder(params) { assert(params, 'No params passed'); - assert(params.order_id, 'Parameter order_id is required'); + assert(params.order_id || params.order_link_id, 'Parameter order_id OR order_link_id is required'); - return await this.request.post('/open-api/order/cancel', params); + return await this.request.post('/v2/private/order/cancel', params); + } + + async cancelAllActiveOrders(params) { + assert(params, 'No params passed'); + assert(params.symbol, 'Parameter symbol is required'); + + return await this.request.post('/v2/private/order/cancelAll', params); + } + + async replaceActiveOrder(params) { + assert(params, 'No params passed'); + assert(params.order_id || params.order_link_id, 'Parameter order_id OR order_link_id is required'); + assert(params.symbol, 'Parameter symbol is required'); + + return await this.request.post('/open-api/order/replace', params); } async placeConditionalOrder(params) { @@ -126,6 +141,10 @@ module.exports = class RestClient { return await this.request.get('/v2/public/time'); } + async getSymbols() { + return await this.request.get('/v2/public/symbols'); + } + async getTimeOffset() { return await this.request.getTimeOffset(); }