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