Add missing endpoints, switch to v2

Adds missing endpoints:

* queryActiveOrder
* cancelAllConditionalOrders
* queryConditionalOrder
* setTradingStop
* getWalletFundRecords
* getWithdrawRecords
* setRiskLimit
* getRiskLimitList
* getPublicTradingRecords
* getApiAnnouncements

Switches Endpoints to v2:

* getPosition
This commit is contained in:
Stefan Aebischer
2020-01-17 21:36:41 -05:00
parent d6c18b1e57
commit d8c7a551a4
2 changed files with 93 additions and 2 deletions

View File

@@ -48,6 +48,14 @@ module.exports = class RestClient {
return await this.request.post('/open-api/order/replace', params);
}
async queryActiveOrder(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.get('/v2/private/order', params);
}
async placeConditionalOrder(params) {
assert(params, 'No params passed');
assert(params.side, 'Parameter side is required');
@@ -74,6 +82,21 @@ module.exports = class RestClient {
return await this.request.post('/open-api/stop-order/cancel', params);
}
async cancelAllConditionalOrders(params) {
assert(params, 'No params passed');
assert(params.symbol, 'Parameter symbol is required');
return await this.request.post('/v2/private/stop-order/cancelAll', params);
}
async queryConditionalOrder(params) {
assert(params, 'No params passed');
assert(params.stop_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.get('GET /v2/private/stop-order', params);
}
async getUserLeverage() {
return await this.request.get('/user/leverage');
}
@@ -87,7 +110,7 @@ module.exports = class RestClient {
}
async getPosition() {
return await this.request.get('/position/list');
return await this.request.get('/v2/private/position/list');
}
async changePositionMargin(params) {
@@ -98,6 +121,33 @@ module.exports = class RestClient {
return await this.request.post('/position/change-position-margin', params);
}
async setTradingStop(params) {
assert(params, 'No params passed');
assert(params.symbol, 'Parameter symbol is required');
return await this.request.post('/open-api/position/trading-stop', params);
}
async getWalletFundRecords(params) {
return await this.request.get('/open-api/wallet/fund/records', params);
}
async getWithdrawRecords(params) {
return await this.request.get('/open-api/wallet/withdraw/list', params);
}
async setRiskLimit(params) {
assert(params, 'No params passed');
assert(params.symbol, 'Parameter symbol is required');
assert(params.risk_id, 'Parameter risk_id is required');
return await this.request.post('/open-api/wallet/risk-limit', params);
}
async getRiskLimitList() {
return await this.request.get('/open-api/wallet/risk-limit/list');
}
async getLastFundingRate(params) {
assert(params, 'No params passed');
assert(params.symbol, 'Parameter symbol is required');
@@ -137,10 +187,21 @@ module.exports = class RestClient {
return await this.request.get('/v2/public/tickers');
}
async getPublicTradingRecords(params) {
assert(params, 'No params passed');
assert(params.symbol, 'Parameter symbol is required');
return await this.request.get('/v2/public/trading-records', params);
}
async getServerTime() {
return await this.request.get('/v2/public/time');
}
async getApiAnnouncements() {
return await this.request.get('/v2/public/announcement');
}
async getSymbols() {
return await this.request.get('/v2/public/symbols');
}