ccxt 4.1.90 → 4.1.91

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/dist/cjs/ccxt.js CHANGED
@@ -168,7 +168,7 @@ var woo$1 = require('./src/pro/woo.js');
168
168
 
169
169
  //-----------------------------------------------------------------------------
170
170
  // this is updated by vss.js when building
171
- const version = '4.1.90';
171
+ const version = '4.1.91';
172
172
  Exchange["default"].ccxtVersion = version;
173
173
  const exchanges = {
174
174
  'ace': ace,
@@ -41,6 +41,9 @@ class binance extends binance$1 {
41
41
  'closeAllPositions': false,
42
42
  'closePosition': false,
43
43
  'createDepositAddress': false,
44
+ 'createMarketBuyOrderWithCost': true,
45
+ 'createMarketOrderWithCost': true,
46
+ 'createMarketSellOrderWithCost': true,
44
47
  'createOrder': true,
45
48
  'createOrders': true,
46
49
  'createPostOnlyOrder': true,
@@ -4654,6 +4657,64 @@ class binance extends binance$1 {
4654
4657
  const requestParams = this.omit(params, ['quoteOrderQty', 'cost', 'stopPrice', 'test', 'type', 'newClientOrderId', 'clientOrderId', 'postOnly']);
4655
4658
  return this.extend(request, requestParams);
4656
4659
  }
4660
+ async createMarketOrderWithCost(symbol, side, cost, params = {}) {
4661
+ /**
4662
+ * @method
4663
+ * @name binance#createMarketOrderWithCost
4664
+ * @description create a market order by providing the symbol, side and cost
4665
+ * @see https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
4666
+ * @param {string} symbol unified symbol of the market to create an order in
4667
+ * @param {string} side 'buy' or 'sell'
4668
+ * @param {float} cost how much you want to trade in units of the quote currency
4669
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4670
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4671
+ */
4672
+ await this.loadMarkets();
4673
+ const market = this.market(symbol);
4674
+ if (!market['spot']) {
4675
+ throw new errors.NotSupported(this.id + ' createMarketOrderWithCost() supports spot orders only');
4676
+ }
4677
+ params['quoteOrderQty'] = cost;
4678
+ return await this.createOrder(symbol, 'market', side, cost, undefined, params);
4679
+ }
4680
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
4681
+ /**
4682
+ * @method
4683
+ * @name binance#createMarketBuyOrderWithCost
4684
+ * @description create a market buy order by providing the symbol and cost
4685
+ * @see https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
4686
+ * @param {string} symbol unified symbol of the market to create an order in
4687
+ * @param {float} cost how much you want to trade in units of the quote currency
4688
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4689
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4690
+ */
4691
+ await this.loadMarkets();
4692
+ const market = this.market(symbol);
4693
+ if (!market['spot']) {
4694
+ throw new errors.NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
4695
+ }
4696
+ params['quoteOrderQty'] = cost;
4697
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
4698
+ }
4699
+ async createMarketSellOrderWithCost(symbol, cost, params = {}) {
4700
+ /**
4701
+ * @method
4702
+ * @name binance#createMarketSellOrderWithCost
4703
+ * @description create a market sell order by providing the symbol and cost
4704
+ * @see https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
4705
+ * @param {string} symbol unified symbol of the market to create an order in
4706
+ * @param {float} cost how much you want to trade in units of the quote currency
4707
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4708
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4709
+ */
4710
+ await this.loadMarkets();
4711
+ const market = this.market(symbol);
4712
+ if (!market['spot']) {
4713
+ throw new errors.NotSupported(this.id + ' createMarketSellOrderWithCost() supports spot orders only');
4714
+ }
4715
+ params['quoteOrderQty'] = cost;
4716
+ return await this.createOrder(symbol, 'market', 'sell', cost, undefined, params);
4717
+ }
4657
4718
  async fetchOrder(id, symbol = undefined, params = {}) {
4658
4719
  /**
4659
4720
  * @method
@@ -490,6 +490,7 @@ class kucoin extends kucoin$1 {
490
490
  'commonCurrencies': {
491
491
  'BIFI': 'BIFIF',
492
492
  'VAI': 'VAIOT',
493
+ 'WAX': 'WAXP',
493
494
  },
494
495
  'options': {
495
496
  'version': 'v1',
@@ -35,6 +35,8 @@ class kucoinfutures extends kucoinfutures$1 {
35
35
  'createStopLimitOrder': true,
36
36
  'createStopMarketOrder': true,
37
37
  'createStopOrder': true,
38
+ 'closePosition': true,
39
+ 'closePositions': false,
38
40
  'fetchAccounts': true,
39
41
  'fetchBalance': true,
40
42
  'fetchBorrowRateHistories': false,
@@ -2412,6 +2414,41 @@ class kucoinfutures extends kucoinfutures$1 {
2412
2414
  'datetime': this.iso8601(timestamp),
2413
2415
  };
2414
2416
  }
2417
+ async closePosition(symbol, side = undefined, params = {}) {
2418
+ /**
2419
+ * @method
2420
+ * @name kucoinfutures#closePosition
2421
+ * @description closes open positions for a market
2422
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/place-order
2423
+ * @param {string} symbol Unified CCXT market symbol
2424
+ * @param {string} side not used by kucoinfutures closePositions
2425
+ * @param {object} [params] extra parameters specific to the okx api endpoint
2426
+ * @param {string} [params.clientOrderId] client order id of the order
2427
+ * @returns {[object]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
2428
+ */
2429
+ await this.loadMarkets();
2430
+ const market = this.market(symbol);
2431
+ let clientOrderId = this.safeString(params, 'clientOrderId');
2432
+ const testOrder = this.safeValue(params, 'test', false);
2433
+ params = this.omit(params, ['test', 'clientOrderId']);
2434
+ if (clientOrderId === undefined) {
2435
+ clientOrderId = this.numberToString(this.nonce());
2436
+ }
2437
+ const request = {
2438
+ 'symbol': market['id'],
2439
+ 'closeOrder': true,
2440
+ 'clientOid': clientOrderId,
2441
+ 'type': 'market',
2442
+ };
2443
+ let response = undefined;
2444
+ if (testOrder) {
2445
+ response = await this.futuresPrivatePostOrdersTest(this.extend(request, params));
2446
+ }
2447
+ else {
2448
+ response = await this.futuresPrivatePostOrders(this.extend(request, params));
2449
+ }
2450
+ return this.parseOrder(response, market);
2451
+ }
2415
2452
  }
2416
2453
 
2417
2454
  module.exports = kucoinfutures;
@@ -457,6 +457,7 @@ class phemex extends phemex$1 {
457
457
  'networks': {
458
458
  'TRC20': 'TRX',
459
459
  'ERC20': 'ETH',
460
+ 'BEP20': 'BNB',
460
461
  },
461
462
  'defaultNetworks': {
462
463
  'USDT': 'ETH',
@@ -3395,6 +3396,19 @@ class phemex extends phemex$1 {
3395
3396
  const statuses = {
3396
3397
  'Success': 'ok',
3397
3398
  'Succeed': 'ok',
3399
+ 'Rejected': 'failed',
3400
+ 'Security check failed': 'failed',
3401
+ 'SecurityCheckFailed': 'failed',
3402
+ 'Expired': 'failed',
3403
+ 'Address Risk': 'failed',
3404
+ 'Security Checking': 'pending',
3405
+ 'SecurityChecking': 'pending',
3406
+ 'Pending Review': 'pending',
3407
+ 'Pending Transfer': 'pending',
3408
+ 'AmlCsApporve': 'pending',
3409
+ 'New': 'pending',
3410
+ 'Confirmed': 'pending',
3411
+ 'Cancelled': 'canceled',
3398
3412
  };
3399
3413
  return this.safeString(statuses, status, status);
3400
3414
  }
@@ -3402,36 +3416,68 @@ class phemex extends phemex$1 {
3402
3416
  //
3403
3417
  // withdraw
3404
3418
  //
3405
- // ...
3419
+ // {
3420
+ // "id": "10000001",
3421
+ // "freezeId": null,
3422
+ // "address": "44exxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
3423
+ // "amountRv": "100",
3424
+ // "chainCode": "11",
3425
+ // "chainName": "TRX",
3426
+ // "currency": "USDT",
3427
+ // "currencyCode": 3,
3428
+ // "email": "abc@gmail.com",
3429
+ // "expiredTime": "0",
3430
+ // "feeRv": "1",
3431
+ // "nickName": null,
3432
+ // "phone": null,
3433
+ // "rejectReason": "",
3434
+ // "submitedAt": "1670000000000",
3435
+ // "submittedAt": "1670000000000",
3436
+ // "txHash": null,
3437
+ // "userId": "10000001",
3438
+ // "status": "Success"
3406
3439
  //
3407
3440
  // fetchDeposits
3408
3441
  //
3409
3442
  // {
3410
- // "id":29200,
3411
- // "currency":"USDT",
3412
- // "currencyCode":3,
3413
- // "txHash":"0x0bdbdc47807769a03b158d5753f54dfc58b92993d2f5e818db21863e01238e5d",
3414
- // "address":"0x5bfbf60e0fa7f63598e6cfd8a7fd3ffac4ccc6ad",
3415
- // "amountEv":3000000000,
3416
- // "confirmations":13,
3417
- // "type":"Deposit",
3418
- // "status":"Success",
3419
- // "createdAt":1592722565000
3443
+ // "id": "29200",
3444
+ // "currency": "USDT",
3445
+ // "currencyCode": "3",
3446
+ // "chainName": "ETH",
3447
+ // "chainCode": "4",
3448
+ // "txHash": "0x0bdbdc47807769a03b158d5753f54dfc58b92993d2f5e818db21863e01238e5d",
3449
+ // "address": "0x5bfbf60e0fa7f63598e6cfd8a7fd3ffac4ccc6ad",
3450
+ // "amountEv": "3000000000",
3451
+ // "confirmations": "13",
3452
+ // "type": "Deposit",
3453
+ // "status": "Success",
3454
+ // "createdAt": "1592722565000",
3420
3455
  // }
3421
3456
  //
3422
3457
  // fetchWithdrawals
3423
3458
  //
3424
3459
  // {
3425
- // "address": "1Lxxxxxxxxxxx"
3426
- // "amountEv": 200000
3427
- // "currency": "BTC"
3428
- // "currencyCode": 1
3429
- // "expiredTime": 0
3430
- // "feeEv": 50000
3431
- // "rejectReason": null
3432
- // "status": "Succeed"
3433
- // "txHash": "44exxxxxxxxxxxxxxxxxxxxxx"
3434
- // "withdrawStatus: ""
3460
+ // "id": "10000001",
3461
+ // "userId": "10000001",
3462
+ // "freezeId": "10000002",
3463
+ // "phone": null,
3464
+ // "email": "abc@gmail.com",
3465
+ // "nickName": null,
3466
+ // "currency": "USDT",
3467
+ // "currencyCode": "3",
3468
+ // "status": "Succeed",
3469
+ // "withdrawStatus": "Succeed",
3470
+ // "amountEv": "8800000000",
3471
+ // "feeEv": "1200000000",
3472
+ // "address": "0x5xxxad",
3473
+ // "txHash: "0x0xxxx5d",
3474
+ // "submitedAt": "1702571922000",
3475
+ // "submittedAt": "1702571922000",
3476
+ // "expiredTime": "0",
3477
+ // "rejectReason": null,
3478
+ // "chainName": "ETH",
3479
+ // "chainCode": "4",
3480
+ // "proxyAddress": null
3435
3481
  // }
3436
3482
  //
3437
3483
  const id = this.safeString(transaction, 'id');
@@ -3441,9 +3487,13 @@ class phemex extends phemex$1 {
3441
3487
  const currencyId = this.safeString(transaction, 'currency');
3442
3488
  currency = this.safeCurrency(currencyId, currency);
3443
3489
  const code = currency['code'];
3444
- const timestamp = this.safeInteger2(transaction, 'createdAt', 'submitedAt');
3490
+ const networkId = this.safeString(transaction, 'chainName');
3491
+ const timestamp = this.safeIntegerN(transaction, ['createdAt', 'submitedAt', 'submittedAt']);
3445
3492
  let type = this.safeStringLower(transaction, 'type');
3446
- const feeCost = this.parseNumber(this.fromEn(this.safeString(transaction, 'feeEv'), currency['valueScale']));
3493
+ let feeCost = this.parseNumber(this.fromEn(this.safeString(transaction, 'feeEv'), currency['valueScale']));
3494
+ if (feeCost === undefined) {
3495
+ feeCost = this.safeNumber(transaction, 'feeRv');
3496
+ }
3447
3497
  let fee = undefined;
3448
3498
  if (feeCost !== undefined) {
3449
3499
  type = 'withdrawal';
@@ -3453,14 +3503,17 @@ class phemex extends phemex$1 {
3453
3503
  };
3454
3504
  }
3455
3505
  const status = this.parseTransactionStatus(this.safeString(transaction, 'status'));
3456
- const amount = this.parseNumber(this.fromEn(this.safeString(transaction, 'amountEv'), currency['valueScale']));
3506
+ let amount = this.parseNumber(this.fromEn(this.safeString(transaction, 'amountEv'), currency['valueScale']));
3507
+ if (amount === undefined) {
3508
+ amount = this.safeNumber(transaction, 'amountRv');
3509
+ }
3457
3510
  return {
3458
3511
  'info': transaction,
3459
3512
  'id': id,
3460
3513
  'txid': txid,
3461
3514
  'timestamp': timestamp,
3462
3515
  'datetime': this.iso8601(timestamp),
3463
- 'network': undefined,
3516
+ 'network': this.networkIdToCode(networkId),
3464
3517
  'address': address,
3465
3518
  'addressTo': address,
3466
3519
  'addressFrom': undefined,
@@ -4602,10 +4655,38 @@ class phemex extends phemex$1 {
4602
4655
  'chainName': networkId.toUpperCase(),
4603
4656
  };
4604
4657
  if (tag !== undefined) {
4605
- request['tag'] = tag;
4658
+ request['addressTag'] = tag;
4606
4659
  }
4607
4660
  const response = await this.privatePostPhemexWithdrawWalletsApiCreateWithdraw(this.extend(request, params));
4608
- return this.parseTransaction(response, currency);
4661
+ //
4662
+ // {
4663
+ // "code": 0,
4664
+ // "msg": "OK",
4665
+ // "data": {
4666
+ // "id": "10000001",
4667
+ // "freezeId": null,
4668
+ // "address": "44exxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
4669
+ // "amountRv": "100",
4670
+ // "chainCode": "11",
4671
+ // "chainName": "TRX",
4672
+ // "currency": "USDT",
4673
+ // "currencyCode": 3,
4674
+ // "email": "abc@gmail.com",
4675
+ // "expiredTime": "0",
4676
+ // "feeRv": "1",
4677
+ // "nickName": null,
4678
+ // "phone": null,
4679
+ // "rejectReason": "",
4680
+ // "submitedAt": "1670000000000",
4681
+ // "submittedAt": "1670000000000",
4682
+ // "txHash": null,
4683
+ // "userId": "10000001",
4684
+ // "status": "Success"
4685
+ // }
4686
+ // }
4687
+ //
4688
+ const data = this.safeValue(response, 'data', {});
4689
+ return this.parseTransaction(data, currency);
4609
4690
  }
4610
4691
  handleErrors(httpCode, reason, url, method, headers, body, response, requestHeaders, requestBody) {
4611
4692
  if (response === undefined) {
@@ -48,7 +48,7 @@ class bitmart extends bitmart$1 {
48
48
  'defaultType': 'spot',
49
49
  'watchBalance': {
50
50
  'fetchBalanceSnapshot': true,
51
- 'awaitBalanceSnapshot': true, // whether to wait for the balance snapshot before providing updates
51
+ 'awaitBalanceSnapshot': false, // whether to wait for the balance snapshot before providing updates
52
52
  },
53
53
  'watchOrderBook': {
54
54
  'depth': 'depth50', // depth5, depth20, depth50
@@ -128,30 +128,31 @@ class bitmart extends bitmart$1 {
128
128
  const messageHash = 'balance:' + type;
129
129
  const url = this.implodeHostname(this.urls['api']['ws'][type]['private']);
130
130
  const client = this.client(url);
131
- this.setBalanceCache(client, type);
132
- const fetchBalanceSnapshot = this.handleOptionAndParams(this.options, 'watchBalance', 'fetchBalanceSnapshot', true);
133
- const awaitBalanceSnapshot = this.handleOptionAndParams(this.options, 'watchBalance', 'awaitBalanceSnapshot', false);
131
+ this.setBalanceCache(client, type, messageHash);
132
+ let fetchBalanceSnapshot = undefined;
133
+ let awaitBalanceSnapshot = undefined;
134
+ [fetchBalanceSnapshot, params] = this.handleOptionAndParams(this.options, 'watchBalance', 'fetchBalanceSnapshot', true);
135
+ [awaitBalanceSnapshot, params] = this.handleOptionAndParams(this.options, 'watchBalance', 'awaitBalanceSnapshot', false);
134
136
  if (fetchBalanceSnapshot && awaitBalanceSnapshot) {
135
137
  await client.future(type + ':fetchBalanceSnapshot');
136
138
  }
137
139
  return await this.watch(url, messageHash, this.deepExtend(request, params), messageHash);
138
140
  }
139
- setBalanceCache(client, type) {
140
- if (type in client.subscriptions) {
141
- return undefined;
141
+ setBalanceCache(client, type, subscribeHash) {
142
+ if (subscribeHash in client.subscriptions) {
143
+ return;
142
144
  }
143
145
  const options = this.safeValue(this.options, 'watchBalance');
144
- const fetchBalanceSnapshot = this.handleOptionAndParams(options, 'watchBalance', 'fetchBalanceSnapshot', true);
145
- if (fetchBalanceSnapshot) {
146
- const messageHash = type + ':fetchBalanceSnapshot';
146
+ const snapshot = this.safeValue(options, 'fetchBalanceSnapshot', true);
147
+ if (snapshot) {
148
+ const messageHash = type + ':' + 'fetchBalanceSnapshot';
147
149
  if (!(messageHash in client.futures)) {
148
150
  client.future(messageHash);
149
151
  this.spawn(this.loadBalanceSnapshot, client, messageHash, type);
150
152
  }
151
153
  }
152
- else {
153
- this.balance[type] = {};
154
- }
154
+ this.balance[type] = {};
155
+ // without this comment, transpilation breaks for some reason...
155
156
  }
156
157
  async loadBalanceSnapshot(client, messageHash, type) {
157
158
  const response = await this.fetchBalance({ 'type': type });
@@ -198,15 +199,15 @@ class bitmart extends bitmart$1 {
198
199
  }
199
200
  const isSpot = (channel.indexOf('spot') >= 0);
200
201
  const type = isSpot ? 'spot' : 'swap';
201
- this.balance['info'] = message;
202
+ this.balance[type]['info'] = message;
202
203
  if (isSpot) {
203
204
  if (!Array.isArray(data)) {
204
205
  return;
205
206
  }
206
207
  for (let i = 0; i < data.length; i++) {
207
208
  const timestamp = this.safeInteger(message, 'event_time');
208
- this.balance['timestamp'] = timestamp;
209
- this.balance['datetime'] = this.iso8601(timestamp);
209
+ this.balance[type]['timestamp'] = timestamp;
210
+ this.balance[type]['datetime'] = this.iso8601(timestamp);
210
211
  const balanceDetails = this.safeValue(data[i], 'balance_details', []);
211
212
  for (let ii = 0; ii < balanceDetails.length; ii++) {
212
213
  const rawBalance = balanceDetails[i];
@@ -214,8 +215,8 @@ class bitmart extends bitmart$1 {
214
215
  const currencyId = this.safeString(rawBalance, 'ccy');
215
216
  const code = this.safeCurrencyCode(currencyId);
216
217
  account['free'] = this.safeString(rawBalance, 'av_bal');
217
- account['total'] = this.safeString(rawBalance, 'fz_bal');
218
- this.balance[code] = account;
218
+ account['used'] = this.safeString(rawBalance, 'fz_bal');
219
+ this.balance[type][code] = account;
219
220
  }
220
221
  }
221
222
  }
@@ -299,15 +299,14 @@ class zaif extends zaif$1 {
299
299
  // }
300
300
  //
301
301
  const symbol = this.safeSymbol(undefined, market);
302
- const timestamp = this.milliseconds();
303
302
  const vwap = this.safeString(ticker, 'vwap');
304
303
  const baseVolume = this.safeString(ticker, 'volume');
305
304
  const quoteVolume = Precise["default"].stringMul(baseVolume, vwap);
306
305
  const last = this.safeString(ticker, 'last');
307
306
  return this.safeTicker({
308
307
  'symbol': symbol,
309
- 'timestamp': timestamp,
310
- 'datetime': this.iso8601(timestamp),
308
+ 'timestamp': undefined,
309
+ 'datetime': undefined,
311
310
  'high': this.safeString(ticker, 'high'),
312
311
  'low': this.safeString(ticker, 'low'),
313
312
  'bid': this.safeString(ticker, 'bid'),
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 type { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation, FundingHistory, MarginMode, Greeks } 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, NoChange } from './src/base/errors.js';
7
- declare const version = "4.1.89";
7
+ declare const version = "4.1.90";
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, NoChange } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.1.90';
41
+ const version = '4.1.91';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -48,6 +48,9 @@ export default class binance extends Exchange {
48
48
  createOrders(orders: OrderRequest[], params?: {}): Promise<Order[]>;
49
49
  createOrder(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): Promise<Order>;
50
50
  createOrderRequest(symbol: string, type: OrderType, side: OrderSide, amount: any, price?: any, params?: {}): any;
51
+ createMarketOrderWithCost(symbol: string, side: OrderSide, cost: any, params?: {}): Promise<Order>;
52
+ createMarketBuyOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
53
+ createMarketSellOrderWithCost(symbol: string, cost: any, params?: {}): Promise<Order>;
51
54
  fetchOrder(id: string, symbol?: Str, params?: {}): Promise<Order>;
52
55
  fetchOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
53
56
  fetchOpenOrders(symbol?: Str, since?: Int, limit?: Int, params?: {}): Promise<Order[]>;
package/js/src/binance.js CHANGED
@@ -44,6 +44,9 @@ export default class binance extends Exchange {
44
44
  'closeAllPositions': false,
45
45
  'closePosition': false,
46
46
  'createDepositAddress': false,
47
+ 'createMarketBuyOrderWithCost': true,
48
+ 'createMarketOrderWithCost': true,
49
+ 'createMarketSellOrderWithCost': true,
47
50
  'createOrder': true,
48
51
  'createOrders': true,
49
52
  'createPostOnlyOrder': true,
@@ -4657,6 +4660,64 @@ export default class binance extends Exchange {
4657
4660
  const requestParams = this.omit(params, ['quoteOrderQty', 'cost', 'stopPrice', 'test', 'type', 'newClientOrderId', 'clientOrderId', 'postOnly']);
4658
4661
  return this.extend(request, requestParams);
4659
4662
  }
4663
+ async createMarketOrderWithCost(symbol, side, cost, params = {}) {
4664
+ /**
4665
+ * @method
4666
+ * @name binance#createMarketOrderWithCost
4667
+ * @description create a market order by providing the symbol, side and cost
4668
+ * @see https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
4669
+ * @param {string} symbol unified symbol of the market to create an order in
4670
+ * @param {string} side 'buy' or 'sell'
4671
+ * @param {float} cost how much you want to trade in units of the quote currency
4672
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4673
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4674
+ */
4675
+ await this.loadMarkets();
4676
+ const market = this.market(symbol);
4677
+ if (!market['spot']) {
4678
+ throw new NotSupported(this.id + ' createMarketOrderWithCost() supports spot orders only');
4679
+ }
4680
+ params['quoteOrderQty'] = cost;
4681
+ return await this.createOrder(symbol, 'market', side, cost, undefined, params);
4682
+ }
4683
+ async createMarketBuyOrderWithCost(symbol, cost, params = {}) {
4684
+ /**
4685
+ * @method
4686
+ * @name binance#createMarketBuyOrderWithCost
4687
+ * @description create a market buy order by providing the symbol and cost
4688
+ * @see https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
4689
+ * @param {string} symbol unified symbol of the market to create an order in
4690
+ * @param {float} cost how much you want to trade in units of the quote currency
4691
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4692
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4693
+ */
4694
+ await this.loadMarkets();
4695
+ const market = this.market(symbol);
4696
+ if (!market['spot']) {
4697
+ throw new NotSupported(this.id + ' createMarketBuyOrderWithCost() supports spot orders only');
4698
+ }
4699
+ params['quoteOrderQty'] = cost;
4700
+ return await this.createOrder(symbol, 'market', 'buy', cost, undefined, params);
4701
+ }
4702
+ async createMarketSellOrderWithCost(symbol, cost, params = {}) {
4703
+ /**
4704
+ * @method
4705
+ * @name binance#createMarketSellOrderWithCost
4706
+ * @description create a market sell order by providing the symbol and cost
4707
+ * @see https://binance-docs.github.io/apidocs/spot/en/#new-order-trade
4708
+ * @param {string} symbol unified symbol of the market to create an order in
4709
+ * @param {float} cost how much you want to trade in units of the quote currency
4710
+ * @param {object} [params] extra parameters specific to the exchange API endpoint
4711
+ * @returns {object} an [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
4712
+ */
4713
+ await this.loadMarkets();
4714
+ const market = this.market(symbol);
4715
+ if (!market['spot']) {
4716
+ throw new NotSupported(this.id + ' createMarketSellOrderWithCost() supports spot orders only');
4717
+ }
4718
+ params['quoteOrderQty'] = cost;
4719
+ return await this.createOrder(symbol, 'market', 'sell', cost, undefined, params);
4720
+ }
4660
4721
  async fetchOrder(id, symbol = undefined, params = {}) {
4661
4722
  /**
4662
4723
  * @method
package/js/src/kucoin.js CHANGED
@@ -493,6 +493,7 @@ export default class kucoin extends Exchange {
493
493
  'commonCurrencies': {
494
494
  'BIFI': 'BIFIF',
495
495
  'VAI': 'VAIOT',
496
+ 'WAX': 'WAXP',
496
497
  },
497
498
  'options': {
498
499
  'version': 'v1',
@@ -93,4 +93,5 @@ export default class kucoinfutures extends kucoin {
93
93
  timestamp: number;
94
94
  datetime: string;
95
95
  };
96
+ closePosition(symbol: string, side?: OrderSide, params?: {}): Promise<Order>;
96
97
  }
@@ -38,6 +38,8 @@ export default class kucoinfutures extends kucoin {
38
38
  'createStopLimitOrder': true,
39
39
  'createStopMarketOrder': true,
40
40
  'createStopOrder': true,
41
+ 'closePosition': true,
42
+ 'closePositions': false,
41
43
  'fetchAccounts': true,
42
44
  'fetchBalance': true,
43
45
  'fetchBorrowRateHistories': false,
@@ -2415,4 +2417,39 @@ export default class kucoinfutures extends kucoin {
2415
2417
  'datetime': this.iso8601(timestamp),
2416
2418
  };
2417
2419
  }
2420
+ async closePosition(symbol, side = undefined, params = {}) {
2421
+ /**
2422
+ * @method
2423
+ * @name kucoinfutures#closePosition
2424
+ * @description closes open positions for a market
2425
+ * @see https://www.kucoin.com/docs/rest/futures-trading/orders/place-order
2426
+ * @param {string} symbol Unified CCXT market symbol
2427
+ * @param {string} side not used by kucoinfutures closePositions
2428
+ * @param {object} [params] extra parameters specific to the okx api endpoint
2429
+ * @param {string} [params.clientOrderId] client order id of the order
2430
+ * @returns {[object]} [A list of position structures]{@link https://docs.ccxt.com/#/?id=position-structure}
2431
+ */
2432
+ await this.loadMarkets();
2433
+ const market = this.market(symbol);
2434
+ let clientOrderId = this.safeString(params, 'clientOrderId');
2435
+ const testOrder = this.safeValue(params, 'test', false);
2436
+ params = this.omit(params, ['test', 'clientOrderId']);
2437
+ if (clientOrderId === undefined) {
2438
+ clientOrderId = this.numberToString(this.nonce());
2439
+ }
2440
+ const request = {
2441
+ 'symbol': market['id'],
2442
+ 'closeOrder': true,
2443
+ 'clientOid': clientOrderId,
2444
+ 'type': 'market',
2445
+ };
2446
+ let response = undefined;
2447
+ if (testOrder) {
2448
+ response = await this.futuresPrivatePostOrdersTest(this.extend(request, params));
2449
+ }
2450
+ else {
2451
+ response = await this.futuresPrivatePostOrders(this.extend(request, params));
2452
+ }
2453
+ return this.parseOrder(response, market);
2454
+ }
2418
2455
  }