ccxt 4.0.81 → 4.0.83

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.
Files changed (42) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.js +167 -84
  3. package/dist/ccxt.browser.min.js +3 -3
  4. package/dist/cjs/ccxt.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +0 -1
  6. package/dist/cjs/src/bigone.js +1 -1
  7. package/dist/cjs/src/binance.js +2 -1
  8. package/dist/cjs/src/bitfinex2.js +2 -1
  9. package/dist/cjs/src/bitmart.js +9 -6
  10. package/dist/cjs/src/bittrex.js +14 -1
  11. package/dist/cjs/src/bybit.js +68 -53
  12. package/dist/cjs/src/exmo.js +41 -3
  13. package/dist/cjs/src/gate.js +1 -5
  14. package/dist/cjs/src/kucoin.js +7 -2
  15. package/dist/cjs/src/latoken.js +8 -4
  16. package/dist/cjs/src/lykke.js +2 -1
  17. package/dist/cjs/src/ndax.js +6 -1
  18. package/dist/cjs/src/pro/gate.js +5 -2
  19. package/dist/cjs/src/yobit.js +0 -1
  20. package/js/ccxt.d.ts +1 -1
  21. package/js/ccxt.js +1 -1
  22. package/js/src/abstract/binance.d.ts +1 -0
  23. package/js/src/abstract/binancecoinm.d.ts +1 -0
  24. package/js/src/abstract/binanceus.d.ts +1 -0
  25. package/js/src/abstract/binanceusdm.d.ts +1 -0
  26. package/js/src/base/Exchange.d.ts +0 -1
  27. package/js/src/base/Exchange.js +0 -1
  28. package/js/src/bigone.js +1 -1
  29. package/js/src/binance.js +2 -1
  30. package/js/src/bitfinex2.js +2 -1
  31. package/js/src/bitmart.js +9 -6
  32. package/js/src/bittrex.js +14 -1
  33. package/js/src/bybit.js +68 -53
  34. package/js/src/exmo.js +41 -3
  35. package/js/src/gate.js +1 -5
  36. package/js/src/kucoin.js +7 -2
  37. package/js/src/latoken.js +8 -4
  38. package/js/src/lykke.js +2 -1
  39. package/js/src/ndax.js +6 -1
  40. package/js/src/pro/gate.js +5 -2
  41. package/js/src/yobit.js +0 -1
  42. package/package.json +1 -1
package/dist/cjs/ccxt.js CHANGED
@@ -180,7 +180,7 @@ var woo$1 = require('./src/pro/woo.js');
180
180
 
181
181
  //-----------------------------------------------------------------------------
182
182
  // this is updated by vss.js when building
183
- const version = '4.0.81';
183
+ const version = '4.0.83';
184
184
  Exchange["default"].ccxtVersion = version;
185
185
  const exchanges = {
186
186
  'ace': ace,
@@ -500,7 +500,6 @@ class Exchange {
500
500
  'commonCurrencies': {
501
501
  'XBT': 'BTC',
502
502
  'BCC': 'BCH',
503
- 'BCHABC': 'BCH',
504
503
  'BCHSV': 'BSV',
505
504
  },
506
505
  'precisionMode': DECIMAL_PLACES,
@@ -422,7 +422,6 @@ class bigone extends bigone$1 {
422
422
  networks[networkCode] = {
423
423
  'id': networkId,
424
424
  'network': networkCode,
425
- 'type': type,
426
425
  'margin': undefined,
427
426
  'deposit': deposit,
428
427
  'withdraw': withdraw,
@@ -451,6 +450,7 @@ class bigone extends bigone$1 {
451
450
  'code': code,
452
451
  'info': currency,
453
452
  'name': name,
453
+ 'type': type,
454
454
  'active': undefined,
455
455
  'deposit': currencyDepositEnabled,
456
456
  'withdraw': currencyWithdrawEnabled,
@@ -240,6 +240,7 @@ class binance extends binance$1 {
240
240
  'margin/exchange-small-liability': 0.6667,
241
241
  'margin/exchange-small-liability-history': 0.6667,
242
242
  'margin/next-hourly-interest-rate': 0.6667,
243
+ 'margin/capital-flow': 10,
243
244
  'margin/delist-schedule': 0.6667,
244
245
  'loan/vip/loanable/data': 40,
245
246
  'loan/vip/collateral/data': 40,
@@ -276,7 +277,7 @@ class binance extends binance$1 {
276
277
  'capital/deposit/hisrec': 0.1,
277
278
  'capital/deposit/subAddress': 0.1,
278
279
  'capital/deposit/subHisrec': 0.1,
279
- 'capital/withdraw/history': 0.1,
280
+ 'capital/withdraw/history': 1800,
280
281
  'capital/contract/convertible-coins': 4.0002,
281
282
  'convert/tradeFlow': 20.001,
282
283
  'convert/exchangeInfo': 50,
@@ -699,7 +699,8 @@ class bitfinex2 extends bitfinex2$1 {
699
699
  const label = this.safeValue(indexed['label'], id, []);
700
700
  const name = this.safeString(label, 1);
701
701
  const pool = this.safeValue(indexed['pool'], id, []);
702
- const type = this.safeString(pool, 1);
702
+ const rawType = this.safeString(pool, 1);
703
+ const type = (rawType === undefined) ? 'other' : 'crypto';
703
704
  const feeValues = this.safeValue(indexed['fees'], id, []);
704
705
  const fees = this.safeValue(feeValues, 1, []);
705
706
  const fee = this.safeNumber(fees, 1);
@@ -1470,11 +1470,13 @@ class bitmart extends bitmart$1 {
1470
1470
  request[fromRequest] = start;
1471
1471
  request[toRequest] = Math.min(end, now);
1472
1472
  }
1473
- let method = 'publicGetSpotV1SymbolsKline';
1473
+ let response = undefined;
1474
1474
  if (type === 'swap') {
1475
- method = 'publicGetContractPublicKline';
1475
+ response = await this.publicGetContractPublicKline(this.extend(request, params));
1476
+ }
1477
+ else {
1478
+ response = await this.publicGetSpotQuotationV3Klines(this.extend(request, params));
1476
1479
  }
1477
- const response = await this[method](this.extend(request, params));
1478
1480
  //
1479
1481
  // spot
1480
1482
  //
@@ -1511,8 +1513,7 @@ class bitmart extends bitmart$1 {
1511
1513
  // }
1512
1514
  //
1513
1515
  const data = this.safeValue(response, 'data', {});
1514
- const klines = this.safeValue(data, 'klines', []);
1515
- const ohlcv = (type === 'spot') ? klines : data;
1516
+ const ohlcv = this.safeValue(data, 'klines', data);
1516
1517
  return this.parseOHLCVs(ohlcv, market, timeframe, since, limit);
1517
1518
  }
1518
1519
  async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
@@ -3213,8 +3214,10 @@ class bitmart extends bitmart$1 {
3213
3214
  // {"errno":"OK","message":"INVALID_PARAMETER","code":49998,"trace":"eb5ebb54-23cd-4de2-9064-e090b6c3b2e3","data":null}
3214
3215
  //
3215
3216
  const message = this.safeStringLower(response, 'message');
3217
+ const isErrorMessage = (message !== undefined) && (message !== 'ok') && (message !== 'success');
3216
3218
  const errorCode = this.safeString(response, 'code');
3217
- if (((errorCode !== undefined) && (errorCode !== '1000')) || ((message !== undefined) && (message !== 'ok'))) {
3219
+ const isErrorCode = (errorCode !== undefined) && (errorCode !== '1000');
3220
+ if (isErrorCode || isErrorMessage) {
3218
3221
  const feedback = this.id + ' ' + body;
3219
3222
  this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
3220
3223
  this.throwBroadlyMatchedException(this.exceptions['broad'], errorCode, feedback);
@@ -473,11 +473,24 @@ class bittrex extends bittrex$1 {
473
473
  const precision = this.parseNumber('1e-8'); // default precision, seems exchange has same amount-precision across all pairs in UI too. todo: fix "magic constants"
474
474
  const fee = this.safeNumber(currency, 'txFee'); // todo: redesign
475
475
  const isActive = this.safeString(currency, 'status');
476
+ const coinType = this.safeString(currency, 'coinType');
477
+ let type = undefined;
478
+ if (coinType === 'FIAT') {
479
+ type = 'fiat';
480
+ }
481
+ else if (coinType === 'Award') {
482
+ // these are exchange credits
483
+ type = 'other';
484
+ }
485
+ else {
486
+ // all others are cryptos
487
+ type = 'crypto';
488
+ }
476
489
  result[code] = {
477
490
  'id': id,
478
491
  'code': code,
479
492
  'info': currency,
480
- 'type': this.safeString(currency, 'coinType'),
493
+ 'type': type,
481
494
  'name': this.safeString(currency, 'name'),
482
495
  'active': (isActive === 'ONLINE'),
483
496
  'deposit': undefined,
@@ -3950,11 +3950,11 @@ class bybit extends bybit$1 {
3950
3950
  else if (timeInForce === 'ioc') {
3951
3951
  request['timeInForce'] = 'IOC';
3952
3952
  }
3953
- let triggerPrice = this.safeNumber2(params, 'triggerPrice', 'stopPrice');
3954
- const stopLossTriggerPrice = this.safeNumber(params, 'stopLossPrice');
3955
- const takeProfitTriggerPrice = this.safeNumber(params, 'takeProfitPrice');
3956
- const stopLoss = this.safeNumber(params, 'stopLoss');
3957
- const takeProfit = this.safeNumber(params, 'takeProfit');
3953
+ let triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
3954
+ const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
3955
+ const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
3956
+ const stopLoss = this.safeValue(params, 'stopLoss');
3957
+ const takeProfit = this.safeValue(params, 'takeProfit');
3958
3958
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
3959
3959
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
3960
3960
  const isStopLoss = stopLoss !== undefined;
@@ -3973,15 +3973,20 @@ class bybit extends bybit$1 {
3973
3973
  }
3974
3974
  else if (isStopLoss || isTakeProfit) {
3975
3975
  if (isStopLoss) {
3976
- request['stopLoss'] = this.priceToPrecision(symbol, stopLoss);
3976
+ const stopLossTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
3977
+ request['stopLoss'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
3977
3978
  }
3978
3979
  if (isTakeProfit) {
3979
- request['takeProfit'] = this.priceToPrecision(symbol, takeProfit);
3980
+ const takeProfitTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
3981
+ request['takeProfit'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
3980
3982
  }
3981
3983
  }
3982
3984
  if (market['spot']) {
3983
3985
  // only works for spot market
3984
- if (triggerPrice !== undefined || stopLossTriggerPrice !== undefined || takeProfitTriggerPrice !== undefined || isStopLoss || isTakeProfit) {
3986
+ if (triggerPrice !== undefined) {
3987
+ request['orderFilter'] = 'StopOrder';
3988
+ }
3989
+ else if (stopLossTriggerPrice !== undefined || takeProfitTriggerPrice !== undefined || isStopLoss || isTakeProfit) {
3985
3990
  request['orderFilter'] = 'tpslOrder';
3986
3991
  }
3987
3992
  }
@@ -4160,11 +4165,11 @@ class bybit extends bybit$1 {
4160
4165
  else if (timeInForce === 'ioc') {
4161
4166
  request['timeInForce'] = 'ImmediateOrCancel';
4162
4167
  }
4163
- const triggerPrice = this.safeNumber2(params, 'stopPrice', 'triggerPrice');
4164
- const stopLossTriggerPrice = this.safeNumber(params, 'stopLossPrice', triggerPrice);
4165
- const takeProfitTriggerPrice = this.safeNumber(params, 'takeProfitPrice');
4166
- const stopLoss = this.safeNumber(params, 'stopLoss');
4167
- const takeProfit = this.safeNumber(params, 'takeProfit');
4168
+ const triggerPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
4169
+ const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice', triggerPrice);
4170
+ const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
4171
+ const stopLoss = this.safeValue(params, 'stopLoss');
4172
+ const takeProfit = this.safeValue(params, 'takeProfit');
4168
4173
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
4169
4174
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
4170
4175
  const isStopLoss = stopLoss !== undefined;
@@ -4182,10 +4187,12 @@ class bybit extends bybit$1 {
4182
4187
  }
4183
4188
  else if (isStopLoss || isTakeProfit) {
4184
4189
  if (isStopLoss) {
4185
- request['stopLoss'] = this.priceToPrecision(symbol, stopLoss);
4190
+ const stopLossTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
4191
+ request['stopLoss'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
4186
4192
  }
4187
4193
  if (isTakeProfit) {
4188
- request['takeProfit'] = this.priceToPrecision(symbol, takeProfit);
4194
+ const takeProfitTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
4195
+ request['takeProfit'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
4189
4196
  }
4190
4197
  }
4191
4198
  const clientOrderId = this.safeString(params, 'clientOrderId');
@@ -4265,11 +4272,11 @@ class bybit extends bybit$1 {
4265
4272
  else if (timeInForce === 'ioc') {
4266
4273
  request['timeInForce'] = 'ImmediateOrCancel';
4267
4274
  }
4268
- let triggerPrice = this.safeNumber2(params, 'triggerPrice', 'stopPrice');
4269
- const stopLossTriggerPrice = this.safeNumber(params, 'stopLossPrice', triggerPrice);
4270
- const takeProfitTriggerPrice = this.safeNumber(params, 'takeProfitPrice');
4271
- const stopLoss = this.safeNumber(params, 'stopLoss');
4272
- const takeProfit = this.safeNumber(params, 'takeProfit');
4275
+ let triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
4276
+ const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
4277
+ const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
4278
+ const stopLoss = this.safeValue(params, 'stopLoss');
4279
+ const takeProfit = this.safeValue(params, 'takeProfit');
4273
4280
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
4274
4281
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
4275
4282
  const isStopLoss = stopLoss !== undefined;
@@ -4288,10 +4295,12 @@ class bybit extends bybit$1 {
4288
4295
  }
4289
4296
  else if (isStopLoss || isTakeProfit) {
4290
4297
  if (isStopLoss) {
4291
- request['stopLoss'] = this.priceToPrecision(symbol, stopLoss);
4298
+ const stopLossTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
4299
+ request['stopLoss'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
4292
4300
  }
4293
4301
  if (isTakeProfit) {
4294
- request['takeProfit'] = this.priceToPrecision(symbol, takeProfit);
4302
+ const takeProfitTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
4303
+ request['takeProfit'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
4295
4304
  }
4296
4305
  }
4297
4306
  const clientOrderId = this.safeString(params, 'clientOrderId');
@@ -4368,11 +4377,11 @@ class bybit extends bybit$1 {
4368
4377
  request['time_in_force'] = 'ImmediateOrCancel';
4369
4378
  }
4370
4379
  if (market['swap']) {
4371
- const triggerPrice = this.safeNumber2(params, 'stopPrice', 'triggerPrice');
4372
- const stopLossTriggerPrice = this.safeNumber(params, 'stopLossPrice', triggerPrice);
4373
- const takeProfitTriggerPrice = this.safeNumber(params, 'takeProfitPrice');
4374
- const stopLoss = this.safeNumber(params, 'stopLoss');
4375
- const takeProfit = this.safeNumber(params, 'takeProfit');
4380
+ const triggerPrice = this.safeValue2(params, 'stopPrice', 'triggerPrice');
4381
+ const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice', triggerPrice);
4382
+ const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
4383
+ const stopLoss = this.safeValue(params, 'stopLoss');
4384
+ const takeProfit = this.safeValue(params, 'takeProfit');
4376
4385
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
4377
4386
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
4378
4387
  const isStopLoss = stopLoss !== undefined;
@@ -4389,10 +4398,12 @@ class bybit extends bybit$1 {
4389
4398
  }
4390
4399
  else if (isStopLoss || isTakeProfit) {
4391
4400
  if (isStopLoss) {
4392
- request['stopLoss'] = this.priceToPrecision(symbol, stopLoss);
4401
+ const stopLossTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
4402
+ request['stopLoss'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
4393
4403
  }
4394
4404
  if (isTakeProfit) {
4395
- request['takeProfit'] = this.priceToPrecision(symbol, takeProfit);
4405
+ const takeProfitTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
4406
+ request['takeProfit'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
4396
4407
  }
4397
4408
  }
4398
4409
  else {
@@ -4474,11 +4485,11 @@ class bybit extends bybit$1 {
4474
4485
  if (amount !== undefined) {
4475
4486
  request['qty'] = this.amountToPrecision(symbol, amount);
4476
4487
  }
4477
- let triggerPrice = this.safeNumber2(params, 'triggerPrice', 'stopPrice');
4478
- const stopLossTriggerPrice = this.safeNumber(params, 'stopLossPrice');
4479
- const takeProfitTriggerPrice = this.safeNumber(params, 'takeProfitPrice');
4480
- const stopLoss = this.safeNumber(params, 'stopLoss');
4481
- const takeProfit = this.safeNumber(params, 'takeProfit');
4488
+ let triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
4489
+ const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
4490
+ const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
4491
+ const stopLoss = this.safeValue(params, 'stopLoss');
4492
+ const takeProfit = this.safeValue(params, 'takeProfit');
4482
4493
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
4483
4494
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
4484
4495
  const isStopLoss = stopLoss !== undefined;
@@ -4491,10 +4502,12 @@ class bybit extends bybit$1 {
4491
4502
  }
4492
4503
  if (isStopLoss || isTakeProfit) {
4493
4504
  if (isStopLoss) {
4494
- request['stopLoss'] = this.priceToPrecision(symbol, stopLoss);
4505
+ const stopLossTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
4506
+ request['stopLoss'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
4495
4507
  }
4496
4508
  if (isTakeProfit) {
4497
- request['takeProfit'] = this.priceToPrecision(symbol, takeProfit);
4509
+ const takeProfitTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
4510
+ request['takeProfit'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
4498
4511
  }
4499
4512
  }
4500
4513
  const clientOrderId = this.safeString(params, 'clientOrderId');
@@ -4575,11 +4588,11 @@ class bybit extends bybit$1 {
4575
4588
  else if (timeInForce === 'ioc') {
4576
4589
  request['timeInForce'] = 'ImmediateOrCancel';
4577
4590
  }
4578
- let triggerPrice = this.safeNumber2(params, 'triggerPrice', 'stopPrice');
4579
- const stopLossTriggerPrice = this.safeNumber(params, 'stopLossPrice');
4580
- const takeProfitTriggerPrice = this.safeNumber(params, 'takeProfitPrice');
4581
- const stopLoss = this.safeNumber(params, 'stopLoss');
4582
- const takeProfit = this.safeNumber(params, 'takeProfit');
4591
+ let triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
4592
+ const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
4593
+ const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
4594
+ const stopLoss = this.safeValue(params, 'stopLoss');
4595
+ const takeProfit = this.safeValue(params, 'takeProfit');
4583
4596
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
4584
4597
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
4585
4598
  const isStopLoss = stopLoss !== undefined;
@@ -4592,10 +4605,12 @@ class bybit extends bybit$1 {
4592
4605
  }
4593
4606
  if (isStopLoss || isTakeProfit) {
4594
4607
  if (isStopLoss) {
4595
- request['stopLoss'] = this.priceToPrecision(symbol, stopLoss);
4608
+ const stopLossTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
4609
+ request['stopLoss'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
4596
4610
  }
4597
4611
  if (isTakeProfit) {
4598
- request['takeProfit'] = this.priceToPrecision(symbol, takeProfit);
4612
+ const takeProfitTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
4613
+ request['takeProfit'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
4599
4614
  }
4600
4615
  }
4601
4616
  const clientOrderId = this.safeString(params, 'clientOrderId');
@@ -4637,11 +4652,11 @@ class bybit extends bybit$1 {
4637
4652
  if (amount !== undefined) {
4638
4653
  request['qty'] = this.amountToPrecision(symbol, amount);
4639
4654
  }
4640
- let triggerPrice = this.safeNumber2(params, 'triggerPrice', 'stopPrice');
4641
- const stopLossTriggerPrice = this.safeNumber(params, 'stopLossPrice');
4642
- const takeProfitTriggerPrice = this.safeNumber(params, 'takeProfitPrice');
4643
- const stopLoss = this.safeNumber(params, 'stopLoss');
4644
- const takeProfit = this.safeNumber(params, 'takeProfit');
4655
+ let triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
4656
+ const stopLossTriggerPrice = this.safeValue(params, 'stopLossPrice');
4657
+ const takeProfitTriggerPrice = this.safeValue(params, 'takeProfitPrice');
4658
+ const stopLoss = this.safeValue(params, 'stopLoss');
4659
+ const takeProfit = this.safeValue(params, 'takeProfit');
4645
4660
  const isStopLossTriggerOrder = stopLossTriggerPrice !== undefined;
4646
4661
  const isTakeProfitTriggerOrder = takeProfitTriggerPrice !== undefined;
4647
4662
  const isStopLoss = stopLoss !== undefined;
@@ -4654,10 +4669,12 @@ class bybit extends bybit$1 {
4654
4669
  }
4655
4670
  if (isStopLoss || isTakeProfit) {
4656
4671
  if (isStopLoss) {
4657
- request['stopLoss'] = this.priceToPrecision(symbol, stopLoss);
4672
+ const stopLossTriggerPrice = this.safeValue2(stopLoss, 'triggerPrice', 'stopPrice', stopLoss);
4673
+ request['stopLoss'] = this.priceToPrecision(symbol, stopLossTriggerPrice);
4658
4674
  }
4659
4675
  if (isTakeProfit) {
4660
- request['takeProfit'] = this.priceToPrecision(symbol, takeProfit);
4676
+ const takeProfitTriggerPrice = this.safeValue2(takeProfit, 'triggerPrice', 'stopPrice', takeProfit);
4677
+ request['takeProfit'] = this.priceToPrecision(symbol, takeProfitTriggerPrice);
4661
4678
  }
4662
4679
  }
4663
4680
  const clientOrderId = this.safeString(params, 'clientOrderId');
@@ -4703,9 +4720,7 @@ class bybit extends bybit$1 {
4703
4720
  * @param {object} [params] extra parameters specific to the bybit api endpoint
4704
4721
  * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
4705
4722
  */
4706
- if (symbol === undefined) {
4707
- throw new errors.ArgumentsRequired(this.id + ' editOrder() requires an symbol argument');
4708
- }
4723
+ this.checkRequiredSymbol('editOrder', symbol);
4709
4724
  await this.loadMarkets();
4710
4725
  const market = this.market(symbol);
4711
4726
  const [enableUnifiedMargin, enableUnifiedAccount] = await this.isUnifiedEnabled();
@@ -727,17 +727,55 @@ class exmo extends exmo$1 {
727
727
  // },
728
728
  // }
729
729
  //
730
+ let marginPairsDict = {};
731
+ if (this.checkRequiredCredentials(false)) {
732
+ const marginPairs = await this.privatePostMarginPairList(params);
733
+ //
734
+ // {
735
+ // "pairs": [
736
+ // {
737
+ // "buy_price": "55978.85",
738
+ // "default_leverage": "3",
739
+ // "is_fair_price": true,
740
+ // "last_trade_price": "55999.23",
741
+ // "liquidation_fee": "2",
742
+ // "liquidation_level": "10",
743
+ // "margin_call_level": "15",
744
+ // "max_leverage": "3",
745
+ // "max_order_price": "150000",
746
+ // "max_order_quantity": "1",
747
+ // "max_position_quantity": "1",
748
+ // "max_price_precision": 2,
749
+ // "min_order_price": "1",
750
+ // "min_order_quantity": "0.00002",
751
+ // "name": "BTC_USD",
752
+ // "position": 1,
753
+ // "sell_price": "55985.51",
754
+ // "ticker_updated": "1619019818936107989",
755
+ // "trade_maker_fee": "0",
756
+ // "trade_taker_fee": "0.05",
757
+ // "updated": "1619008608955599013"
758
+ // }
759
+ // ]
760
+ // }
761
+ //
762
+ const pairs = this.safeValue(marginPairs, 'pairs');
763
+ marginPairsDict = this.indexBy(pairs, 'name');
764
+ }
730
765
  const keys = Object.keys(response);
731
766
  const result = [];
732
767
  for (let i = 0; i < keys.length; i++) {
733
768
  const id = keys[i];
734
769
  const market = response[id];
770
+ const marginMarket = this.safeValue(marginPairsDict, id);
735
771
  const symbol = id.replace('_', '/');
736
772
  const [baseId, quoteId] = symbol.split('/');
737
773
  const base = this.safeCurrencyCode(baseId);
738
774
  const quote = this.safeCurrencyCode(quoteId);
739
775
  const takerString = this.safeString(market, 'commission_taker_percent');
740
776
  const makerString = this.safeString(market, 'commission_maker_percent');
777
+ const maxQuantity = this.safeString(market, 'max_quantity');
778
+ const marginMaxQuantity = this.safeString(marginMarket, 'max_order_quantity');
741
779
  result.push({
742
780
  'id': id,
743
781
  'symbol': symbol,
@@ -749,7 +787,7 @@ class exmo extends exmo$1 {
749
787
  'settleId': undefined,
750
788
  'type': 'spot',
751
789
  'spot': true,
752
- 'margin': true,
790
+ 'margin': marginMarket !== undefined,
753
791
  'swap': false,
754
792
  'future': false,
755
793
  'option': false,
@@ -771,11 +809,11 @@ class exmo extends exmo$1 {
771
809
  'limits': {
772
810
  'leverage': {
773
811
  'min': undefined,
774
- 'max': undefined,
812
+ 'max': this.safeNumber(market, 'leverage'),
775
813
  },
776
814
  'amount': {
777
815
  'min': this.safeNumber(market, 'min_quantity'),
778
- 'max': this.safeNumber(market, 'max_quantity'),
816
+ 'max': this.parseNumber(Precise["default"].stringMax(maxQuantity, marginMaxQuantity)),
779
817
  },
780
818
  'price': {
781
819
  'min': this.safeNumber(market, 'min_price'),
@@ -4155,7 +4155,6 @@ class gate extends gate$1 {
4155
4155
  let remainingString = this.safeString(order, 'left');
4156
4156
  let cost = this.safeString(order, 'filled_total');
4157
4157
  const triggerPrice = this.safeNumber(trigger, 'price');
4158
- let rawStatus = undefined;
4159
4158
  let average = this.safeNumber2(order, 'avg_deal_price', 'fill_price');
4160
4159
  if (triggerPrice) {
4161
4160
  remainingString = amount;
@@ -4165,11 +4164,8 @@ class gate extends gate$1 {
4165
4164
  const isMarketOrder = Precise["default"].stringEquals(price, '0') && (timeInForce === 'IOC');
4166
4165
  type = isMarketOrder ? 'market' : 'limit';
4167
4166
  side = Precise["default"].stringGt(amount, '0') ? 'buy' : 'sell';
4168
- rawStatus = this.safeString(order, 'finish_as', 'open');
4169
- }
4170
- else {
4171
- rawStatus = this.safeString(order, 'status');
4172
4167
  }
4168
+ const rawStatus = this.safeStringN(order, ['status', 'finish_as', 'open']);
4173
4169
  let timestamp = this.safeInteger(order, 'create_time_ms');
4174
4170
  if (timestamp === undefined) {
4175
4171
  timestamp = this.safeTimestamp2(order, 'create_time', 'ctime');
@@ -1079,8 +1079,10 @@ class kucoin extends kucoin$1 {
1079
1079
  const networks = {};
1080
1080
  const chains = this.safeValue(entry, 'chains', []);
1081
1081
  const extraChainsData = this.indexBy(this.safeValue(additionalDataGrouped, id, []), 'chain');
1082
- const precision = this.parseNumber(this.parsePrecision(this.safeString(entry, 'precision')));
1083
- for (let j = 0; j < chains.length; j++) {
1082
+ const rawPrecision = this.safeString(entry, 'precision');
1083
+ const precision = this.parseNumber(this.parsePrecision(rawPrecision));
1084
+ const chainsLength = chains.length;
1085
+ for (let j = 0; j < chainsLength; j++) {
1084
1086
  const chain = chains[j];
1085
1087
  const chainId = this.safeString(chain, 'chain');
1086
1088
  const networkCode = this.networkIdToCode(chainId);
@@ -1121,10 +1123,13 @@ class kucoin extends kucoin$1 {
1121
1123
  },
1122
1124
  };
1123
1125
  }
1126
+ // kucoin has determined 'fiat' currencies with below logic
1127
+ const isFiat = (rawPrecision === '2') && (chainsLength === 0);
1124
1128
  result[code] = {
1125
1129
  'id': id,
1126
1130
  'name': name,
1127
1131
  'code': code,
1132
+ 'type': isFiat ? 'fiat' : 'crypto',
1128
1133
  'precision': precision,
1129
1134
  'info': entry,
1130
1135
  'active': (isDepositEnabled || isWithdrawEnabled),
@@ -430,10 +430,14 @@ class latoken extends latoken$1 {
430
430
  const code = this.safeCurrencyCode(tag);
431
431
  const fee = this.safeNumber(currency, 'fee');
432
432
  const currencyType = this.safeString(currency, 'type');
433
- const parts = currencyType.split('_');
434
- const numParts = parts.length;
435
- const lastPart = this.safeValue(parts, numParts - 1);
436
- const type = lastPart.toLowerCase();
433
+ let type = undefined;
434
+ if (currencyType === 'CURRENCY_TYPE_ALTERNATIVE') {
435
+ type = 'other';
436
+ }
437
+ else {
438
+ // CURRENCY_TYPE_CRYPTO and CURRENCY_TYPE_IEO are all cryptos
439
+ type = 'crypto';
440
+ }
437
441
  const status = this.safeString(currency, 'status');
438
442
  const active = (status === 'CURRENCY_STATUS_ACTIVE');
439
443
  const name = this.safeString(currency, 'name');
@@ -223,7 +223,8 @@ class lykke extends lykke$1 {
223
223
  const id = this.safeString(currency, 'assetId');
224
224
  const code = this.safeString(currency, 'symbol');
225
225
  const name = this.safeString(currency, 'name');
226
- const type = this.safeString(currency, 'type');
226
+ const rawType = this.safeString(currency, 'type');
227
+ const type = (rawType === 'erc20Token') ? 'crypto' : 'other';
227
228
  const deposit = this.safeValue(currency, 'blockchainDepositEnabled');
228
229
  const withdraw = this.safeValue(currency, 'blockchainWithdrawal');
229
230
  const isDisabled = this.safeValue(currency, 'isDisabled');
@@ -359,7 +359,12 @@ class ndax extends ndax$1 {
359
359
  const currency = response[i];
360
360
  const id = this.safeString(currency, 'ProductId');
361
361
  const name = this.safeString(currency, 'ProductFullName');
362
- const type = this.safeString(currency, 'ProductType');
362
+ const ProductType = this.safeString(currency, 'ProductType');
363
+ let type = (ProductType === 'NationalCurrency') ? 'fiat' : 'crypto';
364
+ if (ProductType === 'Unknown') {
365
+ // such currency is just a blanket entry
366
+ type = 'other';
367
+ }
363
368
  const code = this.safeCurrencyCode(this.safeString(currency, 'Product'));
364
369
  const isDisabled = this.safeValue(currency, 'IsDisabled');
365
370
  const active = !isDisabled;
@@ -822,8 +822,11 @@ class gate extends gate$1 {
822
822
  parsed['status'] = 'open';
823
823
  }
824
824
  else if (event === 'finish') {
825
- const left = this.safeNumber(info, 'left');
826
- parsed['status'] = (left === 0) ? 'closed' : 'canceled';
825
+ const status = this.safeString(parsed, 'status');
826
+ if (status === undefined) {
827
+ const left = this.safeNumber(info, 'left');
828
+ parsed['status'] = (left === 0) ? 'closed' : 'canceled';
829
+ }
827
830
  }
828
831
  stored.append(parsed);
829
832
  const symbol = parsed['symbol'];
@@ -206,7 +206,6 @@ class yobit extends yobit$1 {
206
206
  'PAC': '$PAC',
207
207
  'PLAY': 'PlayCoin',
208
208
  'PIVX': 'Darknet',
209
- 'PRS': 'PRE',
210
209
  'PURE': 'PurePOS',
211
210
  'PUTIN': 'PutinCoin',
212
211
  'SPACE': 'Spacecoin',
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending } from './src/base/errors.js';
7
- declare const version = "4.0.80";
7
+ declare const version = "4.0.82";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.0.81';
41
+ const version = '4.0.83';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -47,6 +47,7 @@ interface Exchange {
47
47
  sapiGetMarginExchangeSmallLiability(params?: {}): Promise<implicitReturnType>;
48
48
  sapiGetMarginExchangeSmallLiabilityHistory(params?: {}): Promise<implicitReturnType>;
49
49
  sapiGetMarginNextHourlyInterestRate(params?: {}): Promise<implicitReturnType>;
50
+ sapiGetMarginCapitalFlow(params?: {}): Promise<implicitReturnType>;
50
51
  sapiGetMarginDelistSchedule(params?: {}): Promise<implicitReturnType>;
51
52
  sapiGetLoanVipLoanableData(params?: {}): Promise<implicitReturnType>;
52
53
  sapiGetLoanVipCollateralData(params?: {}): Promise<implicitReturnType>;
@@ -47,6 +47,7 @@ interface binance {
47
47
  sapiGetMarginExchangeSmallLiability(params?: {}): Promise<implicitReturnType>;
48
48
  sapiGetMarginExchangeSmallLiabilityHistory(params?: {}): Promise<implicitReturnType>;
49
49
  sapiGetMarginNextHourlyInterestRate(params?: {}): Promise<implicitReturnType>;
50
+ sapiGetMarginCapitalFlow(params?: {}): Promise<implicitReturnType>;
50
51
  sapiGetMarginDelistSchedule(params?: {}): Promise<implicitReturnType>;
51
52
  sapiGetLoanVipLoanableData(params?: {}): Promise<implicitReturnType>;
52
53
  sapiGetLoanVipCollateralData(params?: {}): Promise<implicitReturnType>;
@@ -47,6 +47,7 @@ interface binance {
47
47
  sapiGetMarginExchangeSmallLiability(params?: {}): Promise<implicitReturnType>;
48
48
  sapiGetMarginExchangeSmallLiabilityHistory(params?: {}): Promise<implicitReturnType>;
49
49
  sapiGetMarginNextHourlyInterestRate(params?: {}): Promise<implicitReturnType>;
50
+ sapiGetMarginCapitalFlow(params?: {}): Promise<implicitReturnType>;
50
51
  sapiGetMarginDelistSchedule(params?: {}): Promise<implicitReturnType>;
51
52
  sapiGetLoanVipLoanableData(params?: {}): Promise<implicitReturnType>;
52
53
  sapiGetLoanVipCollateralData(params?: {}): Promise<implicitReturnType>;