ccxt 4.3.3 → 4.3.5

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.
@@ -359,35 +359,55 @@ export default class Exchange {
359
359
  'cancelAllOrders': undefined,
360
360
  'cancelAllOrdersWs': undefined,
361
361
  'cancelOrder': true,
362
+ 'cancelOrderWs': undefined,
362
363
  'cancelOrders': undefined,
363
364
  'cancelOrdersWs': undefined,
364
- 'cancelOrderWs': undefined,
365
365
  'closeAllPositions': undefined,
366
366
  'closePosition': undefined,
367
367
  'createDepositAddress': undefined,
368
368
  'createLimitBuyOrder': undefined,
369
+ 'createLimitBuyOrderWs': undefined,
369
370
  'createLimitOrder': true,
371
+ 'createLimitOrderWs': undefined,
370
372
  'createLimitSellOrder': undefined,
373
+ 'createLimitSellOrderWs': undefined,
371
374
  'createMarketBuyOrder': undefined,
375
+ 'createMarketBuyOrderWs': undefined,
372
376
  'createMarketBuyOrderWithCost': undefined,
377
+ 'createMarketBuyOrderWithCostWs': undefined,
373
378
  'createMarketOrder': true,
379
+ 'createMarketOrderWs': true,
374
380
  'createMarketOrderWithCost': undefined,
381
+ 'createMarketOrderWithCostWs': undefined,
375
382
  'createMarketSellOrder': undefined,
383
+ 'createMarketSellOrderWs': undefined,
376
384
  'createMarketSellOrderWithCost': undefined,
385
+ 'createMarketSellOrderWithCostWs': undefined,
377
386
  'createOrder': true,
387
+ 'createOrderWs': undefined,
378
388
  'createOrders': undefined,
379
389
  'createOrderWithTakeProfitAndStopLoss': undefined,
380
- 'createOrderWs': undefined,
390
+ 'createOrderWithTakeProfitAndStopLossWs': undefined,
381
391
  'createPostOnlyOrder': undefined,
392
+ 'createPostOnlyOrderWs': undefined,
382
393
  'createReduceOnlyOrder': undefined,
394
+ 'createReduceOnlyOrderWs': undefined,
383
395
  'createStopLimitOrder': undefined,
396
+ 'createStopLimitOrderWs': undefined,
384
397
  'createStopLossOrder': undefined,
398
+ 'createStopLossOrderWs': undefined,
385
399
  'createStopMarketOrder': undefined,
400
+ 'createStopMarketOrderWs': undefined,
386
401
  'createStopOrder': undefined,
402
+ 'createStopOrderWs': undefined,
387
403
  'createTakeProfitOrder': undefined,
404
+ 'createTakeProfitOrderWs': undefined,
388
405
  'createTrailingAmountOrder': undefined,
406
+ 'createTrailingAmountOrderWs': undefined,
389
407
  'createTrailingPercentOrder': undefined,
408
+ 'createTrailingPercentOrderWs': undefined,
390
409
  'createTriggerOrder': undefined,
410
+ 'createTriggerOrderWs': undefined,
391
411
  'deposit': undefined,
392
412
  'editOrder': 'emulated',
393
413
  'editOrderWs': undefined,
@@ -470,16 +490,20 @@ export default class Exchange {
470
490
  'fetchOrderWs': undefined,
471
491
  'fetchPermissions': undefined,
472
492
  'fetchPosition': undefined,
493
+ 'fetchPositionWs': undefined,
473
494
  'fetchPositionMode': undefined,
474
495
  'fetchPositions': undefined,
496
+ 'fetchPositionsWs': undefined,
475
497
  'fetchPositionsForSymbol': undefined,
498
+ 'fetchPositionsForSymbolWs': undefined,
476
499
  'fetchPositionsRisk': undefined,
477
500
  'fetchPremiumIndexOHLCV': undefined,
478
501
  'fetchSettlementHistory': undefined,
479
502
  'fetchStatus': undefined,
480
503
  'fetchTicker': true,
481
- 'fetchTickers': undefined,
482
504
  'fetchTickerWs': undefined,
505
+ 'fetchTickers': undefined,
506
+ 'fetchTickersWs': undefined,
483
507
  'fetchTime': undefined,
484
508
  'fetchTrades': true,
485
509
  'fetchTradesWs': undefined,
@@ -3771,6 +3795,9 @@ export default class Exchange {
3771
3795
  async fetchPosition(symbol, params = {}) {
3772
3796
  throw new NotSupported(this.id + ' fetchPosition() is not supported yet');
3773
3797
  }
3798
+ async fetchPositionWs(symbol, params = {}) {
3799
+ throw new NotSupported(this.id + ' fetchPositionWs() is not supported yet');
3800
+ }
3774
3801
  async watchPosition(symbol = undefined, params = {}) {
3775
3802
  throw new NotSupported(this.id + ' watchPosition() is not supported yet');
3776
3803
  }
@@ -3791,9 +3818,23 @@ export default class Exchange {
3791
3818
  */
3792
3819
  throw new NotSupported(this.id + ' fetchPositionsForSymbol() is not supported yet');
3793
3820
  }
3821
+ async fetchPositionsForSymbolWs(symbol, params = {}) {
3822
+ /**
3823
+ * @method
3824
+ * @name exchange#fetchPositionsForSymbol
3825
+ * @description fetches all open positions for specific symbol, unlike fetchPositions (which is designed to work with multiple symbols) so this method might be preffered for one-market position, because of less rate-limit consumption and speed
3826
+ * @param {string} symbol unified market symbol
3827
+ * @param {object} params extra parameters specific to the endpoint
3828
+ * @returns {object[]} a list of [position structure]{@link https://docs.ccxt.com/#/?id=position-structure} with maximum 3 items - possible one position for "one-way" mode, and possible two positions (long & short) for "two-way" (a.k.a. hedge) mode
3829
+ */
3830
+ throw new NotSupported(this.id + ' fetchPositionsForSymbol() is not supported yet');
3831
+ }
3794
3832
  async fetchPositions(symbols = undefined, params = {}) {
3795
3833
  throw new NotSupported(this.id + ' fetchPositions() is not supported yet');
3796
3834
  }
3835
+ async fetchPositionsWs(symbols = undefined, params = {}) {
3836
+ throw new NotSupported(this.id + ' fetchPositions() is not supported yet');
3837
+ }
3797
3838
  async fetchPositionsRisk(symbols = undefined, params = {}) {
3798
3839
  throw new NotSupported(this.id + ' fetchPositionsRisk() is not supported yet');
3799
3840
  }
@@ -4170,12 +4211,33 @@ export default class Exchange {
4170
4211
  throw new NotSupported(this.id + ' fetchTicker() is not supported yet');
4171
4212
  }
4172
4213
  }
4214
+ async fetchTickerWs(symbol, params = {}) {
4215
+ if (this.has['fetchTickersWs']) {
4216
+ await this.loadMarkets();
4217
+ const market = this.market(symbol);
4218
+ symbol = market['symbol'];
4219
+ const tickers = await this.fetchTickerWs(symbol, params);
4220
+ const ticker = this.safeDict(tickers, symbol);
4221
+ if (ticker === undefined) {
4222
+ throw new NullResponse(this.id + ' fetchTickers() could not find a ticker for ' + symbol);
4223
+ }
4224
+ else {
4225
+ return ticker;
4226
+ }
4227
+ }
4228
+ else {
4229
+ throw new NotSupported(this.id + ' fetchTicker() is not supported yet');
4230
+ }
4231
+ }
4173
4232
  async watchTicker(symbol, params = {}) {
4174
4233
  throw new NotSupported(this.id + ' watchTicker() is not supported yet');
4175
4234
  }
4176
4235
  async fetchTickers(symbols = undefined, params = {}) {
4177
4236
  throw new NotSupported(this.id + ' fetchTickers() is not supported yet');
4178
4237
  }
4238
+ async fetchTickersWs(symbols = undefined, params = {}) {
4239
+ throw new NotSupported(this.id + ' fetchTickers() is not supported yet');
4240
+ }
4179
4241
  async fetchOrderBooks(symbols = undefined, limit = undefined, params = {}) {
4180
4242
  throw new NotSupported(this.id + ' fetchOrderBooks() is not supported yet');
4181
4243
  }
@@ -4230,6 +4292,33 @@ export default class Exchange {
4230
4292
  }
4231
4293
  throw new NotSupported(this.id + ' createTrailingAmountOrder() is not supported yet');
4232
4294
  }
4295
+ async createTrailingAmountOrderWs(symbol, type, side, amount, price = undefined, trailingAmount = undefined, trailingTriggerPrice = undefined, params = {}) {
4296
+ /**
4297
+ * @method
4298
+ * @name createTrailingAmountOrderWs
4299
+ * @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
4300
+ * @param {string} symbol unified symbol of the market to create an order in
4301
+ * @param {string} type 'market' or 'limit'
4302
+ * @param {string} side 'buy' or 'sell'
4303
+ * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
4304
+ * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
4305
+ * @param {float} trailingAmount the quote amount to trail away from the current market price
4306
+ * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
4307
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4308
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4309
+ */
4310
+ if (trailingAmount === undefined) {
4311
+ throw new ArgumentsRequired(this.id + ' createTrailingAmountOrderWs() requires a trailingAmount argument');
4312
+ }
4313
+ params['trailingAmount'] = trailingAmount;
4314
+ if (trailingTriggerPrice !== undefined) {
4315
+ params['trailingTriggerPrice'] = trailingTriggerPrice;
4316
+ }
4317
+ if (this.has['createTrailingAmountOrderWs']) {
4318
+ return await this.createOrderWs(symbol, type, side, amount, price, params);
4319
+ }
4320
+ throw new NotSupported(this.id + ' createTrailingAmountOrderWs() is not supported yet');
4321
+ }
4233
4322
  async createTrailingPercentOrder(symbol, type, side, amount, price = undefined, trailingPercent = undefined, trailingTriggerPrice = undefined, params = {}) {
4234
4323
  /**
4235
4324
  * @method
@@ -4257,6 +4346,33 @@ export default class Exchange {
4257
4346
  }
4258
4347
  throw new NotSupported(this.id + ' createTrailingPercentOrder() is not supported yet');
4259
4348
  }
4349
+ async createTrailingPercentOrderWs(symbol, type, side, amount, price = undefined, trailingPercent = undefined, trailingTriggerPrice = undefined, params = {}) {
4350
+ /**
4351
+ * @method
4352
+ * @name createTrailingPercentOrderWs
4353
+ * @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
4354
+ * @param {string} symbol unified symbol of the market to create an order in
4355
+ * @param {string} type 'market' or 'limit'
4356
+ * @param {string} side 'buy' or 'sell'
4357
+ * @param {float} amount how much you want to trade in units of the base currency, or number of contracts
4358
+ * @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
4359
+ * @param {float} trailingPercent the percent to trail away from the current market price
4360
+ * @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
4361
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4362
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4363
+ */
4364
+ if (trailingPercent === undefined) {
4365
+ throw new ArgumentsRequired(this.id + ' createTrailingPercentOrderWs() requires a trailingPercent argument');
4366
+ }
4367
+ params['trailingPercent'] = trailingPercent;
4368
+ if (trailingTriggerPrice !== undefined) {
4369
+ params['trailingTriggerPrice'] = trailingTriggerPrice;
4370
+ }
4371
+ if (this.has['createTrailingPercentOrderWs']) {
4372
+ return await this.createOrderWs(symbol, type, side, amount, price, params);
4373
+ }
4374
+ throw new NotSupported(this.id + ' createTrailingPercentOrderWs() is not supported yet');
4375
+ }
4260
4376
  async createMarketOrderWithCost(symbol, side, cost, params = {}) {
4261
4377
  /**
4262
4378
  * @method
@@ -4303,6 +4419,22 @@ export default class Exchange {
4303
4419
  }
4304
4420
  throw new NotSupported(this.id + ' createMarketSellOrderWithCost() is not supported yet');
4305
4421
  }
4422
+ async createMarketOrderWithCostWs(symbol, side, cost, params = {}) {
4423
+ /**
4424
+ * @method
4425
+ * @name createMarketOrderWithCostWs
4426
+ * @description create a market order by providing the symbol, side and cost
4427
+ * @param {string} symbol unified symbol of the market to create an order in
4428
+ * @param {string} side 'buy' or 'sell'
4429
+ * @param {float} cost how much you want to trade in units of the quote currency
4430
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4431
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4432
+ */
4433
+ if (this.has['createMarketOrderWithCostWs'] || (this.has['createMarketBuyOrderWithCostWs'] && this.has['createMarketSellOrderWithCostWs'])) {
4434
+ return await this.createOrderWs(symbol, 'market', side, cost, 1, params);
4435
+ }
4436
+ throw new NotSupported(this.id + ' createMarketOrderWithCostWs() is not supported yet');
4437
+ }
4306
4438
  async createTriggerOrder(symbol, type, side, amount, price = undefined, triggerPrice = undefined, params = {}) {
4307
4439
  /**
4308
4440
  * @method
@@ -4326,6 +4458,29 @@ export default class Exchange {
4326
4458
  }
4327
4459
  throw new NotSupported(this.id + ' createTriggerOrder() is not supported yet');
4328
4460
  }
4461
+ async createTriggerOrderWs(symbol, type, side, amount, price = undefined, triggerPrice = undefined, params = {}) {
4462
+ /**
4463
+ * @method
4464
+ * @name createTriggerOrderWs
4465
+ * @description create a trigger stop order (type 1)
4466
+ * @param {string} symbol unified symbol of the market to create an order in
4467
+ * @param {string} type 'market' or 'limit'
4468
+ * @param {string} side 'buy' or 'sell'
4469
+ * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
4470
+ * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
4471
+ * @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
4472
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4473
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4474
+ */
4475
+ if (triggerPrice === undefined) {
4476
+ throw new ArgumentsRequired(this.id + ' createTriggerOrderWs() requires a triggerPrice argument');
4477
+ }
4478
+ params['triggerPrice'] = triggerPrice;
4479
+ if (this.has['createTriggerOrderWs']) {
4480
+ return await this.createOrderWs(symbol, type, side, amount, price, params);
4481
+ }
4482
+ throw new NotSupported(this.id + ' createTriggerOrderWs() is not supported yet');
4483
+ }
4329
4484
  async createStopLossOrder(symbol, type, side, amount, price = undefined, stopLossPrice = undefined, params = {}) {
4330
4485
  /**
4331
4486
  * @method
@@ -4349,6 +4504,29 @@ export default class Exchange {
4349
4504
  }
4350
4505
  throw new NotSupported(this.id + ' createStopLossOrder() is not supported yet');
4351
4506
  }
4507
+ async createStopLossOrderWs(symbol, type, side, amount, price = undefined, stopLossPrice = undefined, params = {}) {
4508
+ /**
4509
+ * @method
4510
+ * @name createStopLossOrderWs
4511
+ * @description create a trigger stop loss order (type 2)
4512
+ * @param {string} symbol unified symbol of the market to create an order in
4513
+ * @param {string} type 'market' or 'limit'
4514
+ * @param {string} side 'buy' or 'sell'
4515
+ * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
4516
+ * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
4517
+ * @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
4518
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4519
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4520
+ */
4521
+ if (stopLossPrice === undefined) {
4522
+ throw new ArgumentsRequired(this.id + ' createStopLossOrderWs() requires a stopLossPrice argument');
4523
+ }
4524
+ params['stopLossPrice'] = stopLossPrice;
4525
+ if (this.has['createStopLossOrderWs']) {
4526
+ return await this.createOrderWs(symbol, type, side, amount, price, params);
4527
+ }
4528
+ throw new NotSupported(this.id + ' createStopLossOrderWs() is not supported yet');
4529
+ }
4352
4530
  async createTakeProfitOrder(symbol, type, side, amount, price = undefined, takeProfitPrice = undefined, params = {}) {
4353
4531
  /**
4354
4532
  * @method
@@ -4372,6 +4550,29 @@ export default class Exchange {
4372
4550
  }
4373
4551
  throw new NotSupported(this.id + ' createTakeProfitOrder() is not supported yet');
4374
4552
  }
4553
+ async createTakeProfitOrderWs(symbol, type, side, amount, price = undefined, takeProfitPrice = undefined, params = {}) {
4554
+ /**
4555
+ * @method
4556
+ * @name createTakeProfitOrderWs
4557
+ * @description create a trigger take profit order (type 2)
4558
+ * @param {string} symbol unified symbol of the market to create an order in
4559
+ * @param {string} type 'market' or 'limit'
4560
+ * @param {string} side 'buy' or 'sell'
4561
+ * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
4562
+ * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
4563
+ * @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
4564
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4565
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4566
+ */
4567
+ if (takeProfitPrice === undefined) {
4568
+ throw new ArgumentsRequired(this.id + ' createTakeProfitOrderWs() requires a takeProfitPrice argument');
4569
+ }
4570
+ params['takeProfitPrice'] = takeProfitPrice;
4571
+ if (this.has['createTakeProfitOrderWs']) {
4572
+ return await this.createOrderWs(symbol, type, side, amount, price, params);
4573
+ }
4574
+ throw new NotSupported(this.id + ' createTakeProfitOrderWs() is not supported yet');
4575
+ }
4375
4576
  async createOrderWithTakeProfitAndStopLoss(symbol, type, side, amount, price = undefined, takeProfit = undefined, stopLoss = undefined, params = {}) {
4376
4577
  /**
4377
4578
  * @method
@@ -4395,6 +4596,13 @@ export default class Exchange {
4395
4596
  * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
4396
4597
  * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4397
4598
  */
4599
+ params = this.setTakeProfitAndStopLossParams(symbol, type, side, amount, price, takeProfit, stopLoss, params);
4600
+ if (this.has['createOrderWithTakeProfitAndStopLoss']) {
4601
+ return await this.createOrder(symbol, type, side, amount, price, params);
4602
+ }
4603
+ throw new NotSupported(this.id + ' createOrderWithTakeProfitAndStopLoss() is not supported yet');
4604
+ }
4605
+ setTakeProfitAndStopLossParams(symbol, type, side, amount, price = undefined, takeProfit = undefined, stopLoss = undefined, params = {}) {
4398
4606
  if ((takeProfit === undefined) && (stopLoss === undefined)) {
4399
4607
  throw new ArgumentsRequired(this.id + ' createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument');
4400
4608
  }
@@ -4441,10 +4649,36 @@ export default class Exchange {
4441
4649
  params['stopLoss']['amount'] = this.parseToNumeric(stopLossAmount);
4442
4650
  }
4443
4651
  params = this.omit(params, ['takeProfitType', 'takeProfitPriceType', 'takeProfitLimitPrice', 'takeProfitAmount', 'stopLossType', 'stopLossPriceType', 'stopLossLimitPrice', 'stopLossAmount']);
4444
- if (this.has['createOrderWithTakeProfitAndStopLoss']) {
4445
- return await this.createOrder(symbol, type, side, amount, price, params);
4652
+ return params;
4653
+ }
4654
+ async createOrderWithTakeProfitAndStopLossWs(symbol, type, side, amount, price = undefined, takeProfit = undefined, stopLoss = undefined, params = {}) {
4655
+ /**
4656
+ * @method
4657
+ * @name createOrderWithTakeProfitAndStopLossWs
4658
+ * @description create an order with a stop loss or take profit attached (type 3)
4659
+ * @param {string} symbol unified symbol of the market to create an order in
4660
+ * @param {string} type 'market' or 'limit'
4661
+ * @param {string} side 'buy' or 'sell'
4662
+ * @param {float} amount how much you want to trade in units of the base currency or the number of contracts
4663
+ * @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
4664
+ * @param {float} [takeProfit] the take profit price, in units of the quote currency
4665
+ * @param {float} [stopLoss] the stop loss price, in units of the quote currency
4666
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4667
+ * @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
4668
+ * @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
4669
+ * @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
4670
+ * @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
4671
+ * @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
4672
+ * @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
4673
+ * @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
4674
+ * @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
4675
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4676
+ */
4677
+ params = this.setTakeProfitAndStopLossParams(symbol, type, side, amount, price, takeProfit, stopLoss, params);
4678
+ if (this.has['createOrderWithTakeProfitAndStopLossWs']) {
4679
+ return await this.createOrderWs(symbol, type, side, amount, price, params);
4446
4680
  }
4447
- throw new NotSupported(this.id + ' createOrderWithTakeProfitAndStopLoss() is not supported yet');
4681
+ throw new NotSupported(this.id + ' createOrderWithTakeProfitAndStopLossWs() is not supported yet');
4448
4682
  }
4449
4683
  async createOrders(orders, params = {}) {
4450
4684
  throw new NotSupported(this.id + ' createOrders() is not supported yet');
@@ -4686,21 +4920,39 @@ export default class Exchange {
4686
4920
  async createLimitOrder(symbol, side, amount, price, params = {}) {
4687
4921
  return await this.createOrder(symbol, 'limit', side, amount, price, params);
4688
4922
  }
4923
+ async createLimitOrderWs(symbol, side, amount, price, params = {}) {
4924
+ return await this.createOrderWs(symbol, 'limit', side, amount, price, params);
4925
+ }
4689
4926
  async createMarketOrder(symbol, side, amount, price = undefined, params = {}) {
4690
4927
  return await this.createOrder(symbol, 'market', side, amount, price, params);
4691
4928
  }
4929
+ async createMarketOrderWs(symbol, side, amount, price = undefined, params = {}) {
4930
+ return await this.createOrderWs(symbol, 'market', side, amount, price, params);
4931
+ }
4692
4932
  async createLimitBuyOrder(symbol, amount, price, params = {}) {
4693
4933
  return await this.createOrder(symbol, 'limit', 'buy', amount, price, params);
4694
4934
  }
4935
+ async createLimitBuyOrderWs(symbol, amount, price, params = {}) {
4936
+ return await this.createOrderWs(symbol, 'limit', 'buy', amount, price, params);
4937
+ }
4695
4938
  async createLimitSellOrder(symbol, amount, price, params = {}) {
4696
4939
  return await this.createOrder(symbol, 'limit', 'sell', amount, price, params);
4697
4940
  }
4941
+ async createLimitSellOrderWs(symbol, amount, price, params = {}) {
4942
+ return await this.createOrderWs(symbol, 'limit', 'sell', amount, price, params);
4943
+ }
4698
4944
  async createMarketBuyOrder(symbol, amount, params = {}) {
4699
4945
  return await this.createOrder(symbol, 'market', 'buy', amount, undefined, params);
4700
4946
  }
4947
+ async createMarketBuyOrderWs(symbol, amount, params = {}) {
4948
+ return await this.createOrderWs(symbol, 'market', 'buy', amount, undefined, params);
4949
+ }
4701
4950
  async createMarketSellOrder(symbol, amount, params = {}) {
4702
4951
  return await this.createOrder(symbol, 'market', 'sell', amount, undefined, params);
4703
4952
  }
4953
+ async createMarketSellOrderWs(symbol, amount, params = {}) {
4954
+ return await this.createOrderWs(symbol, 'market', 'sell', amount, undefined, params);
4955
+ }
4704
4956
  costToPrecision(symbol, cost) {
4705
4957
  const market = this.market(symbol);
4706
4958
  return this.decimalToPrecision(cost, TRUNCATE, market['precision']['price'], this.precisionMode, this.paddingMode);
@@ -4836,6 +5088,13 @@ export default class Exchange {
4836
5088
  const query = this.extend(params, { 'postOnly': true });
4837
5089
  return await this.createOrder(symbol, type, side, amount, price, query);
4838
5090
  }
5091
+ async createPostOnlyOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
5092
+ if (!this.has['createPostOnlyOrderWs']) {
5093
+ throw new NotSupported(this.id + 'createPostOnlyOrderWs() is not supported yet');
5094
+ }
5095
+ const query = this.extend(params, { 'postOnly': true });
5096
+ return await this.createOrderWs(symbol, type, side, amount, price, query);
5097
+ }
4839
5098
  async createReduceOnlyOrder(symbol, type, side, amount, price = undefined, params = {}) {
4840
5099
  if (!this.has['createReduceOnlyOrder']) {
4841
5100
  throw new NotSupported(this.id + 'createReduceOnlyOrder() is not supported yet');
@@ -4843,6 +5102,13 @@ export default class Exchange {
4843
5102
  const query = this.extend(params, { 'reduceOnly': true });
4844
5103
  return await this.createOrder(symbol, type, side, amount, price, query);
4845
5104
  }
5105
+ async createReduceOnlyOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
5106
+ if (!this.has['createReduceOnlyOrderWs']) {
5107
+ throw new NotSupported(this.id + 'createReduceOnlyOrderWs() is not supported yet');
5108
+ }
5109
+ const query = this.extend(params, { 'reduceOnly': true });
5110
+ return await this.createOrderWs(symbol, type, side, amount, price, query);
5111
+ }
4846
5112
  async createStopOrder(symbol, type, side, amount, price = undefined, stopPrice = undefined, params = {}) {
4847
5113
  if (!this.has['createStopOrder']) {
4848
5114
  throw new NotSupported(this.id + ' createStopOrder() is not supported yet');
@@ -4853,6 +5119,16 @@ export default class Exchange {
4853
5119
  const query = this.extend(params, { 'stopPrice': stopPrice });
4854
5120
  return await this.createOrder(symbol, type, side, amount, price, query);
4855
5121
  }
5122
+ async createStopOrderWs(symbol, type, side, amount, price = undefined, stopPrice = undefined, params = {}) {
5123
+ if (!this.has['createStopOrderWs']) {
5124
+ throw new NotSupported(this.id + ' createStopOrderWs() is not supported yet');
5125
+ }
5126
+ if (stopPrice === undefined) {
5127
+ throw new ArgumentsRequired(this.id + ' createStopOrderWs() requires a stopPrice argument');
5128
+ }
5129
+ const query = this.extend(params, { 'stopPrice': stopPrice });
5130
+ return await this.createOrderWs(symbol, type, side, amount, price, query);
5131
+ }
4856
5132
  async createStopLimitOrder(symbol, side, amount, price, stopPrice, params = {}) {
4857
5133
  if (!this.has['createStopLimitOrder']) {
4858
5134
  throw new NotSupported(this.id + ' createStopLimitOrder() is not supported yet');
@@ -4860,6 +5136,13 @@ export default class Exchange {
4860
5136
  const query = this.extend(params, { 'stopPrice': stopPrice });
4861
5137
  return await this.createOrder(symbol, 'limit', side, amount, price, query);
4862
5138
  }
5139
+ async createStopLimitOrderWs(symbol, side, amount, price, stopPrice, params = {}) {
5140
+ if (!this.has['createStopLimitOrderWs']) {
5141
+ throw new NotSupported(this.id + ' createStopLimitOrderWs() is not supported yet');
5142
+ }
5143
+ const query = this.extend(params, { 'stopPrice': stopPrice });
5144
+ return await this.createOrderWs(symbol, 'limit', side, amount, price, query);
5145
+ }
4863
5146
  async createStopMarketOrder(symbol, side, amount, stopPrice, params = {}) {
4864
5147
  if (!this.has['createStopMarketOrder']) {
4865
5148
  throw new NotSupported(this.id + ' createStopMarketOrder() is not supported yet');
@@ -4867,6 +5150,13 @@ export default class Exchange {
4867
5150
  const query = this.extend(params, { 'stopPrice': stopPrice });
4868
5151
  return await this.createOrder(symbol, 'market', side, amount, undefined, query);
4869
5152
  }
5153
+ async createStopMarketOrderWs(symbol, side, amount, stopPrice, params = {}) {
5154
+ if (!this.has['createStopMarketOrderWs']) {
5155
+ throw new NotSupported(this.id + ' createStopMarketOrderWs() is not supported yet');
5156
+ }
5157
+ const query = this.extend(params, { 'stopPrice': stopPrice });
5158
+ return await this.createOrderWs(symbol, 'market', side, amount, undefined, query);
5159
+ }
4870
5160
  safeCurrencyCode(currencyId, currency = undefined) {
4871
5161
  currency = this.safeCurrency(currencyId, currency);
4872
5162
  return currency['code'];
@@ -49,6 +49,10 @@ export default class binance extends Exchange {
49
49
  fetchTrades(symbol: string, since?: Int, limit?: Int, params?: {}): Promise<Trade[]>;
50
50
  editSpotOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
51
51
  editSpotOrderRequest(id: string, symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): any;
52
+ editContractOrderRequest(id: string, symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): {
53
+ symbol: string;
54
+ side: string;
55
+ };
52
56
  editContractOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount: number, price?: Num, params?: {}): Promise<Order>;
53
57
  editOrder(id: string, symbol: string, type: OrderType, side: OrderSide, amount?: Num, price?: Num, params?: {}): Promise<Order>;
54
58
  parseOrderStatus(status: any): string;
package/js/src/binance.js CHANGED
@@ -4948,23 +4948,7 @@ export default class binance extends Exchange {
4948
4948
  params = this.omit(params, ['quoteOrderQty', 'cost', 'stopPrice', 'newClientOrderId', 'clientOrderId', 'postOnly']);
4949
4949
  return this.extend(request, params);
4950
4950
  }
4951
- async editContractOrder(id, symbol, type, side, amount, price = undefined, params = {}) {
4952
- /**
4953
- * @method
4954
- * @name binance#editContractOrder
4955
- * @description edit a trade order
4956
- * @see https://binance-docs.github.io/apidocs/futures/en/#modify-order-trade
4957
- * @see https://binance-docs.github.io/apidocs/delivery/en/#modify-order-trade
4958
- * @param {string} id cancel order id
4959
- * @param {string} symbol unified symbol of the market to create an order in
4960
- * @param {string} type 'market' or 'limit'
4961
- * @param {string} side 'buy' or 'sell'
4962
- * @param {float} amount how much of currency you want to trade in units of base currency
4963
- * @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
4964
- * @param {object} [params] extra parameters specific to the exchange API endpoint
4965
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4966
- */
4967
- await this.loadMarkets();
4951
+ editContractOrderRequest(id, symbol, type, side, amount, price = undefined, params = {}) {
4968
4952
  const market = this.market(symbol);
4969
4953
  if (!market['contract']) {
4970
4954
  throw new NotSupported(this.id + ' editContractOrder() does not support ' + market['type'] + ' orders');
@@ -4983,6 +4967,27 @@ export default class binance extends Exchange {
4983
4967
  request['origClientOrderId'] = clientOrderId;
4984
4968
  }
4985
4969
  params = this.omit(params, ['clientOrderId', 'newClientOrderId']);
4970
+ return request;
4971
+ }
4972
+ async editContractOrder(id, symbol, type, side, amount, price = undefined, params = {}) {
4973
+ /**
4974
+ * @method
4975
+ * @name binance#editContractOrder
4976
+ * @description edit a trade order
4977
+ * @see https://binance-docs.github.io/apidocs/futures/en/#modify-order-trade
4978
+ * @see https://binance-docs.github.io/apidocs/delivery/en/#modify-order-trade
4979
+ * @param {string} id cancel order id
4980
+ * @param {string} symbol unified symbol of the market to create an order in
4981
+ * @param {string} type 'market' or 'limit'
4982
+ * @param {string} side 'buy' or 'sell'
4983
+ * @param {float} amount how much of currency you want to trade in units of base currency
4984
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
4985
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4986
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4987
+ */
4988
+ await this.loadMarkets();
4989
+ const market = this.market(symbol);
4990
+ const request = this.editContractOrderRequest(id, symbol, type, side, amount, price, params);
4986
4991
  let response = undefined;
4987
4992
  if (market['linear']) {
4988
4993
  response = await this.fapiPrivatePutOrder(this.extend(request, params));
@@ -87,6 +87,7 @@ export default class kucoin extends Exchange {
87
87
  parseTrade(trade: any, market?: Market): Trade;
88
88
  fetchTradingFee(symbol: string, params?: {}): Promise<TradingFeeInterface>;
89
89
  withdraw(code: string, amount: number, address: any, tag?: any, params?: {}): Promise<Transaction>;
90
+ loadCurrencyPrecision(currency: any, networkCode?: Str): Promise<void>;
90
91
  parseTransactionStatus(status: any): string;
91
92
  parseTransaction(transaction: any, currency?: Currency): Transaction;
92
93
  fetchDeposits(code?: Str, since?: Int, limit?: Int, params?: {}): Promise<Transaction[]>;
package/js/src/kucoin.js CHANGED
@@ -1152,8 +1152,10 @@ export default class kucoin extends Exchange {
1152
1152
  // "chains":[
1153
1153
  // {
1154
1154
  // "chainName":"ERC20",
1155
- // "chain":"eth",
1155
+ // "chainId": "eth"
1156
1156
  // "withdrawalMinSize":"2999",
1157
+ // "depositMinSize":null,
1158
+ // "withdrawFeeRate":"0",
1157
1159
  // "withdrawalMinFee":"2999",
1158
1160
  // "isWithdrawEnabled":false,
1159
1161
  // "isDepositEnabled":false,
@@ -1261,7 +1263,7 @@ export default class kucoin extends Exchange {
1261
1263
  'max': undefined,
1262
1264
  },
1263
1265
  'deposit': {
1264
- 'min': this.safeNumber(chainExtraData, 'depositMinSize'),
1266
+ 'min': this.safeNumber(chain, 'depositMinSize'),
1265
1267
  'max': undefined,
1266
1268
  },
1267
1269
  },
@@ -3204,7 +3206,6 @@ export default class kucoin extends Exchange {
3204
3206
  const request = {
3205
3207
  'currency': currency['id'],
3206
3208
  'address': address,
3207
- 'amount': amount,
3208
3209
  // 'memo': tag,
3209
3210
  // 'isInner': false, // internal transfer or external withdrawal
3210
3211
  // 'remark': 'optional',
@@ -3218,6 +3219,8 @@ export default class kucoin extends Exchange {
3218
3219
  if (networkCode !== undefined) {
3219
3220
  request['chain'] = this.networkCodeToId(networkCode).toLowerCase();
3220
3221
  }
3222
+ await this.loadCurrencyPrecision(currency, networkCode);
3223
+ request['amount'] = this.currencyToPrecision(code, amount, networkCode);
3221
3224
  let includeFee = undefined;
3222
3225
  [includeFee, params] = this.handleOptionAndParams(params, 'withdraw', 'includeFee', false);
3223
3226
  if (includeFee) {
@@ -3237,6 +3240,53 @@ export default class kucoin extends Exchange {
3237
3240
  const data = this.safeDict(response, 'data', {});
3238
3241
  return this.parseTransaction(data, currency);
3239
3242
  }
3243
+ async loadCurrencyPrecision(currency, networkCode = undefined) {
3244
+ // as kucoin might not have network specific precisions defined in fetchCurrencies (because of webapi failure)
3245
+ // we should check and refetch precision once-per-instance for that specific currency & network
3246
+ // so avoids thorwing exceptions and burden to users
3247
+ // Note: this needs to be executed only if networkCode was provided
3248
+ if (networkCode !== undefined) {
3249
+ const networks = currency['networks'];
3250
+ const network = this.safeDict(networks, networkCode);
3251
+ if (this.safeNumber(network, 'precision') !== undefined) {
3252
+ // if precision exists, no need to refetch
3253
+ return;
3254
+ }
3255
+ // otherwise try to fetch and store in instance
3256
+ const request = {
3257
+ 'currency': currency['id'],
3258
+ 'chain': this.networkCodeToId(networkCode).toLowerCase(),
3259
+ };
3260
+ const response = await this.privateGetWithdrawalsQuotas(request);
3261
+ //
3262
+ // {
3263
+ // "code": "200000",
3264
+ // "data": {
3265
+ // "currency": "USDT",
3266
+ // "limitBTCAmount": "14.24094850",
3267
+ // "usedBTCAmount": "0.00000000",
3268
+ // "quotaCurrency": "USDT",
3269
+ // "limitQuotaCurrencyAmount": "999999.00000000",
3270
+ // "usedQuotaCurrencyAmount": "0",
3271
+ // "remainAmount": "999999.0000",
3272
+ // "availableAmount": "10.77545071",
3273
+ // "withdrawMinFee": "1",
3274
+ // "innerWithdrawMinFee": "0",
3275
+ // "withdrawMinSize": "10",
3276
+ // "isWithdrawEnabled": true,
3277
+ // "precision": 4,
3278
+ // "chain": "EOS",
3279
+ // "reason": null,
3280
+ // "lockedAmount": "0"
3281
+ // }
3282
+ // }
3283
+ //
3284
+ const data = this.safeDict(response, 'data', {});
3285
+ const precision = this.parseNumber(this.parsePrecision(this.safeString(data, 'precision')));
3286
+ const code = currency['code'];
3287
+ this.currencies[code]['networks'][networkCode]['precision'] = precision;
3288
+ }
3289
+ }
3240
3290
  parseTransactionStatus(status) {
3241
3291
  const statuses = {
3242
3292
  'SUCCESS': 'ok',