ccxt 4.1.99 → 4.2.1

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.
@@ -0,0 +1,2310 @@
1
+ // ----------------------------------------------------------------------------
2
+
3
+ // PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
4
+ // https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
5
+ // EDIT THE CORRESPONDENT .ts FILE INSTEAD
6
+
7
+ // ---------------------------------------------------------------------------
8
+ import Exchange from './abstract/bitteam.js';
9
+ import { ArgumentsRequired, AuthenticationError, BadRequest, BadSymbol, ExchangeError, ExchangeNotAvailable, InsufficientFunds, OrderNotFound } from './base/errors.js';
10
+ import { DECIMAL_PLACES } from './base/functions/number.js';
11
+ import { Precise } from './base/Precise.js';
12
+ // ---------------------------------------------------------------------------
13
+ /**
14
+ * @class bitteam
15
+ * @augments Exchange
16
+ */
17
+ export default class bitteam extends Exchange {
18
+ describe() {
19
+ return this.deepExtend(super.describe(), {
20
+ 'id': 'bitteam',
21
+ 'name': 'BIT.TEAM',
22
+ 'countries': ['UK'],
23
+ 'version': 'v2.0.6',
24
+ 'rateLimit': 1,
25
+ 'certified': false,
26
+ 'pro': false,
27
+ 'has': {
28
+ 'CORS': undefined,
29
+ 'spot': true,
30
+ 'margin': false,
31
+ 'swap': false,
32
+ 'future': false,
33
+ 'option': false,
34
+ 'addMargin': false,
35
+ 'borrowMargin': false,
36
+ 'cancelAllOrders': true,
37
+ 'cancelOrder': true,
38
+ 'cancelOrders': false,
39
+ 'createDepositAddress': false,
40
+ 'createOrder': true,
41
+ 'createPostOnlyOrder': false,
42
+ 'createReduceOnlyOrder': false,
43
+ 'createStopLimitOrder': false,
44
+ 'createStopMarketOrder': false,
45
+ 'createStopOrder': false,
46
+ 'deposit': false,
47
+ 'editOrder': false,
48
+ 'fetchAccounts': false,
49
+ 'fetchBalance': true,
50
+ 'fetchBidsAsks': false,
51
+ 'fetchBorrowInterest': false,
52
+ 'fetchBorrowRateHistories': false,
53
+ 'fetchBorrowRateHistory': false,
54
+ 'fetchCanceledOrders': true,
55
+ 'fetchClosedOrder': false,
56
+ 'fetchClosedOrders': true,
57
+ 'fetchCrossBorrowRate': false,
58
+ 'fetchCrossBorrowRates': false,
59
+ 'fetchCurrencies': true,
60
+ 'fetchDeposit': false,
61
+ 'fetchDepositAddress': false,
62
+ 'fetchDepositAddresses': false,
63
+ 'fetchDepositAddressesByNetwork': false,
64
+ 'fetchDeposits': false,
65
+ 'fetchDepositsWithdrawals': true,
66
+ 'fetchDepositWithdrawFee': false,
67
+ 'fetchDepositWithdrawFees': false,
68
+ 'fetchFundingHistory': false,
69
+ 'fetchFundingRate': false,
70
+ 'fetchFundingRateHistory': false,
71
+ 'fetchFundingRates': false,
72
+ 'fetchIndexOHLCV': false,
73
+ 'fetchIsolatedBorrowRate': false,
74
+ 'fetchIsolatedBorrowRates': false,
75
+ 'fetchL3OrderBook': false,
76
+ 'fetchLedger': false,
77
+ 'fetchLeverage': false,
78
+ 'fetchLeverageTiers': false,
79
+ 'fetchMarketLeverageTiers': false,
80
+ 'fetchMarkets': true,
81
+ 'fetchMarkOHLCV': false,
82
+ 'fetchMyTrades': true,
83
+ 'fetchOHLCV': true,
84
+ 'fetchOpenInterestHistory': false,
85
+ 'fetchOpenOrder': false,
86
+ 'fetchOpenOrders': true,
87
+ 'fetchOrder': true,
88
+ 'fetchOrderBook': true,
89
+ 'fetchOrderBooks': false,
90
+ 'fetchOrders': true,
91
+ 'fetchOrderTrades': false,
92
+ 'fetchPosition': false,
93
+ 'fetchPositions': false,
94
+ 'fetchPositionsRisk': false,
95
+ 'fetchPremiumIndexOHLCV': false,
96
+ 'fetchStatus': false,
97
+ 'fetchTicker': true,
98
+ 'fetchTickers': true,
99
+ 'fetchTime': false,
100
+ 'fetchTrades': true,
101
+ 'fetchTradingFee': false,
102
+ 'fetchTradingFees': false,
103
+ 'fetchTradingLimits': false,
104
+ 'fetchTransactionFee': false,
105
+ 'fetchTransactionFees': false,
106
+ 'fetchTransactions': true,
107
+ 'fetchTransfers': false,
108
+ 'fetchWithdrawal': false,
109
+ 'fetchWithdrawals': false,
110
+ 'fetchWithdrawalWhitelist': false,
111
+ 'reduceMargin': false,
112
+ 'repayMargin': false,
113
+ 'setLeverage': false,
114
+ 'setMargin': false,
115
+ 'setMarginMode': false,
116
+ 'setPositionMode': false,
117
+ 'signIn': false,
118
+ 'transfer': false,
119
+ 'withdraw': false,
120
+ 'ws': false,
121
+ },
122
+ 'timeframes': {
123
+ '1m': '1',
124
+ '5m': '5',
125
+ '15m': '15',
126
+ '1h': '60',
127
+ '1d': '1D',
128
+ },
129
+ 'urls': {
130
+ 'logo': 'https://private-user-images.githubusercontent.com/43336371/291263231-aa2e0d61-edba-44a8-b9bf-68797dc417bd.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTEiLCJleHAiOjE3MDMwOTE4NTYsIm5iZiI6MTcwMzA5MTU1NiwicGF0aCI6Ii80MzMzNjM3MS8yOTEyNjMyMzEtYWEyZTBkNjEtZWRiYS00NGE4LWI5YmYtNjg3OTdkYzQxN2JkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFJV05KWUFYNENTVkVINTNBJTJGMjAyMzEyMjAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjMxMjIwVDE2NTkxNlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTVkOGE5YmY3ZDMzMWY4YzVjODYzYWJjNjE1MGFkNTRkNzVlMDJmNWE1ZTgwNGQ2NzVkMzkyZTFhOTc4OTNjMWQmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.B-ySU5Uo6vz53-iDe08tTQmJH6QOzUA9Jcbj-kZc2wg',
131
+ 'api': {
132
+ 'history': 'https://history.bit.team',
133
+ 'public': 'https://bit.team',
134
+ 'private': 'https://bit.team',
135
+ },
136
+ 'www': 'https://bit.team/',
137
+ 'referral': 'https://bit.team/auth/sign-up?ref=bitboy2023',
138
+ 'doc': [
139
+ 'https://bit.team/trade/api/documentation',
140
+ ],
141
+ },
142
+ 'api': {
143
+ 'history': {
144
+ 'get': {
145
+ 'api/tw/history/{pairName}/{resolution}': 1,
146
+ },
147
+ },
148
+ 'public': {
149
+ 'get': {
150
+ 'trade/api/asset': 1,
151
+ 'trade/api/currencies': 1,
152
+ 'trade/api/orderbooks/{symbol}': 1,
153
+ 'trade/api/orders': 1,
154
+ 'trade/api/pair/{name}': 1,
155
+ 'trade/api/pairs': 1,
156
+ 'trade/api/pairs/precisions': 1,
157
+ 'trade/api/rates': 1,
158
+ 'trade/api/trade/{id}': 1,
159
+ 'trade/api/trades': 1,
160
+ 'trade/api/ccxt/pairs': 1,
161
+ 'trade/api/cmc/assets': 1,
162
+ 'trade/api/cmc/orderbook/{pair}': 1,
163
+ 'trade/api/cmc/summary': 1,
164
+ 'trade/api/cmc/ticker': 1,
165
+ 'trade/api/cmc/trades/{pair}': 1,
166
+ },
167
+ },
168
+ 'private': {
169
+ 'get': {
170
+ 'trade/api/ccxt/balance': 1,
171
+ 'trade/api/ccxt/order/{id}': 1,
172
+ 'trade/api/ccxt/ordersOfUser': 1,
173
+ 'trade/api/ccxt/tradesOfUser': 1,
174
+ 'trade/api/transactionsOfUser': 1,
175
+ },
176
+ 'post': {
177
+ 'trade/api/ccxt/cancel-all-order': 1,
178
+ 'trade/api/ccxt/cancelorder': 1,
179
+ 'trade/api/ccxt/ordercreate': 1,
180
+ },
181
+ },
182
+ },
183
+ 'fees': {
184
+ 'trading': {
185
+ 'feeSide': 'get',
186
+ 'tierBased': false,
187
+ 'percentage': true,
188
+ 'taker': this.parseNumber('0.002'),
189
+ 'maker': this.parseNumber('0.002'),
190
+ },
191
+ },
192
+ 'precisionMode': DECIMAL_PLACES,
193
+ // exchange-specific options
194
+ 'options': {
195
+ 'networksById': {
196
+ 'Ethereum': 'ERC20',
197
+ 'ethereum': 'ERC20',
198
+ 'Tron': 'TRC20',
199
+ 'tron': 'TRC20',
200
+ 'Binance': 'BSC',
201
+ 'binance': 'BSC',
202
+ 'Binance Smart Chain': 'BSC',
203
+ 'bscscan': 'BSC',
204
+ 'Bitcoin': 'BTC',
205
+ 'bitcoin': 'BTC',
206
+ 'Litecoin': 'LTC',
207
+ 'litecoin': 'LTC',
208
+ 'Polygon': 'POLYGON',
209
+ 'polygon': 'POLYGON',
210
+ 'PRIZM': 'PRIZM',
211
+ 'Decimal': 'Decimal',
212
+ 'ufobject': 'ufobject',
213
+ 'tonchain': 'tonchain',
214
+ },
215
+ 'currenciesValuedInUsd': {
216
+ 'USDT': true,
217
+ 'BUSD': true,
218
+ },
219
+ },
220
+ 'exceptions': {
221
+ 'exact': {
222
+ '400002': BadSymbol,
223
+ '401000': AuthenticationError,
224
+ '403002': BadRequest,
225
+ '404200': BadSymbol, // {"ok":false,"code":404200,"data":{},"message":"Pair was not found"}
226
+ },
227
+ 'broad': {
228
+ 'is not allowed': BadRequest,
229
+ 'Insufficient funds': InsufficientFunds,
230
+ 'Invalid request params input': BadRequest,
231
+ 'must be a number': BadRequest,
232
+ 'must be a string': BadRequest,
233
+ 'must be of type': BadRequest,
234
+ 'must be one of': BadRequest,
235
+ 'Order not found': OrderNotFound,
236
+ 'Pair with pair name': BadSymbol,
237
+ 'pairName': BadSymbol,
238
+ 'Service Unavailable': ExchangeNotAvailable,
239
+ 'Symbol ': BadSymbol, // {"ok":false,"code":404000,"data":{},"message":"Symbol asdfasdfas was not found"}
240
+ },
241
+ },
242
+ });
243
+ }
244
+ async fetchMarkets(params = {}) {
245
+ /**
246
+ * @method
247
+ * @name bitteam#fetchMarkets
248
+ * @description retrieves data on all markets for bitteam
249
+ * @see https://bit.team/trade/api/documentation#/CCXT/getTradeApiCcxtPairs
250
+ * @param {object} [params] extra parameters specific to the exchange api endpoint
251
+ * @returns {object[]} an array of objects representing market data
252
+ */
253
+ const response = await this.publicGetTradeApiCcxtPairs(params);
254
+ //
255
+ // {
256
+ // "ok": true,
257
+ // "result": {
258
+ // "count": 28,
259
+ // "pairs": [
260
+ // {
261
+ // "id": 2,
262
+ // "name": "eth_usdt",
263
+ // "baseAssetId": 2,
264
+ // "quoteAssetId": 3,
265
+ // "fullName": "ETH USDT",
266
+ // "description": "ETH USDT",
267
+ // "lastBuy": 1964.665001,
268
+ // "lastSell": 1959.835005,
269
+ // "lastPrice": 1964.665001,
270
+ // "change24": 1.41,
271
+ // "volume24": 28.22627543,
272
+ // "volume24USD": 55662.35636401598,
273
+ // "active": true,
274
+ // "baseStep": 8,
275
+ // "quoteStep": 6,
276
+ // "status": 1,
277
+ // "settings": {
278
+ // "limit_usd": "0.1",
279
+ // "price_max": "10000000000000",
280
+ // "price_min": "1",
281
+ // "price_tick": "1",
282
+ // "pricescale": 10000,
283
+ // "lot_size_max": "1000000000000000",
284
+ // "lot_size_min": "1",
285
+ // "lot_size_tick": "1",
286
+ // "price_view_min": 6,
287
+ // "default_slippage": 10,
288
+ // "lot_size_view_min": 6
289
+ // },
290
+ // "updateId": "50620",
291
+ // "timeStart": "2021-01-28T09:19:30.706Z",
292
+ // "makerFee": 200,
293
+ // "takerFee": 200,
294
+ // "quoteVolume24": 54921.93404134529,
295
+ // "lowPrice24": 1919.355,
296
+ // "highPrice24": 1971.204995
297
+ // },
298
+ // {
299
+ // "id": 27,
300
+ // "name": "ltc_usdt",
301
+ // "baseAssetId": 13,
302
+ // "quoteAssetId": 3,
303
+ // "fullName": "LTC USDT",
304
+ // "description": "This is LTC USDT",
305
+ // "lastBuy": 53.14,
306
+ // "lastSell": 53.58,
307
+ // "lastPrice": 53.58,
308
+ // "change24": -6.72,
309
+ // "volume24": 0,
310
+ // "volume24USD": null,
311
+ // "active": true,
312
+ // "baseStep": 8,
313
+ // "quoteStep": 6,
314
+ // "status": 0,
315
+ // "settings": {
316
+ // "limit_usd": "0.1",
317
+ // "price_max": "1000000000000",
318
+ // "price_min": "1",
319
+ // "price_tick": "1",
320
+ // "pricescale": 10000,
321
+ // "lot_size_max": "1000000000000",
322
+ // "lot_size_min": "1",
323
+ // "lot_size_tick": "1",
324
+ // "price_view_min": 6,
325
+ // "default_slippage": 10,
326
+ // "lot_size_view_min": 6
327
+ // },
328
+ // "updateId": "30",
329
+ // "timeStart": "2021-10-13T12:11:05.359Z",
330
+ // "makerFee": 200,
331
+ // "takerFee": 200,
332
+ // "quoteVolume24": 0,
333
+ // "lowPrice24": null,
334
+ // "highPrice24": null
335
+ // }
336
+ // ]
337
+ // }
338
+ // }
339
+ //
340
+ const result = this.safeValue(response, 'result', {});
341
+ const markets = this.safeValue(result, 'pairs', []);
342
+ return this.parseMarkets(markets);
343
+ }
344
+ parseMarket(market) {
345
+ const id = this.safeString(market, 'name');
346
+ const numericId = this.safeInteger(market, 'id');
347
+ const parts = id.split('_');
348
+ const baseId = this.safeString(parts, 0);
349
+ const quoteId = this.safeString(parts, 1);
350
+ const base = this.safeCurrencyCode(baseId);
351
+ const quote = this.safeCurrencyCode(quoteId);
352
+ const active = this.safeValue(market, 'active');
353
+ const amountPrecision = this.safeInteger(market, 'baseStep');
354
+ const pricePrecision = this.safeInteger(market, 'quoteStep');
355
+ const timeStart = this.safeString(market, 'timeStart');
356
+ const created = this.parse8601(timeStart);
357
+ let minCost = undefined;
358
+ const currenciesValuedInUsd = this.safeValue(this.options, 'currenciesValuedInUsd', {});
359
+ const quoteInUsd = this.safeValue(currenciesValuedInUsd, quote, false);
360
+ if (quoteInUsd) {
361
+ const settings = this.safeValue(market, 'settings', {});
362
+ minCost = this.safeNumber(settings, 'limit_usd');
363
+ }
364
+ return this.safeMarketStructure({
365
+ 'id': id,
366
+ 'numericId': numericId,
367
+ 'symbol': base + '/' + quote,
368
+ 'base': base,
369
+ 'quote': quote,
370
+ 'settle': undefined,
371
+ 'baseId': baseId,
372
+ 'quoteId': quoteId,
373
+ 'settleId': undefined,
374
+ 'type': 'spot',
375
+ 'spot': true,
376
+ 'margin': false,
377
+ 'swap': false,
378
+ 'future': false,
379
+ 'option': false,
380
+ 'active': active,
381
+ 'contract': false,
382
+ 'linear': undefined,
383
+ 'inverse': undefined,
384
+ 'contractSize': undefined,
385
+ 'expiry': undefined,
386
+ 'expiryDatetime': undefined,
387
+ 'strike': undefined,
388
+ 'optionType': undefined,
389
+ 'precision': {
390
+ 'amount': amountPrecision,
391
+ 'price': pricePrecision,
392
+ },
393
+ 'limits': {
394
+ 'leverage': {
395
+ 'min': undefined,
396
+ 'max': undefined,
397
+ },
398
+ 'amount': {
399
+ 'min': undefined,
400
+ 'max': undefined,
401
+ },
402
+ 'price': {
403
+ 'min': undefined,
404
+ 'max': undefined,
405
+ },
406
+ 'cost': {
407
+ 'min': minCost,
408
+ 'max': undefined,
409
+ },
410
+ },
411
+ 'created': created,
412
+ 'info': market,
413
+ });
414
+ }
415
+ async fetchCurrencies(params = {}) {
416
+ /**
417
+ * @method
418
+ * @name bitteam#fetchCurrencies
419
+ * @description fetches all available currencies on an exchange
420
+ * @see https://bit.team/trade/api/documentation#/PUBLIC/getTradeApiCurrencies
421
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
422
+ * @returns {object} an associative dictionary of currencies
423
+ */
424
+ const response = await this.publicGetTradeApiCurrencies(params);
425
+ //
426
+ // {
427
+ // "ok": true,
428
+ // "result": {
429
+ // "count": 24,
430
+ // "currencies": [
431
+ // {
432
+ // "txLimits": {
433
+ // "minDeposit": "0.0001",
434
+ // "minWithdraw": "0.02",
435
+ // "maxWithdraw": "10000",
436
+ // "withdrawCommissionPercentage": "NaN",
437
+ // "withdrawCommissionFixed": "0.005"
438
+ // },
439
+ // "id": 2,
440
+ // "status": 1,
441
+ // "symbol": "eth",
442
+ // "title": "Ethereum",
443
+ // "logoURL": "https://ethereum.org/static/6b935ac0e6194247347855dc3d328e83/34ca5/eth-diamond-black.png",
444
+ // "isDiscount": false,
445
+ // "address": "https://ethereum.org/",
446
+ // "description": "Ethereum ETH",
447
+ // "decimals": 18,
448
+ // "blockChain": "Ethereum",
449
+ // "precision": 8,
450
+ // "currentRate": null,
451
+ // "active": true,
452
+ // "timeStart": "2021-01-28T08:57:41.719Z",
453
+ // "type": "crypto",
454
+ // "typeNetwork": "internalGW",
455
+ // "idSorting": 2,
456
+ // "links": [
457
+ // {
458
+ // "tx": "https://etherscan.io/tx/",
459
+ // "address": "https://etherscan.io/address/",
460
+ // "blockChain": "Ethereum"
461
+ // }
462
+ // ]
463
+ // },
464
+ // {
465
+ // "txLimits": {
466
+ // "minDeposit": "0.001",
467
+ // "minWithdraw": "1",
468
+ // "maxWithdraw": "100000",
469
+ // "withdrawCommissionPercentage": "NaN",
470
+ // "withdrawCommissionFixed": {
471
+ // "Tron": "2",
472
+ // "Binance": "2",
473
+ // "Ethereum": "20"
474
+ // }
475
+ // },
476
+ // "id": 3,
477
+ // "status": 1,
478
+ // "symbol": "usdt",
479
+ // "title": "Tether USD",
480
+ // "logoURL": "https://cryptologos.cc/logos/tether-usdt-logo.png?v=010",
481
+ // "isDiscount": false,
482
+ // "address": "https://tether.to/",
483
+ // "description": "Tether USD",
484
+ // "decimals": 6,
485
+ // "blockChain": "",
486
+ // "precision": 6,
487
+ // "currentRate": null,
488
+ // "active": true,
489
+ // "timeStart": "2021-01-28T09:04:17.170Z",
490
+ // "type": "crypto",
491
+ // "typeNetwork": "internalGW",
492
+ // "idSorting": 0,
493
+ // "links": [
494
+ // {
495
+ // "tx": "https://etherscan.io/tx/",
496
+ // "address": "https://etherscan.io/address/",
497
+ // "blockChain": "Ethereum"
498
+ // },
499
+ // {
500
+ // "tx": "https://tronscan.org/#/transaction/",
501
+ // "address": "https://tronscan.org/#/address/",
502
+ // "blockChain": "Tron"
503
+ // },
504
+ // {
505
+ // "tx": "https://bscscan.com/tx/",
506
+ // "address": "https://bscscan.com/address/",
507
+ // "blockChain": "Binance"
508
+ // }
509
+ // ]
510
+ // }
511
+ // ]
512
+ // }
513
+ // }
514
+ //
515
+ const responseResult = this.safeValue(response, 'result', {});
516
+ const currencies = this.safeValue(responseResult, 'currencies', []);
517
+ // usding another endpoint to fetch statuses of deposits and withdrawals
518
+ let statusesResponse = await this.publicGetTradeApiCmcAssets();
519
+ //
520
+ // {
521
+ // "ZNX": {
522
+ // "name": "ZeNeX Coin",
523
+ // "unified_cryptoasset_id": 30,
524
+ // "withdrawStatus": true,
525
+ // "depositStatus": true,
526
+ // "min_withdraw": 0.00001,
527
+ // "max_withdraw": 10000
528
+ // },
529
+ // "USDT": {
530
+ // "name": "Tether USD",
531
+ // "unified_cryptoasset_id": 3,
532
+ // "withdrawStatus": true,
533
+ // "depositStatus": true,
534
+ // "min_withdraw": 1,
535
+ // "max_withdraw": 100000
536
+ // },
537
+ // }
538
+ //
539
+ statusesResponse = this.indexBy(statusesResponse, 'unified_cryptoasset_id');
540
+ const result = {};
541
+ for (let i = 0; i < currencies.length; i++) {
542
+ const currency = currencies[i];
543
+ const id = this.safeString(currency, 'symbol');
544
+ const numericId = this.safeInteger(currency, 'id');
545
+ const code = this.safeCurrencyCode(id);
546
+ const active = this.safeValue(currency, 'active', false);
547
+ const precision = this.safeInteger(currency, 'precision');
548
+ const txLimits = this.safeValue(currency, 'txLimits', {});
549
+ const minWithdraw = this.safeString(txLimits, 'minWithdraw');
550
+ const maxWithdraw = this.safeString(txLimits, 'maxWithdraw');
551
+ const minDeposit = this.safeString(txLimits, 'minDeposit');
552
+ let fee = undefined;
553
+ const withdrawCommissionFixed = this.safeValue(txLimits, 'withdrawCommissionFixed', {});
554
+ let feesByNetworkId = {};
555
+ const blockChain = this.safeString(currency, 'blockChain');
556
+ // if only one blockChain
557
+ if ((blockChain !== undefined) && (blockChain !== '')) {
558
+ fee = this.parseNumber(withdrawCommissionFixed);
559
+ feesByNetworkId[blockChain] = fee;
560
+ }
561
+ else {
562
+ feesByNetworkId = withdrawCommissionFixed;
563
+ }
564
+ const statuses = this.safeValue(statusesResponse, numericId, {});
565
+ const deposit = this.safeValue(statuses, 'depositStatus');
566
+ const withdraw = this.safeValue(statuses, 'withdrawStatus');
567
+ const networkIds = Object.keys(feesByNetworkId);
568
+ const networks = {};
569
+ const networkPrecision = this.safeInteger(currency, 'decimals');
570
+ for (let j = 0; j < networkIds.length; j++) {
571
+ const networkId = networkIds[j];
572
+ const networkCode = this.networkIdToCode(networkId, code);
573
+ const networkFee = this.safeNumber(feesByNetworkId, networkId);
574
+ networks[networkCode] = {
575
+ 'id': networkId,
576
+ 'network': networkCode,
577
+ 'deposit': deposit,
578
+ 'withdraw': withdraw,
579
+ 'active': active,
580
+ 'fee': networkFee,
581
+ 'precision': networkPrecision,
582
+ 'limits': {
583
+ 'amount': {
584
+ 'min': undefined,
585
+ 'max': undefined,
586
+ },
587
+ 'withdraw': {
588
+ 'min': this.parseNumber(minWithdraw),
589
+ 'max': this.parseNumber(maxWithdraw),
590
+ },
591
+ 'deposit': {
592
+ 'min': this.parseNumber(minDeposit),
593
+ 'max': undefined,
594
+ },
595
+ },
596
+ 'info': currency,
597
+ };
598
+ }
599
+ result[code] = {
600
+ 'id': id,
601
+ 'numericId': numericId,
602
+ 'code': code,
603
+ 'name': code,
604
+ 'info': currency,
605
+ 'active': active,
606
+ 'deposit': deposit,
607
+ 'withdraw': withdraw,
608
+ 'fee': fee,
609
+ 'precision': precision,
610
+ 'limits': {
611
+ 'amount': {
612
+ 'min': undefined,
613
+ 'max': undefined,
614
+ },
615
+ 'withdraw': {
616
+ 'min': this.parseNumber(minWithdraw),
617
+ 'max': this.parseNumber(maxWithdraw),
618
+ },
619
+ 'deposit': {
620
+ 'min': this.parseNumber(minDeposit),
621
+ 'max': undefined,
622
+ },
623
+ },
624
+ 'networks': networks,
625
+ };
626
+ }
627
+ return result;
628
+ }
629
+ async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
630
+ /**
631
+ * @method
632
+ * @name bitteam#fetchOHLCV
633
+ * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
634
+ * @param {string} symbol unified symbol of the market to fetch OHLCV data for
635
+ * @param {string} timeframe the length of time each candle represents
636
+ * @param {int} [since] timestamp in ms of the earliest candle to fetch
637
+ * @param {int} [limit] the maximum amount of candles to fetch
638
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
639
+ * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
640
+ */
641
+ await this.loadMarkets();
642
+ const market = this.market(symbol);
643
+ const resolution = this.safeString(this.timeframes, timeframe, timeframe);
644
+ const request = {
645
+ 'pairName': market['id'],
646
+ 'resolution': resolution,
647
+ };
648
+ const response = await this.historyGetApiTwHistoryPairNameResolution(this.extend(request, params));
649
+ //
650
+ // {
651
+ // "ok": true,
652
+ // "result": {
653
+ // "count": 364,
654
+ // "data": [
655
+ // {
656
+ // "t": 1669593600,
657
+ // "o": 16211.259266,
658
+ // "h": 16476.985001,
659
+ // "l": 16023.714999,
660
+ // "c": 16430.636894,
661
+ // "v": 2.60150368999999
662
+ // },
663
+ // {
664
+ // "t": 1669680000,
665
+ // "o": 16430.636894,
666
+ // "h": 17065.229582,
667
+ // "l": 16346.114155,
668
+ // "c": 16882.297736,
669
+ // "v": 3.0872548400000115
670
+ // },
671
+ // ...
672
+ // ]
673
+ // }
674
+ // }
675
+ //
676
+ const result = this.safeValue(response, 'result', {});
677
+ const data = this.safeValue(result, 'data', []);
678
+ return this.parseOHLCVs(data, market, timeframe, since, limit);
679
+ }
680
+ parseOHLCV(ohlcv, market = undefined) {
681
+ //
682
+ // {
683
+ // "t": 1669680000,
684
+ // "o": 16430.636894,
685
+ // "h": 17065.229582,
686
+ // "l": 16346.114155,
687
+ // "c": 16882.297736,
688
+ // "v": 3.0872548400000115
689
+ // },
690
+ //
691
+ return [
692
+ this.safeTimestamp(ohlcv, 't'),
693
+ this.safeNumber(ohlcv, 'o'),
694
+ this.safeNumber(ohlcv, 'h'),
695
+ this.safeNumber(ohlcv, 'l'),
696
+ this.safeNumber(ohlcv, 'c'),
697
+ this.safeNumber(ohlcv, 'v'),
698
+ ];
699
+ }
700
+ async fetchOrderBook(symbol, limit = undefined, params = {}) {
701
+ /**
702
+ * @method
703
+ * @name bitteam#fetchOrderBook
704
+ * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
705
+ * @see https://bit.team/trade/api/documentation#/CMC/getTradeApiCmcOrderbookPair
706
+ * @param {string} symbol unified symbol of the market to fetch the order book for
707
+ * @param {int} [limit] the maximum amount of order book entries to return (default 100, max 200)
708
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
709
+ * @returns {object} A dictionary of [order book structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure} indexed by market symbols
710
+ */
711
+ await this.loadMarkets();
712
+ const market = this.market(symbol);
713
+ const request = {
714
+ 'pair': market['id'],
715
+ };
716
+ const response = await this.publicGetTradeApiCmcOrderbookPair(this.extend(request, params));
717
+ //
718
+ // {
719
+ // "timestamp": 1701166703285,
720
+ // "bids": [
721
+ // [
722
+ // 2019.334988,
723
+ // 0.09048525
724
+ // ],
725
+ // [
726
+ // 1999.860002,
727
+ // 0.0225
728
+ // ],
729
+ // ...
730
+ // ],
731
+ // "asks": [
732
+ // [
733
+ // 2019.334995,
734
+ // 0.00899078
735
+ // ],
736
+ // [
737
+ // 2019.335013,
738
+ // 0.09833052
739
+ // ],
740
+ // ...
741
+ // ]
742
+ // }
743
+ //
744
+ const timestamp = this.safeInteger(response, 'timestamp');
745
+ const orderbook = this.parseOrderBook(response, symbol, timestamp);
746
+ return orderbook;
747
+ }
748
+ async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
749
+ /**
750
+ * @method
751
+ * @name bitteam#fetchOrders
752
+ * @description fetches information on multiple orders made by the user
753
+ * @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
754
+ * @param {string} symbol unified market symbol of the market orders were made in
755
+ * @param {int} [since] the earliest time in ms to fetch orders for
756
+ * @param {int} [limit] the maximum number of orde structures to retrieve (default 10)
757
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
758
+ * @param {string} [params.type] the status of the order - 'active', 'closed', 'cancelled', 'all', 'history' (default 'all')
759
+ * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
760
+ */
761
+ await this.loadMarkets();
762
+ const type = this.safeString(params, 'type', 'all');
763
+ const request = {
764
+ 'type': type,
765
+ };
766
+ let market = undefined;
767
+ if (symbol !== undefined) {
768
+ market = this.market(symbol);
769
+ request['pair'] = market['id'];
770
+ }
771
+ if (limit !== undefined) {
772
+ request['limit'] = limit;
773
+ }
774
+ const response = await this.privateGetTradeApiCcxtOrdersOfUser(this.extend(request, params));
775
+ //
776
+ // {
777
+ // "ok": true,
778
+ // "result": {
779
+ // "count": 3,
780
+ // "orders": [
781
+ // {
782
+ // "id": 106733026,
783
+ // "orderId": null,
784
+ // "userId": 21639,
785
+ // "pair": "btc_usdt",
786
+ // "pairId": 22,
787
+ // "quantity": "0.00001",
788
+ // "price": "40",
789
+ // "executedPrice": "0",
790
+ // "fee": null,
791
+ // "orderCid": null,
792
+ // "executed": "0",
793
+ // "expires": null,
794
+ // "baseDecimals": 8,
795
+ // "quoteDecimals": 6,
796
+ // "timestamp": 1700594804,
797
+ // "status": "inactive",
798
+ // "side": "buy",
799
+ // "type": "limit",
800
+ // "createdAt": "2023-11-21T19:26:43.868Z",
801
+ // "updatedAt": "2023-11-21T19:26:43.868Z"
802
+ // },
803
+ // {
804
+ // "id": 106733308,
805
+ // "orderId": "13074362",
806
+ // "userId": 21639,
807
+ // "pair": "btc_usdt",
808
+ // "pairId": 22,
809
+ // "quantity": "0.00001",
810
+ // "price": "50000",
811
+ // "executedPrice": "37017.495008",
812
+ // "fee": {
813
+ // "amount": "0.00000002",
814
+ // "symbol": "btc",
815
+ // "userId": 21639,
816
+ // "decimals": 8,
817
+ // "symbolId": 11
818
+ // },
819
+ // "orderCid": null,
820
+ // "executed": "0.00001",
821
+ // "expires": null,
822
+ // "baseDecimals": 8,
823
+ // "quoteDecimals": 6,
824
+ // "timestamp": 1700594959,
825
+ // "status": "executed",
826
+ // "side": "buy",
827
+ // "type": "limit",
828
+ // "createdAt": "2023-11-21T19:29:19.946Z",
829
+ // "updatedAt": "2023-11-21T19:29:19.946Z"
830
+ // },
831
+ // {
832
+ // "id": 106734455,
833
+ // "orderId": "13248984",
834
+ // "userId": 21639,
835
+ // "pair": "eth_usdt",
836
+ // "pairId": 2,
837
+ // "quantity": "0.001",
838
+ // "price": "1750",
839
+ // "executedPrice": "0",
840
+ // "fee": null,
841
+ // "orderCid": null,
842
+ // "executed": "0",
843
+ // "expires": null,
844
+ // "baseDecimals": 18,
845
+ // "quoteDecimals": 6,
846
+ // "timestamp": 1700595523,
847
+ // "status": "accepted",
848
+ // "side": "buy",
849
+ // "type": "limit",
850
+ // "createdAt": "2023-11-21T19:38:43.530Z",
851
+ // "updatedAt": "2023-11-21T19:38:43.530Z"
852
+ // }
853
+ // ]
854
+ // }
855
+ // }
856
+ //
857
+ const result = this.safeValue(response, 'result', {});
858
+ const orders = this.safeValue(result, 'orders', []);
859
+ return this.parseOrders(orders, market, since, limit);
860
+ }
861
+ async fetchOrder(id, symbol = undefined, params = {}) {
862
+ /**
863
+ * @method
864
+ * @name bitteam#fetchOrder
865
+ * @description fetches information on an order
866
+ * @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrderId
867
+ * @param {int|string} id order id
868
+ * @param {string} symbol not used by bitteam fetchOrder ()
869
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
870
+ * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
871
+ */
872
+ await this.loadMarkets();
873
+ const request = {
874
+ 'id': id,
875
+ };
876
+ let market = undefined;
877
+ if (symbol !== undefined) {
878
+ market = this.market(symbol);
879
+ }
880
+ const response = await this.privateGetTradeApiCcxtOrderId(this.extend(request, params));
881
+ //
882
+ // {
883
+ // "ok": true,
884
+ // "result": {
885
+ // "id": 106494347,
886
+ // "orderId": "13214332",
887
+ // "userId": 15912,
888
+ // "pair": "eth_usdt",
889
+ // "pairId": 2,
890
+ // "quantity": "0.00448598",
891
+ // "price": "2015.644995",
892
+ // "executedPrice": "2015.644995",
893
+ // "fee": {
894
+ // "amount": "0",
895
+ // "symbol": "eth",
896
+ // "userId": 15912,
897
+ // "decimals": 18,
898
+ // "symbolId": 2,
899
+ // "discountAmount": "0",
900
+ // "discountSymbol": "btt",
901
+ // "discountDecimals": 18,
902
+ // "discountSymbolId": 5
903
+ // },
904
+ // "orderCid": null,
905
+ // "executed": "0.00448598",
906
+ // "expires": null,
907
+ // "baseDecimals": 18,
908
+ // "quoteDecimals": 6,
909
+ // "timestamp": 1700470476,
910
+ // "status": "executed",
911
+ // "side": "buy",
912
+ // "type": "limit",
913
+ // "stopPrice": null,
914
+ // "slippage": null
915
+ // }
916
+ // }
917
+ //
918
+ const result = this.safeValue(response, 'result');
919
+ return this.parseOrder(result, market);
920
+ }
921
+ async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
922
+ /**
923
+ * @method
924
+ * @name bitteam#fetchOpenOrders
925
+ * @description fetch all unfilled currently open orders
926
+ * @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
927
+ * @param {string} symbol unified market symbol
928
+ * @param {int} [since] the earliest time in ms to fetch open orders for
929
+ * @param {int} [limit] the maximum number of open order structures to retrieve (default 10)
930
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
931
+ * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
932
+ */
933
+ await this.loadMarkets();
934
+ const request = {
935
+ 'type': 'active',
936
+ };
937
+ return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
938
+ }
939
+ async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
940
+ /**
941
+ * @method
942
+ * @name bitteam#fetchClosedOrders
943
+ * @description fetches information on multiple closed orders made by the user
944
+ * @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
945
+ * @param {string} symbol unified market symbol of the market orders were made in
946
+ * @param {int} [since] the earliest time in ms to fetch orders for
947
+ * @param {int} [limit] the maximum number of closed order structures to retrieve (default 10)
948
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
949
+ * @returns {Order[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
950
+ */
951
+ await this.loadMarkets();
952
+ const request = {
953
+ 'type': 'closed',
954
+ };
955
+ return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
956
+ }
957
+ async fetchCanceledOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
958
+ /**
959
+ * @method
960
+ * @name bitteam#fetchCanceledOrders
961
+ * @description fetches information on multiple canceled orders made by the user
962
+ * @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtOrdersofuser
963
+ * @param {string} symbol unified market symbol of the market orders were made in
964
+ * @param {int} [since] the earliest time in ms to fetch orders for
965
+ * @param {int} [limit] the maximum number of canceled order structures to retrieve (default 10)
966
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
967
+ * @returns {object} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
968
+ */
969
+ await this.loadMarkets();
970
+ const request = {
971
+ 'type': 'cancelled',
972
+ };
973
+ return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
974
+ }
975
+ async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
976
+ /**
977
+ * @method
978
+ * @name bitteam#createOrder
979
+ * @description create a trade order
980
+ * @see https://bit.team/trade/api/documentation#/PRIVATE/postTradeApiCcxtOrdercreate
981
+ * @param {string} symbol unified symbol of the market to create an order in
982
+ * @param {string} type 'market' or 'limit'
983
+ * @param {string} side 'buy' or 'sell'
984
+ * @param {float} amount how much of currency you want to trade in units of base currency
985
+ * @param {float} [price] the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
986
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
987
+ * @returns {object} an [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
988
+ */
989
+ await this.loadMarkets();
990
+ const market = this.market(symbol);
991
+ const request = {
992
+ 'pairId': market['numericId'].toString(),
993
+ 'type': type,
994
+ 'side': side,
995
+ 'amount': this.amountToPrecision(symbol, amount),
996
+ };
997
+ if (type === 'limit') {
998
+ if (price === undefined) {
999
+ throw new ArgumentsRequired(this.id + ' createOrder() requires a price argument for a ' + type + ' order');
1000
+ }
1001
+ else {
1002
+ request['price'] = this.priceToPrecision(symbol, price);
1003
+ }
1004
+ }
1005
+ const response = await this.privatePostTradeApiCcxtOrdercreate(this.extend(request, params));
1006
+ //
1007
+ // {
1008
+ // "ok": true,
1009
+ // "result": {
1010
+ // "id": 106733308,
1011
+ // "userId": 21639,
1012
+ // "quantity": "0.00001",
1013
+ // "pair": "btc_usdt",
1014
+ // "side": "buy",
1015
+ // "price": "50000",
1016
+ // "executed": "0",
1017
+ // "executedPrice": "0",
1018
+ // "status": "created",
1019
+ // "baseDecimals": 8,
1020
+ // "quoteDecimals": 6,
1021
+ // "pairId": 22,
1022
+ // "type": "limit",
1023
+ // "stopPrice": null,
1024
+ // "slippage": null,
1025
+ // "timestamp": "1700594959"
1026
+ // }
1027
+ // }
1028
+ //
1029
+ const order = this.safeValue(response, 'result', {});
1030
+ return this.parseOrder(order, market);
1031
+ }
1032
+ async cancelOrder(id, symbol = undefined, params = {}) {
1033
+ /**
1034
+ * @method
1035
+ * @name bitteam#cancelOrder
1036
+ * @description cancels an open order
1037
+ * @see https://bit.team/trade/api/documentation#/PRIVATE/postTradeApiCcxtCancelorder
1038
+ * @param {string} id order id
1039
+ * @param {string} symbol not used by bitteam cancelOrder ()
1040
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
1041
+ * @returns {object} An [order structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1042
+ */
1043
+ await this.loadMarkets();
1044
+ const request = {
1045
+ 'id': id,
1046
+ };
1047
+ const response = await this.privatePostTradeApiCcxtCancelorder(this.extend(request, params));
1048
+ //
1049
+ // {
1050
+ // "ok": true,
1051
+ // "result": {
1052
+ // "message": "The request to cancel your order was received"
1053
+ // }
1054
+ // }
1055
+ //
1056
+ const result = this.safeValue(response, 'result', {});
1057
+ return this.parseOrder(result);
1058
+ }
1059
+ async cancelAllOrders(symbol = undefined, params = {}) {
1060
+ /**
1061
+ * @method
1062
+ * @name bitteam#cancelAllOrders
1063
+ * @description cancel open orders of market
1064
+ * @see https://bit.team/trade/api/documentation#/PRIVATE/postTradeApiCcxtCancelallorder
1065
+ * @param {string} symbol unified market symbol
1066
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
1067
+ * @returns {object[]} a list of [order structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#order-structure}
1068
+ */
1069
+ await this.loadMarkets();
1070
+ let market = undefined;
1071
+ const request = {};
1072
+ if (symbol !== undefined) {
1073
+ market = this.market(symbol);
1074
+ request['pairId'] = market['numericId'].toString();
1075
+ }
1076
+ else {
1077
+ request['pairId'] = '0'; // '0' for all markets
1078
+ }
1079
+ const response = await this.privatePostTradeApiCcxtCancelAllOrder(this.extend(request, params));
1080
+ //
1081
+ // {
1082
+ // "ok": true,
1083
+ // "result": {
1084
+ // "message":"The request to cancel all your orders was received"
1085
+ // }
1086
+ // }
1087
+ //
1088
+ const result = this.safeValue(response, 'result', {});
1089
+ const orders = [result];
1090
+ return this.parseOrders(orders, market);
1091
+ }
1092
+ parseOrder(order, market = undefined) {
1093
+ //
1094
+ // fetchOrders
1095
+ // {
1096
+ // "id": 106733308,
1097
+ // "orderId": "13074362",
1098
+ // "userId": 21639,
1099
+ // "pair": "btc_usdt",
1100
+ // "pairId": 22,
1101
+ // "quantity": "0.00001",
1102
+ // "price": "50000",
1103
+ // "executedPrice": "37017.495008",
1104
+ // "fee": {
1105
+ // "amount": "0.00000002",
1106
+ // "symbol": "btc",
1107
+ // "userId": 21639,
1108
+ // "decimals": 8,
1109
+ // "symbolId": 11
1110
+ // },
1111
+ // "orderCid": null,
1112
+ // "executed": "0.00001",
1113
+ // "expires": null,
1114
+ // "baseDecimals": 8,
1115
+ // "quoteDecimals": 6,
1116
+ // "timestamp": 1700594959,
1117
+ // "status": "executed",
1118
+ // "side": "buy",
1119
+ // "type": "limit",
1120
+ // "createdAt": "2023-11-21T19:29:19.946Z",
1121
+ // "updatedAt": "2023-11-21T19:29:19.946Z"
1122
+ // },
1123
+ //
1124
+ // fetchOrder
1125
+ // {
1126
+ // "id": 106494347,
1127
+ // "orderId": "13214332",
1128
+ // "userId": 15912,
1129
+ // "pair": "eth_usdt",
1130
+ // "pairId": 2,
1131
+ // "quantity": "0.00448598",
1132
+ // "price": "2015.644995",
1133
+ // "executedPrice": "2015.644995",
1134
+ // "fee": {
1135
+ // "amount": "0",
1136
+ // "symbol": "eth",
1137
+ // "userId": 15912,
1138
+ // "decimals": 18,
1139
+ // "symbolId": 2,
1140
+ // "discountAmount": "0",
1141
+ // "discountSymbol": "btt",
1142
+ // "discountDecimals": 18,
1143
+ // "discountSymbolId": 5
1144
+ // },
1145
+ // "orderCid": null,
1146
+ // "executed": "0.00448598",
1147
+ // "expires": null,
1148
+ // "baseDecimals": 18,
1149
+ // "quoteDecimals": 6,
1150
+ // "timestamp": 1700470476,
1151
+ // "status": "executed",
1152
+ // "side": "buy",
1153
+ // "type": "limit",
1154
+ // "stopPrice": null,
1155
+ // "slippage": null
1156
+ // }
1157
+ //
1158
+ // createOrder
1159
+ // {
1160
+ // "id": 106733308,
1161
+ // "userId": 21639,
1162
+ // "quantity": "0.00001",
1163
+ // "pair": "btc_usdt",
1164
+ // "side": "buy",
1165
+ // "price": "50000",
1166
+ // "executed": "0",
1167
+ // "executedPrice": "0",
1168
+ // "status": "created",
1169
+ // "baseDecimals": 8,
1170
+ // "quoteDecimals": 6,
1171
+ // "pairId": 22,
1172
+ // "type": "limit",
1173
+ // "stopPrice": null,
1174
+ // "slippage": null,
1175
+ // "timestamp": "1700594959"
1176
+ // }
1177
+ //
1178
+ const id = this.safeString(order, 'id');
1179
+ const marketId = this.safeString(order, 'pair');
1180
+ market = this.safeMarket(marketId, market);
1181
+ const clientOrderId = this.safeString(order, 'orderCid');
1182
+ let timestamp = undefined;
1183
+ const createdAt = this.safeString(order, 'createdAt');
1184
+ if (createdAt !== undefined) {
1185
+ timestamp = this.parse8601(createdAt);
1186
+ }
1187
+ else {
1188
+ timestamp = this.safeTimestamp(order, 'timestamp');
1189
+ }
1190
+ const updatedAt = this.safeString(order, 'updatedAt');
1191
+ const lastUpdateTimestamp = this.parse8601(updatedAt);
1192
+ const status = this.parseOrderStatus(this.safeString(order, 'status'));
1193
+ const type = this.parseOrderType(this.safeString(order, 'type'));
1194
+ const side = this.safeString(order, 'side');
1195
+ const feeRaw = this.safeValue(order, 'fee');
1196
+ const price = this.safeString(order, 'price');
1197
+ const stopPrice = this.safeString(order, 'stopPrice');
1198
+ const amount = this.safeString(order, 'quantity');
1199
+ const filled = this.safeString(order, 'executed');
1200
+ let fee = undefined;
1201
+ if (feeRaw !== undefined) {
1202
+ const feeCost = this.safeString(feeRaw, 'amount');
1203
+ const feeCurrencyId = this.safeString(feeRaw, 'symbol');
1204
+ fee = {
1205
+ 'currency': this.safeCurrencyCode(feeCurrencyId),
1206
+ 'cost': feeCost,
1207
+ 'rate': undefined,
1208
+ };
1209
+ }
1210
+ return this.safeOrder({
1211
+ 'id': id,
1212
+ 'clientOrderId': clientOrderId,
1213
+ 'timestamp': timestamp,
1214
+ 'datetime': this.iso8601(timestamp),
1215
+ 'lastTradeTimestamp': undefined,
1216
+ 'lastUpdateTimestamp': lastUpdateTimestamp,
1217
+ 'status': status,
1218
+ 'symbol': market['symbol'],
1219
+ 'type': type,
1220
+ 'timeInForce': 'GTC',
1221
+ 'side': side,
1222
+ 'price': price,
1223
+ 'stopPrice': stopPrice,
1224
+ 'triggerPrice': stopPrice,
1225
+ 'average': undefined,
1226
+ 'amount': amount,
1227
+ 'cost': undefined,
1228
+ 'filled': filled,
1229
+ 'remaining': undefined,
1230
+ 'fee': fee,
1231
+ 'trades': undefined,
1232
+ 'info': order,
1233
+ 'postOnly': false,
1234
+ }, market);
1235
+ }
1236
+ parseOrderStatus(status) {
1237
+ const statuses = {
1238
+ 'accepted': 'open',
1239
+ 'executed': 'closed',
1240
+ 'cancelled': 'canceled',
1241
+ 'partiallyCancelled': 'canceled',
1242
+ 'delete': 'rejected',
1243
+ 'inactive': 'rejected',
1244
+ 'executing': 'open',
1245
+ 'created': 'open',
1246
+ };
1247
+ return this.safeString(statuses, status, status);
1248
+ }
1249
+ parseOrderType(status) {
1250
+ const statuses = {
1251
+ 'market': 'market',
1252
+ 'limit': 'limit',
1253
+ };
1254
+ return this.safeString(statuses, status, status);
1255
+ }
1256
+ parseValueToPricision(valueObject, valueKey, preciseObject, precisionKey) {
1257
+ const valueRawString = this.safeString(valueObject, valueKey);
1258
+ const precisionRawString = this.safeString(preciseObject, precisionKey);
1259
+ if (valueRawString === undefined || precisionRawString === undefined) {
1260
+ return undefined;
1261
+ }
1262
+ const precisionString = this.parsePrecision(precisionRawString);
1263
+ return Precise.stringMul(valueRawString, precisionString);
1264
+ }
1265
+ async fetchTickers(symbols = undefined, params = {}) {
1266
+ /**
1267
+ * @method
1268
+ * @name bitteam#fetchTickers
1269
+ * @description fetches price tickers for multiple markets, statistical calculations with the information calculated over the past 24 hours each market
1270
+ * @see https://bit.team/trade/api/documentation#/CMC/getTradeApiCmcSummary
1271
+ * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
1272
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
1273
+ * @returns {object} a dictionary of [ticker structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
1274
+ */
1275
+ await this.loadMarkets();
1276
+ let response = await this.publicGetTradeApiCmcSummary();
1277
+ //
1278
+ // [
1279
+ // {
1280
+ // "trading_pairs": "BTC_USDT",
1281
+ // "base_currency": "BTC",
1282
+ // "quote_currency": "USDT",
1283
+ // "last_price": 37669.955001,
1284
+ // "lowest_ask": 37670.055,
1285
+ // "highest_bid": 37669.955,
1286
+ // "base_volume": 6.81156888,
1287
+ // "quote_volume": 257400.516878529,
1288
+ // "price_change_percent_24h": -0.29,
1289
+ // "highest_price_24h": 38389.994463,
1290
+ // "lowest_price_24h": 37574.894999
1291
+ // },
1292
+ // {
1293
+ // "trading_pairs": "BNB_USDT",
1294
+ // "base_currency": "BNB",
1295
+ // "quote_currency": "USDT",
1296
+ // "last_price": 233.525142,
1297
+ // "lowest_ask": 233.675,
1298
+ // "highest_bid": 233.425,
1299
+ // "base_volume": 245.0199339,
1300
+ // "quote_volume": 57356.91823827642,
1301
+ // "price_change_percent_24h": -0.32,
1302
+ // "highest_price_24h": 236.171123,
1303
+ // "lowest_price_24h": 231.634637
1304
+ // },
1305
+ // ...
1306
+ // ]
1307
+ //
1308
+ const tickers = [];
1309
+ if (!Array.isArray(response)) {
1310
+ response = [];
1311
+ }
1312
+ for (let i = 0; i < response.length; i++) {
1313
+ const rawTicker = response[i];
1314
+ const ticker = this.parseTicker(rawTicker);
1315
+ tickers.push(ticker);
1316
+ }
1317
+ return this.filterByArrayTickers(tickers, 'symbol', symbols);
1318
+ }
1319
+ async fetchTicker(symbol, params = {}) {
1320
+ /**
1321
+ * @method
1322
+ * @name bitteam#fetchTicker
1323
+ * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
1324
+ * @see https://bit.team/trade/api/documentation#/PUBLIC/getTradeApiPairName
1325
+ * @param {string} symbol unified symbol of the market to fetch the ticker for
1326
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
1327
+ * @returns {object} a [ticker structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#ticker-structure}
1328
+ */
1329
+ await this.loadMarkets();
1330
+ const market = this.market(symbol);
1331
+ const request = {
1332
+ 'name': market['id'],
1333
+ };
1334
+ const response = await this.publicGetTradeApiPairName(this.extend(request, params));
1335
+ //
1336
+ // {
1337
+ // "ok": true,
1338
+ // "result": {
1339
+ // "pair": {
1340
+ // "id": 2,
1341
+ // "name": "eth_usdt",
1342
+ // "baseAssetId": 2,
1343
+ // "quoteAssetId": 3,
1344
+ // "fullName": "ETH USDT",
1345
+ // "description": "ETH USDT",
1346
+ // "lastBuy": "1976.715012",
1347
+ // "lastSell": "1971.995006",
1348
+ // "lastPrice": "1976.715012",
1349
+ // "change24": "1.02",
1350
+ // "volume24": 24.0796457,
1351
+ // "volume24USD": 44282.347995912205,
1352
+ // "active": true,
1353
+ // "baseStep": 8,
1354
+ // "quoteStep": 6,
1355
+ // "status": 1,
1356
+ // "settings": {
1357
+ // "limit_usd": "0.1",
1358
+ // "price_max": "10000000000000",
1359
+ // "price_min": "1",
1360
+ // "price_tick": "1",
1361
+ // "pricescale": 10000,
1362
+ // "lot_size_max": "1000000000000000",
1363
+ // "lot_size_min": "1",
1364
+ // "lot_size_tick": "1",
1365
+ // "price_view_min": 6,
1366
+ // "default_slippage": 10,
1367
+ // "lot_size_view_min": 6
1368
+ // },
1369
+ // "asks": [
1370
+ // {
1371
+ // "price": "1976.405003",
1372
+ // "quantity": "0.0051171",
1373
+ // "amount": "10.1134620408513"
1374
+ // },
1375
+ // {
1376
+ // "price": "1976.405013",
1377
+ // "quantity": "0.09001559",
1378
+ // "amount": "177.90726332415267"
1379
+ // },
1380
+ // {
1381
+ // "price": "2010.704988",
1382
+ // "quantity": "0.00127892",
1383
+ // "amount": "2.57153082325296"
1384
+ // }
1385
+ // ],
1386
+ // "bids": [
1387
+ // {
1388
+ // "price": "1976.404988",
1389
+ // "quantity": "0.09875861",
1390
+ // "amount": "195.18700941194668"
1391
+ // },
1392
+ // {
1393
+ // "price": "1905.472973",
1394
+ // "quantity": "0.00263591",
1395
+ // "amount": "5.02265526426043"
1396
+ // },
1397
+ // {
1398
+ // "price": "1904.274973",
1399
+ // "quantity": "0.09425304",
1400
+ // "amount": "179.48370520116792"
1401
+ // }
1402
+ // ],
1403
+ // "updateId": "78",
1404
+ // "timeStart": "2021-01-28T09:19:30.706Z",
1405
+ // "makerFee": 200,
1406
+ // "takerFee": 200,
1407
+ // "quoteVolume24": 49125.1374009045,
1408
+ // "lowPrice24": 1966.704999,
1409
+ // "highPrice24": 2080.354997,
1410
+ // "baseCurrency": {
1411
+ // "id": 2,
1412
+ // "status": 1,
1413
+ // "symbol": "eth",
1414
+ // "title": "Ethereum",
1415
+ // "logoURL": "https://ethereum.org/static/6b935ac0e6194247347855dc3d328e83/34ca5/eth-diamond-black.png",
1416
+ // "isDiscount": false,
1417
+ // "address": "https://ethereum.org/",
1418
+ // "description": "Ethereum ETH",
1419
+ // "decimals": 18,
1420
+ // "blockChain": "Ethereum",
1421
+ // "precision": 8,
1422
+ // "currentRate": null,
1423
+ // "active": true,
1424
+ // "timeStart": "2021-01-28T08:57:41.719Z",
1425
+ // "txLimits": {
1426
+ // "minDeposit": "100000000000000",
1427
+ // "maxWithdraw": "10000000000000000000000",
1428
+ // "minWithdraw": "20000000000000000",
1429
+ // "withdrawCommissionFixed": "5000000000000000",
1430
+ // "withdrawCommissionPercentage": "NaN"
1431
+ // },
1432
+ // "type": "crypto",
1433
+ // "typeNetwork": "internalGW",
1434
+ // "icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIHZpZXdCb3g9IjAgMCAzMCAzMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTAgMTVDMCA2LjcxNTczIDYuNzE1NzMgMCAxNSAwVjBDMjMuMjg0MyAwIDMwIDYuNzE1NzMgMzAgMTVWMTVDMzAgMjMuMjg0MyAyMy4yODQzIDMwIDE1IDMwVjMwQzYuNzE1NzMgMzAgMCAyMy4yODQzIDAgMTVWMTVaIiBmaWxsPSJibGFjayIvPgo8cGF0aCBkPSJNMTQuOTU1NyAxOS45NzM5TDkgMTYuMzUwOUwxNC45NTIxIDI1TDIwLjkxMDkgMTYuMzUwOUwxNC45NTIxIDE5Ljk3MzlIMTQuOTU1N1pNMTUuMDQ0MyA1TDkuMDkwOTUgMTUuMTg1M0wxNS4wNDQzIDE4LjgxNDZMMjEgMTUuMTg5MUwxNS4wNDQzIDVaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K",
1435
+ // "idSorting": 2,
1436
+ // "links": [
1437
+ // {
1438
+ // "tx": "https://etherscan.io/tx/",
1439
+ // "address": "https://etherscan.io/address/",
1440
+ // "blockChain": "Ethereum"
1441
+ // }
1442
+ // ],
1443
+ // "clientTxLimits": {
1444
+ // "minDeposit": "0.0001",
1445
+ // "minWithdraw": "0.02",
1446
+ // "maxWithdraw": "10000",
1447
+ // "withdrawCommissionPercentage": "NaN",
1448
+ // "withdrawCommissionFixed": "0.005"
1449
+ // }
1450
+ // },
1451
+ // "quoteCurrency": {
1452
+ // "id": 3,
1453
+ // "status": 1,
1454
+ // "symbol": "usdt",
1455
+ // "title": "Tether USD",
1456
+ // "logoURL": "https://cryptologos.cc/logos/tether-usdt-logo.png?v=010",
1457
+ // "isDiscount": false,
1458
+ // "address": "https://tether.to/",
1459
+ // "description": "Tether USD",
1460
+ // "decimals": 6,
1461
+ // "blockChain": "",
1462
+ // "precision": 6,
1463
+ // "currentRate": null,
1464
+ // "active": true,
1465
+ // "timeStart": "2021-01-28T09:04:17.170Z",
1466
+ // "txLimits": {
1467
+ // "minDeposit": "1000",
1468
+ // "maxWithdraw": "100000000000",
1469
+ // "minWithdraw": "1000000",
1470
+ // "withdrawCommissionFixed": {
1471
+ // "Tron": "2000000",
1472
+ // "Binance": "2000000000000000000",
1473
+ // "Ethereum": "20000000"
1474
+ // },
1475
+ // "withdrawCommissionPercentage": "NaN"
1476
+ // },
1477
+ // "type": "crypto",
1478
+ // "typeNetwork": "internalGW",
1479
+ // "icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzAiIGhlaWdodD0iMzAiIHZpZXdCb3g9IjAgMCAzMCAzMCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTAgMTVDMCA2LjcxNTczIDYuNzE1NzMgMCAxNSAwVjBDMjMuMjg0MyAwIDMwIDYuNzE1NzMgMzAgMTVWMTVDMzAgMjMuMjg0MyAyMy4yODQzIDMwIDE1IDMwVjMwQzYuNzE1NzMgMzAgMCAyMy4yODQzIDAgMTVWMTVaIiBmaWxsPSIjNkZBNjg4Ii8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNMjMgN0g3VjExSDEzVjEyLjA2MkM4Ljk5MjAyIDEyLjMxNDYgNiAxMy4zMTAyIDYgMTQuNUM2IDE1LjY4OTggOC45OTIwMiAxNi42ODU0IDEzIDE2LjkzOFYyM0gxN1YxNi45MzhDMjEuMDA4IDE2LjY4NTQgMjQgMTUuNjg5OCAyNCAxNC41QzI0IDEzLjMxMDIgMjEuMDA4IDEyLjMxNDYgMTcgMTIuMDYyVjExSDIzVjdaTTcuNSAxNC41QzcuNSAxMy40NjA2IDkuMzMzMzMgMTIuMzY4IDEzIDEyLjA3NTZWMTUuNUgxN1YxMi4wNzU5QzIwLjkzODQgMTIuMzkyNyAyMi41IDEzLjYzMzkgMjIuNSAxNC41QzIyLjUgMTUuMzIyIDIwLjAwMDggMTUuODA2MSAxNyAxNS45NTI1QzE1LjcwODIgMTYuMDQ2MiAxMy43OTUxIDE1Ljk4MjYgMTMgMTUuOTM5MUM5Ljk5OTIxIDE1Ljc1NTkgNy41IDE1LjE4MDkgNy41IDE0LjVaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K",
1480
+ // "idSorting": 0,
1481
+ // "links": [
1482
+ // {
1483
+ // "tx": "https://etherscan.io/tx/",
1484
+ // "address": "https://etherscan.io/address/",
1485
+ // "blockChain": "Ethereum"
1486
+ // },
1487
+ // {
1488
+ // "tx": "https://tronscan.org/#/transaction/",
1489
+ // "address": "https://tronscan.org/#/address/",
1490
+ // "blockChain": "Tron"
1491
+ // },
1492
+ // {
1493
+ // "tx": "https://bscscan.com/tx/",
1494
+ // "address": "https://bscscan.com/address/",
1495
+ // "blockChain": "Binance"
1496
+ // }
1497
+ // ],
1498
+ // "clientTxLimits": {
1499
+ // "minDeposit": "0.001",
1500
+ // "minWithdraw": "1",
1501
+ // "maxWithdraw": "100000",
1502
+ // "withdrawCommissionPercentage": "NaN",
1503
+ // "withdrawCommissionFixed": {
1504
+ // "Tron": "2",
1505
+ // "Binance": "2",
1506
+ // "Ethereum": "20"
1507
+ // }
1508
+ // }
1509
+ // },
1510
+ // "quantities": {
1511
+ // "asks": "5.58760757",
1512
+ // "bids": "2226.98663823032198"
1513
+ // }
1514
+ // }
1515
+ // }
1516
+ // }
1517
+ //
1518
+ const result = this.safeValue(response, 'result', {});
1519
+ const pair = this.safeValue(result, 'pair', {});
1520
+ return this.parseTicker(pair, market);
1521
+ }
1522
+ parseTicker(ticker, market = undefined) {
1523
+ //
1524
+ // fetchTicker
1525
+ // {
1526
+ // "id": 2,
1527
+ // "name": "eth_usdt",
1528
+ // "baseAssetId": 2,
1529
+ // "quoteAssetId": 3,
1530
+ // "fullName": "ETH USDT",
1531
+ // "description": "ETH USDT",
1532
+ // "lastBuy": "1976.715012",
1533
+ // "lastSell": "1971.995006",
1534
+ // "lastPrice": "1976.715012",
1535
+ // "change24": "1.02",
1536
+ // "volume24": 24.0796457,
1537
+ // "volume24USD": 44282.347995912205,
1538
+ // "active": true,
1539
+ // "baseStep": 8,
1540
+ // "quoteStep": 6,
1541
+ // "status": 1,
1542
+ // "asks": [
1543
+ // {
1544
+ // "price": "1976.405003",
1545
+ // "quantity": "0.0051171",
1546
+ // "amount": "10.1134620408513"
1547
+ // },
1548
+ // {
1549
+ // "price": "1976.405013",
1550
+ // "quantity": "0.09001559",
1551
+ // "amount": "177.90726332415267"
1552
+ // },
1553
+ // {
1554
+ // "price": "2010.704988",
1555
+ // "quantity": "0.00127892",
1556
+ // "amount": "2.57153082325296"
1557
+ // }
1558
+ // ...
1559
+ // ],
1560
+ // "bids": [
1561
+ // {
1562
+ // "price": "1976.404988",
1563
+ // "quantity": "0.09875861",
1564
+ // "amount": "195.18700941194668"
1565
+ // },
1566
+ // {
1567
+ // "price": "1905.472973",
1568
+ // "quantity": "0.00263591",
1569
+ // "amount": "5.02265526426043"
1570
+ // },
1571
+ // {
1572
+ // "price": "1904.274973",
1573
+ // "quantity": "0.09425304",
1574
+ // "amount": "179.48370520116792"
1575
+ // }
1576
+ // ...
1577
+ // ],
1578
+ // "updateId": "78",
1579
+ // "timeStart": "2021-01-28T09:19:30.706Z",
1580
+ // "makerFee": 200,
1581
+ // "takerFee": 200,
1582
+ // "quoteVolume24": 49125.1374009045,
1583
+ // "lowPrice24": 1966.704999,
1584
+ // "highPrice24": 2080.354997,
1585
+ // ...
1586
+ // }
1587
+ //
1588
+ // fetchTickers
1589
+ // {
1590
+ // "trading_pairs": "BTC_USDT",
1591
+ // "base_currency": "BTC",
1592
+ // "quote_currency": "USDT",
1593
+ // "last_price": 37669.955001,
1594
+ // "lowest_ask": 37670.055,
1595
+ // "highest_bid": 37669.955,
1596
+ // "base_volume": 6.81156888,
1597
+ // "quote_volume": 257400.516878529,
1598
+ // "price_change_percent_24h": -0.29,
1599
+ // "highest_price_24h": 38389.994463,
1600
+ // "lowest_price_24h": 37574.894999
1601
+ // }
1602
+ const marketId = this.safeStringLower(ticker, 'trading_pairs');
1603
+ market = this.safeMarket(marketId, market);
1604
+ let bestBidPrice = undefined;
1605
+ let bestAskPrice = undefined;
1606
+ let bestBidVolume = undefined;
1607
+ let bestAskVolume = undefined;
1608
+ const bids = this.safeValue(ticker, 'bids');
1609
+ const asks = this.safeValue(ticker, 'asks');
1610
+ if ((bids !== undefined) && (Array.isArray(bids)) && (asks !== undefined) && (Array.isArray(asks))) {
1611
+ const bestBid = this.safeValue(bids, 0, {});
1612
+ bestBidPrice = this.safeString(bestBid, 'price');
1613
+ bestBidVolume = this.safeString(bestBid, 'quantity');
1614
+ const bestAsk = this.safeValue(asks, 0, {});
1615
+ bestAskPrice = this.safeString(bestAsk, 'price');
1616
+ bestAskVolume = this.safeString(bestAsk, 'quantity');
1617
+ }
1618
+ else {
1619
+ bestBidPrice = this.safeString(ticker, 'highest_bid');
1620
+ bestAskPrice = this.safeString(ticker, 'lowest_ask');
1621
+ }
1622
+ const baseVolume = this.safeString2(ticker, 'volume24', 'base_volume');
1623
+ const quoteVolume = this.safeString2(ticker, 'quoteVolume24', 'quote_volume');
1624
+ const high = this.safeString2(ticker, 'highPrice24', 'highest_price_24h');
1625
+ const low = this.safeString2(ticker, 'lowPrice24', 'lowest_price_24h');
1626
+ const close = this.safeString2(ticker, 'lastPrice', 'last_price');
1627
+ const changePcnt = this.safeString2(ticker, 'change24', 'price_change_percent_24h');
1628
+ return this.safeTicker({
1629
+ 'symbol': market['symbol'],
1630
+ 'timestamp': undefined,
1631
+ 'datetime': undefined,
1632
+ 'open': undefined,
1633
+ 'high': high,
1634
+ 'low': low,
1635
+ 'close': close,
1636
+ 'bid': bestBidPrice,
1637
+ 'bidVolume': bestBidVolume,
1638
+ 'ask': bestAskPrice,
1639
+ 'askVolume': bestAskVolume,
1640
+ 'vwap': undefined,
1641
+ 'previousClose': undefined,
1642
+ 'change': undefined,
1643
+ 'percentage': changePcnt,
1644
+ 'average': undefined,
1645
+ 'baseVolume': baseVolume,
1646
+ 'quoteVolume': quoteVolume,
1647
+ 'info': ticker,
1648
+ }, market);
1649
+ }
1650
+ async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
1651
+ /**
1652
+ * @method
1653
+ * @name bitteam#fetchTrades
1654
+ * @description get the list of most recent trades for a particular symbol
1655
+ * @see https://bit.team/trade/api/documentation#/CMC/getTradeApiCmcTradesPair
1656
+ * @param {string} symbol unified symbol of the market to fetch trades for
1657
+ * @param {int} [since] timestamp in ms of the earliest trade to fetch
1658
+ * @param {int} [limit] the maximum amount of trades to fetch
1659
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
1660
+ * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#public-trades}
1661
+ */
1662
+ await this.loadMarkets();
1663
+ const market = this.market(symbol);
1664
+ const request = {
1665
+ 'pair': market['id'],
1666
+ };
1667
+ const response = await this.publicGetTradeApiCmcTradesPair(this.extend(request, params));
1668
+ //
1669
+ // [
1670
+ // {
1671
+ // "trade_id": 34970337,
1672
+ // "price": 37769.994793,
1673
+ // "base_volume": 0.00119062,
1674
+ // "quote_volume": 44.96971120044166,
1675
+ // "timestamp": 1700827234000,
1676
+ // "type": "buy"
1677
+ // },
1678
+ // {
1679
+ // "trade_id": 34970347,
1680
+ // "price": 37769.634497,
1681
+ // "base_volume": 0.00104009,
1682
+ // "quote_volume": 39.28381914398473,
1683
+ // "timestamp": 1700827248000,
1684
+ // "type": "buy"
1685
+ // },
1686
+ // ...
1687
+ // ]
1688
+ //
1689
+ return this.parseTrades(response, market, since, limit);
1690
+ }
1691
+ async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1692
+ /**
1693
+ * @method
1694
+ * @name bitteam#fetchMyTrades
1695
+ * @description fetch all trades made by the user
1696
+ * @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtTradesofuser
1697
+ * @param {string} symbol unified market symbol
1698
+ * @param {int} [since] the earliest time in ms to fetch trades for
1699
+ * @param {int} [limit] the maximum number of trades structures to retrieve (default 10)
1700
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
1701
+ * @returns {Trade[]} a list of [trade structures]{@link https://github.com/ccxt/ccxt/wiki/Manual#trade-structure}
1702
+ */
1703
+ await this.loadMarkets();
1704
+ const request = {};
1705
+ let market = undefined;
1706
+ if (symbol !== undefined) {
1707
+ market = this.market(symbol);
1708
+ request['pairId'] = market['numericId'];
1709
+ }
1710
+ if (limit !== undefined) {
1711
+ request['limit'] = limit;
1712
+ }
1713
+ const response = await this.privateGetTradeApiCcxtTradesOfUser(this.extend(request, params));
1714
+ //
1715
+ // {
1716
+ // "ok": true,
1717
+ // "result": {
1718
+ // "count": 3,
1719
+ // "trades": [
1720
+ // {
1721
+ // "id": 34880724,
1722
+ // "tradeId": "4368041",
1723
+ // "makerOrderId": 106742914,
1724
+ // "takerOrderId": 106761614,
1725
+ // "pairId": 2,
1726
+ // "quantity": "0.00955449",
1727
+ // "price": "1993.674994",
1728
+ // "isBuyerMaker": true,
1729
+ // "baseDecimals": 18,
1730
+ // "quoteDecimals": 6,
1731
+ // "side": "sell",
1732
+ // "timestamp": 1700615250,
1733
+ // "rewarded": true,
1734
+ // "makerUserId": 21639,
1735
+ // "takerUserId": 15913,
1736
+ // "baseCurrencyId": 2,
1737
+ // "quoteCurrencyId": 3,
1738
+ // "feeMaker": {
1739
+ // "amount": "0.0000191",
1740
+ // "symbol": "eth",
1741
+ // "userId": 21639,
1742
+ // "decimals": 18,
1743
+ // "symbolId": 2
1744
+ // },
1745
+ // "feeTaker": {
1746
+ // "amount": "0",
1747
+ // "symbol": "usdt",
1748
+ // "userId": 15913,
1749
+ // "decimals": 6,
1750
+ // "symbolId": 3,
1751
+ // "discountAmount": "0",
1752
+ // "discountSymbol": "btt",
1753
+ // "discountDecimals": 18,
1754
+ // "discountSymbolId": 5
1755
+ // },
1756
+ // "pair": "eth_usdt",
1757
+ // "createdAt": "2023-11-22T01:07:30.593Z",
1758
+ // "updatedAt": "2023-11-22T01:10:00.117Z",
1759
+ // "isCurrentSide": "maker"
1760
+ // },
1761
+ // {
1762
+ // "id": 34875793,
1763
+ // "tradeId": "4368010",
1764
+ // "makerOrderId": 106742914,
1765
+ // "takerOrderId": 106745926,
1766
+ // "pairId": 2,
1767
+ // "quantity": "0.0027193",
1768
+ // "price": "1993.674994",
1769
+ // "isBuyerMaker": true,
1770
+ // "baseDecimals": 18,
1771
+ // "quoteDecimals": 6,
1772
+ // "side": "sell",
1773
+ // "timestamp": 1700602983,
1774
+ // "rewarded": true,
1775
+ // "makerUserId": 21639,
1776
+ // "takerUserId": 15912,
1777
+ // "baseCurrencyId": 2,
1778
+ // "quoteCurrencyId": 3,
1779
+ // "feeMaker": {
1780
+ // "amount": "0.00000543",
1781
+ // "symbol": "eth",
1782
+ // "userId": 21639,
1783
+ // "decimals": 18,
1784
+ // "symbolId": 2
1785
+ // },
1786
+ // "feeTaker": {
1787
+ // "amount": "0",
1788
+ // "symbol": "usdt",
1789
+ // "userId": 15912,
1790
+ // "decimals": 6,
1791
+ // "symbolId": 3,
1792
+ // "discountAmount": "0",
1793
+ // "discountSymbol": "btt",
1794
+ // "discountDecimals": 18,
1795
+ // "discountSymbolId": 5
1796
+ // },
1797
+ // "pair": "eth_usdt",
1798
+ // "createdAt": "2023-11-21T21:43:02.758Z",
1799
+ // "updatedAt": "2023-11-21T21:45:00.147Z",
1800
+ // "isCurrentSide": "maker"
1801
+ // },
1802
+ // {
1803
+ // "id": 34871727,
1804
+ // "tradeId": "3441840",
1805
+ // "makerOrderId": 106733299,
1806
+ // "takerOrderId": 106733308,
1807
+ // "pairId": 22,
1808
+ // "quantity": "0.00001",
1809
+ // "price": "37017.495008",
1810
+ // "isBuyerMaker": false,
1811
+ // "baseDecimals": 8,
1812
+ // "quoteDecimals": 6,
1813
+ // "side": "buy",
1814
+ // "timestamp": 1700594960,
1815
+ // "rewarded": true,
1816
+ // "makerUserId": 15909,
1817
+ // "takerUserId": 21639,
1818
+ // "baseCurrencyId": 11,
1819
+ // "quoteCurrencyId": 3,
1820
+ // "feeMaker": {
1821
+ // "amount": "0",
1822
+ // "symbol": "usdt",
1823
+ // "userId": 15909,
1824
+ // "decimals": 6,
1825
+ // "symbolId": 3,
1826
+ // "discountAmount": "0",
1827
+ // "discountSymbol": "btt",
1828
+ // "discountDecimals": 18,
1829
+ // "discountSymbolId": 5
1830
+ // },
1831
+ // "feeTaker": {
1832
+ // "amount": "0.00000002",
1833
+ // "symbol": "btc",
1834
+ // "userId": 21639,
1835
+ // "decimals": 8,
1836
+ // "symbolId": 11
1837
+ // },
1838
+ // "pair": "btc_usdt",
1839
+ // "createdAt": "2023-11-21T19:29:20.092Z",
1840
+ // "updatedAt": "2023-11-21T19:30:00.159Z"
1841
+ // "isCurrentSide": "taker"
1842
+ // }
1843
+ // ]
1844
+ // }
1845
+ // }
1846
+ //
1847
+ const result = this.safeValue(response, 'result', {});
1848
+ const trades = this.safeValue(result, 'trades', []);
1849
+ return this.parseTrades(trades, market, since, limit);
1850
+ }
1851
+ parseTrade(trade, market = undefined) {
1852
+ //
1853
+ // fetchTrades
1854
+ // {
1855
+ // "trade_id": 34970337,
1856
+ // "price": 37769.994793,
1857
+ // "base_volume": 0.00119062,
1858
+ // "quote_volume": 44.96971120044166,
1859
+ // "timestamp": 1700827234000,
1860
+ // "type": "buy"
1861
+ // },
1862
+ //
1863
+ // fetchMyTrades
1864
+ // {
1865
+ // "id": 34875793,
1866
+ // "tradeId": "4368010",
1867
+ // "makerOrderId": 106742914,
1868
+ // "takerOrderId": 106745926,
1869
+ // "pairId": 2,
1870
+ // "quantity": "0.0027193",
1871
+ // "price": "1993.674994",
1872
+ // "isBuyerMaker": true,
1873
+ // "baseDecimals": 18,
1874
+ // "quoteDecimals": 6,
1875
+ // "side": "sell",
1876
+ // "timestamp": 1700602983,
1877
+ // "rewarded": true,
1878
+ // "makerUserId": 21639,
1879
+ // "takerUserId": 15912,
1880
+ // "baseCurrencyId": 2,
1881
+ // "quoteCurrencyId": 3,
1882
+ // "feeMaker": {
1883
+ // "amount": "0.00000543",
1884
+ // "symbol": "eth",
1885
+ // "userId": 21639,
1886
+ // "decimals": 18,
1887
+ // "symbolId": 2
1888
+ // },
1889
+ // "feeTaker": {
1890
+ // "amount": "0",
1891
+ // "symbol": "usdt",
1892
+ // "userId": 15912,
1893
+ // "decimals": 6,
1894
+ // "symbolId": 3,
1895
+ // "discountAmount": "0",
1896
+ // "discountSymbol": "btt",
1897
+ // "discountDecimals": 18,
1898
+ // "discountSymbolId": 5
1899
+ // },
1900
+ // "pair": "eth_usdt",
1901
+ // "createdAt": "2023-11-21T21:43:02.758Z",
1902
+ // "updatedAt": "2023-11-21T21:45:00.147Z",
1903
+ // "isCurrentSide": "maker"
1904
+ // }
1905
+ //
1906
+ const marketId = this.safeString(trade, 'pair');
1907
+ market = this.safeMarket(marketId, market);
1908
+ const symbol = market['symbol'];
1909
+ const id = this.safeString2(trade, 'id', 'trade_id');
1910
+ const price = this.safeString(trade, 'price');
1911
+ const amount = this.safeString2(trade, 'quantity', 'base_volume');
1912
+ const cost = this.safeString(trade, 'quote_volume');
1913
+ const takerOrMaker = this.safeString(trade, 'isCurrentSide');
1914
+ let timestamp = this.safeString(trade, 'timestamp');
1915
+ if (takerOrMaker !== undefined) {
1916
+ timestamp = Precise.stringMul(timestamp, '1000');
1917
+ }
1918
+ // the exchange returns the side of the taker
1919
+ let side = this.safeString2(trade, 'side', 'type');
1920
+ let feeInfo = undefined;
1921
+ let order = undefined;
1922
+ if (takerOrMaker === 'maker') {
1923
+ if (side === 'sell') {
1924
+ side = 'buy';
1925
+ }
1926
+ else if (side === 'buy') {
1927
+ side = 'sell';
1928
+ }
1929
+ order = this.safeString(trade, 'makerOrderId');
1930
+ feeInfo = this.safeValue(trade, 'feeMaker', {});
1931
+ }
1932
+ else if (takerOrMaker === 'taker') {
1933
+ order = this.safeString(trade, 'takerOrderId');
1934
+ feeInfo = this.safeValue(trade, 'feeTaker', {});
1935
+ }
1936
+ const feeCurrencyId = this.safeString(feeInfo, 'symbol');
1937
+ const feeCost = this.safeString(feeInfo, 'amount');
1938
+ const fee = {
1939
+ 'currency': this.safeCurrencyCode(feeCurrencyId),
1940
+ 'cost': feeCost,
1941
+ 'rate': undefined,
1942
+ };
1943
+ const intTs = this.parseToInt(timestamp);
1944
+ return this.safeTrade({
1945
+ 'id': id,
1946
+ 'order': order,
1947
+ 'timestamp': intTs,
1948
+ 'datetime': this.iso8601(intTs),
1949
+ 'symbol': symbol,
1950
+ 'type': undefined,
1951
+ 'side': side,
1952
+ 'takerOrMaker': takerOrMaker,
1953
+ 'price': price,
1954
+ 'amount': amount,
1955
+ 'cost': cost,
1956
+ 'fee': fee,
1957
+ 'info': trade,
1958
+ }, market);
1959
+ }
1960
+ async fetchBalance(params = {}) {
1961
+ /**
1962
+ * @method
1963
+ * @name betteam#fetchBalance
1964
+ * @description query for balance and get the amount of funds available for trading or funds locked in orders
1965
+ * @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiCcxtBalance
1966
+ * @param {object} [params] extra parameters specific to the betteam api endpoint
1967
+ * @returns {object} a [balance structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#balance-structure}
1968
+ */
1969
+ await this.loadMarkets();
1970
+ const response = await this.privateGetTradeApiCcxtBalance(params);
1971
+ return this.parseBalance(response);
1972
+ }
1973
+ parseBalance(response) {
1974
+ //
1975
+ // {
1976
+ // "ok": true,
1977
+ // "result": {
1978
+ // "free": {
1979
+ // "USDT": "0",
1980
+ // "DEL": "0",
1981
+ // "BTC": "0",
1982
+ // ...
1983
+ // },
1984
+ // "used": {
1985
+ // "USDT": "0",
1986
+ // "DEL": "0",
1987
+ // "BTC": "0",
1988
+ // ...
1989
+ // },
1990
+ // "total": {
1991
+ // "USDT": "0",
1992
+ // "DEL": "0",
1993
+ // "BTC": "0",
1994
+ // ...
1995
+ // },
1996
+ // "USDT": {
1997
+ // "free": "0",
1998
+ // "used": "0",
1999
+ // "total": "0",
2000
+ // },
2001
+ // "DEL": {
2002
+ // "free": "0",
2003
+ // "used": "0",
2004
+ // "total": "0",
2005
+ // },
2006
+ // "BTC": {
2007
+ // "free": "0",
2008
+ // "used": "0",
2009
+ // "total": "0",
2010
+ // }
2011
+ // ...
2012
+ // }
2013
+ // }
2014
+ //
2015
+ const timestamp = this.milliseconds();
2016
+ const balance = {
2017
+ 'info': response,
2018
+ 'timestamp': timestamp,
2019
+ 'datetime': this.iso8601(timestamp),
2020
+ };
2021
+ const result = this.safeValue(response, 'result', {});
2022
+ const balanceByCurrencies = this.omit(result, ['free', 'used', 'total']);
2023
+ const rawCurrencyIds = Object.keys(balanceByCurrencies);
2024
+ for (let i = 0; i < rawCurrencyIds.length; i++) {
2025
+ const rawCurrencyId = rawCurrencyIds[i];
2026
+ const currencyBalance = this.safeValue(result, rawCurrencyId);
2027
+ const free = this.safeString(currencyBalance, 'free');
2028
+ const used = this.safeString(currencyBalance, 'used');
2029
+ const total = this.safeString(currencyBalance, 'total');
2030
+ const currencyCode = this.safeCurrencyCode(rawCurrencyId.toLowerCase());
2031
+ balance[currencyCode] = {
2032
+ 'free': free,
2033
+ 'used': used,
2034
+ 'total': total,
2035
+ };
2036
+ }
2037
+ return this.safeBalance(balance);
2038
+ }
2039
+ async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
2040
+ /**
2041
+ * @method
2042
+ * @name bitteam#fetchDepositsWithdrawals
2043
+ * @description fetch history of deposits and withdrawals from external wallets and between CoinList Pro trading account and CoinList wallet
2044
+ * @see https://bit.team/trade/api/documentation#/PRIVATE/getTradeApiTransactionsofuser
2045
+ * @param {string} [code] unified currency code for the currency of the deposit/withdrawals
2046
+ * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal
2047
+ * @param {int} [limit] max number of deposit/withdrawals to return (default 10)
2048
+ * @param {object} [params] extra parameters specific to the bitteam api endpoint
2049
+ * @returns {object} a list of [transaction structure]{@link https://github.com/ccxt/ccxt/wiki/Manual#transaction-structure}
2050
+ */
2051
+ await this.loadMarkets();
2052
+ let currency = undefined;
2053
+ const request = {};
2054
+ if (code !== undefined) {
2055
+ currency = this.currency(code);
2056
+ request['currency'] = currency['numericId'];
2057
+ }
2058
+ if (limit !== undefined) {
2059
+ request['limit'] = limit;
2060
+ }
2061
+ const response = await this.privateGetTradeApiTransactionsOfUser(this.extend(request, params));
2062
+ //
2063
+ // {
2064
+ // "ok": true,
2065
+ // "result": {
2066
+ // "count": 2,
2067
+ // "transactions": [
2068
+ // {
2069
+ // "id": 1329686,
2070
+ // "orderId": "2f060ad5-30f7-4f2b-ac5f-1bb8f5fd34dc",
2071
+ // "transactionCoreId": "561863",
2072
+ // "userId": 21639,
2073
+ // "recipient": "0x9050dfA063D1bE7cA711c750b18D51fDD13e90Ee",
2074
+ // "sender": "0x6894a93B6fea044584649278621723cac51443Cd",
2075
+ // "symbolId": 2,
2076
+ // "CommissionId": 17571,
2077
+ // "amount": "44000000000000000",
2078
+ // "params": {},
2079
+ // "reason": null,
2080
+ // "timestamp": 1700715341743,
2081
+ // "status": "approving",
2082
+ // "statusDescription": null,
2083
+ // "type": "withdraw",
2084
+ // "message": null,
2085
+ // "blockChain": "",
2086
+ // "before": null,
2087
+ // "after": null,
2088
+ // "currency": {
2089
+ // "symbol": "eth",
2090
+ // "decimals": 18,
2091
+ // "blockChain": "Ethereum",
2092
+ // "links": [
2093
+ // {
2094
+ // "tx": "https://etherscan.io/tx/",
2095
+ // "address": "https://etherscan.io/address/",
2096
+ // "blockChain": "Ethereum"
2097
+ // }
2098
+ // ]
2099
+ // }
2100
+ // },
2101
+ // {
2102
+ // "id": 1329229,
2103
+ // "orderId": null,
2104
+ // "transactionCoreId": "561418",
2105
+ // "userId": 21639,
2106
+ // "recipient": "0x7d6a797f2406e06b2f9b41d067df324affa315dd",
2107
+ // "sender": null,
2108
+ // "symbolId": 3,
2109
+ // "CommissionId": null,
2110
+ // "amount": "100000000",
2111
+ // "params": {
2112
+ // "tx_id": "0x2253823c828d838acd983fe6a348fb0e034efe3874b081871d8b80da76ec758b"
2113
+ // },
2114
+ // "reason": null,
2115
+ // "timestamp": 1700594180417,
2116
+ // "status": "success",
2117
+ // "statusDescription": null,
2118
+ // "type": "deposit",
2119
+ // "message": null,
2120
+ // "blockChain": "Ethereum",
2121
+ // "before": 0,
2122
+ // "after": 100000000,
2123
+ // "currency": {
2124
+ // "symbol": "usdt",
2125
+ // "decimals": 6,
2126
+ // "blockChain": "",
2127
+ // "links": [
2128
+ // {
2129
+ // "tx": "https://etherscan.io/tx/",
2130
+ // "address": "https://etherscan.io/address/",
2131
+ // "blockChain": "Ethereum"
2132
+ // },
2133
+ // {
2134
+ // "tx": "https://tronscan.org/#/transaction/",
2135
+ // "address": "https://tronscan.org/#/address/",
2136
+ // "blockChain": "Tron"
2137
+ // },
2138
+ // {
2139
+ // "tx": "https://bscscan.com/tx/",
2140
+ // "address": "https://bscscan.com/address/",
2141
+ // "blockChain": "Binance"
2142
+ // }
2143
+ // ]
2144
+ // }
2145
+ // }
2146
+ // ]
2147
+ // }
2148
+ // }
2149
+ //
2150
+ const result = this.safeValue(response, 'result', {});
2151
+ const transactions = this.safeValue(result, 'transactions', []);
2152
+ return this.parseTransactions(transactions, currency, since, limit);
2153
+ }
2154
+ parseTransaction(transaction, currency = undefined) {
2155
+ //
2156
+ // {
2157
+ // "id": 1329229,
2158
+ // "orderId": null,
2159
+ // "transactionCoreId": "561418",
2160
+ // "userId": 21639,
2161
+ // "recipient": "0x7d6a797f2406e06b2f9b41d067df324affa315dd",
2162
+ // "sender": null,
2163
+ // "symbolId": 3,
2164
+ // "CommissionId": null,
2165
+ // "amount": "100000000",
2166
+ // "params": {
2167
+ // "tx_id": "0x2253823c828d838acd983fe6a348fb0e034efe3874b081871d8b80da76ec758b"
2168
+ // },
2169
+ // "reason": null,
2170
+ // "timestamp": 1700594180417,
2171
+ // "status": "success",
2172
+ // "statusDescription": null,
2173
+ // "type": "deposit",
2174
+ // "message": null,
2175
+ // "blockChain": "Ethereum",
2176
+ // "before": 0,
2177
+ // "after": 100000000,
2178
+ // "currency": {
2179
+ // "symbol": "usdt",
2180
+ // "decimals": 6,
2181
+ // "blockChain": "",
2182
+ // "links": [
2183
+ // {
2184
+ // "tx": "https://etherscan.io/tx/",
2185
+ // "address": "https://etherscan.io/address/",
2186
+ // "blockChain": "Ethereum"
2187
+ // },
2188
+ // {
2189
+ // "tx": "https://tronscan.org/#/transaction/",
2190
+ // "address": "https://tronscan.org/#/address/",
2191
+ // "blockChain": "Tron"
2192
+ // },
2193
+ // {
2194
+ // "tx": "https://bscscan.com/tx/",
2195
+ // "address": "https://bscscan.com/address/",
2196
+ // "blockChain": "Binance"
2197
+ // }
2198
+ // ]
2199
+ // }
2200
+ // }
2201
+ //
2202
+ const currencyObject = this.safeValue(transaction, 'currency');
2203
+ const currencyId = this.safeString(currencyObject, 'symbol');
2204
+ const code = this.safeCurrencyCode(currencyId, currency);
2205
+ const id = this.safeString(transaction, 'id');
2206
+ const params = this.safeValue(transaction, 'params');
2207
+ const txid = this.safeString(params, 'tx_id');
2208
+ const timestamp = this.safeInteger(transaction, 'timestamp');
2209
+ let networkId = this.safeString(transaction, 'blockChain');
2210
+ if (networkId === undefined) {
2211
+ const links = this.safeValue(currencyObject, 'links', []);
2212
+ const blockChain = this.safeValue(links, 0, {});
2213
+ networkId = this.safeString(blockChain, 'blockChain');
2214
+ }
2215
+ const addressFrom = this.safeString(transaction, 'sender');
2216
+ const addressTo = this.safeString(transaction, 'recipient');
2217
+ const tag = this.safeString(transaction, 'message');
2218
+ const type = this.parseTransactionType(this.safeString(transaction, 'type'));
2219
+ const amount = this.parseValueToPricision(transaction, 'amount', currencyObject, 'decimals');
2220
+ const status = this.parseTransactionStatus(this.safeValue(transaction, 'status'));
2221
+ return {
2222
+ 'info': transaction,
2223
+ 'id': id,
2224
+ 'txid': txid,
2225
+ 'timestamp': timestamp,
2226
+ 'datetime': this.iso8601(timestamp),
2227
+ 'network': this.networkIdToCode(networkId),
2228
+ 'addressFrom': addressFrom,
2229
+ 'address': undefined,
2230
+ 'addressTo': addressTo,
2231
+ 'tagFrom': undefined,
2232
+ 'tag': tag,
2233
+ 'tagTo': undefined,
2234
+ 'type': type,
2235
+ 'amount': this.parseNumber(amount),
2236
+ 'currency': code,
2237
+ 'status': status,
2238
+ 'updated': undefined,
2239
+ 'fee': undefined,
2240
+ 'comment': this.safeString(transaction, 'description'),
2241
+ 'internal': false,
2242
+ };
2243
+ }
2244
+ parseTransactionType(type) {
2245
+ const types = {
2246
+ 'deposit': 'deposit',
2247
+ 'withdraw': 'withdrawal',
2248
+ };
2249
+ return this.safeString(types, type, type);
2250
+ }
2251
+ parseTransactionStatus(status) {
2252
+ const statuses = {
2253
+ 'approving': 'pending',
2254
+ 'success': 'ok',
2255
+ };
2256
+ return this.safeString(statuses, status, status);
2257
+ }
2258
+ sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
2259
+ const request = this.omit(params, this.extractParams(path));
2260
+ const endpoint = '/' + this.implodeParams(path, params);
2261
+ let url = this.urls['api'][api] + endpoint;
2262
+ const query = this.urlencode(request);
2263
+ if (api === 'private') {
2264
+ this.checkRequiredCredentials();
2265
+ if (method === 'POST') {
2266
+ body = this.json(request);
2267
+ }
2268
+ else if (query.length !== 0) {
2269
+ url += '?' + query;
2270
+ }
2271
+ const auth = this.apiKey + ':' + this.secret;
2272
+ const auth64 = this.stringToBase64(auth);
2273
+ const signature = 'Basic ' + auth64;
2274
+ headers = {
2275
+ 'Authorization': signature,
2276
+ 'Content-Type': 'application/json',
2277
+ };
2278
+ }
2279
+ else if (query.length !== 0) {
2280
+ url += '?' + query;
2281
+ }
2282
+ return { 'url': url, 'method': method, 'body': body, 'headers': headers };
2283
+ }
2284
+ handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
2285
+ if (response === undefined) {
2286
+ return undefined;
2287
+ }
2288
+ if (code !== 200) {
2289
+ if (code === 404) {
2290
+ if ((url.indexOf('/ccxt/order/') >= 0) && (method === 'GET')) {
2291
+ const parts = url.split('/order/');
2292
+ const orderId = this.safeString(parts, 1);
2293
+ throw new OrderNotFound(this.id + ' order ' + orderId + ' not found');
2294
+ }
2295
+ if (url.indexOf('/cmc/orderbook/') >= 0) {
2296
+ const parts = url.split('/cmc/orderbook/');
2297
+ const symbolId = this.safeString(parts, 1);
2298
+ throw new BadSymbol(this.id + ' symbolId ' + symbolId + ' not found');
2299
+ }
2300
+ }
2301
+ const feedback = this.id + ' ' + body;
2302
+ const message = this.safeString(response, 'message');
2303
+ const responseCode = this.safeString(response, 'code');
2304
+ this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
2305
+ this.throwExactlyMatchedException(this.exceptions['exact'], responseCode, feedback);
2306
+ throw new ExchangeError(feedback);
2307
+ }
2308
+ return undefined;
2309
+ }
2310
+ }