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:
@@ -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