spacing & fix prefixed endpoints
This commit is contained in:
@@ -1,6 +1,4 @@
|
|||||||
|
|
||||||
const assert = require('assert');
|
const assert = require('assert');
|
||||||
|
|
||||||
const request = require('request');
|
const request = require('request');
|
||||||
|
|
||||||
const {signMessage} = require('./utility.js');
|
const {signMessage} = require('./utility.js');
|
||||||
@@ -32,7 +30,6 @@ module.exports = class Request {
|
|||||||
this.secret = secret;
|
this.secret = secret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
async get(endpoint, params) {
|
async get(endpoint, params) {
|
||||||
const result = await this._call('GET', endpoint, params);
|
const result = await this._call('GET', endpoint, params);
|
||||||
|
|
||||||
|
|||||||
@@ -19,11 +19,11 @@ module.exports = class RestClient {
|
|||||||
|
|
||||||
if(params.order_type === 'Limit') assert(params.price, 'Parameter price is required for limit orders');
|
if(params.order_type === 'Limit') assert(params.price, 'Parameter price is required for limit orders');
|
||||||
|
|
||||||
return await this.request.post('/v2/private/order/create', params);
|
return await this.request.post('v2/private/order/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getActiveOrder(params) {
|
async getActiveOrder(params) {
|
||||||
return await this.request.get('/open-api/order/list', params);
|
return await this.request.get('open-api/order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async cancelActiveOrder(params) {
|
async cancelActiveOrder(params) {
|
||||||
@@ -31,14 +31,14 @@ module.exports = class RestClient {
|
|||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
assert(params.order_id || params.order_link_id, 'Parameter order_id OR order_link_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('/v2/private/order/cancel', params);
|
return await this.request.post('v2/private/order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async cancelAllActiveOrders(params) {
|
async cancelAllActiveOrders(params) {
|
||||||
assert(params, 'No params passed');
|
assert(params, 'No params passed');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.post('/v2/private/order/cancelAll', params);
|
return await this.request.post('v2/private/order/cancelAll', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async replaceActiveOrder(params) {
|
async replaceActiveOrder(params) {
|
||||||
@@ -46,7 +46,7 @@ module.exports = class RestClient {
|
|||||||
assert(params.order_id || params.order_link_id, 'Parameter order_id OR order_link_id is required');
|
assert(params.order_id || params.order_link_id, 'Parameter order_id OR order_link_id is required');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.post('/open-api/order/replace', params);
|
return await this.request.post('open-api/order/replace', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async queryActiveOrder(params) {
|
async queryActiveOrder(params) {
|
||||||
@@ -54,7 +54,7 @@ module.exports = class RestClient {
|
|||||||
assert(params.order_id || params.order_link_id, 'Parameter order_id OR order_link_id is required');
|
assert(params.order_id || params.order_link_id, 'Parameter order_id OR order_link_id is required');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.get('/v2/private/order', params);
|
return await this.request.get('v2/private/order', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async placeConditionalOrder(params) {
|
async placeConditionalOrder(params) {
|
||||||
@@ -69,25 +69,25 @@ module.exports = class RestClient {
|
|||||||
|
|
||||||
if(params.order_type === 'Limit') assert(params.price, 'Parameter price is required for limit orders');
|
if(params.order_type === 'Limit') assert(params.price, 'Parameter price is required for limit orders');
|
||||||
|
|
||||||
return await this.request.post('/open-api/stop-order/create', params);
|
return await this.request.post('open-api/stop-order/create', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getConditioanlOrder(params) {
|
async getConditioanlOrder(params) {
|
||||||
return await this.request.get('/open-api/stop-order/list', params);
|
return await this.request.get('open-api/stop-order/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async cancelConditionalOrder(params) {
|
async cancelConditionalOrder(params) {
|
||||||
assert(params, 'No params passed');
|
assert(params, 'No params passed');
|
||||||
assert(params.stop_order_id, 'Parameter stop_order_id is required');
|
assert(params.stop_order_id, 'Parameter stop_order_id is required');
|
||||||
|
|
||||||
return await this.request.post('/open-api/stop-order/cancel', params);
|
return await this.request.post('open-api/stop-order/cancel', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async cancelAllConditionalOrders(params) {
|
async cancelAllConditionalOrders(params) {
|
||||||
assert(params, 'No params passed');
|
assert(params, 'No params passed');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.post('/v2/private/stop-order/cancelAll', params);
|
return await this.request.post('v2/private/stop-order/cancelAll', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async queryConditionalOrder(params) {
|
async queryConditionalOrder(params) {
|
||||||
@@ -99,7 +99,7 @@ module.exports = class RestClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async getUserLeverage() {
|
async getUserLeverage() {
|
||||||
return await this.request.get('/user/leverage');
|
return await this.request.get('user/leverage');
|
||||||
}
|
}
|
||||||
|
|
||||||
async changeUserLeverage(params) {
|
async changeUserLeverage(params) {
|
||||||
@@ -107,18 +107,18 @@ module.exports = class RestClient {
|
|||||||
assert(params.leverage, 'Parameter leverage is required');
|
assert(params.leverage, 'Parameter leverage is required');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.post('/user/leverage/save', params);
|
return await this.request.post('user/leverage/save', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPosition(params) {
|
async getPosition(params) {
|
||||||
assert(params, 'No params passed');
|
assert(params, 'No params passed');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.get('/v2/private/position/list', params);
|
return await this.request.get('v2/private/position/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPositions() {
|
async getPositions() {
|
||||||
return await this.request.get('/position/list');
|
return await this.request.get('position/list');
|
||||||
}
|
}
|
||||||
|
|
||||||
async changePositionMargin(params) {
|
async changePositionMargin(params) {
|
||||||
@@ -126,28 +126,28 @@ module.exports = class RestClient {
|
|||||||
assert(params.margin, 'Parameter margin is required');
|
assert(params.margin, 'Parameter margin is required');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.post('/position/change-position-margin', params);
|
return await this.request.post('position/change-position-margin', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setTradingStop(params) {
|
async setTradingStop(params) {
|
||||||
assert(params, 'No params passed');
|
assert(params, 'No params passed');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.post('/open-api/position/trading-stop', params);
|
return await this.request.post('open-api/position/trading-stop', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getWalletFundRecords(params) {
|
async getWalletFundRecords(params) {
|
||||||
return await this.request.get('/open-api/wallet/fund/records', params);
|
return await this.request.get('open-api/wallet/fund/records', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getWithdrawRecords(params) {
|
async getWithdrawRecords(params) {
|
||||||
return await this.request.get('/open-api/wallet/withdraw/list', params);
|
return await this.request.get('open-api/wallet/withdraw/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getWalletBalance(params) {
|
async getWalletBalance(params) {
|
||||||
assert(params, 'No params passed');
|
assert(params, 'No params passed');
|
||||||
assert(params.coin, 'Parameter coin is required');
|
assert(params.coin, 'Parameter coin is required');
|
||||||
return await this.request.get('/v2/private/wallet/balance', params);
|
return await this.request.get('v2/private/wallet/balance', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setRiskLimit(params) {
|
async setRiskLimit(params) {
|
||||||
@@ -155,46 +155,46 @@ module.exports = class RestClient {
|
|||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
assert(params.risk_id, 'Parameter risk_id is required');
|
assert(params.risk_id, 'Parameter risk_id is required');
|
||||||
|
|
||||||
return await this.request.post('/open-api/wallet/risk-limit', params);
|
return await this.request.post('open-api/wallet/risk-limit', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getRiskLimitList() {
|
async getRiskLimitList() {
|
||||||
return await this.request.get('/open-api/wallet/risk-limit/list');
|
return await this.request.get('open-api/wallet/risk-limit/list');
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLastFundingRate(params) {
|
async getLastFundingRate(params) {
|
||||||
assert(params, 'No params passed');
|
assert(params, 'No params passed');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.get('/open-api/funding/prev-funding-rate', params);
|
return await this.request.get('open-api/funding/prev-funding-rate', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMyLastFundingFee(params) {
|
async getMyLastFundingFee(params) {
|
||||||
assert(params, 'No params passed');
|
assert(params, 'No params passed');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.get('/open-api/funding/prev-funding', params);
|
return await this.request.get('open-api/funding/prev-funding', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPredictedFunding(params) {
|
async getPredictedFunding(params) {
|
||||||
assert(params, 'No params passed');
|
assert(params, 'No params passed');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.get('/open-api/funding/predicted-funding', params);
|
return await this.request.get('open-api/funding/predicted-funding', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTradeRecords(params) {
|
async getTradeRecords(params) {
|
||||||
assert(params, 'No params passed');
|
assert(params, 'No params passed');
|
||||||
assert(params.order_id || params.symbol, 'Parameter order_id OR symbol is required');
|
assert(params.order_id || params.symbol, 'Parameter order_id OR symbol is required');
|
||||||
|
|
||||||
return await this.request.get('/v2/private/execution/list', params);
|
return await this.request.get('v2/private/execution/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getOrderBook(params) {
|
async getOrderBook(params) {
|
||||||
assert(params, 'No params passed');
|
assert(params, 'No params passed');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.get('/v2/public/orderBook/L2', params);
|
return await this.request.get('v2/public/orderBook/L2', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getKline(params) {
|
async getKline(params) {
|
||||||
@@ -203,30 +203,30 @@ module.exports = class RestClient {
|
|||||||
assert(params.interval, 'Parameter interval is required');
|
assert(params.interval, 'Parameter interval is required');
|
||||||
assert(params.from, 'Parameter from is required');
|
assert(params.from, 'Parameter from is required');
|
||||||
|
|
||||||
return await this.request.get('/v2/public/kline/list', params);
|
return await this.request.get('v2/public/kline/list', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getLatestInformation() {
|
async getLatestInformation() {
|
||||||
return await this.request.get('/v2/public/tickers');
|
return await this.request.get('v2/public/tickers');
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPublicTradingRecords(params) {
|
async getPublicTradingRecords(params) {
|
||||||
assert(params, 'No params passed');
|
assert(params, 'No params passed');
|
||||||
assert(params.symbol, 'Parameter symbol is required');
|
assert(params.symbol, 'Parameter symbol is required');
|
||||||
|
|
||||||
return await this.request.get('/v2/public/trading-records', params);
|
return await this.request.get('v2/public/trading-records', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async getServerTime() {
|
async getServerTime() {
|
||||||
return await this.request.get('/v2/public/time');
|
return await this.request.get('v2/public/time');
|
||||||
}
|
}
|
||||||
|
|
||||||
async getApiAnnouncements() {
|
async getApiAnnouncements() {
|
||||||
return await this.request.get('/v2/public/announcement');
|
return await this.request.get('v2/public/announcement');
|
||||||
}
|
}
|
||||||
|
|
||||||
async getSymbols() {
|
async getSymbols() {
|
||||||
return await this.request.get('/v2/public/symbols');
|
return await this.request.get('v2/public/symbols');
|
||||||
}
|
}
|
||||||
|
|
||||||
async getTimeOffset() {
|
async getTimeOffset() {
|
||||||
|
|||||||
Reference in New Issue
Block a user