Expand API support, including some V2 endpoints (#4)
Switch to V2 versions of some APIs: * place order * cancel order Add missing APIs: * cancel all orders * replace order * get symbols Add support for custom order ID for cancel active order.
This commit is contained in:
@@ -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,6 +72,12 @@ 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).
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user