ccxt 4.0.86 → 4.0.87

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
@@ -180,7 +180,7 @@ var woo$1 = require('./src/pro/woo.js');
180
180
 
181
181
  //-----------------------------------------------------------------------------
182
182
  // this is updated by vss.js when building
183
- const version = '4.0.86';
183
+ const version = '4.0.87';
184
184
  Exchange["default"].ccxtVersion = version;
185
185
  const exchanges = {
186
186
  'ace': ace,
@@ -147,6 +147,7 @@ class bitget extends bitget$1 {
147
147
  'market/candles': 1,
148
148
  'market/depth': 1,
149
149
  'market/spot-vip-level': 2,
150
+ 'market/merge-depth': 1,
150
151
  'market/history-candles': 1,
151
152
  'public/loan/coinInfos': 2,
152
153
  'public/loan/hour-interest': 2, // 10 times/1s (IP) => 20/10 = 2
@@ -174,6 +175,7 @@ class bitget extends bitget$1 {
174
175
  'market/history-candles': 1,
175
176
  'market/history-index-candles': 1,
176
177
  'market/history-mark-candles': 1,
178
+ 'market/merge-depth': 1,
177
179
  },
178
180
  },
179
181
  'margin': {
@@ -1173,6 +1173,19 @@ class exmo extends exmo$1 {
1173
1173
  // "commission_percent": "0.2"
1174
1174
  // }
1175
1175
  //
1176
+ // margin
1177
+ //
1178
+ // {
1179
+ // "is_maker": false,
1180
+ // "order_id": "123",
1181
+ // "pair": "BTC_USD",
1182
+ // "price": "54122.25",
1183
+ // "quantity": "0.00069994",
1184
+ // "trade_dt": "1619069561718824428",
1185
+ // "trade_id": "692842802860135010",
1186
+ // "type": "sell"
1187
+ // }
1188
+ //
1176
1189
  const timestamp = this.safeTimestamp(trade, 'date');
1177
1190
  const id = this.safeString(trade, 'trade_id');
1178
1191
  const orderId = this.safeString(trade, 'order_id');
@@ -1184,7 +1197,12 @@ class exmo extends exmo$1 {
1184
1197
  const marketId = this.safeString(trade, 'pair');
1185
1198
  market = this.safeMarket(marketId, market, '_');
1186
1199
  const symbol = market['symbol'];
1187
- const takerOrMaker = this.safeString(trade, 'exec_type');
1200
+ const isMaker = this.safeValue(trade, 'is_maker');
1201
+ let takerOrMakerDefault = undefined;
1202
+ if (isMaker !== undefined) {
1203
+ takerOrMakerDefault = isMaker ? 'maker' : 'taker';
1204
+ }
1205
+ const takerOrMaker = this.safeString(trade, 'exec_type', takerOrMakerDefault);
1188
1206
  let fee = undefined;
1189
1207
  const feeCostString = this.safeString(trade, 'commission_amount');
1190
1208
  if (feeCostString !== undefined) {
@@ -1424,13 +1442,21 @@ class exmo extends exmo$1 {
1424
1442
  * @method
1425
1443
  * @name exmo#fetchOrderTrades
1426
1444
  * @description fetch all the trades made from a single order
1445
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#cf27781e-28e5-4b39-a52d-3110f5d22459 // spot
1446
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#00810661-9119-46c5-aec5-55abe9cb42c7 // margin
1427
1447
  * @param {string} id order id
1428
1448
  * @param {string} symbol unified market symbol
1429
1449
  * @param {int} [since] the earliest time in ms to fetch trades for
1430
1450
  * @param {int} [limit] the maximum number of trades to retrieve
1431
1451
  * @param {object} [params] extra parameters specific to the exmo api endpoint
1452
+ * @param {string} [params.marginMode] set to "isolated" to fetch trades for a margin order
1432
1453
  * @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
1433
1454
  */
1455
+ let marginMode = undefined;
1456
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOrderTrades', params);
1457
+ if (marginMode === 'cross') {
1458
+ throw new errors.BadRequest(this.id + ' only supports isolated margin');
1459
+ }
1434
1460
  let market = undefined;
1435
1461
  if (symbol !== undefined) {
1436
1462
  market = this.market(symbol);
@@ -1438,32 +1464,54 @@ class exmo extends exmo$1 {
1438
1464
  const request = {
1439
1465
  'order_id': id.toString(),
1440
1466
  };
1441
- const response = await this.privatePostOrderTrades(this.extend(request, params));
1442
- //
1443
- // {
1444
- // "type": "buy",
1445
- // "in_currency": "BTC",
1446
- // "in_amount": "1",
1447
- // "out_currency": "USD",
1448
- // "out_amount": "100",
1449
- // "trades": [
1450
- // {
1451
- // "trade_id": 3,
1452
- // "date": 1435488248,
1453
- // "type": "buy",
1454
- // "pair": "BTC_USD",
1455
- // "order_id": 12345,
1456
- // "quantity": 1,
1457
- // "price": 100,
1458
- // "amount": 100,
1459
- // "exec_type": "taker",
1460
- // "commission_amount": "0.02",
1461
- // "commission_currency": "BTC",
1462
- // "commission_percent": "0.2"
1463
- // }
1464
- // ]
1465
- // }
1466
- //
1467
+ let response = undefined;
1468
+ if (marginMode === 'isolated') {
1469
+ response = await this.privatePostMarginUserOrderTrades(this.extend(request, params));
1470
+ //
1471
+ // {
1472
+ // "trades": [
1473
+ // {
1474
+ // "is_maker": false,
1475
+ // "order_id": "123",
1476
+ // "pair": "BTC_USD",
1477
+ // "price": "54122.25",
1478
+ // "quantity": "0.00069994",
1479
+ // "trade_dt": "1619069561718824428",
1480
+ // "trade_id": "692842802860135010",
1481
+ // "type": "sell"
1482
+ // }
1483
+ // ]
1484
+ // }
1485
+ //
1486
+ }
1487
+ else {
1488
+ response = await this.privatePostOrderTrades(this.extend(request, params));
1489
+ //
1490
+ // {
1491
+ // "type": "buy",
1492
+ // "in_currency": "BTC",
1493
+ // "in_amount": "1",
1494
+ // "out_currency": "USD",
1495
+ // "out_amount": "100",
1496
+ // "trades": [
1497
+ // {
1498
+ // "trade_id": 3,
1499
+ // "date": 1435488248,
1500
+ // "type": "buy",
1501
+ // "pair": "BTC_USD",
1502
+ // "order_id": 12345,
1503
+ // "quantity": 1,
1504
+ // "price": 100,
1505
+ // "amount": 100,
1506
+ // "exec_type": "taker",
1507
+ // "commission_amount": "0.02",
1508
+ // "commission_currency": "BTC",
1509
+ // "commission_percent": "0.2"
1510
+ // }
1511
+ // ]
1512
+ // }
1513
+ //
1514
+ }
1467
1515
  const trades = this.safeValue(response, 'trades');
1468
1516
  return this.parseTrades(trades, market, since, limit);
1469
1517
  }
@@ -1232,6 +1232,9 @@ class hitbtc extends hitbtc$1 {
1232
1232
  if (taker !== undefined) {
1233
1233
  takerOrMaker = taker ? 'taker' : 'maker';
1234
1234
  }
1235
+ else {
1236
+ takerOrMaker = 'taker'; // the only case when `taker` field is missing, is public fetchTrades and it must be taker
1237
+ }
1235
1238
  if (feeCostString !== undefined) {
1236
1239
  const info = this.safeValue(market, 'info', {});
1237
1240
  const feeCurrency = this.safeString(info, 'fee_currency');
@@ -267,13 +267,13 @@ class bitfinex2 extends bitfinex2$1 {
267
267
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
268
268
  this.myTrades = new Cache.ArrayCacheBySymbolById(limit);
269
269
  }
270
- const array = this.myTrades;
271
- array.append(trade);
272
- this.myTrades = array;
270
+ const tradesArray = this.myTrades;
271
+ tradesArray.append(trade);
272
+ this.myTrades = tradesArray;
273
273
  // generic subscription
274
- client.resolve(array, name);
274
+ client.resolve(tradesArray, name);
275
275
  // specific subscription
276
- client.resolve(array, messageHash);
276
+ client.resolve(tradesArray, messageHash);
277
277
  }
278
278
  handleTrades(client, message, subscription) {
279
279
  //
@@ -738,8 +738,8 @@ class blockchaincom extends blockchaincom$1 {
738
738
  };
739
739
  }
740
740
  handleDelta(bookside, delta) {
741
- const array = this.parseCountedBidAsk(delta, 'px', 'qty', 'num');
742
- bookside.storeArray(array);
741
+ const bookArray = this.parseCountedBidAsk(delta, 'px', 'qty', 'num');
742
+ bookside.storeArray(bookArray);
743
743
  }
744
744
  handleDeltas(bookside, deltas) {
745
745
  for (let i = 0; i < deltas.length; i++) {
@@ -288,13 +288,13 @@ class luno extends luno$1 {
288
288
  const asksOrderSide = orderbook['asks'];
289
289
  const bidsOrderSide = orderbook['bids'];
290
290
  if (createUpdate !== undefined) {
291
- const array = this.customParseBidAsk(createUpdate, 'price', 'volume', 'order_id');
291
+ const bidAskArray = this.customParseBidAsk(createUpdate, 'price', 'volume', 'order_id');
292
292
  const type = this.safeString(createUpdate, 'type');
293
293
  if (type === 'ASK') {
294
- asksOrderSide.storeArray(array);
294
+ asksOrderSide.storeArray(bidAskArray);
295
295
  }
296
296
  else if (type === 'BID') {
297
- bidsOrderSide.storeArray(array);
297
+ bidsOrderSide.storeArray(bidAskArray);
298
298
  }
299
299
  }
300
300
  const deleteUpdate = this.safeValue(message, 'delete_update');
package/js/ccxt.d.ts CHANGED
@@ -4,7 +4,7 @@ import * as functions from './src/base/functions.js';
4
4
  import * as errors from './src/base/errors.js';
5
5
  import { Market, Trade, Fee, Ticker, OrderBook, Order, Transaction, Tickers, Currency, Balance, DepositAddress, WithdrawalResponse, DepositAddressResponse, OHLCV, Balances, PartialBalances, Dictionary, MinMax } from './src/base/types.js';
6
6
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending } from './src/base/errors.js';
7
- declare const version = "4.0.85";
7
+ declare const version = "4.0.86";
8
8
  import ace from './src/ace.js';
9
9
  import alpaca from './src/alpaca.js';
10
10
  import ascendex from './src/ascendex.js';
package/js/ccxt.js CHANGED
@@ -38,7 +38,7 @@ import * as errors from './src/base/errors.js';
38
38
  import { BaseError, ExchangeError, PermissionDenied, AccountNotEnabled, AccountSuspended, ArgumentsRequired, BadRequest, BadSymbol, MarginModeAlreadySet, BadResponse, NullResponse, InsufficientFunds, InvalidAddress, InvalidOrder, OrderNotFound, OrderNotCached, CancelPending, OrderImmediatelyFillable, OrderNotFillable, DuplicateOrderId, NotSupported, NetworkError, DDoSProtection, RateLimitExceeded, ExchangeNotAvailable, OnMaintenance, InvalidNonce, RequestTimeout, AuthenticationError, AddressPending } from './src/base/errors.js';
39
39
  //-----------------------------------------------------------------------------
40
40
  // this is updated by vss.js when building
41
- const version = '4.0.86';
41
+ const version = '4.0.87';
42
42
  Exchange.ccxtVersion = version;
43
43
  //-----------------------------------------------------------------------------
44
44
  import ace from './src/ace.js';
@@ -13,6 +13,7 @@ interface Exchange {
13
13
  publicSpotGetMarketCandles(params?: {}): Promise<implicitReturnType>;
14
14
  publicSpotGetMarketDepth(params?: {}): Promise<implicitReturnType>;
15
15
  publicSpotGetMarketSpotVipLevel(params?: {}): Promise<implicitReturnType>;
16
+ publicSpotGetMarketMergeDepth(params?: {}): Promise<implicitReturnType>;
16
17
  publicSpotGetMarketHistoryCandles(params?: {}): Promise<implicitReturnType>;
17
18
  publicSpotGetPublicLoanCoinInfos(params?: {}): Promise<implicitReturnType>;
18
19
  publicSpotGetPublicLoanHourInterest(params?: {}): Promise<implicitReturnType>;
@@ -36,6 +37,7 @@ interface Exchange {
36
37
  publicMixGetMarketHistoryCandles(params?: {}): Promise<implicitReturnType>;
37
38
  publicMixGetMarketHistoryIndexCandles(params?: {}): Promise<implicitReturnType>;
38
39
  publicMixGetMarketHistoryMarkCandles(params?: {}): Promise<implicitReturnType>;
40
+ publicMixGetMarketMergeDepth(params?: {}): Promise<implicitReturnType>;
39
41
  publicMarginGetCrossPublicInterestRateAndLimit(params?: {}): Promise<implicitReturnType>;
40
42
  publicMarginGetIsolatedPublicInterestRateAndLimit(params?: {}): Promise<implicitReturnType>;
41
43
  publicMarginGetCrossPublicTierData(params?: {}): Promise<implicitReturnType>;
package/js/src/bitget.js CHANGED
@@ -150,6 +150,7 @@ export default class bitget extends Exchange {
150
150
  'market/candles': 1,
151
151
  'market/depth': 1,
152
152
  'market/spot-vip-level': 2,
153
+ 'market/merge-depth': 1,
153
154
  'market/history-candles': 1,
154
155
  'public/loan/coinInfos': 2,
155
156
  'public/loan/hour-interest': 2, // 10 times/1s (IP) => 20/10 = 2
@@ -177,6 +178,7 @@ export default class bitget extends Exchange {
177
178
  'market/history-candles': 1,
178
179
  'market/history-index-candles': 1,
179
180
  'market/history-mark-candles': 1,
181
+ 'market/merge-depth': 1,
180
182
  },
181
183
  },
182
184
  'margin': {
package/js/src/exmo.js CHANGED
@@ -1176,6 +1176,19 @@ export default class exmo extends Exchange {
1176
1176
  // "commission_percent": "0.2"
1177
1177
  // }
1178
1178
  //
1179
+ // margin
1180
+ //
1181
+ // {
1182
+ // "is_maker": false,
1183
+ // "order_id": "123",
1184
+ // "pair": "BTC_USD",
1185
+ // "price": "54122.25",
1186
+ // "quantity": "0.00069994",
1187
+ // "trade_dt": "1619069561718824428",
1188
+ // "trade_id": "692842802860135010",
1189
+ // "type": "sell"
1190
+ // }
1191
+ //
1179
1192
  const timestamp = this.safeTimestamp(trade, 'date');
1180
1193
  const id = this.safeString(trade, 'trade_id');
1181
1194
  const orderId = this.safeString(trade, 'order_id');
@@ -1187,7 +1200,12 @@ export default class exmo extends Exchange {
1187
1200
  const marketId = this.safeString(trade, 'pair');
1188
1201
  market = this.safeMarket(marketId, market, '_');
1189
1202
  const symbol = market['symbol'];
1190
- const takerOrMaker = this.safeString(trade, 'exec_type');
1203
+ const isMaker = this.safeValue(trade, 'is_maker');
1204
+ let takerOrMakerDefault = undefined;
1205
+ if (isMaker !== undefined) {
1206
+ takerOrMakerDefault = isMaker ? 'maker' : 'taker';
1207
+ }
1208
+ const takerOrMaker = this.safeString(trade, 'exec_type', takerOrMakerDefault);
1191
1209
  let fee = undefined;
1192
1210
  const feeCostString = this.safeString(trade, 'commission_amount');
1193
1211
  if (feeCostString !== undefined) {
@@ -1427,13 +1445,21 @@ export default class exmo extends Exchange {
1427
1445
  * @method
1428
1446
  * @name exmo#fetchOrderTrades
1429
1447
  * @description fetch all the trades made from a single order
1448
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#cf27781e-28e5-4b39-a52d-3110f5d22459 // spot
1449
+ * @see https://documenter.getpostman.com/view/10287440/SzYXWKPi#00810661-9119-46c5-aec5-55abe9cb42c7 // margin
1430
1450
  * @param {string} id order id
1431
1451
  * @param {string} symbol unified market symbol
1432
1452
  * @param {int} [since] the earliest time in ms to fetch trades for
1433
1453
  * @param {int} [limit] the maximum number of trades to retrieve
1434
1454
  * @param {object} [params] extra parameters specific to the exmo api endpoint
1455
+ * @param {string} [params.marginMode] set to "isolated" to fetch trades for a margin order
1435
1456
  * @returns {object[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
1436
1457
  */
1458
+ let marginMode = undefined;
1459
+ [marginMode, params] = this.handleMarginModeAndParams('fetchOrderTrades', params);
1460
+ if (marginMode === 'cross') {
1461
+ throw new BadRequest(this.id + ' only supports isolated margin');
1462
+ }
1437
1463
  let market = undefined;
1438
1464
  if (symbol !== undefined) {
1439
1465
  market = this.market(symbol);
@@ -1441,32 +1467,54 @@ export default class exmo extends Exchange {
1441
1467
  const request = {
1442
1468
  'order_id': id.toString(),
1443
1469
  };
1444
- const response = await this.privatePostOrderTrades(this.extend(request, params));
1445
- //
1446
- // {
1447
- // "type": "buy",
1448
- // "in_currency": "BTC",
1449
- // "in_amount": "1",
1450
- // "out_currency": "USD",
1451
- // "out_amount": "100",
1452
- // "trades": [
1453
- // {
1454
- // "trade_id": 3,
1455
- // "date": 1435488248,
1456
- // "type": "buy",
1457
- // "pair": "BTC_USD",
1458
- // "order_id": 12345,
1459
- // "quantity": 1,
1460
- // "price": 100,
1461
- // "amount": 100,
1462
- // "exec_type": "taker",
1463
- // "commission_amount": "0.02",
1464
- // "commission_currency": "BTC",
1465
- // "commission_percent": "0.2"
1466
- // }
1467
- // ]
1468
- // }
1469
- //
1470
+ let response = undefined;
1471
+ if (marginMode === 'isolated') {
1472
+ response = await this.privatePostMarginUserOrderTrades(this.extend(request, params));
1473
+ //
1474
+ // {
1475
+ // "trades": [
1476
+ // {
1477
+ // "is_maker": false,
1478
+ // "order_id": "123",
1479
+ // "pair": "BTC_USD",
1480
+ // "price": "54122.25",
1481
+ // "quantity": "0.00069994",
1482
+ // "trade_dt": "1619069561718824428",
1483
+ // "trade_id": "692842802860135010",
1484
+ // "type": "sell"
1485
+ // }
1486
+ // ]
1487
+ // }
1488
+ //
1489
+ }
1490
+ else {
1491
+ response = await this.privatePostOrderTrades(this.extend(request, params));
1492
+ //
1493
+ // {
1494
+ // "type": "buy",
1495
+ // "in_currency": "BTC",
1496
+ // "in_amount": "1",
1497
+ // "out_currency": "USD",
1498
+ // "out_amount": "100",
1499
+ // "trades": [
1500
+ // {
1501
+ // "trade_id": 3,
1502
+ // "date": 1435488248,
1503
+ // "type": "buy",
1504
+ // "pair": "BTC_USD",
1505
+ // "order_id": 12345,
1506
+ // "quantity": 1,
1507
+ // "price": 100,
1508
+ // "amount": 100,
1509
+ // "exec_type": "taker",
1510
+ // "commission_amount": "0.02",
1511
+ // "commission_currency": "BTC",
1512
+ // "commission_percent": "0.2"
1513
+ // }
1514
+ // ]
1515
+ // }
1516
+ //
1517
+ }
1470
1518
  const trades = this.safeValue(response, 'trades');
1471
1519
  return this.parseTrades(trades, market, since, limit);
1472
1520
  }
package/js/src/hitbtc.js CHANGED
@@ -1235,6 +1235,9 @@ export default class hitbtc extends Exchange {
1235
1235
  if (taker !== undefined) {
1236
1236
  takerOrMaker = taker ? 'taker' : 'maker';
1237
1237
  }
1238
+ else {
1239
+ takerOrMaker = 'taker'; // the only case when `taker` field is missing, is public fetchTrades and it must be taker
1240
+ }
1238
1241
  if (feeCostString !== undefined) {
1239
1242
  const info = this.safeValue(market, 'info', {});
1240
1243
  const feeCurrency = this.safeString(info, 'fee_currency');
@@ -270,13 +270,13 @@ export default class bitfinex2 extends bitfinex2Rest {
270
270
  const limit = this.safeInteger(this.options, 'tradesLimit', 1000);
271
271
  this.myTrades = new ArrayCacheBySymbolById(limit);
272
272
  }
273
- const array = this.myTrades;
274
- array.append(trade);
275
- this.myTrades = array;
273
+ const tradesArray = this.myTrades;
274
+ tradesArray.append(trade);
275
+ this.myTrades = tradesArray;
276
276
  // generic subscription
277
- client.resolve(array, name);
277
+ client.resolve(tradesArray, name);
278
278
  // specific subscription
279
- client.resolve(array, messageHash);
279
+ client.resolve(tradesArray, messageHash);
280
280
  }
281
281
  handleTrades(client, message, subscription) {
282
282
  //
@@ -741,8 +741,8 @@ export default class blockchaincom extends blockchaincomRest {
741
741
  };
742
742
  }
743
743
  handleDelta(bookside, delta) {
744
- const array = this.parseCountedBidAsk(delta, 'px', 'qty', 'num');
745
- bookside.storeArray(array);
744
+ const bookArray = this.parseCountedBidAsk(delta, 'px', 'qty', 'num');
745
+ bookside.storeArray(bookArray);
746
746
  }
747
747
  handleDeltas(bookside, deltas) {
748
748
  for (let i = 0; i < deltas.length; i++) {
@@ -291,13 +291,13 @@ export default class luno extends lunoRest {
291
291
  const asksOrderSide = orderbook['asks'];
292
292
  const bidsOrderSide = orderbook['bids'];
293
293
  if (createUpdate !== undefined) {
294
- const array = this.customParseBidAsk(createUpdate, 'price', 'volume', 'order_id');
294
+ const bidAskArray = this.customParseBidAsk(createUpdate, 'price', 'volume', 'order_id');
295
295
  const type = this.safeString(createUpdate, 'type');
296
296
  if (type === 'ASK') {
297
- asksOrderSide.storeArray(array);
297
+ asksOrderSide.storeArray(bidAskArray);
298
298
  }
299
299
  else if (type === 'BID') {
300
- bidsOrderSide.storeArray(array);
300
+ bidsOrderSide.storeArray(bidAskArray);
301
301
  }
302
302
  }
303
303
  const deleteUpdate = this.safeValue(message, 'delete_update');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ccxt",
3
- "version": "4.0.86",
3
+ "version": "4.0.87",
4
4
  "description": "A JavaScript / TypeScript / Python / C# / PHP cryptocurrency trading library with support for 130+ exchanges",
5
5
  "unpkg": "dist/ccxt.browser.js",
6
6
  "type": "module",