ccxt 4.3.5 → 4.3.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/ace.js +5 -0
- package/dist/cjs/src/alpaca.js +6 -0
- package/dist/cjs/src/base/Exchange.js +37 -0
- package/dist/cjs/src/binance.js +4 -0
- package/dist/cjs/src/bingx.js +47 -0
- package/dist/cjs/src/bitbank.js +3 -0
- package/dist/cjs/src/bitget.js +74 -1
- package/dist/cjs/src/bithumb.js +4 -0
- package/dist/cjs/src/bitmex.js +26 -0
- package/dist/cjs/src/bitopro.js +5 -0
- package/dist/cjs/src/bitso.js +3 -0
- package/dist/cjs/src/bitstamp.js +3 -0
- package/dist/cjs/src/bitteam.js +4 -0
- package/dist/cjs/src/bitvavo.js +3 -0
- package/dist/cjs/src/bl3p.js +3 -0
- package/dist/cjs/src/btcalpha.js +3 -0
- package/dist/cjs/src/btcbox.js +3 -0
- package/dist/cjs/src/btcmarkets.js +3 -0
- package/dist/cjs/src/btcturk.js +3 -0
- package/dist/cjs/src/bybit.js +209 -12
- package/dist/cjs/src/cex.js +6 -0
- package/dist/cjs/src/coinbase.js +100 -21
- package/dist/cjs/src/coinbaseinternational.js +2 -0
- package/dist/cjs/src/coinbasepro.js +6 -0
- package/dist/cjs/src/coincheck.js +3 -0
- package/dist/cjs/src/coinex.js +180 -75
- package/dist/cjs/src/coinlist.js +4 -0
- package/dist/cjs/src/coinmate.js +3 -0
- package/dist/cjs/src/coinone.js +3 -0
- package/dist/cjs/src/coinsph.js +4 -0
- package/dist/cjs/src/coinspot.js +3 -0
- package/dist/cjs/src/cryptocom.js +34 -0
- package/dist/cjs/src/exmo.js +5 -0
- package/dist/cjs/src/gate.js +124 -22
- package/dist/cjs/src/hitbtc.js +4 -3
- package/dist/cjs/src/htx.js +30 -0
- package/dist/cjs/src/hyperliquid.js +40 -0
- package/dist/cjs/src/idex.js +3 -0
- package/dist/cjs/src/independentreserve.js +3 -0
- package/dist/cjs/src/indodax.js +3 -0
- package/dist/cjs/src/kraken.js +30 -0
- package/dist/cjs/src/krakenfutures.js +28 -0
- package/dist/cjs/src/kucoin.js +2 -0
- package/dist/cjs/src/kucoinfutures.js +4 -2
- package/dist/cjs/src/latoken.js +6 -0
- package/dist/cjs/src/luno.js +3 -0
- package/dist/cjs/src/lykke.js +5 -0
- package/dist/cjs/src/mercado.js +3 -0
- package/dist/cjs/src/mexc.js +111 -0
- package/dist/cjs/src/ndax.js +4 -0
- package/dist/cjs/src/novadax.js +4 -0
- package/dist/cjs/src/okx.js +196 -0
- package/dist/cjs/src/onetrading.js +3 -0
- package/dist/cjs/src/p2b.js +3 -0
- package/dist/cjs/src/pro/bitget.js +1 -1
- package/dist/cjs/src/pro/bybit.js +1 -1
- package/dist/cjs/src/pro/coinbase.js +30 -29
- package/dist/cjs/src/probit.js +3 -0
- package/dist/cjs/src/timex.js +3 -0
- package/dist/cjs/src/tradeogre.js +3 -0
- package/dist/cjs/src/wavesexchange.js +3 -0
- package/dist/cjs/src/wazirx.js +3 -0
- package/dist/cjs/src/whitebit.js +42 -0
- package/dist/cjs/src/woo.js +31 -0
- package/dist/cjs/src/yobit.js +3 -0
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/binance.d.ts +1 -0
- package/js/src/abstract/binancecoinm.d.ts +1 -0
- package/js/src/abstract/binanceus.d.ts +1 -0
- package/js/src/abstract/binanceusdm.d.ts +1 -0
- package/js/src/abstract/bingx.d.ts +1 -0
- package/js/src/abstract/coinbase.d.ts +5 -0
- package/js/src/abstract/woo.d.ts +1 -0
- package/js/src/ace.js +5 -0
- package/js/src/alpaca.js +6 -0
- package/js/src/ascendex.d.ts +2 -2
- package/js/src/base/Exchange.d.ts +5 -0
- package/js/src/base/Exchange.js +37 -0
- package/js/src/bigone.d.ts +1 -1
- package/js/src/binance.d.ts +3 -3
- package/js/src/binance.js +4 -0
- package/js/src/bingx.d.ts +2 -1
- package/js/src/bingx.js +47 -0
- package/js/src/bitbank.d.ts +1 -1
- package/js/src/bitbank.js +3 -0
- package/js/src/bitfinex.d.ts +1 -1
- package/js/src/bitfinex2.d.ts +1 -1
- package/js/src/bitflyer.d.ts +1 -1
- package/js/src/bitget.d.ts +4 -3
- package/js/src/bitget.js +74 -1
- package/js/src/bithumb.d.ts +1 -1
- package/js/src/bithumb.js +4 -0
- package/js/src/bitmart.d.ts +1 -1
- package/js/src/bitmex.d.ts +2 -1
- package/js/src/bitmex.js +26 -0
- package/js/src/bitopro.d.ts +1 -1
- package/js/src/bitopro.js +5 -0
- package/js/src/bitrue.d.ts +1 -1
- package/js/src/bitso.d.ts +1 -1
- package/js/src/bitso.js +3 -0
- package/js/src/bitstamp.d.ts +1 -1
- package/js/src/bitstamp.js +3 -0
- package/js/src/bitteam.js +4 -0
- package/js/src/bitvavo.d.ts +1 -1
- package/js/src/bitvavo.js +3 -0
- package/js/src/bl3p.js +3 -0
- package/js/src/blockchaincom.d.ts +1 -1
- package/js/src/btcalpha.js +3 -0
- package/js/src/btcbox.js +3 -0
- package/js/src/btcmarkets.d.ts +1 -1
- package/js/src/btcmarkets.js +3 -0
- package/js/src/btcturk.js +3 -0
- package/js/src/bybit.d.ts +8 -6
- package/js/src/bybit.js +209 -12
- package/js/src/cex.js +6 -0
- package/js/src/coinbase.d.ts +1 -1
- package/js/src/coinbase.js +100 -21
- package/js/src/coinbaseinternational.d.ts +1 -1
- package/js/src/coinbaseinternational.js +2 -0
- package/js/src/coinbasepro.d.ts +1 -1
- package/js/src/coinbasepro.js +6 -0
- package/js/src/coincheck.js +3 -0
- package/js/src/coinex.d.ts +8 -7
- package/js/src/coinex.js +180 -75
- package/js/src/coinlist.d.ts +1 -1
- package/js/src/coinlist.js +4 -0
- package/js/src/coinmate.d.ts +1 -1
- package/js/src/coinmate.js +3 -0
- package/js/src/coinone.js +3 -0
- package/js/src/coinsph.d.ts +1 -1
- package/js/src/coinsph.js +4 -0
- package/js/src/coinspot.js +3 -0
- package/js/src/cryptocom.d.ts +3 -2
- package/js/src/cryptocom.js +34 -0
- package/js/src/delta.d.ts +2 -2
- package/js/src/deribit.d.ts +1 -1
- package/js/src/digifinex.d.ts +3 -3
- package/js/src/exmo.d.ts +3 -3
- package/js/src/exmo.js +5 -0
- package/js/src/gate.d.ts +8 -7
- package/js/src/gate.js +124 -22
- package/js/src/gemini.d.ts +1 -1
- package/js/src/hitbtc.d.ts +3 -3
- package/js/src/hitbtc.js +4 -3
- package/js/src/hollaex.d.ts +1 -1
- package/js/src/htx.d.ts +2 -1
- package/js/src/htx.js +30 -0
- package/js/src/huobijp.d.ts +1 -1
- package/js/src/hyperliquid.d.ts +3 -2
- package/js/src/hyperliquid.js +40 -0
- package/js/src/idex.d.ts +1 -1
- package/js/src/idex.js +3 -0
- package/js/src/independentreserve.js +3 -0
- package/js/src/indodax.d.ts +1 -1
- package/js/src/indodax.js +3 -0
- package/js/src/kraken.d.ts +2 -1
- package/js/src/kraken.js +30 -0
- package/js/src/krakenfutures.d.ts +1 -0
- package/js/src/krakenfutures.js +28 -0
- package/js/src/kucoin.d.ts +1 -1
- package/js/src/kucoin.js +2 -0
- package/js/src/kucoinfutures.d.ts +1 -1
- package/js/src/kucoinfutures.js +4 -2
- package/js/src/kuna.d.ts +1 -1
- package/js/src/latoken.js +6 -0
- package/js/src/lbank.d.ts +1 -1
- package/js/src/luno.js +3 -0
- package/js/src/lykke.d.ts +1 -1
- package/js/src/lykke.js +5 -0
- package/js/src/mercado.d.ts +1 -1
- package/js/src/mercado.js +3 -0
- package/js/src/mexc.d.ts +4 -3
- package/js/src/mexc.js +111 -0
- package/js/src/ndax.d.ts +1 -1
- package/js/src/ndax.js +4 -0
- package/js/src/novadax.d.ts +1 -1
- package/js/src/novadax.js +4 -0
- package/js/src/okcoin.d.ts +1 -1
- package/js/src/okx.d.ts +11 -8
- package/js/src/okx.js +196 -0
- package/js/src/onetrading.d.ts +1 -1
- package/js/src/onetrading.js +3 -0
- package/js/src/p2b.js +3 -0
- package/js/src/phemex.d.ts +1 -1
- package/js/src/poloniex.d.ts +1 -1
- package/js/src/pro/bitget.d.ts +1 -1
- package/js/src/pro/bitget.js +1 -1
- package/js/src/pro/bybit.js +1 -1
- package/js/src/pro/coinbase.d.ts +2 -2
- package/js/src/pro/coinbase.js +30 -29
- package/js/src/probit.d.ts +1 -1
- package/js/src/probit.js +3 -0
- package/js/src/timex.js +3 -0
- package/js/src/tokocrypto.d.ts +1 -1
- package/js/src/tradeogre.js +3 -0
- package/js/src/upbit.d.ts +1 -1
- package/js/src/wavesexchange.d.ts +1 -1
- package/js/src/wavesexchange.js +3 -0
- package/js/src/wazirx.js +3 -0
- package/js/src/whitebit.d.ts +2 -1
- package/js/src/whitebit.js +42 -0
- package/js/src/woo.d.ts +3 -2
- package/js/src/woo.js +31 -0
- package/js/src/yobit.d.ts +1 -1
- package/js/src/yobit.js +3 -0
- package/js/src/zaif.d.ts +1 -1
- package/js/src/zonda.d.ts +1 -1
- package/package.json +1 -1
package/js/src/okx.js
CHANGED
|
@@ -34,8 +34,10 @@ export default class okx extends Exchange {
|
|
|
34
34
|
'option': true,
|
|
35
35
|
'addMargin': true,
|
|
36
36
|
'cancelAllOrders': false,
|
|
37
|
+
'cancelAllOrdersAfter': true,
|
|
37
38
|
'cancelOrder': true,
|
|
38
39
|
'cancelOrders': true,
|
|
40
|
+
'cancelOrdersForSymbols': true,
|
|
39
41
|
'closeAllPositions': false,
|
|
40
42
|
'closePosition': true,
|
|
41
43
|
'createConvertTrade': true,
|
|
@@ -112,8 +114,10 @@ export default class okx extends Exchange {
|
|
|
112
114
|
'fetchOrderTrades': true,
|
|
113
115
|
'fetchPermissions': undefined,
|
|
114
116
|
'fetchPosition': true,
|
|
117
|
+
'fetchPositionHistory': 'emulated',
|
|
115
118
|
'fetchPositions': true,
|
|
116
119
|
'fetchPositionsForSymbol': true,
|
|
120
|
+
'fetchPositionsHistory': true,
|
|
117
121
|
'fetchPositionsRisk': false,
|
|
118
122
|
'fetchPremiumIndexOHLCV': false,
|
|
119
123
|
'fetchSettlementHistory': true,
|
|
@@ -3285,6 +3289,117 @@ export default class okx extends Exchange {
|
|
|
3285
3289
|
const ordersData = this.safeList(response, 'data', []);
|
|
3286
3290
|
return this.parseOrders(ordersData, market, undefined, undefined, params);
|
|
3287
3291
|
}
|
|
3292
|
+
async cancelOrdersForSymbols(orders, params = {}) {
|
|
3293
|
+
/**
|
|
3294
|
+
* @method
|
|
3295
|
+
* @name okx#cancelOrdersForSymbols
|
|
3296
|
+
* @description cancel multiple orders for multiple symbols
|
|
3297
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-multiple-orders
|
|
3298
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-algo-trading-post-cancel-algo-order
|
|
3299
|
+
* @param {CancellationRequest[]} orders each order should contain the parameters required by cancelOrder namely id and symbol
|
|
3300
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3301
|
+
* @param {boolean} [params.trigger] whether the order is a stop/trigger order
|
|
3302
|
+
* @param {boolean} [params.trailing] set to true if you want to cancel trailing orders
|
|
3303
|
+
* @returns {object} an list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
3304
|
+
*/
|
|
3305
|
+
await this.loadMarkets();
|
|
3306
|
+
const request = [];
|
|
3307
|
+
const options = this.safeDict(this.options, 'cancelOrders', {});
|
|
3308
|
+
const defaultMethod = this.safeString(options, 'method', 'privatePostTradeCancelBatchOrders');
|
|
3309
|
+
let method = this.safeString(params, 'method', defaultMethod);
|
|
3310
|
+
const stop = this.safeBool2(params, 'stop', 'trigger');
|
|
3311
|
+
const trailing = this.safeBool(params, 'trailing', false);
|
|
3312
|
+
const isStopOrTrailing = stop || trailing;
|
|
3313
|
+
if (isStopOrTrailing) {
|
|
3314
|
+
method = 'privatePostTradeCancelAlgos';
|
|
3315
|
+
}
|
|
3316
|
+
for (let i = 0; i < orders.length; i++) {
|
|
3317
|
+
const order = orders[i];
|
|
3318
|
+
const id = this.safeString(order, 'id');
|
|
3319
|
+
const clientOrderId = this.safeString2(order, 'clOrdId', 'clientOrderId');
|
|
3320
|
+
const symbol = this.safeString(order, 'symbol');
|
|
3321
|
+
const market = this.market(symbol);
|
|
3322
|
+
let idKey = 'ordId';
|
|
3323
|
+
if (isStopOrTrailing) {
|
|
3324
|
+
idKey = 'algoId';
|
|
3325
|
+
}
|
|
3326
|
+
else if (clientOrderId !== undefined) {
|
|
3327
|
+
idKey = 'clOrdId';
|
|
3328
|
+
}
|
|
3329
|
+
const requestItem = {
|
|
3330
|
+
'instId': market['id'],
|
|
3331
|
+
};
|
|
3332
|
+
requestItem[idKey] = (clientOrderId !== undefined) ? clientOrderId : id;
|
|
3333
|
+
request.push(requestItem);
|
|
3334
|
+
}
|
|
3335
|
+
let response = undefined;
|
|
3336
|
+
if (method === 'privatePostTradeCancelAlgos') {
|
|
3337
|
+
response = await this.privatePostTradeCancelAlgos(request); // * dont extend with params, otherwise ARRAY will be turned into OBJECT
|
|
3338
|
+
}
|
|
3339
|
+
else {
|
|
3340
|
+
response = await this.privatePostTradeCancelBatchOrders(request); // * dont extend with params, otherwise ARRAY will be turned into OBJECT
|
|
3341
|
+
}
|
|
3342
|
+
//
|
|
3343
|
+
// {
|
|
3344
|
+
// "code": "0",
|
|
3345
|
+
// "data": [
|
|
3346
|
+
// {
|
|
3347
|
+
// "clOrdId": "e123456789ec4dBC1123456ba123b45e",
|
|
3348
|
+
// "ordId": "405071912345641543",
|
|
3349
|
+
// "sCode": "0",
|
|
3350
|
+
// "sMsg": ""
|
|
3351
|
+
// },
|
|
3352
|
+
// ...
|
|
3353
|
+
// ],
|
|
3354
|
+
// "msg": ""
|
|
3355
|
+
// }
|
|
3356
|
+
//
|
|
3357
|
+
// Algo order
|
|
3358
|
+
//
|
|
3359
|
+
// {
|
|
3360
|
+
// "code": "0",
|
|
3361
|
+
// "data": [
|
|
3362
|
+
// {
|
|
3363
|
+
// "algoId": "431375349042380800",
|
|
3364
|
+
// "sCode": "0",
|
|
3365
|
+
// "sMsg": ""
|
|
3366
|
+
// }
|
|
3367
|
+
// ],
|
|
3368
|
+
// "msg": ""
|
|
3369
|
+
// }
|
|
3370
|
+
//
|
|
3371
|
+
const ordersData = this.safeList(response, 'data', []);
|
|
3372
|
+
return this.parseOrders(ordersData, undefined, undefined, undefined, params);
|
|
3373
|
+
}
|
|
3374
|
+
async cancelAllOrdersAfter(timeout, params = {}) {
|
|
3375
|
+
/**
|
|
3376
|
+
* @method
|
|
3377
|
+
* @name okx#cancelAllOrdersAfter
|
|
3378
|
+
* @description dead man's switch, cancel all orders after the given timeout
|
|
3379
|
+
* @see https://www.okx.com/docs-v5/en/#order-book-trading-trade-post-cancel-all-after
|
|
3380
|
+
* @param {number} timeout time in milliseconds, 0 represents cancel the timer
|
|
3381
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
3382
|
+
* @returns {object} the api result
|
|
3383
|
+
*/
|
|
3384
|
+
await this.loadMarkets();
|
|
3385
|
+
const request = {
|
|
3386
|
+
'timeOut': (timeout > 0) ? this.parseToInt(timeout / 1000) : 0,
|
|
3387
|
+
};
|
|
3388
|
+
const response = await this.privatePostTradeCancelAllAfter(this.extend(request, params));
|
|
3389
|
+
//
|
|
3390
|
+
// {
|
|
3391
|
+
// "code":"0",
|
|
3392
|
+
// "msg":"",
|
|
3393
|
+
// "data":[
|
|
3394
|
+
// {
|
|
3395
|
+
// "triggerTime":"1587971460",
|
|
3396
|
+
// "ts":"1587971400"
|
|
3397
|
+
// }
|
|
3398
|
+
// ]
|
|
3399
|
+
// }
|
|
3400
|
+
//
|
|
3401
|
+
return response;
|
|
3402
|
+
}
|
|
3288
3403
|
parseOrderStatus(status) {
|
|
3289
3404
|
const statuses = {
|
|
3290
3405
|
'canceled': 'canceled',
|
|
@@ -8089,4 +8204,85 @@ export default class okx extends Exchange {
|
|
|
8089
8204
|
const modifications = this.parseMarginModifications(data);
|
|
8090
8205
|
return this.filterBySymbolSinceLimit(modifications, symbol, since, limit);
|
|
8091
8206
|
}
|
|
8207
|
+
async fetchPositionsHistory(symbols = undefined, since = undefined, limit = undefined, params = {}) {
|
|
8208
|
+
/**
|
|
8209
|
+
* @method
|
|
8210
|
+
* @name okx#fetchPositionsHistory
|
|
8211
|
+
* @description fetches historical positions
|
|
8212
|
+
* @see https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history
|
|
8213
|
+
* @param {string} [symbols] unified market symbols
|
|
8214
|
+
* @param {int} [since] timestamp in ms of the earliest position to fetch
|
|
8215
|
+
* @param {int} [limit] the maximum amount of records to fetch, default=100, max=100
|
|
8216
|
+
* @param {object} params extra parameters specific to the exchange api endpoint
|
|
8217
|
+
* @param {string} [params.marginMode] "cross" or "isolated"
|
|
8218
|
+
*
|
|
8219
|
+
* EXCHANGE SPECIFIC PARAMETERS
|
|
8220
|
+
* @param {string} [params.instType] margin, swap, futures or option
|
|
8221
|
+
* @param {string} [params.type] the type of latest close position 1: close position partially, 2:close all, 3:liquidation, 4:partial liquidation; 5:adl, is it is the latest type if there are several types for the same position
|
|
8222
|
+
* @param {string} [params.posId] position id, there is attribute expiration, the posid will be expired if it is more than 30 days after the last full close position, then position will use new posid
|
|
8223
|
+
* @param {string} [params.before] timestamp in ms of the earliest position to fetch based on the last update time of the position
|
|
8224
|
+
* @param {string} [params.after] timestamp in ms of the latest position to fetch based on the last update time of the position
|
|
8225
|
+
* @returns {object[]} a list of [position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
|
|
8226
|
+
*/
|
|
8227
|
+
await this.loadMarkets();
|
|
8228
|
+
const marginMode = this.safeString(params, 'marginMode');
|
|
8229
|
+
const instType = this.safeStringUpper(params, 'instType');
|
|
8230
|
+
params = this.omit(params, ['until', 'marginMode', 'instType']);
|
|
8231
|
+
if (limit === undefined) {
|
|
8232
|
+
limit = 100;
|
|
8233
|
+
}
|
|
8234
|
+
const request = {
|
|
8235
|
+
'limit': limit,
|
|
8236
|
+
};
|
|
8237
|
+
if (symbols !== undefined) {
|
|
8238
|
+
const symbolsLength = symbols.length;
|
|
8239
|
+
if (symbolsLength === 1) {
|
|
8240
|
+
const market = this.market(symbols[0]);
|
|
8241
|
+
request['instId'] = market['id'];
|
|
8242
|
+
}
|
|
8243
|
+
}
|
|
8244
|
+
if (marginMode !== undefined) {
|
|
8245
|
+
request['mgnMode'] = marginMode;
|
|
8246
|
+
}
|
|
8247
|
+
if (instType !== undefined) {
|
|
8248
|
+
request['instType'] = instType;
|
|
8249
|
+
}
|
|
8250
|
+
const response = await this.privateGetAccountPositionsHistory(this.extend(request, params));
|
|
8251
|
+
//
|
|
8252
|
+
// {
|
|
8253
|
+
// code: '0',
|
|
8254
|
+
// data: [
|
|
8255
|
+
// {
|
|
8256
|
+
// cTime: '1708735940395',
|
|
8257
|
+
// ccy: 'USDT',
|
|
8258
|
+
// closeAvgPx: '0.6330444444444444',
|
|
8259
|
+
// closeTotalPos: '27',
|
|
8260
|
+
// direction: 'long',
|
|
8261
|
+
// fee: '-1.69566',
|
|
8262
|
+
// fundingFee: '-11.870404179341788',
|
|
8263
|
+
// instId: 'XRP-USDT-SWAP',
|
|
8264
|
+
// instType: 'SWAP',
|
|
8265
|
+
// lever: '3.0',
|
|
8266
|
+
// liqPenalty: '0',
|
|
8267
|
+
// mgnMode: 'cross',
|
|
8268
|
+
// openAvgPx: '0.623',
|
|
8269
|
+
// openMaxPos: '15',
|
|
8270
|
+
// pnl: '27.11999999999988',
|
|
8271
|
+
// pnlRatio: '0.0241732402722634',
|
|
8272
|
+
// posId: '681423155054862336',
|
|
8273
|
+
// realizedPnl: '13.553935820658092',
|
|
8274
|
+
// triggerPx: '',
|
|
8275
|
+
// type: '2',
|
|
8276
|
+
// uTime: '1711088748170',
|
|
8277
|
+
// uly: 'XRP-USDT'
|
|
8278
|
+
// },
|
|
8279
|
+
// ...
|
|
8280
|
+
// ],
|
|
8281
|
+
// msg: ''
|
|
8282
|
+
// }
|
|
8283
|
+
//
|
|
8284
|
+
const data = this.safeList(response, 'data');
|
|
8285
|
+
const positions = this.parsePositions(data, symbols, params);
|
|
8286
|
+
return this.filterBySinceLimit(positions, since, limit);
|
|
8287
|
+
}
|
|
8092
8288
|
}
|
package/js/src/onetrading.d.ts
CHANGED
|
@@ -50,7 +50,7 @@ export default class onetrading extends Exchange {
|
|
|
50
50
|
}>;
|
|
51
51
|
fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
52
52
|
fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
53
|
-
withdraw(code: string, amount: number, address:
|
|
53
|
+
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
54
54
|
parseTransaction(transaction: any, currency?: Currency): Transaction;
|
|
55
55
|
parseOrderStatus(status: any): string;
|
|
56
56
|
parseOrder(order: any, market?: Market): Order;
|
package/js/src/onetrading.js
CHANGED
|
@@ -77,8 +77,11 @@ export default class onetrading extends Exchange {
|
|
|
77
77
|
'fetchOrders': false,
|
|
78
78
|
'fetchOrderTrades': true,
|
|
79
79
|
'fetchPosition': false,
|
|
80
|
+
'fetchPositionHistory': false,
|
|
80
81
|
'fetchPositionMode': false,
|
|
81
82
|
'fetchPositions': false,
|
|
83
|
+
'fetchPositionsForSymbol': false,
|
|
84
|
+
'fetchPositionsHistory': false,
|
|
82
85
|
'fetchPositionsRisk': false,
|
|
83
86
|
'fetchPremiumIndexOHLCV': false,
|
|
84
87
|
'fetchTicker': true,
|
package/js/src/p2b.js
CHANGED
|
@@ -82,8 +82,11 @@ export default class p2b extends Exchange {
|
|
|
82
82
|
'fetchOrderTrades': true,
|
|
83
83
|
'fetchPermissions': false,
|
|
84
84
|
'fetchPosition': false,
|
|
85
|
+
'fetchPositionHistory': false,
|
|
86
|
+
'fetchPositionMode': false,
|
|
85
87
|
'fetchPositions': false,
|
|
86
88
|
'fetchPositionsForSymbol': false,
|
|
89
|
+
'fetchPositionsHistory': false,
|
|
87
90
|
'fetchPositionsRisk': false,
|
|
88
91
|
'fetchPremiumIndexOHLCV': false,
|
|
89
92
|
'fetchTicker': true,
|
package/js/src/phemex.d.ts
CHANGED
|
@@ -128,6 +128,6 @@ export default class phemex extends Exchange {
|
|
|
128
128
|
};
|
|
129
129
|
parseTransferStatus(status: any): string;
|
|
130
130
|
fetchFundingRateHistory(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<FundingRateHistory[]>;
|
|
131
|
-
withdraw(code: string, amount: number, address:
|
|
131
|
+
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
132
132
|
handleErrors(httpCode: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
|
133
133
|
}
|
package/js/src/poloniex.d.ts
CHANGED
|
@@ -62,7 +62,7 @@ export default class poloniex extends Exchange {
|
|
|
62
62
|
toAccount: any;
|
|
63
63
|
status: any;
|
|
64
64
|
};
|
|
65
|
-
withdraw(code: string, amount: number, address:
|
|
65
|
+
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
66
66
|
fetchTransactionsHelper(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<any>;
|
|
67
67
|
fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
68
68
|
fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
package/js/src/pro/bitget.d.ts
CHANGED
|
@@ -29,7 +29,7 @@ export default class bitget extends bitgetRest {
|
|
|
29
29
|
handlePositions(client: Client, message: any): void;
|
|
30
30
|
parseWsPosition(position: any, market?: any): Position;
|
|
31
31
|
watchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
32
|
-
handleOrder(client: Client, message: any
|
|
32
|
+
handleOrder(client: Client, message: any): void;
|
|
33
33
|
parseWsOrder(order: any, market?: any): Order;
|
|
34
34
|
parseWsOrderStatus(status: any): string;
|
|
35
35
|
watchMyTrades(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
|
package/js/src/pro/bitget.js
CHANGED
|
@@ -1007,7 +1007,7 @@ export default class bitget extends bitgetRest {
|
|
|
1007
1007
|
}
|
|
1008
1008
|
return this.filterBySymbolSinceLimit(orders, symbol, since, limit, true);
|
|
1009
1009
|
}
|
|
1010
|
-
handleOrder(client, message
|
|
1010
|
+
handleOrder(client, message) {
|
|
1011
1011
|
//
|
|
1012
1012
|
// spot
|
|
1013
1013
|
//
|
package/js/src/pro/bybit.js
CHANGED
package/js/src/pro/coinbase.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import coinbaseRest from '../coinbase.js';
|
|
|
2
2
|
import { Strings, Tickers, Ticker, Int, Trade, OrderBook, Order, Str } from '../base/types.js';
|
|
3
3
|
export default class coinbase extends coinbaseRest {
|
|
4
4
|
describe(): any;
|
|
5
|
-
subscribe(name:
|
|
5
|
+
subscribe(name: string, isPrivate: boolean, symbol?: any, params?: {}): Promise<any>;
|
|
6
6
|
watchTicker(symbol: string, params?: {}): Promise<Ticker>;
|
|
7
7
|
watchTickers(symbols?: Strings, params?: {}): Promise<Tickers>;
|
|
8
8
|
handleTickers(client: any, message: any): any;
|
|
@@ -14,7 +14,7 @@ export default class coinbase extends coinbaseRest {
|
|
|
14
14
|
handleOrder(client: any, message: any): any;
|
|
15
15
|
parseWsOrder(order: any, market?: any): Order;
|
|
16
16
|
handleOrderBookHelper(orderbook: any, updates: any): void;
|
|
17
|
-
handleOrderBook(client: any, message: any):
|
|
17
|
+
handleOrderBook(client: any, message: any): void;
|
|
18
18
|
handleSubscriptionStatus(client: any, message: any): any;
|
|
19
19
|
handleMessage(client: any, message: any): void;
|
|
20
20
|
}
|
package/js/src/pro/coinbase.js
CHANGED
|
@@ -49,7 +49,7 @@ export default class coinbase extends coinbaseRest {
|
|
|
49
49
|
},
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
async subscribe(name, symbol = undefined, params = {}) {
|
|
52
|
+
async subscribe(name, isPrivate, symbol = undefined, params = {}) {
|
|
53
53
|
/**
|
|
54
54
|
* @ignore
|
|
55
55
|
* @method
|
|
@@ -61,7 +61,6 @@ export default class coinbase extends coinbaseRest {
|
|
|
61
61
|
* @returns {object} subscription to a websocket channel
|
|
62
62
|
*/
|
|
63
63
|
await this.loadMarkets();
|
|
64
|
-
this.checkRequiredCredentials();
|
|
65
64
|
let market = undefined;
|
|
66
65
|
let messageHash = name;
|
|
67
66
|
let productIds = [];
|
|
@@ -78,8 +77,6 @@ export default class coinbase extends coinbaseRest {
|
|
|
78
77
|
}
|
|
79
78
|
const url = this.urls['api']['ws'];
|
|
80
79
|
const timestamp = this.numberToString(this.seconds());
|
|
81
|
-
const isCloudAPiKey = (this.apiKey.indexOf('organizations/') >= 0) || (this.secret.startsWith('-----BEGIN'));
|
|
82
|
-
const auth = timestamp + name + productIds.join(',');
|
|
83
80
|
const subscribe = {
|
|
84
81
|
'type': 'subscribe',
|
|
85
82
|
'product_ids': productIds,
|
|
@@ -88,25 +85,30 @@ export default class coinbase extends coinbaseRest {
|
|
|
88
85
|
// 'timestamp': timestamp,
|
|
89
86
|
// 'signature': this.hmac (this.encode (auth), this.encode (this.secret), sha256),
|
|
90
87
|
};
|
|
91
|
-
if (
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
if (isPrivate) {
|
|
89
|
+
this.checkRequiredCredentials();
|
|
90
|
+
const isCloudAPiKey = (this.apiKey.indexOf('organizations/') >= 0) || (this.secret.startsWith('-----BEGIN'));
|
|
91
|
+
const auth = timestamp + name + productIds.join(',');
|
|
92
|
+
if (!isCloudAPiKey) {
|
|
93
|
+
subscribe['api_key'] = this.apiKey;
|
|
94
|
+
subscribe['timestamp'] = timestamp;
|
|
95
|
+
subscribe['signature'] = this.hmac(this.encode(auth), this.encode(this.secret), sha256);
|
|
99
96
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
|
|
97
|
+
else {
|
|
98
|
+
if (this.apiKey.startsWith('-----BEGIN')) {
|
|
99
|
+
throw new ArgumentsRequired(this.id + ' apiKey should contain the name (eg: organizations/3b910e93....) and not the public key');
|
|
100
|
+
}
|
|
101
|
+
const currentToken = this.safeString(this.options, 'wsToken');
|
|
102
|
+
const tokenTimestamp = this.safeInteger(this.options, 'wsTokenTimestamp', 0);
|
|
103
|
+
const seconds = this.seconds();
|
|
104
|
+
if (currentToken === undefined || tokenTimestamp + 120 < seconds) {
|
|
105
|
+
// we should generate new token
|
|
106
|
+
const token = this.createAuthToken(seconds);
|
|
107
|
+
this.options['wsToken'] = token;
|
|
108
|
+
this.options['wsTokenTimestamp'] = seconds;
|
|
109
|
+
}
|
|
110
|
+
subscribe['jwt'] = this.safeString(this.options, 'wsToken');
|
|
108
111
|
}
|
|
109
|
-
subscribe['jwt'] = this.safeString(this.options, 'wsToken');
|
|
110
112
|
}
|
|
111
113
|
return await this.watch(url, messageHash, subscribe, messageHash);
|
|
112
114
|
}
|
|
@@ -121,7 +123,7 @@ export default class coinbase extends coinbaseRest {
|
|
|
121
123
|
* @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
|
|
122
124
|
*/
|
|
123
125
|
const name = 'ticker';
|
|
124
|
-
return await this.subscribe(name, symbol, params);
|
|
126
|
+
return await this.subscribe(name, false, symbol, params);
|
|
125
127
|
}
|
|
126
128
|
async watchTickers(symbols = undefined, params = {}) {
|
|
127
129
|
/**
|
|
@@ -137,7 +139,7 @@ export default class coinbase extends coinbaseRest {
|
|
|
137
139
|
symbols = this.symbols;
|
|
138
140
|
}
|
|
139
141
|
const name = 'ticker_batch';
|
|
140
|
-
const tickers = await this.subscribe(name, symbols, params);
|
|
142
|
+
const tickers = await this.subscribe(name, false, symbols, params);
|
|
141
143
|
if (this.newUpdates) {
|
|
142
144
|
return tickers;
|
|
143
145
|
}
|
|
@@ -301,7 +303,7 @@ export default class coinbase extends coinbaseRest {
|
|
|
301
303
|
await this.loadMarkets();
|
|
302
304
|
symbol = this.symbol(symbol);
|
|
303
305
|
const name = 'market_trades';
|
|
304
|
-
const trades = await this.subscribe(name, symbol, params);
|
|
306
|
+
const trades = await this.subscribe(name, false, symbol, params);
|
|
305
307
|
if (this.newUpdates) {
|
|
306
308
|
limit = trades.getLimit(symbol, limit);
|
|
307
309
|
}
|
|
@@ -321,7 +323,7 @@ export default class coinbase extends coinbaseRest {
|
|
|
321
323
|
*/
|
|
322
324
|
await this.loadMarkets();
|
|
323
325
|
const name = 'user';
|
|
324
|
-
const orders = await this.subscribe(name, symbol, params);
|
|
326
|
+
const orders = await this.subscribe(name, true, symbol, params);
|
|
325
327
|
if (this.newUpdates) {
|
|
326
328
|
limit = orders.getLimit(symbol, limit);
|
|
327
329
|
}
|
|
@@ -342,7 +344,7 @@ export default class coinbase extends coinbaseRest {
|
|
|
342
344
|
const name = 'level2';
|
|
343
345
|
const market = this.market(symbol);
|
|
344
346
|
symbol = market['symbol'];
|
|
345
|
-
const orderbook = await this.subscribe(name, symbol, params);
|
|
347
|
+
const orderbook = await this.subscribe(name, false, symbol, params);
|
|
346
348
|
return orderbook.limit();
|
|
347
349
|
}
|
|
348
350
|
handleTrade(client, message) {
|
|
@@ -560,8 +562,8 @@ export default class coinbase extends coinbaseRest {
|
|
|
560
562
|
this.orderbooks[symbol] = this.orderBook({}, limit);
|
|
561
563
|
const orderbook = this.orderbooks[symbol];
|
|
562
564
|
this.handleOrderBookHelper(orderbook, updates);
|
|
563
|
-
orderbook['timestamp'] =
|
|
564
|
-
orderbook['datetime'] =
|
|
565
|
+
orderbook['timestamp'] = this.parse8601(datetime);
|
|
566
|
+
orderbook['datetime'] = datetime;
|
|
565
567
|
orderbook['symbol'] = symbol;
|
|
566
568
|
client.resolve(orderbook, messageHash);
|
|
567
569
|
if (messageHash.endsWith('USD')) {
|
|
@@ -580,7 +582,6 @@ export default class coinbase extends coinbaseRest {
|
|
|
580
582
|
}
|
|
581
583
|
}
|
|
582
584
|
}
|
|
583
|
-
return message;
|
|
584
585
|
}
|
|
585
586
|
handleSubscriptionStatus(client, message) {
|
|
586
587
|
//
|
package/js/src/probit.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export default class probit extends Exchange {
|
|
|
45
45
|
info: any;
|
|
46
46
|
}>;
|
|
47
47
|
fetchDepositAddresses(codes?: string[], params?: {}): Promise<{}>;
|
|
48
|
-
withdraw(code: string, amount: number, address:
|
|
48
|
+
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
49
49
|
fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
50
50
|
fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
51
51
|
fetchDepositsWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
package/js/src/probit.js
CHANGED
|
@@ -70,8 +70,11 @@ export default class probit extends Exchange {
|
|
|
70
70
|
'fetchOrder': true,
|
|
71
71
|
'fetchOrderBook': true,
|
|
72
72
|
'fetchPosition': false,
|
|
73
|
+
'fetchPositionHistory': false,
|
|
73
74
|
'fetchPositionMode': false,
|
|
74
75
|
'fetchPositions': false,
|
|
76
|
+
'fetchPositionsForSymbol': false,
|
|
77
|
+
'fetchPositionsHistory': false,
|
|
75
78
|
'fetchPositionsRisk': false,
|
|
76
79
|
'fetchPremiumIndexOHLCV': false,
|
|
77
80
|
'fetchTicker': true,
|
package/js/src/timex.js
CHANGED
|
@@ -67,8 +67,11 @@ export default class timex extends Exchange {
|
|
|
67
67
|
'fetchOrder': true,
|
|
68
68
|
'fetchOrderBook': true,
|
|
69
69
|
'fetchPosition': false,
|
|
70
|
+
'fetchPositionHistory': false,
|
|
70
71
|
'fetchPositionMode': false,
|
|
71
72
|
'fetchPositions': false,
|
|
73
|
+
'fetchPositionsForSymbol': false,
|
|
74
|
+
'fetchPositionsHistory': false,
|
|
72
75
|
'fetchPositionsRisk': false,
|
|
73
76
|
'fetchPremiumIndexOHLCV': false,
|
|
74
77
|
'fetchTicker': true,
|
package/js/src/tokocrypto.d.ts
CHANGED
|
@@ -42,7 +42,7 @@ export default class tokocrypto extends Exchange {
|
|
|
42
42
|
fetchWithdrawals(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
|
|
43
43
|
parseTransactionStatusByType(status: any, type?: any): string;
|
|
44
44
|
parseTransaction(transaction: any, currency?: Currency): Transaction;
|
|
45
|
-
withdraw(code: string, amount: number, address:
|
|
45
|
+
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
46
46
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
47
47
|
url: any;
|
|
48
48
|
method: string;
|
package/js/src/tradeogre.js
CHANGED
|
@@ -82,8 +82,11 @@ export default class tradeogre extends Exchange {
|
|
|
82
82
|
'fetchOrderTrades': false,
|
|
83
83
|
'fetchPermissions': false,
|
|
84
84
|
'fetchPosition': false,
|
|
85
|
+
'fetchPositionHistory': false,
|
|
86
|
+
'fetchPositionMode': false,
|
|
85
87
|
'fetchPositions': false,
|
|
86
88
|
'fetchPositionsForSymbol': false,
|
|
89
|
+
'fetchPositionsHistory': false,
|
|
87
90
|
'fetchPositionsRisk': false,
|
|
88
91
|
'fetchPremiumIndexOHLCV': false,
|
|
89
92
|
'fetchTicker': true,
|
package/js/src/upbit.d.ts
CHANGED
|
@@ -89,7 +89,7 @@ export default class upbit extends Exchange {
|
|
|
89
89
|
network: string;
|
|
90
90
|
info: any;
|
|
91
91
|
}>;
|
|
92
|
-
withdraw(code: string, amount: number, address:
|
|
92
|
+
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
93
93
|
nonce(): number;
|
|
94
94
|
sign(path: any, api?: string, method?: string, params?: {}, headers?: any, body?: any): {
|
|
95
95
|
url: any;
|
|
@@ -88,6 +88,6 @@ export default class wavesexchange extends Exchange {
|
|
|
88
88
|
parseDepositWithdrawFees(response: any, codes?: Strings, currencyIdKey?: any): any;
|
|
89
89
|
fetchDepositWithdrawFees(codes?: Strings, params?: {}): Promise<any>;
|
|
90
90
|
handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
|
91
|
-
withdraw(code: string, amount: number, address:
|
|
91
|
+
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<Transaction>;
|
|
92
92
|
parseTransaction(transaction: any, currency?: Currency): Transaction;
|
|
93
93
|
}
|
package/js/src/wavesexchange.js
CHANGED
|
@@ -69,8 +69,11 @@ export default class wavesexchange extends Exchange {
|
|
|
69
69
|
'fetchOrderBook': true,
|
|
70
70
|
'fetchOrders': true,
|
|
71
71
|
'fetchPosition': false,
|
|
72
|
+
'fetchPositionHistory': false,
|
|
72
73
|
'fetchPositionMode': false,
|
|
73
74
|
'fetchPositions': false,
|
|
75
|
+
'fetchPositionsForSymbol': false,
|
|
76
|
+
'fetchPositionsHistory': false,
|
|
74
77
|
'fetchPositionsRisk': false,
|
|
75
78
|
'fetchPremiumIndexOHLCV': false,
|
|
76
79
|
'fetchTicker': true,
|
package/js/src/wazirx.js
CHANGED
|
@@ -74,8 +74,11 @@ export default class wazirx extends Exchange {
|
|
|
74
74
|
'fetchOrderBook': true,
|
|
75
75
|
'fetchOrders': true,
|
|
76
76
|
'fetchPosition': false,
|
|
77
|
+
'fetchPositionHistory': false,
|
|
77
78
|
'fetchPositionMode': false,
|
|
78
79
|
'fetchPositions': false,
|
|
80
|
+
'fetchPositionsForSymbol': false,
|
|
81
|
+
'fetchPositionsHistory': false,
|
|
79
82
|
'fetchPositionsRisk': false,
|
|
80
83
|
'fetchPremiumIndexOHLCV': false,
|
|
81
84
|
'fetchStatus': true,
|
package/js/src/whitebit.d.ts
CHANGED
|
@@ -38,6 +38,7 @@ export default class whitebit extends Exchange {
|
|
|
38
38
|
editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
|
|
39
39
|
cancelOrder(id: string, symbol?: Str, params?: {}): Promise<any>;
|
|
40
40
|
cancelAllOrders(symbol?: Str, params?: {}): Promise<any>;
|
|
41
|
+
cancelAllOrdersAfter(timeout: Int, params?: {}): Promise<any>;
|
|
41
42
|
parseBalance(response: any): Balances;
|
|
42
43
|
fetchBalance(params?: {}): Promise<Balances>;
|
|
43
44
|
fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
|
|
@@ -65,7 +66,7 @@ export default class whitebit extends Exchange {
|
|
|
65
66
|
toAccount: any;
|
|
66
67
|
status: any;
|
|
67
68
|
};
|
|
68
|
-
withdraw(code: string, amount: number, address:
|
|
69
|
+
withdraw(code: string, amount: number, address: string, tag?: any, params?: {}): Promise<any>;
|
|
69
70
|
parseTransaction(transaction: any, currency?: Currency): Transaction;
|
|
70
71
|
parseTransactionStatus(status: any): string;
|
|
71
72
|
fetchDeposit(id: string, code?: Str, params?: {}): Promise<Transaction>;
|
package/js/src/whitebit.js
CHANGED
|
@@ -32,6 +32,7 @@ export default class whitebit extends Exchange {
|
|
|
32
32
|
'future': false,
|
|
33
33
|
'option': false,
|
|
34
34
|
'cancelAllOrders': true,
|
|
35
|
+
'cancelAllOrdersAfter': true,
|
|
35
36
|
'cancelOrder': true,
|
|
36
37
|
'cancelOrders': false,
|
|
37
38
|
'createOrder': true,
|
|
@@ -1412,6 +1413,47 @@ export default class whitebit extends Exchange {
|
|
|
1412
1413
|
//
|
|
1413
1414
|
return response;
|
|
1414
1415
|
}
|
|
1416
|
+
async cancelAllOrdersAfter(timeout, params = {}) {
|
|
1417
|
+
/**
|
|
1418
|
+
* @method
|
|
1419
|
+
* @name whitebit#cancelAllOrdersAfter
|
|
1420
|
+
* @description dead man's switch, cancel all orders after the given timeout
|
|
1421
|
+
* @see https://docs.whitebit.com/private/http-trade-v4/#sync-kill-switch-timer
|
|
1422
|
+
* @param {number} timeout time in milliseconds, 0 represents cancel the timer
|
|
1423
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
1424
|
+
* @param {string} [params.types] Order types value. Example: "spot", "margin", "futures" or null
|
|
1425
|
+
* @param {string} [params.symbol] symbol unified symbol of the market the order was made in
|
|
1426
|
+
* @returns {object} the api result
|
|
1427
|
+
*/
|
|
1428
|
+
await this.loadMarkets();
|
|
1429
|
+
const symbol = this.safeString(params, 'symbol');
|
|
1430
|
+
if (symbol === undefined) {
|
|
1431
|
+
throw new ArgumentsRequired(this.id + ' cancelAllOrdersAfter() requires a symbol argument in params');
|
|
1432
|
+
}
|
|
1433
|
+
const market = this.market(symbol);
|
|
1434
|
+
params = this.omit(params, 'symbol');
|
|
1435
|
+
const isBiggerThanZero = (timeout > 0);
|
|
1436
|
+
const request = {
|
|
1437
|
+
'market': market['id'],
|
|
1438
|
+
// 'timeout': (timeout > 0) ? this.numberToString (timeout / 1000) : null,
|
|
1439
|
+
};
|
|
1440
|
+
if (isBiggerThanZero) {
|
|
1441
|
+
request['timeout'] = this.numberToString(timeout / 1000);
|
|
1442
|
+
}
|
|
1443
|
+
else {
|
|
1444
|
+
request['timeout'] = 'null';
|
|
1445
|
+
}
|
|
1446
|
+
const response = await this.v4PrivatePostOrderKillSwitch(this.extend(request, params));
|
|
1447
|
+
//
|
|
1448
|
+
// {
|
|
1449
|
+
// "market": "BTC_USDT", // currency market,
|
|
1450
|
+
// "startTime": 1662478154, // now timestamp,
|
|
1451
|
+
// "cancellationTime": 1662478154, // now + timer_value,
|
|
1452
|
+
// "types": ["spot", "margin"]
|
|
1453
|
+
// }
|
|
1454
|
+
//
|
|
1455
|
+
return response;
|
|
1456
|
+
}
|
|
1415
1457
|
parseBalance(response) {
|
|
1416
1458
|
const balanceKeys = Object.keys(response);
|
|
1417
1459
|
const result = {};
|