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.
- package/README.md +3 -3
- package/dist/cjs/ccxt.js +1 -1
- package/dist/cjs/src/base/Exchange.js +296 -6
- package/dist/cjs/src/binance.js +22 -17
- package/dist/cjs/src/kucoin.js +53 -3
- package/dist/cjs/src/phemex.js +5 -0
- package/dist/cjs/src/pro/binance.js +439 -75
- package/dist/cjs/src/pro/woo.js +0 -1
- package/dist/cjs/src/whitebit.js +132 -2
- package/js/ccxt.d.ts +1 -1
- package/js/ccxt.js +1 -1
- package/js/src/abstract/whitebit.d.ts +21 -0
- package/js/src/base/Exchange.d.ts +51 -3
- package/js/src/base/Exchange.js +296 -6
- package/js/src/binance.d.ts +4 -0
- package/js/src/binance.js +22 -17
- package/js/src/kucoin.d.ts +1 -0
- package/js/src/kucoin.js +53 -3
- package/js/src/phemex.js +5 -0
- package/js/src/pro/binance.d.ts +9 -1
- package/js/src/pro/binance.js +439 -75
- package/js/src/pro/cex.d.ts +1 -1
- package/js/src/pro/lbank.d.ts +1 -1
- package/js/src/pro/woo.js +0 -1
- package/js/src/whitebit.d.ts +2 -0
- package/js/src/whitebit.js +132 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -213,13 +213,13 @@ console.log(version, Object.keys(exchanges));
|
|
|
213
213
|
|
|
214
214
|
All-in-one browser bundle (dependencies included), served from a CDN of your choice:
|
|
215
215
|
|
|
216
|
-
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.
|
|
217
|
-
* unpkg: https://unpkg.com/ccxt@4.3.
|
|
216
|
+
* jsDelivr: https://cdn.jsdelivr.net/npm/ccxt@4.3.5/dist/ccxt.browser.js
|
|
217
|
+
* unpkg: https://unpkg.com/ccxt@4.3.5/dist/ccxt.browser.js
|
|
218
218
|
|
|
219
219
|
CDNs are not updated in real-time and may have delays. Defaulting to the most recent version without specifying the version number is not recommended. Please, keep in mind that we are not responsible for the correct operation of those CDN servers.
|
|
220
220
|
|
|
221
221
|
```HTML
|
|
222
|
-
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.
|
|
222
|
+
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/ccxt@4.3.5/dist/ccxt.browser.js"></script>
|
|
223
223
|
```
|
|
224
224
|
|
|
225
225
|
Creates a global `ccxt` object:
|
package/dist/cjs/ccxt.js
CHANGED
|
@@ -182,7 +182,7 @@ var woo$1 = require('./src/pro/woo.js');
|
|
|
182
182
|
|
|
183
183
|
//-----------------------------------------------------------------------------
|
|
184
184
|
// this is updated by vss.js when building
|
|
185
|
-
const version = '4.3.
|
|
185
|
+
const version = '4.3.5';
|
|
186
186
|
Exchange["default"].ccxtVersion = version;
|
|
187
187
|
const exchanges = {
|
|
188
188
|
'ace': ace,
|
|
@@ -374,35 +374,55 @@ class Exchange {
|
|
|
374
374
|
'cancelAllOrders': undefined,
|
|
375
375
|
'cancelAllOrdersWs': undefined,
|
|
376
376
|
'cancelOrder': true,
|
|
377
|
+
'cancelOrderWs': undefined,
|
|
377
378
|
'cancelOrders': undefined,
|
|
378
379
|
'cancelOrdersWs': undefined,
|
|
379
|
-
'cancelOrderWs': undefined,
|
|
380
380
|
'closeAllPositions': undefined,
|
|
381
381
|
'closePosition': undefined,
|
|
382
382
|
'createDepositAddress': undefined,
|
|
383
383
|
'createLimitBuyOrder': undefined,
|
|
384
|
+
'createLimitBuyOrderWs': undefined,
|
|
384
385
|
'createLimitOrder': true,
|
|
386
|
+
'createLimitOrderWs': undefined,
|
|
385
387
|
'createLimitSellOrder': undefined,
|
|
388
|
+
'createLimitSellOrderWs': undefined,
|
|
386
389
|
'createMarketBuyOrder': undefined,
|
|
390
|
+
'createMarketBuyOrderWs': undefined,
|
|
387
391
|
'createMarketBuyOrderWithCost': undefined,
|
|
392
|
+
'createMarketBuyOrderWithCostWs': undefined,
|
|
388
393
|
'createMarketOrder': true,
|
|
394
|
+
'createMarketOrderWs': true,
|
|
389
395
|
'createMarketOrderWithCost': undefined,
|
|
396
|
+
'createMarketOrderWithCostWs': undefined,
|
|
390
397
|
'createMarketSellOrder': undefined,
|
|
398
|
+
'createMarketSellOrderWs': undefined,
|
|
391
399
|
'createMarketSellOrderWithCost': undefined,
|
|
400
|
+
'createMarketSellOrderWithCostWs': undefined,
|
|
392
401
|
'createOrder': true,
|
|
402
|
+
'createOrderWs': undefined,
|
|
393
403
|
'createOrders': undefined,
|
|
394
404
|
'createOrderWithTakeProfitAndStopLoss': undefined,
|
|
395
|
-
'
|
|
405
|
+
'createOrderWithTakeProfitAndStopLossWs': undefined,
|
|
396
406
|
'createPostOnlyOrder': undefined,
|
|
407
|
+
'createPostOnlyOrderWs': undefined,
|
|
397
408
|
'createReduceOnlyOrder': undefined,
|
|
409
|
+
'createReduceOnlyOrderWs': undefined,
|
|
398
410
|
'createStopLimitOrder': undefined,
|
|
411
|
+
'createStopLimitOrderWs': undefined,
|
|
399
412
|
'createStopLossOrder': undefined,
|
|
413
|
+
'createStopLossOrderWs': undefined,
|
|
400
414
|
'createStopMarketOrder': undefined,
|
|
415
|
+
'createStopMarketOrderWs': undefined,
|
|
401
416
|
'createStopOrder': undefined,
|
|
417
|
+
'createStopOrderWs': undefined,
|
|
402
418
|
'createTakeProfitOrder': undefined,
|
|
419
|
+
'createTakeProfitOrderWs': undefined,
|
|
403
420
|
'createTrailingAmountOrder': undefined,
|
|
421
|
+
'createTrailingAmountOrderWs': undefined,
|
|
404
422
|
'createTrailingPercentOrder': undefined,
|
|
423
|
+
'createTrailingPercentOrderWs': undefined,
|
|
405
424
|
'createTriggerOrder': undefined,
|
|
425
|
+
'createTriggerOrderWs': undefined,
|
|
406
426
|
'deposit': undefined,
|
|
407
427
|
'editOrder': 'emulated',
|
|
408
428
|
'editOrderWs': undefined,
|
|
@@ -485,16 +505,20 @@ class Exchange {
|
|
|
485
505
|
'fetchOrderWs': undefined,
|
|
486
506
|
'fetchPermissions': undefined,
|
|
487
507
|
'fetchPosition': undefined,
|
|
508
|
+
'fetchPositionWs': undefined,
|
|
488
509
|
'fetchPositionMode': undefined,
|
|
489
510
|
'fetchPositions': undefined,
|
|
511
|
+
'fetchPositionsWs': undefined,
|
|
490
512
|
'fetchPositionsForSymbol': undefined,
|
|
513
|
+
'fetchPositionsForSymbolWs': undefined,
|
|
491
514
|
'fetchPositionsRisk': undefined,
|
|
492
515
|
'fetchPremiumIndexOHLCV': undefined,
|
|
493
516
|
'fetchSettlementHistory': undefined,
|
|
494
517
|
'fetchStatus': undefined,
|
|
495
518
|
'fetchTicker': true,
|
|
496
|
-
'fetchTickers': undefined,
|
|
497
519
|
'fetchTickerWs': undefined,
|
|
520
|
+
'fetchTickers': undefined,
|
|
521
|
+
'fetchTickersWs': undefined,
|
|
498
522
|
'fetchTime': undefined,
|
|
499
523
|
'fetchTrades': true,
|
|
500
524
|
'fetchTradesWs': undefined,
|
|
@@ -3784,6 +3808,9 @@ class Exchange {
|
|
|
3784
3808
|
async fetchPosition(symbol, params = {}) {
|
|
3785
3809
|
throw new errors.NotSupported(this.id + ' fetchPosition() is not supported yet');
|
|
3786
3810
|
}
|
|
3811
|
+
async fetchPositionWs(symbol, params = {}) {
|
|
3812
|
+
throw new errors.NotSupported(this.id + ' fetchPositionWs() is not supported yet');
|
|
3813
|
+
}
|
|
3787
3814
|
async watchPosition(symbol = undefined, params = {}) {
|
|
3788
3815
|
throw new errors.NotSupported(this.id + ' watchPosition() is not supported yet');
|
|
3789
3816
|
}
|
|
@@ -3804,9 +3831,23 @@ class Exchange {
|
|
|
3804
3831
|
*/
|
|
3805
3832
|
throw new errors.NotSupported(this.id + ' fetchPositionsForSymbol() is not supported yet');
|
|
3806
3833
|
}
|
|
3834
|
+
async fetchPositionsForSymbolWs(symbol, params = {}) {
|
|
3835
|
+
/**
|
|
3836
|
+
* @method
|
|
3837
|
+
* @name exchange#fetchPositionsForSymbol
|
|
3838
|
+
* @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
|
|
3839
|
+
* @param {string} symbol unified market symbol
|
|
3840
|
+
* @param {object} params extra parameters specific to the endpoint
|
|
3841
|
+
* @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
|
|
3842
|
+
*/
|
|
3843
|
+
throw new errors.NotSupported(this.id + ' fetchPositionsForSymbol() is not supported yet');
|
|
3844
|
+
}
|
|
3807
3845
|
async fetchPositions(symbols = undefined, params = {}) {
|
|
3808
3846
|
throw new errors.NotSupported(this.id + ' fetchPositions() is not supported yet');
|
|
3809
3847
|
}
|
|
3848
|
+
async fetchPositionsWs(symbols = undefined, params = {}) {
|
|
3849
|
+
throw new errors.NotSupported(this.id + ' fetchPositions() is not supported yet');
|
|
3850
|
+
}
|
|
3810
3851
|
async fetchPositionsRisk(symbols = undefined, params = {}) {
|
|
3811
3852
|
throw new errors.NotSupported(this.id + ' fetchPositionsRisk() is not supported yet');
|
|
3812
3853
|
}
|
|
@@ -4183,12 +4224,33 @@ class Exchange {
|
|
|
4183
4224
|
throw new errors.NotSupported(this.id + ' fetchTicker() is not supported yet');
|
|
4184
4225
|
}
|
|
4185
4226
|
}
|
|
4227
|
+
async fetchTickerWs(symbol, params = {}) {
|
|
4228
|
+
if (this.has['fetchTickersWs']) {
|
|
4229
|
+
await this.loadMarkets();
|
|
4230
|
+
const market = this.market(symbol);
|
|
4231
|
+
symbol = market['symbol'];
|
|
4232
|
+
const tickers = await this.fetchTickerWs(symbol, params);
|
|
4233
|
+
const ticker = this.safeDict(tickers, symbol);
|
|
4234
|
+
if (ticker === undefined) {
|
|
4235
|
+
throw new errors.NullResponse(this.id + ' fetchTickers() could not find a ticker for ' + symbol);
|
|
4236
|
+
}
|
|
4237
|
+
else {
|
|
4238
|
+
return ticker;
|
|
4239
|
+
}
|
|
4240
|
+
}
|
|
4241
|
+
else {
|
|
4242
|
+
throw new errors.NotSupported(this.id + ' fetchTicker() is not supported yet');
|
|
4243
|
+
}
|
|
4244
|
+
}
|
|
4186
4245
|
async watchTicker(symbol, params = {}) {
|
|
4187
4246
|
throw new errors.NotSupported(this.id + ' watchTicker() is not supported yet');
|
|
4188
4247
|
}
|
|
4189
4248
|
async fetchTickers(symbols = undefined, params = {}) {
|
|
4190
4249
|
throw new errors.NotSupported(this.id + ' fetchTickers() is not supported yet');
|
|
4191
4250
|
}
|
|
4251
|
+
async fetchTickersWs(symbols = undefined, params = {}) {
|
|
4252
|
+
throw new errors.NotSupported(this.id + ' fetchTickers() is not supported yet');
|
|
4253
|
+
}
|
|
4192
4254
|
async fetchOrderBooks(symbols = undefined, limit = undefined, params = {}) {
|
|
4193
4255
|
throw new errors.NotSupported(this.id + ' fetchOrderBooks() is not supported yet');
|
|
4194
4256
|
}
|
|
@@ -4243,6 +4305,33 @@ class Exchange {
|
|
|
4243
4305
|
}
|
|
4244
4306
|
throw new errors.NotSupported(this.id + ' createTrailingAmountOrder() is not supported yet');
|
|
4245
4307
|
}
|
|
4308
|
+
async createTrailingAmountOrderWs(symbol, type, side, amount, price = undefined, trailingAmount = undefined, trailingTriggerPrice = undefined, params = {}) {
|
|
4309
|
+
/**
|
|
4310
|
+
* @method
|
|
4311
|
+
* @name createTrailingAmountOrderWs
|
|
4312
|
+
* @description create a trailing order by providing the symbol, type, side, amount, price and trailingAmount
|
|
4313
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
4314
|
+
* @param {string} type 'market' or 'limit'
|
|
4315
|
+
* @param {string} side 'buy' or 'sell'
|
|
4316
|
+
* @param {float} amount how much you want to trade in units of the base currency, or number of contracts
|
|
4317
|
+
* @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
|
|
4318
|
+
* @param {float} trailingAmount the quote amount to trail away from the current market price
|
|
4319
|
+
* @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
|
|
4320
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4321
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4322
|
+
*/
|
|
4323
|
+
if (trailingAmount === undefined) {
|
|
4324
|
+
throw new errors.ArgumentsRequired(this.id + ' createTrailingAmountOrderWs() requires a trailingAmount argument');
|
|
4325
|
+
}
|
|
4326
|
+
params['trailingAmount'] = trailingAmount;
|
|
4327
|
+
if (trailingTriggerPrice !== undefined) {
|
|
4328
|
+
params['trailingTriggerPrice'] = trailingTriggerPrice;
|
|
4329
|
+
}
|
|
4330
|
+
if (this.has['createTrailingAmountOrderWs']) {
|
|
4331
|
+
return await this.createOrderWs(symbol, type, side, amount, price, params);
|
|
4332
|
+
}
|
|
4333
|
+
throw new errors.NotSupported(this.id + ' createTrailingAmountOrderWs() is not supported yet');
|
|
4334
|
+
}
|
|
4246
4335
|
async createTrailingPercentOrder(symbol, type, side, amount, price = undefined, trailingPercent = undefined, trailingTriggerPrice = undefined, params = {}) {
|
|
4247
4336
|
/**
|
|
4248
4337
|
* @method
|
|
@@ -4270,6 +4359,33 @@ class Exchange {
|
|
|
4270
4359
|
}
|
|
4271
4360
|
throw new errors.NotSupported(this.id + ' createTrailingPercentOrder() is not supported yet');
|
|
4272
4361
|
}
|
|
4362
|
+
async createTrailingPercentOrderWs(symbol, type, side, amount, price = undefined, trailingPercent = undefined, trailingTriggerPrice = undefined, params = {}) {
|
|
4363
|
+
/**
|
|
4364
|
+
* @method
|
|
4365
|
+
* @name createTrailingPercentOrderWs
|
|
4366
|
+
* @description create a trailing order by providing the symbol, type, side, amount, price and trailingPercent
|
|
4367
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
4368
|
+
* @param {string} type 'market' or 'limit'
|
|
4369
|
+
* @param {string} side 'buy' or 'sell'
|
|
4370
|
+
* @param {float} amount how much you want to trade in units of the base currency, or number of contracts
|
|
4371
|
+
* @param {float} [price] the price for the order to be filled at, in units of the quote currency, ignored in market orders
|
|
4372
|
+
* @param {float} trailingPercent the percent to trail away from the current market price
|
|
4373
|
+
* @param {float} [trailingTriggerPrice] the price to activate a trailing order, default uses the price argument
|
|
4374
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4375
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4376
|
+
*/
|
|
4377
|
+
if (trailingPercent === undefined) {
|
|
4378
|
+
throw new errors.ArgumentsRequired(this.id + ' createTrailingPercentOrderWs() requires a trailingPercent argument');
|
|
4379
|
+
}
|
|
4380
|
+
params['trailingPercent'] = trailingPercent;
|
|
4381
|
+
if (trailingTriggerPrice !== undefined) {
|
|
4382
|
+
params['trailingTriggerPrice'] = trailingTriggerPrice;
|
|
4383
|
+
}
|
|
4384
|
+
if (this.has['createTrailingPercentOrderWs']) {
|
|
4385
|
+
return await this.createOrderWs(symbol, type, side, amount, price, params);
|
|
4386
|
+
}
|
|
4387
|
+
throw new errors.NotSupported(this.id + ' createTrailingPercentOrderWs() is not supported yet');
|
|
4388
|
+
}
|
|
4273
4389
|
async createMarketOrderWithCost(symbol, side, cost, params = {}) {
|
|
4274
4390
|
/**
|
|
4275
4391
|
* @method
|
|
@@ -4316,6 +4432,22 @@ class Exchange {
|
|
|
4316
4432
|
}
|
|
4317
4433
|
throw new errors.NotSupported(this.id + ' createMarketSellOrderWithCost() is not supported yet');
|
|
4318
4434
|
}
|
|
4435
|
+
async createMarketOrderWithCostWs(symbol, side, cost, params = {}) {
|
|
4436
|
+
/**
|
|
4437
|
+
* @method
|
|
4438
|
+
* @name createMarketOrderWithCostWs
|
|
4439
|
+
* @description create a market order by providing the symbol, side and cost
|
|
4440
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
4441
|
+
* @param {string} side 'buy' or 'sell'
|
|
4442
|
+
* @param {float} cost how much you want to trade in units of the quote currency
|
|
4443
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4444
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4445
|
+
*/
|
|
4446
|
+
if (this.has['createMarketOrderWithCostWs'] || (this.has['createMarketBuyOrderWithCostWs'] && this.has['createMarketSellOrderWithCostWs'])) {
|
|
4447
|
+
return await this.createOrderWs(symbol, 'market', side, cost, 1, params);
|
|
4448
|
+
}
|
|
4449
|
+
throw new errors.NotSupported(this.id + ' createMarketOrderWithCostWs() is not supported yet');
|
|
4450
|
+
}
|
|
4319
4451
|
async createTriggerOrder(symbol, type, side, amount, price = undefined, triggerPrice = undefined, params = {}) {
|
|
4320
4452
|
/**
|
|
4321
4453
|
* @method
|
|
@@ -4339,6 +4471,29 @@ class Exchange {
|
|
|
4339
4471
|
}
|
|
4340
4472
|
throw new errors.NotSupported(this.id + ' createTriggerOrder() is not supported yet');
|
|
4341
4473
|
}
|
|
4474
|
+
async createTriggerOrderWs(symbol, type, side, amount, price = undefined, triggerPrice = undefined, params = {}) {
|
|
4475
|
+
/**
|
|
4476
|
+
* @method
|
|
4477
|
+
* @name createTriggerOrderWs
|
|
4478
|
+
* @description create a trigger stop order (type 1)
|
|
4479
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
4480
|
+
* @param {string} type 'market' or 'limit'
|
|
4481
|
+
* @param {string} side 'buy' or 'sell'
|
|
4482
|
+
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
|
|
4483
|
+
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
|
|
4484
|
+
* @param {float} triggerPrice the price to trigger the stop order, in units of the quote currency
|
|
4485
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4486
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4487
|
+
*/
|
|
4488
|
+
if (triggerPrice === undefined) {
|
|
4489
|
+
throw new errors.ArgumentsRequired(this.id + ' createTriggerOrderWs() requires a triggerPrice argument');
|
|
4490
|
+
}
|
|
4491
|
+
params['triggerPrice'] = triggerPrice;
|
|
4492
|
+
if (this.has['createTriggerOrderWs']) {
|
|
4493
|
+
return await this.createOrderWs(symbol, type, side, amount, price, params);
|
|
4494
|
+
}
|
|
4495
|
+
throw new errors.NotSupported(this.id + ' createTriggerOrderWs() is not supported yet');
|
|
4496
|
+
}
|
|
4342
4497
|
async createStopLossOrder(symbol, type, side, amount, price = undefined, stopLossPrice = undefined, params = {}) {
|
|
4343
4498
|
/**
|
|
4344
4499
|
* @method
|
|
@@ -4362,6 +4517,29 @@ class Exchange {
|
|
|
4362
4517
|
}
|
|
4363
4518
|
throw new errors.NotSupported(this.id + ' createStopLossOrder() is not supported yet');
|
|
4364
4519
|
}
|
|
4520
|
+
async createStopLossOrderWs(symbol, type, side, amount, price = undefined, stopLossPrice = undefined, params = {}) {
|
|
4521
|
+
/**
|
|
4522
|
+
* @method
|
|
4523
|
+
* @name createStopLossOrderWs
|
|
4524
|
+
* @description create a trigger stop loss order (type 2)
|
|
4525
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
4526
|
+
* @param {string} type 'market' or 'limit'
|
|
4527
|
+
* @param {string} side 'buy' or 'sell'
|
|
4528
|
+
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
|
|
4529
|
+
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
|
|
4530
|
+
* @param {float} stopLossPrice the price to trigger the stop loss order, in units of the quote currency
|
|
4531
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4532
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4533
|
+
*/
|
|
4534
|
+
if (stopLossPrice === undefined) {
|
|
4535
|
+
throw new errors.ArgumentsRequired(this.id + ' createStopLossOrderWs() requires a stopLossPrice argument');
|
|
4536
|
+
}
|
|
4537
|
+
params['stopLossPrice'] = stopLossPrice;
|
|
4538
|
+
if (this.has['createStopLossOrderWs']) {
|
|
4539
|
+
return await this.createOrderWs(symbol, type, side, amount, price, params);
|
|
4540
|
+
}
|
|
4541
|
+
throw new errors.NotSupported(this.id + ' createStopLossOrderWs() is not supported yet');
|
|
4542
|
+
}
|
|
4365
4543
|
async createTakeProfitOrder(symbol, type, side, amount, price = undefined, takeProfitPrice = undefined, params = {}) {
|
|
4366
4544
|
/**
|
|
4367
4545
|
* @method
|
|
@@ -4385,6 +4563,29 @@ class Exchange {
|
|
|
4385
4563
|
}
|
|
4386
4564
|
throw new errors.NotSupported(this.id + ' createTakeProfitOrder() is not supported yet');
|
|
4387
4565
|
}
|
|
4566
|
+
async createTakeProfitOrderWs(symbol, type, side, amount, price = undefined, takeProfitPrice = undefined, params = {}) {
|
|
4567
|
+
/**
|
|
4568
|
+
* @method
|
|
4569
|
+
* @name createTakeProfitOrderWs
|
|
4570
|
+
* @description create a trigger take profit order (type 2)
|
|
4571
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
4572
|
+
* @param {string} type 'market' or 'limit'
|
|
4573
|
+
* @param {string} side 'buy' or 'sell'
|
|
4574
|
+
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
|
|
4575
|
+
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
|
|
4576
|
+
* @param {float} takeProfitPrice the price to trigger the take profit order, in units of the quote currency
|
|
4577
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4578
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4579
|
+
*/
|
|
4580
|
+
if (takeProfitPrice === undefined) {
|
|
4581
|
+
throw new errors.ArgumentsRequired(this.id + ' createTakeProfitOrderWs() requires a takeProfitPrice argument');
|
|
4582
|
+
}
|
|
4583
|
+
params['takeProfitPrice'] = takeProfitPrice;
|
|
4584
|
+
if (this.has['createTakeProfitOrderWs']) {
|
|
4585
|
+
return await this.createOrderWs(symbol, type, side, amount, price, params);
|
|
4586
|
+
}
|
|
4587
|
+
throw new errors.NotSupported(this.id + ' createTakeProfitOrderWs() is not supported yet');
|
|
4588
|
+
}
|
|
4388
4589
|
async createOrderWithTakeProfitAndStopLoss(symbol, type, side, amount, price = undefined, takeProfit = undefined, stopLoss = undefined, params = {}) {
|
|
4389
4590
|
/**
|
|
4390
4591
|
* @method
|
|
@@ -4408,6 +4609,13 @@ class Exchange {
|
|
|
4408
4609
|
* @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
|
|
4409
4610
|
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4410
4611
|
*/
|
|
4612
|
+
params = this.setTakeProfitAndStopLossParams(symbol, type, side, amount, price, takeProfit, stopLoss, params);
|
|
4613
|
+
if (this.has['createOrderWithTakeProfitAndStopLoss']) {
|
|
4614
|
+
return await this.createOrder(symbol, type, side, amount, price, params);
|
|
4615
|
+
}
|
|
4616
|
+
throw new errors.NotSupported(this.id + ' createOrderWithTakeProfitAndStopLoss() is not supported yet');
|
|
4617
|
+
}
|
|
4618
|
+
setTakeProfitAndStopLossParams(symbol, type, side, amount, price = undefined, takeProfit = undefined, stopLoss = undefined, params = {}) {
|
|
4411
4619
|
if ((takeProfit === undefined) && (stopLoss === undefined)) {
|
|
4412
4620
|
throw new errors.ArgumentsRequired(this.id + ' createOrderWithTakeProfitAndStopLoss() requires either a takeProfit or stopLoss argument');
|
|
4413
4621
|
}
|
|
@@ -4454,10 +4662,36 @@ class Exchange {
|
|
|
4454
4662
|
params['stopLoss']['amount'] = this.parseToNumeric(stopLossAmount);
|
|
4455
4663
|
}
|
|
4456
4664
|
params = this.omit(params, ['takeProfitType', 'takeProfitPriceType', 'takeProfitLimitPrice', 'takeProfitAmount', 'stopLossType', 'stopLossPriceType', 'stopLossLimitPrice', 'stopLossAmount']);
|
|
4457
|
-
|
|
4458
|
-
|
|
4665
|
+
return params;
|
|
4666
|
+
}
|
|
4667
|
+
async createOrderWithTakeProfitAndStopLossWs(symbol, type, side, amount, price = undefined, takeProfit = undefined, stopLoss = undefined, params = {}) {
|
|
4668
|
+
/**
|
|
4669
|
+
* @method
|
|
4670
|
+
* @name createOrderWithTakeProfitAndStopLossWs
|
|
4671
|
+
* @description create an order with a stop loss or take profit attached (type 3)
|
|
4672
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
4673
|
+
* @param {string} type 'market' or 'limit'
|
|
4674
|
+
* @param {string} side 'buy' or 'sell'
|
|
4675
|
+
* @param {float} amount how much you want to trade in units of the base currency or the number of contracts
|
|
4676
|
+
* @param {float} [price] the price to fulfill the order, in units of the quote currency, ignored in market orders
|
|
4677
|
+
* @param {float} [takeProfit] the take profit price, in units of the quote currency
|
|
4678
|
+
* @param {float} [stopLoss] the stop loss price, in units of the quote currency
|
|
4679
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4680
|
+
* @param {string} [params.takeProfitType] *not available on all exchanges* 'limit' or 'market'
|
|
4681
|
+
* @param {string} [params.stopLossType] *not available on all exchanges* 'limit' or 'market'
|
|
4682
|
+
* @param {string} [params.takeProfitPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
|
|
4683
|
+
* @param {string} [params.stopLossPriceType] *not available on all exchanges* 'last', 'mark' or 'index'
|
|
4684
|
+
* @param {float} [params.takeProfitLimitPrice] *not available on all exchanges* limit price for a limit take profit order
|
|
4685
|
+
* @param {float} [params.stopLossLimitPrice] *not available on all exchanges* stop loss for a limit stop loss order
|
|
4686
|
+
* @param {float} [params.takeProfitAmount] *not available on all exchanges* the amount for a take profit
|
|
4687
|
+
* @param {float} [params.stopLossAmount] *not available on all exchanges* the amount for a stop loss
|
|
4688
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4689
|
+
*/
|
|
4690
|
+
params = this.setTakeProfitAndStopLossParams(symbol, type, side, amount, price, takeProfit, stopLoss, params);
|
|
4691
|
+
if (this.has['createOrderWithTakeProfitAndStopLossWs']) {
|
|
4692
|
+
return await this.createOrderWs(symbol, type, side, amount, price, params);
|
|
4459
4693
|
}
|
|
4460
|
-
throw new errors.NotSupported(this.id + '
|
|
4694
|
+
throw new errors.NotSupported(this.id + ' createOrderWithTakeProfitAndStopLossWs() is not supported yet');
|
|
4461
4695
|
}
|
|
4462
4696
|
async createOrders(orders, params = {}) {
|
|
4463
4697
|
throw new errors.NotSupported(this.id + ' createOrders() is not supported yet');
|
|
@@ -4699,21 +4933,39 @@ class Exchange {
|
|
|
4699
4933
|
async createLimitOrder(symbol, side, amount, price, params = {}) {
|
|
4700
4934
|
return await this.createOrder(symbol, 'limit', side, amount, price, params);
|
|
4701
4935
|
}
|
|
4936
|
+
async createLimitOrderWs(symbol, side, amount, price, params = {}) {
|
|
4937
|
+
return await this.createOrderWs(symbol, 'limit', side, amount, price, params);
|
|
4938
|
+
}
|
|
4702
4939
|
async createMarketOrder(symbol, side, amount, price = undefined, params = {}) {
|
|
4703
4940
|
return await this.createOrder(symbol, 'market', side, amount, price, params);
|
|
4704
4941
|
}
|
|
4942
|
+
async createMarketOrderWs(symbol, side, amount, price = undefined, params = {}) {
|
|
4943
|
+
return await this.createOrderWs(symbol, 'market', side, amount, price, params);
|
|
4944
|
+
}
|
|
4705
4945
|
async createLimitBuyOrder(symbol, amount, price, params = {}) {
|
|
4706
4946
|
return await this.createOrder(symbol, 'limit', 'buy', amount, price, params);
|
|
4707
4947
|
}
|
|
4948
|
+
async createLimitBuyOrderWs(symbol, amount, price, params = {}) {
|
|
4949
|
+
return await this.createOrderWs(symbol, 'limit', 'buy', amount, price, params);
|
|
4950
|
+
}
|
|
4708
4951
|
async createLimitSellOrder(symbol, amount, price, params = {}) {
|
|
4709
4952
|
return await this.createOrder(symbol, 'limit', 'sell', amount, price, params);
|
|
4710
4953
|
}
|
|
4954
|
+
async createLimitSellOrderWs(symbol, amount, price, params = {}) {
|
|
4955
|
+
return await this.createOrderWs(symbol, 'limit', 'sell', amount, price, params);
|
|
4956
|
+
}
|
|
4711
4957
|
async createMarketBuyOrder(symbol, amount, params = {}) {
|
|
4712
4958
|
return await this.createOrder(symbol, 'market', 'buy', amount, undefined, params);
|
|
4713
4959
|
}
|
|
4960
|
+
async createMarketBuyOrderWs(symbol, amount, params = {}) {
|
|
4961
|
+
return await this.createOrderWs(symbol, 'market', 'buy', amount, undefined, params);
|
|
4962
|
+
}
|
|
4714
4963
|
async createMarketSellOrder(symbol, amount, params = {}) {
|
|
4715
4964
|
return await this.createOrder(symbol, 'market', 'sell', amount, undefined, params);
|
|
4716
4965
|
}
|
|
4966
|
+
async createMarketSellOrderWs(symbol, amount, params = {}) {
|
|
4967
|
+
return await this.createOrderWs(symbol, 'market', 'sell', amount, undefined, params);
|
|
4968
|
+
}
|
|
4717
4969
|
costToPrecision(symbol, cost) {
|
|
4718
4970
|
const market = this.market(symbol);
|
|
4719
4971
|
return this.decimalToPrecision(cost, TRUNCATE, market['precision']['price'], this.precisionMode, this.paddingMode);
|
|
@@ -4849,6 +5101,13 @@ class Exchange {
|
|
|
4849
5101
|
const query = this.extend(params, { 'postOnly': true });
|
|
4850
5102
|
return await this.createOrder(symbol, type, side, amount, price, query);
|
|
4851
5103
|
}
|
|
5104
|
+
async createPostOnlyOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
|
|
5105
|
+
if (!this.has['createPostOnlyOrderWs']) {
|
|
5106
|
+
throw new errors.NotSupported(this.id + 'createPostOnlyOrderWs() is not supported yet');
|
|
5107
|
+
}
|
|
5108
|
+
const query = this.extend(params, { 'postOnly': true });
|
|
5109
|
+
return await this.createOrderWs(symbol, type, side, amount, price, query);
|
|
5110
|
+
}
|
|
4852
5111
|
async createReduceOnlyOrder(symbol, type, side, amount, price = undefined, params = {}) {
|
|
4853
5112
|
if (!this.has['createReduceOnlyOrder']) {
|
|
4854
5113
|
throw new errors.NotSupported(this.id + 'createReduceOnlyOrder() is not supported yet');
|
|
@@ -4856,6 +5115,13 @@ class Exchange {
|
|
|
4856
5115
|
const query = this.extend(params, { 'reduceOnly': true });
|
|
4857
5116
|
return await this.createOrder(symbol, type, side, amount, price, query);
|
|
4858
5117
|
}
|
|
5118
|
+
async createReduceOnlyOrderWs(symbol, type, side, amount, price = undefined, params = {}) {
|
|
5119
|
+
if (!this.has['createReduceOnlyOrderWs']) {
|
|
5120
|
+
throw new errors.NotSupported(this.id + 'createReduceOnlyOrderWs() is not supported yet');
|
|
5121
|
+
}
|
|
5122
|
+
const query = this.extend(params, { 'reduceOnly': true });
|
|
5123
|
+
return await this.createOrderWs(symbol, type, side, amount, price, query);
|
|
5124
|
+
}
|
|
4859
5125
|
async createStopOrder(symbol, type, side, amount, price = undefined, stopPrice = undefined, params = {}) {
|
|
4860
5126
|
if (!this.has['createStopOrder']) {
|
|
4861
5127
|
throw new errors.NotSupported(this.id + ' createStopOrder() is not supported yet');
|
|
@@ -4866,6 +5132,16 @@ class Exchange {
|
|
|
4866
5132
|
const query = this.extend(params, { 'stopPrice': stopPrice });
|
|
4867
5133
|
return await this.createOrder(symbol, type, side, amount, price, query);
|
|
4868
5134
|
}
|
|
5135
|
+
async createStopOrderWs(symbol, type, side, amount, price = undefined, stopPrice = undefined, params = {}) {
|
|
5136
|
+
if (!this.has['createStopOrderWs']) {
|
|
5137
|
+
throw new errors.NotSupported(this.id + ' createStopOrderWs() is not supported yet');
|
|
5138
|
+
}
|
|
5139
|
+
if (stopPrice === undefined) {
|
|
5140
|
+
throw new errors.ArgumentsRequired(this.id + ' createStopOrderWs() requires a stopPrice argument');
|
|
5141
|
+
}
|
|
5142
|
+
const query = this.extend(params, { 'stopPrice': stopPrice });
|
|
5143
|
+
return await this.createOrderWs(symbol, type, side, amount, price, query);
|
|
5144
|
+
}
|
|
4869
5145
|
async createStopLimitOrder(symbol, side, amount, price, stopPrice, params = {}) {
|
|
4870
5146
|
if (!this.has['createStopLimitOrder']) {
|
|
4871
5147
|
throw new errors.NotSupported(this.id + ' createStopLimitOrder() is not supported yet');
|
|
@@ -4873,6 +5149,13 @@ class Exchange {
|
|
|
4873
5149
|
const query = this.extend(params, { 'stopPrice': stopPrice });
|
|
4874
5150
|
return await this.createOrder(symbol, 'limit', side, amount, price, query);
|
|
4875
5151
|
}
|
|
5152
|
+
async createStopLimitOrderWs(symbol, side, amount, price, stopPrice, params = {}) {
|
|
5153
|
+
if (!this.has['createStopLimitOrderWs']) {
|
|
5154
|
+
throw new errors.NotSupported(this.id + ' createStopLimitOrderWs() is not supported yet');
|
|
5155
|
+
}
|
|
5156
|
+
const query = this.extend(params, { 'stopPrice': stopPrice });
|
|
5157
|
+
return await this.createOrderWs(symbol, 'limit', side, amount, price, query);
|
|
5158
|
+
}
|
|
4876
5159
|
async createStopMarketOrder(symbol, side, amount, stopPrice, params = {}) {
|
|
4877
5160
|
if (!this.has['createStopMarketOrder']) {
|
|
4878
5161
|
throw new errors.NotSupported(this.id + ' createStopMarketOrder() is not supported yet');
|
|
@@ -4880,6 +5163,13 @@ class Exchange {
|
|
|
4880
5163
|
const query = this.extend(params, { 'stopPrice': stopPrice });
|
|
4881
5164
|
return await this.createOrder(symbol, 'market', side, amount, undefined, query);
|
|
4882
5165
|
}
|
|
5166
|
+
async createStopMarketOrderWs(symbol, side, amount, stopPrice, params = {}) {
|
|
5167
|
+
if (!this.has['createStopMarketOrderWs']) {
|
|
5168
|
+
throw new errors.NotSupported(this.id + ' createStopMarketOrderWs() is not supported yet');
|
|
5169
|
+
}
|
|
5170
|
+
const query = this.extend(params, { 'stopPrice': stopPrice });
|
|
5171
|
+
return await this.createOrderWs(symbol, 'market', side, amount, undefined, query);
|
|
5172
|
+
}
|
|
4883
5173
|
safeCurrencyCode(currencyId, currency = undefined) {
|
|
4884
5174
|
currency = this.safeCurrency(currencyId, currency);
|
|
4885
5175
|
return currency['code'];
|
package/dist/cjs/src/binance.js
CHANGED
|
@@ -4945,23 +4945,7 @@ class binance extends binance$1 {
|
|
|
4945
4945
|
params = this.omit(params, ['quoteOrderQty', 'cost', 'stopPrice', 'newClientOrderId', 'clientOrderId', 'postOnly']);
|
|
4946
4946
|
return this.extend(request, params);
|
|
4947
4947
|
}
|
|
4948
|
-
|
|
4949
|
-
/**
|
|
4950
|
-
* @method
|
|
4951
|
-
* @name binance#editContractOrder
|
|
4952
|
-
* @description edit a trade order
|
|
4953
|
-
* @see https://binance-docs.github.io/apidocs/futures/en/#modify-order-trade
|
|
4954
|
-
* @see https://binance-docs.github.io/apidocs/delivery/en/#modify-order-trade
|
|
4955
|
-
* @param {string} id cancel order id
|
|
4956
|
-
* @param {string} symbol unified symbol of the market to create an order in
|
|
4957
|
-
* @param {string} type 'market' or 'limit'
|
|
4958
|
-
* @param {string} side 'buy' or 'sell'
|
|
4959
|
-
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
4960
|
-
* @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
|
|
4961
|
-
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4962
|
-
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4963
|
-
*/
|
|
4964
|
-
await this.loadMarkets();
|
|
4948
|
+
editContractOrderRequest(id, symbol, type, side, amount, price = undefined, params = {}) {
|
|
4965
4949
|
const market = this.market(symbol);
|
|
4966
4950
|
if (!market['contract']) {
|
|
4967
4951
|
throw new errors.NotSupported(this.id + ' editContractOrder() does not support ' + market['type'] + ' orders');
|
|
@@ -4980,6 +4964,27 @@ class binance extends binance$1 {
|
|
|
4980
4964
|
request['origClientOrderId'] = clientOrderId;
|
|
4981
4965
|
}
|
|
4982
4966
|
params = this.omit(params, ['clientOrderId', 'newClientOrderId']);
|
|
4967
|
+
return request;
|
|
4968
|
+
}
|
|
4969
|
+
async editContractOrder(id, symbol, type, side, amount, price = undefined, params = {}) {
|
|
4970
|
+
/**
|
|
4971
|
+
* @method
|
|
4972
|
+
* @name binance#editContractOrder
|
|
4973
|
+
* @description edit a trade order
|
|
4974
|
+
* @see https://binance-docs.github.io/apidocs/futures/en/#modify-order-trade
|
|
4975
|
+
* @see https://binance-docs.github.io/apidocs/delivery/en/#modify-order-trade
|
|
4976
|
+
* @param {string} id cancel order id
|
|
4977
|
+
* @param {string} symbol unified symbol of the market to create an order in
|
|
4978
|
+
* @param {string} type 'market' or 'limit'
|
|
4979
|
+
* @param {string} side 'buy' or 'sell'
|
|
4980
|
+
* @param {float} amount how much of currency you want to trade in units of base currency
|
|
4981
|
+
* @param {float} [price] the price at which the order is to be fullfilled, in units of the base currency, ignored in market orders
|
|
4982
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
4983
|
+
* @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
|
|
4984
|
+
*/
|
|
4985
|
+
await this.loadMarkets();
|
|
4986
|
+
const market = this.market(symbol);
|
|
4987
|
+
const request = this.editContractOrderRequest(id, symbol, type, side, amount, price, params);
|
|
4983
4988
|
let response = undefined;
|
|
4984
4989
|
if (market['linear']) {
|
|
4985
4990
|
response = await this.fapiPrivatePutOrder(this.extend(request, params));
|