ccxt 4.1.17 → 4.1.18

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.
@@ -250,6 +250,7 @@ class okx extends okx$1 {
250
250
  'trade/orders-history-archive': 1,
251
251
  'trade/fills': 1 / 3,
252
252
  'trade/fills-history': 2.2,
253
+ 'trade/fills-archive': 2,
253
254
  'trade/order-algo': 1,
254
255
  'trade/orders-algo-pending': 1,
255
256
  'trade/orders-algo-history': 1,
@@ -316,6 +317,12 @@ class okx extends okx$1 {
316
317
  'tradingBot/grid/orders-algo-details': 1,
317
318
  'tradingBot/grid/sub-orders': 1,
318
319
  'tradingBot/grid/positions': 1,
320
+ 'tradingBot/grid/ai-param': 1,
321
+ 'tradingBot/public/rsi-back-testing': 1,
322
+ 'tradingBot/signal/orders-algo-details': 1,
323
+ 'tradingBot/signal/positions': 1,
324
+ 'tradingBot/signal/sub-orders': 1,
325
+ 'tradingBot/signal/event-history': 1,
319
326
  'tradingBot/recurring/orders-algo-pending': 1,
320
327
  'tradingBot/recurring/orders-algo-history': 1,
321
328
  'tradingBot/recurring/orders-algo-details': 1,
@@ -372,6 +379,7 @@ class okx extends okx$1 {
372
379
  'trade/amend-order': 1 / 3,
373
380
  'trade/amend-batch-orders': 1 / 150,
374
381
  'trade/close-position': 1,
382
+ 'trade/fills-archive': 172800,
375
383
  'trade/order-algo': 1,
376
384
  'trade/cancel-algos': 1,
377
385
  'trade/amend-algos': 1,
@@ -446,6 +454,7 @@ class okx extends okx$1 {
446
454
  'broker/nd/rebate-per-orders': 36000,
447
455
  'finance/sfp/dcd/quote': 10,
448
456
  'finance/sfp/dcd/order': 10,
457
+ 'broker/nd/report-subaccount-ip': 0.25,
449
458
  'broker/fd/rebate-per-orders': 36000,
450
459
  },
451
460
  },
@@ -101,7 +101,7 @@ class paymium extends paymium$1 {
101
101
  },
102
102
  },
103
103
  'markets': {
104
- 'BTC/EUR': { 'id': 'eur', 'symbol': 'BTC/EUR', 'base': 'BTC', 'quote': 'EUR', 'baseId': 'btc', 'quoteId': 'eur', 'type': 'spot', 'spot': true },
104
+ 'BTC/EUR': this.safeMarketStructure({ 'id': 'eur', 'symbol': 'BTC/EUR', 'base': 'BTC', 'quote': 'EUR', 'baseId': 'btc', 'quoteId': 'eur', 'type': 'spot', 'spot': true }),
105
105
  },
106
106
  'fees': {
107
107
  'trading': {
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax, Position, FundingRateHistory, Liquidation } 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.16";
7
+ declare const version = "4.1.17";
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.17';
41
+ const version = '4.1.18';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -79,6 +79,7 @@ interface okx {
79
79
  privateGetTradeOrdersHistoryArchive(params?: {}): Promise<implicitReturnType>;
80
80
  privateGetTradeFills(params?: {}): Promise<implicitReturnType>;
81
81
  privateGetTradeFillsHistory(params?: {}): Promise<implicitReturnType>;
82
+ privateGetTradeFillsArchive(params?: {}): Promise<implicitReturnType>;
82
83
  privateGetTradeOrderAlgo(params?: {}): Promise<implicitReturnType>;
83
84
  privateGetTradeOrdersAlgoPending(params?: {}): Promise<implicitReturnType>;
84
85
  privateGetTradeOrdersAlgoHistory(params?: {}): Promise<implicitReturnType>;
@@ -141,6 +142,12 @@ interface okx {
141
142
  privateGetTradingBotGridOrdersAlgoDetails(params?: {}): Promise<implicitReturnType>;
142
143
  privateGetTradingBotGridSubOrders(params?: {}): Promise<implicitReturnType>;
143
144
  privateGetTradingBotGridPositions(params?: {}): Promise<implicitReturnType>;
145
+ privateGetTradingBotGridAiParam(params?: {}): Promise<implicitReturnType>;
146
+ privateGetTradingBotPublicRsiBackTesting(params?: {}): Promise<implicitReturnType>;
147
+ privateGetTradingBotSignalOrdersAlgoDetails(params?: {}): Promise<implicitReturnType>;
148
+ privateGetTradingBotSignalPositions(params?: {}): Promise<implicitReturnType>;
149
+ privateGetTradingBotSignalSubOrders(params?: {}): Promise<implicitReturnType>;
150
+ privateGetTradingBotSignalEventHistory(params?: {}): Promise<implicitReturnType>;
144
151
  privateGetTradingBotRecurringOrdersAlgoPending(params?: {}): Promise<implicitReturnType>;
145
152
  privateGetTradingBotRecurringOrdersAlgoHistory(params?: {}): Promise<implicitReturnType>;
146
153
  privateGetTradingBotRecurringOrdersAlgoDetails(params?: {}): Promise<implicitReturnType>;
@@ -189,6 +196,7 @@ interface okx {
189
196
  privatePostTradeAmendOrder(params?: {}): Promise<implicitReturnType>;
190
197
  privatePostTradeAmendBatchOrders(params?: {}): Promise<implicitReturnType>;
191
198
  privatePostTradeClosePosition(params?: {}): Promise<implicitReturnType>;
199
+ privatePostTradeFillsArchive(params?: {}): Promise<implicitReturnType>;
192
200
  privatePostTradeOrderAlgo(params?: {}): Promise<implicitReturnType>;
193
201
  privatePostTradeCancelAlgos(params?: {}): Promise<implicitReturnType>;
194
202
  privatePostTradeAmendAlgos(params?: {}): Promise<implicitReturnType>;
@@ -256,6 +264,7 @@ interface okx {
256
264
  privatePostBrokerNdRebatePerOrders(params?: {}): Promise<implicitReturnType>;
257
265
  privatePostFinanceSfpDcdQuote(params?: {}): Promise<implicitReturnType>;
258
266
  privatePostFinanceSfpDcdOrder(params?: {}): Promise<implicitReturnType>;
267
+ privatePostBrokerNdReportSubaccountIp(params?: {}): Promise<implicitReturnType>;
259
268
  privatePostBrokerFdRebatePerOrders(params?: {}): Promise<implicitReturnType>;
260
269
  }
261
270
  declare abstract class okx extends _okx {
@@ -79,6 +79,7 @@ interface okex {
79
79
  privateGetTradeOrdersHistoryArchive(params?: {}): Promise<implicitReturnType>;
80
80
  privateGetTradeFills(params?: {}): Promise<implicitReturnType>;
81
81
  privateGetTradeFillsHistory(params?: {}): Promise<implicitReturnType>;
82
+ privateGetTradeFillsArchive(params?: {}): Promise<implicitReturnType>;
82
83
  privateGetTradeOrderAlgo(params?: {}): Promise<implicitReturnType>;
83
84
  privateGetTradeOrdersAlgoPending(params?: {}): Promise<implicitReturnType>;
84
85
  privateGetTradeOrdersAlgoHistory(params?: {}): Promise<implicitReturnType>;
@@ -141,6 +142,12 @@ interface okex {
141
142
  privateGetTradingBotGridOrdersAlgoDetails(params?: {}): Promise<implicitReturnType>;
142
143
  privateGetTradingBotGridSubOrders(params?: {}): Promise<implicitReturnType>;
143
144
  privateGetTradingBotGridPositions(params?: {}): Promise<implicitReturnType>;
145
+ privateGetTradingBotGridAiParam(params?: {}): Promise<implicitReturnType>;
146
+ privateGetTradingBotPublicRsiBackTesting(params?: {}): Promise<implicitReturnType>;
147
+ privateGetTradingBotSignalOrdersAlgoDetails(params?: {}): Promise<implicitReturnType>;
148
+ privateGetTradingBotSignalPositions(params?: {}): Promise<implicitReturnType>;
149
+ privateGetTradingBotSignalSubOrders(params?: {}): Promise<implicitReturnType>;
150
+ privateGetTradingBotSignalEventHistory(params?: {}): Promise<implicitReturnType>;
144
151
  privateGetTradingBotRecurringOrdersAlgoPending(params?: {}): Promise<implicitReturnType>;
145
152
  privateGetTradingBotRecurringOrdersAlgoHistory(params?: {}): Promise<implicitReturnType>;
146
153
  privateGetTradingBotRecurringOrdersAlgoDetails(params?: {}): Promise<implicitReturnType>;
@@ -189,6 +196,7 @@ interface okex {
189
196
  privatePostTradeAmendOrder(params?: {}): Promise<implicitReturnType>;
190
197
  privatePostTradeAmendBatchOrders(params?: {}): Promise<implicitReturnType>;
191
198
  privatePostTradeClosePosition(params?: {}): Promise<implicitReturnType>;
199
+ privatePostTradeFillsArchive(params?: {}): Promise<implicitReturnType>;
192
200
  privatePostTradeOrderAlgo(params?: {}): Promise<implicitReturnType>;
193
201
  privatePostTradeCancelAlgos(params?: {}): Promise<implicitReturnType>;
194
202
  privatePostTradeAmendAlgos(params?: {}): Promise<implicitReturnType>;
@@ -256,6 +264,7 @@ interface okex {
256
264
  privatePostBrokerNdRebatePerOrders(params?: {}): Promise<implicitReturnType>;
257
265
  privatePostFinanceSfpDcdQuote(params?: {}): Promise<implicitReturnType>;
258
266
  privatePostFinanceSfpDcdOrder(params?: {}): Promise<implicitReturnType>;
267
+ privatePostBrokerNdReportSubaccountIp(params?: {}): Promise<implicitReturnType>;
259
268
  privatePostBrokerFdRebatePerOrders(params?: {}): Promise<implicitReturnType>;
260
269
  }
261
270
  declare abstract class okex extends _okex {
@@ -79,6 +79,7 @@ interface Exchange {
79
79
  privateGetTradeOrdersHistoryArchive(params?: {}): Promise<implicitReturnType>;
80
80
  privateGetTradeFills(params?: {}): Promise<implicitReturnType>;
81
81
  privateGetTradeFillsHistory(params?: {}): Promise<implicitReturnType>;
82
+ privateGetTradeFillsArchive(params?: {}): Promise<implicitReturnType>;
82
83
  privateGetTradeOrderAlgo(params?: {}): Promise<implicitReturnType>;
83
84
  privateGetTradeOrdersAlgoPending(params?: {}): Promise<implicitReturnType>;
84
85
  privateGetTradeOrdersAlgoHistory(params?: {}): Promise<implicitReturnType>;
@@ -141,6 +142,12 @@ interface Exchange {
141
142
  privateGetTradingBotGridOrdersAlgoDetails(params?: {}): Promise<implicitReturnType>;
142
143
  privateGetTradingBotGridSubOrders(params?: {}): Promise<implicitReturnType>;
143
144
  privateGetTradingBotGridPositions(params?: {}): Promise<implicitReturnType>;
145
+ privateGetTradingBotGridAiParam(params?: {}): Promise<implicitReturnType>;
146
+ privateGetTradingBotPublicRsiBackTesting(params?: {}): Promise<implicitReturnType>;
147
+ privateGetTradingBotSignalOrdersAlgoDetails(params?: {}): Promise<implicitReturnType>;
148
+ privateGetTradingBotSignalPositions(params?: {}): Promise<implicitReturnType>;
149
+ privateGetTradingBotSignalSubOrders(params?: {}): Promise<implicitReturnType>;
150
+ privateGetTradingBotSignalEventHistory(params?: {}): Promise<implicitReturnType>;
144
151
  privateGetTradingBotRecurringOrdersAlgoPending(params?: {}): Promise<implicitReturnType>;
145
152
  privateGetTradingBotRecurringOrdersAlgoHistory(params?: {}): Promise<implicitReturnType>;
146
153
  privateGetTradingBotRecurringOrdersAlgoDetails(params?: {}): Promise<implicitReturnType>;
@@ -189,6 +196,7 @@ interface Exchange {
189
196
  privatePostTradeAmendOrder(params?: {}): Promise<implicitReturnType>;
190
197
  privatePostTradeAmendBatchOrders(params?: {}): Promise<implicitReturnType>;
191
198
  privatePostTradeClosePosition(params?: {}): Promise<implicitReturnType>;
199
+ privatePostTradeFillsArchive(params?: {}): Promise<implicitReturnType>;
192
200
  privatePostTradeOrderAlgo(params?: {}): Promise<implicitReturnType>;
193
201
  privatePostTradeCancelAlgos(params?: {}): Promise<implicitReturnType>;
194
202
  privatePostTradeAmendAlgos(params?: {}): Promise<implicitReturnType>;
@@ -256,6 +264,7 @@ interface Exchange {
256
264
  privatePostBrokerNdRebatePerOrders(params?: {}): Promise<implicitReturnType>;
257
265
  privatePostFinanceSfpDcdQuote(params?: {}): Promise<implicitReturnType>;
258
266
  privatePostFinanceSfpDcdOrder(params?: {}): Promise<implicitReturnType>;
267
+ privatePostBrokerNdReportSubaccountIp(params?: {}): Promise<implicitReturnType>;
259
268
  privatePostBrokerFdRebatePerOrders(params?: {}): Promise<implicitReturnType>;
260
269
  }
261
270
  declare abstract class Exchange extends _Exchange {
@@ -603,6 +603,7 @@ export default class Exchange {
603
603
  info: object;
604
604
  };
605
605
  safeCurrencyStructure(currency: object): any;
606
+ safeMarketStructure(market?: object): any;
606
607
  setMarkets(markets: any, currencies?: any): Dictionary<any>;
607
608
  safeBalance(balance: object): Balances;
608
609
  safeOrder(order: object, market?: object): Order;
@@ -1516,6 +1516,87 @@ export default class Exchange {
1516
1516
  },
1517
1517
  }, currency);
1518
1518
  }
1519
+ safeMarketStructure(market = undefined) {
1520
+ const cleanStructure = {
1521
+ 'id': undefined,
1522
+ 'lowercaseId': undefined,
1523
+ 'symbol': undefined,
1524
+ 'base': undefined,
1525
+ 'quote': undefined,
1526
+ 'settle': undefined,
1527
+ 'baseId': undefined,
1528
+ 'quoteId': undefined,
1529
+ 'settleId': undefined,
1530
+ 'type': undefined,
1531
+ 'spot': undefined,
1532
+ 'margin': undefined,
1533
+ 'swap': undefined,
1534
+ 'future': undefined,
1535
+ 'option': undefined,
1536
+ 'index': undefined,
1537
+ 'active': undefined,
1538
+ 'contract': undefined,
1539
+ 'linear': undefined,
1540
+ 'inverse': undefined,
1541
+ 'taker': undefined,
1542
+ 'maker': undefined,
1543
+ 'contractSize': undefined,
1544
+ 'expiry': undefined,
1545
+ 'expiryDatetime': undefined,
1546
+ 'strike': undefined,
1547
+ 'optionType': undefined,
1548
+ 'precision': {
1549
+ 'amount': undefined,
1550
+ 'price': undefined,
1551
+ 'cost': undefined,
1552
+ 'base': undefined,
1553
+ 'quote': undefined,
1554
+ },
1555
+ 'limits': {
1556
+ 'leverage': {
1557
+ 'min': undefined,
1558
+ 'max': undefined,
1559
+ },
1560
+ 'amount': {
1561
+ 'min': undefined,
1562
+ 'max': undefined,
1563
+ },
1564
+ 'price': {
1565
+ 'min': undefined,
1566
+ 'max': undefined,
1567
+ },
1568
+ 'cost': {
1569
+ 'min': undefined,
1570
+ 'max': undefined,
1571
+ },
1572
+ },
1573
+ 'created': undefined,
1574
+ 'info': undefined,
1575
+ };
1576
+ if (market !== undefined) {
1577
+ const result = this.extend(cleanStructure, market);
1578
+ // set undefined swap/future/etc
1579
+ if (result['spot']) {
1580
+ if (result['contract'] === undefined) {
1581
+ result['contract'] = false;
1582
+ }
1583
+ if (result['swap'] === undefined) {
1584
+ result['swap'] = false;
1585
+ }
1586
+ if (result['future'] === undefined) {
1587
+ result['future'] = false;
1588
+ }
1589
+ if (result['option'] === undefined) {
1590
+ result['option'] = false;
1591
+ }
1592
+ if (result['index'] === undefined) {
1593
+ result['index'] = false;
1594
+ }
1595
+ }
1596
+ return result;
1597
+ }
1598
+ return cleanStructure;
1599
+ }
1519
1600
  setMarkets(markets, currencies = undefined) {
1520
1601
  const values = [];
1521
1602
  this.markets_by_id = {};
@@ -37,7 +37,7 @@ const safeInteger = (o, k, $default) => {
37
37
  return isNumber(n) ? n : $default;
38
38
  };
39
39
  const safeIntegerProduct = (o, k, $factor, $default) => {
40
- const n = asInteger(prop(o, k));
40
+ const n = asFloat(prop(o, k));
41
41
  return isNumber(n) ? parseInt(n * $factor) : $default;
42
42
  };
43
43
  const safeTimestamp = (o, k, $default) => {
package/js/src/bit2c.js CHANGED
@@ -121,10 +121,10 @@ export default class bit2c extends Exchange {
121
121
  },
122
122
  },
123
123
  'markets': {
124
- 'BTC/NIS': { 'id': 'BtcNis', 'symbol': 'BTC/NIS', 'base': 'BTC', 'quote': 'NIS', 'baseId': 'Btc', 'quoteId': 'Nis', 'type': 'spot', 'spot': true },
125
- 'ETH/NIS': { 'id': 'EthNis', 'symbol': 'ETH/NIS', 'base': 'ETH', 'quote': 'NIS', 'baseId': 'Eth', 'quoteId': 'Nis', 'type': 'spot', 'spot': true },
126
- 'LTC/NIS': { 'id': 'LtcNis', 'symbol': 'LTC/NIS', 'base': 'LTC', 'quote': 'NIS', 'baseId': 'Ltc', 'quoteId': 'Nis', 'type': 'spot', 'spot': true },
127
- 'USDC/NIS': { 'id': 'UsdcNis', 'symbol': 'USDC/NIS', 'base': 'USDC', 'quote': 'NIS', 'baseId': 'Usdc', 'quoteId': 'Nis', 'type': 'spot', 'spot': true },
124
+ 'BTC/NIS': this.safeMarketStructure({ 'id': 'BtcNis', 'symbol': 'BTC/NIS', 'base': 'BTC', 'quote': 'NIS', 'baseId': 'Btc', 'quoteId': 'Nis', 'type': 'spot', 'spot': true }),
125
+ 'ETH/NIS': this.safeMarketStructure({ 'id': 'EthNis', 'symbol': 'ETH/NIS', 'base': 'ETH', 'quote': 'NIS', 'baseId': 'Eth', 'quoteId': 'Nis', 'type': 'spot', 'spot': true }),
126
+ 'LTC/NIS': this.safeMarketStructure({ 'id': 'LtcNis', 'symbol': 'LTC/NIS', 'base': 'LTC', 'quote': 'NIS', 'baseId': 'Ltc', 'quoteId': 'Nis', 'type': 'spot', 'spot': true }),
127
+ 'USDC/NIS': this.safeMarketStructure({ 'id': 'UsdcNis', 'symbol': 'USDC/NIS', 'base': 'USDC', 'quote': 'NIS', 'baseId': 'Usdc', 'quoteId': 'Nis', 'type': 'spot', 'spot': true }),
128
128
  },
129
129
  'fees': {
130
130
  'trading': {
package/js/src/bitget.js CHANGED
@@ -2931,10 +2931,26 @@ export default class bitget extends Exchange {
2931
2931
  // "cTime": "1652745674488"
2932
2932
  // }
2933
2933
  //
2934
+ // swap, isolated and cross margin: cancelOrder
2935
+ //
2936
+ // {
2937
+ // "orderId": "1098749943604719616",
2938
+ // "clientOid": "0ec8d262b3d2436aa651095a745b9b8d"
2939
+ // }
2940
+ //
2941
+ // spot: cancelOrder
2942
+ //
2943
+ // {
2944
+ // "code": "00000",
2945
+ // "msg": "success",
2946
+ // "requestTime": 1697689270716,
2947
+ // "data": "1098753830701928448"
2948
+ // }
2949
+ //
2934
2950
  const marketId = this.safeString(order, 'symbol');
2935
2951
  market = this.safeMarket(marketId, market);
2936
2952
  const symbol = market['symbol'];
2937
- const id = this.safeString(order, 'orderId');
2953
+ const id = this.safeString2(order, 'orderId', 'data');
2938
2954
  const price = this.safeString2(order, 'price', 'executePrice');
2939
2955
  const amount = this.safeString2(order, 'quantity', 'size');
2940
2956
  const filled = this.safeString2(order, 'fillQuantity', 'filledQty');
@@ -3353,44 +3369,130 @@ export default class bitget extends Exchange {
3353
3369
  * @see https://bitgetlimited.github.io/apidoc/en/spot/#cancel-plan-order
3354
3370
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#cancel-order
3355
3371
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#cancel-plan-order-tpsl
3372
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-cancel-order
3373
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-cancel-order
3356
3374
  * @param {string} id order id
3357
3375
  * @param {string} symbol unified symbol of the market the order was made in
3358
3376
  * @param {object} [params] extra parameters specific to the bitget api endpoint
3377
+ * @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
3359
3378
  * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
3360
3379
  */
3361
3380
  this.checkRequiredSymbol('cancelOrder', symbol);
3362
3381
  await this.loadMarkets();
3363
3382
  const market = this.market(symbol);
3364
- const [marketType, query] = this.handleMarketTypeAndParams('cancelOrder', market, params);
3365
- let method = this.getSupportedMapping(marketType, {
3366
- 'spot': 'privateSpotPostTradeCancelOrder',
3367
- 'swap': 'privateMixPostOrderCancelOrder',
3368
- 'future': 'privateMixPostOrderCancelOrder',
3369
- });
3383
+ let marketType = undefined;
3384
+ let marginMode = undefined;
3385
+ let response = undefined;
3386
+ [marketType, params] = this.handleMarketTypeAndParams('cancelOrder', market, params);
3387
+ [marginMode, params] = this.handleMarginModeAndParams('cancelOrder', params);
3388
+ const symbolRequest = (marginMode !== undefined) ? (market['info']['symbolName']) : (market['id']);
3370
3389
  const request = {
3371
- 'symbol': market['id'],
3390
+ 'symbol': symbolRequest,
3372
3391
  'orderId': id,
3373
3392
  };
3374
- const stop = this.safeValue(query, 'stop');
3375
- if (stop) {
3376
- if (marketType === 'spot') {
3377
- method = 'privateSpotPostPlanCancelPlan';
3378
- }
3379
- else {
3380
- const planType = this.safeString(params, 'planType');
3393
+ const stop = this.safeValue(params, 'stop');
3394
+ const planType = this.safeString(params, 'planType');
3395
+ params = this.omit(params, ['stop', 'planType']);
3396
+ if ((marketType === 'swap') || (marketType === 'future')) {
3397
+ request['marginCoin'] = market['settleId'];
3398
+ if (stop) {
3381
3399
  if (planType === undefined) {
3382
3400
  throw new ArgumentsRequired(this.id + ' cancelOrder() requires a planType parameter for stop orders, either normal_plan, profit_plan or loss_plan');
3383
3401
  }
3384
3402
  request['planType'] = planType;
3385
- method = 'privateMixPostPlanCancelPlan';
3403
+ response = await this.privateMixPostPlanCancelPlan(this.extend(request, params));
3404
+ }
3405
+ else {
3406
+ response = await this.privateMixPostOrderCancelOrder(this.extend(request, params));
3386
3407
  }
3387
3408
  }
3388
- if (marketType === 'swap') {
3389
- request['marginCoin'] = market['settleId'];
3409
+ else if (marketType === 'spot') {
3410
+ if (marginMode !== undefined) {
3411
+ if (marginMode === 'isolated') {
3412
+ response = await this.privateMarginPostIsolatedOrderCancelOrder(this.extend(request, params));
3413
+ }
3414
+ else if (marginMode === 'cross') {
3415
+ response = await this.privateMarginPostCrossOrderCancelOrder(this.extend(request, params));
3416
+ }
3417
+ }
3418
+ else {
3419
+ if (stop) {
3420
+ response = await this.privateSpotPostPlanCancelPlan(this.extend(request, params));
3421
+ }
3422
+ else {
3423
+ response = await this.privateSpotPostTradeCancelOrder(this.extend(request, params));
3424
+ }
3425
+ }
3426
+ }
3427
+ else {
3428
+ throw new NotSupported(this.id + ' cancelOrder() does not support ' + marketType + ' orders');
3429
+ }
3430
+ //
3431
+ // spot
3432
+ //
3433
+ // {
3434
+ // "code": "00000",
3435
+ // "msg": "success",
3436
+ // "requestTime": 1697689270716,
3437
+ // "data": "1098753830701928448"
3438
+ // }
3439
+ //
3440
+ // isolated margin
3441
+ //
3442
+ // {
3443
+ // "code": "00000",
3444
+ // "msg": "success",
3445
+ // "requestTime": 1697688367859,
3446
+ // "data": {
3447
+ // "resultList": [
3448
+ // {
3449
+ // "orderId": "1098749943604719616",
3450
+ // "clientOid": "0ec8d262b3d2436aa651095a745b9b8d"
3451
+ // }
3452
+ // ],
3453
+ // "failure": []
3454
+ // }
3455
+ // }
3456
+ //
3457
+ // cross margin
3458
+ //
3459
+ // {
3460
+ // "code": "00000",
3461
+ // "msg": "success",
3462
+ // "requestTime": :1697689028972,
3463
+ // "data": {
3464
+ // "resultList": [
3465
+ // {
3466
+ // "orderId": "1098751730051067906",
3467
+ // "clientOid": "ecb50ca373374c5bb814bc724e36b0eb"
3468
+ // }
3469
+ // ],
3470
+ // "failure": []
3471
+ // }
3472
+ // }
3473
+ //
3474
+ // swap
3475
+ //
3476
+ // {
3477
+ // "code": "00000",
3478
+ // "msg": "success",
3479
+ // "requestTime": 1697690413177,
3480
+ // "data": {
3481
+ // "orderId": "1098758604547850241",
3482
+ // "clientOid": "1098758604585598977"
3483
+ // }
3484
+ // }
3485
+ //
3486
+ let order = response;
3487
+ if ((marketType === 'swap') || (marketType === 'future')) {
3488
+ order = this.safeValue(response, 'data', {});
3489
+ }
3490
+ else if (marginMode !== undefined) {
3491
+ const data = this.safeValue(response, 'data', {});
3492
+ const resultList = this.safeValue(data, 'resultList', []);
3493
+ order = resultList[0];
3390
3494
  }
3391
- const ommitted = this.omit(query, ['stop', 'planType']);
3392
- const response = await this[method](this.extend(request, ommitted));
3393
- return this.parseOrder(response, market);
3495
+ return this.parseOrder(order, market);
3394
3496
  }
3395
3497
  async cancelOrders(ids, symbol = undefined, params = {}) {
3396
3498
  /**
@@ -3399,30 +3501,44 @@ export default class bitget extends Exchange {
3399
3501
  * @description cancel multiple orders
3400
3502
  * @see https://bitgetlimited.github.io/apidoc/en/spot/#cancel-order-in-batch-v2-single-instruments
3401
3503
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#batch-cancel-order
3504
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-batch-cancel-orders
3505
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-batch-cancel-order
3402
3506
  * @param {string[]} ids order ids
3403
3507
  * @param {string} symbol unified market symbol, default is undefined
3404
3508
  * @param {object} [params] extra parameters specific to the bitget api endpoint
3509
+ * @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
3405
3510
  * @returns {object} an list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
3406
3511
  */
3407
3512
  this.checkRequiredSymbol('cancelOrders', symbol);
3408
3513
  await this.loadMarkets();
3409
3514
  const market = this.market(symbol);
3410
3515
  let type = undefined;
3516
+ let marginMode = undefined;
3517
+ [marginMode, params] = this.handleMarginModeAndParams('cancelOrders', params);
3411
3518
  [type, params] = this.handleMarketTypeAndParams('cancelOrders', market, params);
3412
3519
  const request = {};
3413
- let method = undefined;
3520
+ let response = undefined;
3414
3521
  if (type === 'spot') {
3415
- method = 'privateSpotPostTradeCancelBatchOrdersV2';
3416
- request['symbol'] = market['id'];
3522
+ request['symbol'] = market['info']['symbolName']; // regular id like LTCUSDT_SPBL does not work here
3417
3523
  request['orderIds'] = ids;
3524
+ if (marginMode !== undefined) {
3525
+ if (marginMode === 'cross') {
3526
+ response = await this.privateMarginPostCrossOrderBatchCancelOrder(this.extend(request, params));
3527
+ }
3528
+ else {
3529
+ response = await this.privateMarginPostIsolatedOrderBatchCancelOrder(this.extend(request, params));
3530
+ }
3531
+ }
3532
+ else {
3533
+ response = await this.privateSpotPostTradeCancelBatchOrdersV2(this.extend(request, params));
3534
+ }
3418
3535
  }
3419
3536
  else {
3420
- method = 'privateMixPostOrderCancelBatchOrders';
3421
3537
  request['symbol'] = market['id'];
3422
3538
  request['marginCoin'] = market['quote'];
3423
3539
  request['orderIds'] = ids;
3540
+ response = await this.privateMixPostOrderCancelBatchOrders(this.extend(request, params));
3424
3541
  }
3425
- const response = await this[method](this.extend(request, params));
3426
3542
  //
3427
3543
  // spot
3428
3544
  //
@@ -3468,8 +3584,11 @@ export default class bitget extends Exchange {
3468
3584
  * @description cancel all open orders
3469
3585
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#cancel-all-order
3470
3586
  * @see https://bitgetlimited.github.io/apidoc/en/mix/#cancel-all-trigger-order-tpsl
3587
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#isolated-batch-cancel-orders
3588
+ * @see https://bitgetlimited.github.io/apidoc/en/margin/#cross-batch-cancel-order
3471
3589
  * @param {string} symbol unified market symbol
3472
3590
  * @param {object} [params] extra parameters specific to the bitget api endpoint
3591
+ * @param {string} [params.marginMode] 'isolated' or 'cross' for spot margin trading
3473
3592
  * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
3474
3593
  */
3475
3594
  const sandboxMode = this.safeValue(this.options, 'sandboxMode', false);
@@ -3486,8 +3605,22 @@ export default class bitget extends Exchange {
3486
3605
  }
3487
3606
  let marketType = undefined;
3488
3607
  [marketType, params] = this.handleMarketTypeAndParams('cancelAllOrders', market, params);
3608
+ let marginMode = undefined;
3609
+ [marginMode, params] = this.handleMarginModeAndParams('cancelAllOrders', params);
3489
3610
  if (marketType === 'spot') {
3490
- throw new NotSupported(this.id + ' cancelAllOrders () does not support spot markets');
3611
+ if (marginMode === undefined) {
3612
+ throw new NotSupported(this.id + ' cancelAllOrders () does not support spot markets, only spot-margin');
3613
+ }
3614
+ this.checkRequiredSymbol('cancelAllOrders', symbol);
3615
+ const spotMarginRequest = {
3616
+ 'symbol': market['info']['symbolName'], // regular id like LTCUSDT_SPBL does not work here
3617
+ };
3618
+ if (marginMode === 'cross') {
3619
+ return await this.privateMarginPostCrossOrderBatchCancelOrder(this.extend(spotMarginRequest, params));
3620
+ }
3621
+ else {
3622
+ return await this.privateMarginPostIsolatedOrderBatchCancelOrder(this.extend(spotMarginRequest, params));
3623
+ }
3491
3624
  }
3492
3625
  const request = {
3493
3626
  'productType': productType,
@@ -111,18 +111,18 @@ export default class bitstamp1 extends Exchange {
111
111
  },
112
112
  'precisionMode': TICK_SIZE,
113
113
  'markets': {
114
- 'BTC/USD': { 'id': 'btcusd', 'symbol': 'BTC/USD', 'base': 'BTC', 'quote': 'USD', 'baseId': 'btc', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
115
- 'BTC/EUR': { 'id': 'btceur', 'symbol': 'BTC/EUR', 'base': 'BTC', 'quote': 'EUR', 'baseId': 'btc', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
116
- 'EUR/USD': { 'id': 'eurusd', 'symbol': 'EUR/USD', 'base': 'EUR', 'quote': 'USD', 'baseId': 'eur', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
117
- 'XRP/USD': { 'id': 'xrpusd', 'symbol': 'XRP/USD', 'base': 'XRP', 'quote': 'USD', 'baseId': 'xrp', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
118
- 'XRP/EUR': { 'id': 'xrpeur', 'symbol': 'XRP/EUR', 'base': 'XRP', 'quote': 'EUR', 'baseId': 'xrp', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
119
- 'XRP/BTC': { 'id': 'xrpbtc', 'symbol': 'XRP/BTC', 'base': 'XRP', 'quote': 'BTC', 'baseId': 'xrp', 'quoteId': 'btc', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
120
- 'LTC/USD': { 'id': 'ltcusd', 'symbol': 'LTC/USD', 'base': 'LTC', 'quote': 'USD', 'baseId': 'ltc', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
121
- 'LTC/EUR': { 'id': 'ltceur', 'symbol': 'LTC/EUR', 'base': 'LTC', 'quote': 'EUR', 'baseId': 'ltc', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
122
- 'LTC/BTC': { 'id': 'ltcbtc', 'symbol': 'LTC/BTC', 'base': 'LTC', 'quote': 'BTC', 'baseId': 'ltc', 'quoteId': 'btc', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
123
- 'ETH/USD': { 'id': 'ethusd', 'symbol': 'ETH/USD', 'base': 'ETH', 'quote': 'USD', 'baseId': 'eth', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
124
- 'ETH/EUR': { 'id': 'etheur', 'symbol': 'ETH/EUR', 'base': 'ETH', 'quote': 'EUR', 'baseId': 'eth', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
125
- 'ETH/BTC': { 'id': 'ethbtc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true },
114
+ 'BTC/USD': this.safeMarketStructure({ 'id': 'btcusd', 'symbol': 'BTC/USD', 'base': 'BTC', 'quote': 'USD', 'baseId': 'btc', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true }),
115
+ 'BTC/EUR': this.safeMarketStructure({ 'id': 'btceur', 'symbol': 'BTC/EUR', 'base': 'BTC', 'quote': 'EUR', 'baseId': 'btc', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true }),
116
+ 'EUR/USD': this.safeMarketStructure({ 'id': 'eurusd', 'symbol': 'EUR/USD', 'base': 'EUR', 'quote': 'USD', 'baseId': 'eur', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true }),
117
+ 'XRP/USD': this.safeMarketStructure({ 'id': 'xrpusd', 'symbol': 'XRP/USD', 'base': 'XRP', 'quote': 'USD', 'baseId': 'xrp', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true }),
118
+ 'XRP/EUR': this.safeMarketStructure({ 'id': 'xrpeur', 'symbol': 'XRP/EUR', 'base': 'XRP', 'quote': 'EUR', 'baseId': 'xrp', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true }),
119
+ 'XRP/BTC': this.safeMarketStructure({ 'id': 'xrpbtc', 'symbol': 'XRP/BTC', 'base': 'XRP', 'quote': 'BTC', 'baseId': 'xrp', 'quoteId': 'btc', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true }),
120
+ 'LTC/USD': this.safeMarketStructure({ 'id': 'ltcusd', 'symbol': 'LTC/USD', 'base': 'LTC', 'quote': 'USD', 'baseId': 'ltc', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true }),
121
+ 'LTC/EUR': this.safeMarketStructure({ 'id': 'ltceur', 'symbol': 'LTC/EUR', 'base': 'LTC', 'quote': 'EUR', 'baseId': 'ltc', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true }),
122
+ 'LTC/BTC': this.safeMarketStructure({ 'id': 'ltcbtc', 'symbol': 'LTC/BTC', 'base': 'LTC', 'quote': 'BTC', 'baseId': 'ltc', 'quoteId': 'btc', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true }),
123
+ 'ETH/USD': this.safeMarketStructure({ 'id': 'ethusd', 'symbol': 'ETH/USD', 'base': 'ETH', 'quote': 'USD', 'baseId': 'eth', 'quoteId': 'usd', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true }),
124
+ 'ETH/EUR': this.safeMarketStructure({ 'id': 'etheur', 'symbol': 'ETH/EUR', 'base': 'ETH', 'quote': 'EUR', 'baseId': 'eth', 'quoteId': 'eur', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true }),
125
+ 'ETH/BTC': this.safeMarketStructure({ 'id': 'ethbtc', 'symbol': 'ETH/BTC', 'base': 'ETH', 'quote': 'BTC', 'baseId': 'eth', 'quoteId': 'btc', 'maker': 0.005, 'taker': 0.005, 'type': 'spot', 'spot': true }),
126
126
  },
127
127
  });
128
128
  }
package/js/src/bl3p.js CHANGED
@@ -110,7 +110,7 @@ export default class bl3p extends Exchange {
110
110
  },
111
111
  },
112
112
  'markets': {
113
- 'BTC/EUR': { 'id': 'BTCEUR', 'symbol': 'BTC/EUR', 'base': 'BTC', 'quote': 'EUR', 'baseId': 'BTC', 'quoteId': 'EUR', 'maker': 0.0025, 'taker': 0.0025, 'type': 'spot', 'spot': true },
113
+ 'BTC/EUR': this.safeMarketStructure({ 'id': 'BTCEUR', 'symbol': 'BTC/EUR', 'base': 'BTC', 'quote': 'EUR', 'baseId': 'BTC', 'quoteId': 'EUR', 'maker': 0.0025, 'taker': 0.0025, 'type': 'spot', 'spot': true }),
114
114
  },
115
115
  'precisionMode': TICK_SIZE,
116
116
  });