ccxt 4.5.44 → 4.5.45

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.
Files changed (81) hide show
  1. package/README.md +9 -12
  2. package/dist/ccxt.browser.min.js +3 -3
  3. package/dist/cjs/ccxt.js +1 -12
  4. package/dist/cjs/src/abstract/kucoinfutures.js +1 -1
  5. package/dist/cjs/src/base/Exchange.js +36 -3
  6. package/dist/cjs/src/base/functions/encode.js +2 -2
  7. package/dist/cjs/src/base/functions/generic.js +8 -2
  8. package/dist/cjs/src/bitrue.js +1 -1
  9. package/dist/cjs/src/bitteam.js +1 -1
  10. package/dist/cjs/src/btcbox.js +1 -1
  11. package/dist/cjs/src/cex.js +1 -0
  12. package/dist/cjs/src/gate.js +227 -168
  13. package/dist/cjs/src/grvt.js +3 -2
  14. package/dist/cjs/src/hyperliquid.js +16 -5
  15. package/dist/cjs/src/kraken.js +2 -2
  16. package/dist/cjs/src/krakenfutures.js +1 -5
  17. package/dist/cjs/src/kucoin.js +4729 -970
  18. package/dist/cjs/src/kucoinfutures.js +14 -3434
  19. package/dist/cjs/src/lbank.js +1 -1
  20. package/dist/cjs/src/poloniex.js +1 -1
  21. package/dist/cjs/src/pro/gate.js +37 -1
  22. package/dist/cjs/src/pro/kucoin.js +819 -178
  23. package/dist/cjs/src/pro/kucoinfutures.js +95 -1261
  24. package/dist/cjs/src/pro/mexc.js +10 -5
  25. package/dist/cjs/src/pro/okx.js +84 -39
  26. package/js/ccxt.d.ts +2 -14
  27. package/js/ccxt.js +2 -10
  28. package/js/src/abstract/kucoin.d.ts +46 -3
  29. package/js/src/abstract/kucoinfutures.d.ts +27 -12
  30. package/js/src/base/Exchange.d.ts +12 -1
  31. package/js/src/base/Exchange.js +36 -3
  32. package/js/src/base/functions/encode.js +2 -2
  33. package/js/src/base/functions/generic.js +9 -3
  34. package/js/src/bitrue.js +1 -1
  35. package/js/src/bitteam.js +1 -1
  36. package/js/src/btcbox.js +1 -1
  37. package/js/src/cex.js +2 -1
  38. package/js/src/gate.d.ts +125 -119
  39. package/js/src/gate.js +227 -168
  40. package/js/src/grvt.js +3 -2
  41. package/js/src/hyperliquid.d.ts +3 -1
  42. package/js/src/hyperliquid.js +16 -5
  43. package/js/src/kraken.js +2 -2
  44. package/js/src/krakenfutures.js +1 -5
  45. package/js/src/kucoin.d.ts +696 -100
  46. package/js/src/kucoin.js +4730 -971
  47. package/js/src/kucoinfutures.d.ts +4 -522
  48. package/js/src/kucoinfutures.js +14 -3434
  49. package/js/src/lbank.js +1 -1
  50. package/js/src/poloniex.js +1 -1
  51. package/js/src/pro/gate.d.ts +30 -1
  52. package/js/src/pro/gate.js +37 -1
  53. package/js/src/pro/kucoin.d.ts +70 -30
  54. package/js/src/pro/kucoin.js +821 -180
  55. package/js/src/pro/kucoinfutures.d.ts +17 -195
  56. package/js/src/pro/kucoinfutures.js +96 -1262
  57. package/js/src/pro/mexc.js +10 -5
  58. package/js/src/pro/okx.d.ts +1 -0
  59. package/js/src/pro/okx.js +84 -39
  60. package/package.json +1 -1
  61. package/dist/cjs/src/abstract/alp.js +0 -11
  62. package/dist/cjs/src/abstract/defx.js +0 -11
  63. package/dist/cjs/src/abstract/timex.js +0 -11
  64. package/dist/cjs/src/alp.js +0 -1059
  65. package/dist/cjs/src/defx.js +0 -2142
  66. package/dist/cjs/src/pro/defx.js +0 -866
  67. package/dist/cjs/src/timex.js +0 -1793
  68. package/js/src/abstract/alp.d.ts +0 -21
  69. package/js/src/abstract/alp.js +0 -5
  70. package/js/src/abstract/defx.d.ts +0 -72
  71. package/js/src/abstract/defx.js +0 -5
  72. package/js/src/abstract/timex.d.ts +0 -65
  73. package/js/src/abstract/timex.js +0 -5
  74. package/js/src/alp.d.ts +0 -209
  75. package/js/src/alp.js +0 -1052
  76. package/js/src/defx.d.ts +0 -348
  77. package/js/src/defx.js +0 -2135
  78. package/js/src/pro/defx.d.ts +0 -236
  79. package/js/src/pro/defx.js +0 -859
  80. package/js/src/timex.d.ts +0 -247
  81. package/js/src/timex.js +0 -1786
@@ -1,1793 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var timex$1 = require('./abstract/timex.js');
6
- var errors = require('./base/errors.js');
7
- var Precise = require('./base/Precise.js');
8
- var number = require('./base/functions/number.js');
9
-
10
- /**
11
- * @class timex
12
- * @augments Exchange
13
- */
14
- class timex extends timex$1["default"] {
15
- describe() {
16
- return this.deepExtend(super.describe(), {
17
- 'id': 'timex',
18
- 'name': 'TimeX',
19
- 'countries': ['AU'],
20
- 'version': 'v1',
21
- 'rateLimit': 1500,
22
- 'has': {
23
- 'CORS': undefined,
24
- 'spot': true,
25
- 'margin': false,
26
- 'swap': false,
27
- 'future': false,
28
- 'option': false,
29
- 'addMargin': false,
30
- 'borrowCrossMargin': false,
31
- 'borrowIsolatedMargin': false,
32
- 'borrowMargin': false,
33
- 'cancelOrder': true,
34
- 'cancelOrders': true,
35
- 'closeAllPositions': false,
36
- 'closePosition': false,
37
- 'createOrder': true,
38
- 'createReduceOnlyOrder': false,
39
- 'createStopLimitOrder': false,
40
- 'createStopMarketOrder': false,
41
- 'createStopOrder': false,
42
- 'editOrder': true,
43
- 'fetchAllGreeks': false,
44
- 'fetchBalance': true,
45
- 'fetchBorrowInterest': false,
46
- 'fetchBorrowRate': false,
47
- 'fetchBorrowRateHistories': false,
48
- 'fetchBorrowRateHistory': false,
49
- 'fetchBorrowRates': false,
50
- 'fetchBorrowRatesPerSymbol': false,
51
- 'fetchClosedOrders': true,
52
- 'fetchCrossBorrowRate': false,
53
- 'fetchCrossBorrowRates': false,
54
- 'fetchCurrencies': true,
55
- 'fetchDeposit': false,
56
- 'fetchDepositAddress': true,
57
- 'fetchDepositAddresses': false,
58
- 'fetchDepositAddressesByNetwork': false,
59
- 'fetchDeposits': true,
60
- 'fetchFundingHistory': false,
61
- 'fetchFundingInterval': false,
62
- 'fetchFundingIntervals': false,
63
- 'fetchFundingRate': false,
64
- 'fetchFundingRateHistory': false,
65
- 'fetchFundingRates': false,
66
- 'fetchGreeks': false,
67
- 'fetchIndexOHLCV': false,
68
- 'fetchIsolatedBorrowRate': false,
69
- 'fetchIsolatedBorrowRates': false,
70
- 'fetchIsolatedPositions': false,
71
- 'fetchLeverage': false,
72
- 'fetchLeverages': false,
73
- 'fetchLeverageTiers': false,
74
- 'fetchLiquidations': false,
75
- 'fetchLongShortRatio': false,
76
- 'fetchLongShortRatioHistory': false,
77
- 'fetchMarginAdjustmentHistory': false,
78
- 'fetchMarginMode': false,
79
- 'fetchMarginModes': false,
80
- 'fetchMarketLeverageTiers': false,
81
- 'fetchMarkets': true,
82
- 'fetchMarkOHLCV': false,
83
- 'fetchMarkPrice': false,
84
- 'fetchMarkPrices': false,
85
- 'fetchMyLiquidations': false,
86
- 'fetchMySettlementHistory': false,
87
- 'fetchMyTrades': true,
88
- 'fetchOHLCV': true,
89
- 'fetchOpenInterest': false,
90
- 'fetchOpenInterestHistory': false,
91
- 'fetchOpenInterests': false,
92
- 'fetchOpenOrders': true,
93
- 'fetchOption': false,
94
- 'fetchOptionChain': false,
95
- 'fetchOrder': true,
96
- 'fetchOrderBook': true,
97
- 'fetchPosition': false,
98
- 'fetchPositionHistory': false,
99
- 'fetchPositionMode': false,
100
- 'fetchPositions': false,
101
- 'fetchPositionsForSymbol': false,
102
- 'fetchPositionsHistory': false,
103
- 'fetchPositionsRisk': false,
104
- 'fetchPremiumIndexOHLCV': false,
105
- 'fetchSettlementHistory': false,
106
- 'fetchTicker': true,
107
- 'fetchTickers': true,
108
- 'fetchTime': true,
109
- 'fetchTrades': true,
110
- 'fetchTradingFee': true,
111
- 'fetchUnderlyingAssets': false,
112
- 'fetchVolatilityHistory': false,
113
- 'fetchWithdrawal': false,
114
- 'fetchWithdrawals': true,
115
- 'reduceMargin': false,
116
- 'repayCrossMargin': false,
117
- 'repayIsolatedMargin': false,
118
- 'setLeverage': false,
119
- 'setMargin': false,
120
- 'setMarginMode': false,
121
- 'setPositionMode': false,
122
- },
123
- 'timeframes': {
124
- '1m': 'I1',
125
- '5m': 'I5',
126
- '15m': 'I15',
127
- '30m': 'I30',
128
- '1h': 'H1',
129
- '2h': 'H2',
130
- '4h': 'H4',
131
- '6h': 'H6',
132
- '12h': 'H12',
133
- '1d': 'D1',
134
- '1w': 'W1',
135
- },
136
- 'urls': {
137
- 'logo': 'https://user-images.githubusercontent.com/1294454/70423869-6839ab00-1a7f-11ea-8f94-13ae72c31115.jpg',
138
- 'api': {
139
- 'rest': 'https://plasma-relay-backend.timex.io',
140
- },
141
- 'www': 'https://timex.io',
142
- 'doc': 'https://plasma-relay-backend.timex.io/swagger-ui/index.html',
143
- 'referral': 'https://timex.io/?refcode=1x27vNkTbP1uwkCck',
144
- },
145
- 'api': {
146
- 'addressbook': {
147
- 'get': [
148
- 'me',
149
- ],
150
- 'post': [
151
- '',
152
- 'id/{id}',
153
- 'id/{id}/remove',
154
- ],
155
- },
156
- 'custody': {
157
- 'get': [
158
- 'credentials',
159
- 'credentials/h/{hash}',
160
- 'credentials/k/{key}',
161
- 'credentials/me',
162
- 'credentials/me/address',
163
- 'deposit-addresses',
164
- 'deposit-addresses/h/{hash}', // Get deposit address by hash
165
- ],
166
- },
167
- 'history': {
168
- 'get': [
169
- 'orders',
170
- 'orders/details',
171
- 'orders/export/csv',
172
- 'trades',
173
- 'trades/export/csv', // Export trades to csv
174
- ],
175
- },
176
- 'currencies': {
177
- 'get': [
178
- 'a/{address}',
179
- 'i/{id}',
180
- 's/{symbol}', // Gets currency by symbol
181
- ],
182
- 'post': [
183
- 'perform',
184
- 'prepare',
185
- 'remove/perform',
186
- 's/{symbol}/remove/prepare',
187
- 's/{symbol}/update/perform',
188
- 's/{symbol}/update/prepare', // Prepare update currency by symbol
189
- ],
190
- },
191
- 'manager': {
192
- 'get': [
193
- 'deposits',
194
- 'transfers',
195
- 'withdrawals',
196
- ],
197
- },
198
- 'markets': {
199
- 'get': [
200
- 'i/{id}',
201
- 's/{symbol}', // Gets market by symbol
202
- ],
203
- 'post': [
204
- 'perform',
205
- 'prepare',
206
- 'remove/perform',
207
- 's/{symbol}/remove/prepare',
208
- 's/{symbol}/update/perform',
209
- 's/{symbol}/update/prepare', // Prepare update market by symbol
210
- ],
211
- },
212
- 'public': {
213
- 'get': [
214
- 'candles',
215
- 'currencies',
216
- 'markets',
217
- 'orderbook',
218
- 'orderbook/raw',
219
- 'orderbook/v2',
220
- 'tickers',
221
- 'trades', // Gets trades
222
- ],
223
- },
224
- 'statistics': {
225
- 'get': [
226
- 'address', // calculateAddressStatistics
227
- ],
228
- },
229
- 'trading': {
230
- 'get': [
231
- 'balances',
232
- 'fees',
233
- 'orders', // Gets open orders
234
- ],
235
- 'post': [
236
- 'orders',
237
- 'orders/json', // Create orders
238
- ],
239
- 'put': [
240
- 'orders',
241
- 'orders/json', // Update orders
242
- ],
243
- 'delete': [
244
- 'orders',
245
- 'orders/json', // Delete orders
246
- ],
247
- },
248
- 'tradingview': {
249
- 'get': [
250
- 'config',
251
- 'history',
252
- 'symbol_info',
253
- 'time', // Gets time
254
- ],
255
- },
256
- },
257
- 'precisionMode': number.TICK_SIZE,
258
- 'exceptions': {
259
- 'exact': {
260
- '0': errors.ExchangeError,
261
- '1': errors.NotSupported,
262
- '4000': errors.BadRequest,
263
- '4001': errors.BadRequest,
264
- '4002': errors.InsufficientFunds,
265
- '4003': errors.AuthenticationError,
266
- '4004': errors.AuthenticationError,
267
- '4005': errors.BadRequest,
268
- '4006': errors.BadRequest,
269
- '4007': errors.BadRequest,
270
- '4300': errors.PermissionDenied,
271
- '4100': errors.AuthenticationError,
272
- '4400': errors.OrderNotFound,
273
- '5001': errors.InvalidOrder,
274
- '5002': errors.ExchangeError,
275
- '400': errors.BadRequest,
276
- '401': errors.AuthenticationError,
277
- '403': errors.PermissionDenied,
278
- '404': errors.OrderNotFound,
279
- '429': errors.RateLimitExceeded,
280
- '500': errors.ExchangeError,
281
- '503': errors.ExchangeNotAvailable,
282
- },
283
- 'broad': {
284
- 'Insufficient': errors.InsufficientFunds,
285
- },
286
- },
287
- 'options': {
288
- 'expireIn': 31536000,
289
- 'fetchTickers': {
290
- 'period': '1d',
291
- },
292
- 'fetchTrades': {
293
- 'sort': 'timestamp,asc',
294
- },
295
- 'fetchMyTrades': {
296
- 'sort': 'timestamp,asc',
297
- },
298
- 'fetchOpenOrders': {
299
- 'sort': 'createdAt,asc',
300
- },
301
- 'fetchClosedOrders': {
302
- 'sort': 'createdAt,asc',
303
- },
304
- 'defaultSort': 'timestamp,asc',
305
- 'defaultSortOrders': 'createdAt,asc',
306
- },
307
- 'features': {
308
- 'spot': {
309
- 'sandbox': false,
310
- 'createOrder': {
311
- 'marginMode': false,
312
- 'triggerPrice': false,
313
- 'triggerDirection': false,
314
- 'triggerPriceType': undefined,
315
- 'stopLossPrice': false,
316
- 'takeProfitPrice': false,
317
- 'attachedStopLossTakeProfit': undefined,
318
- // todo
319
- 'timeInForce': {
320
- 'IOC': true,
321
- 'FOK': true,
322
- 'PO': false,
323
- 'GTD': true,
324
- },
325
- 'hedged': false,
326
- 'trailing': false,
327
- 'leverage': false,
328
- 'marketBuyByCost': false,
329
- 'marketBuyRequiresPrice': false,
330
- 'selfTradePrevention': false,
331
- 'iceberg': false,
332
- },
333
- 'createOrders': undefined,
334
- 'fetchMyTrades': {
335
- 'marginMode': false,
336
- 'limit': 100,
337
- 'daysBack': 100000,
338
- 'untilDays': 100000,
339
- 'symbolRequired': false,
340
- },
341
- 'fetchOrder': {
342
- 'marginMode': false,
343
- 'trigger': false,
344
- 'trailing': false,
345
- 'symbolRequired': false,
346
- },
347
- 'fetchOpenOrders': {
348
- 'marginMode': false,
349
- 'limit': 100,
350
- 'trigger': false,
351
- 'trailing': false,
352
- 'symbolRequired': false,
353
- },
354
- 'fetchOrders': undefined,
355
- 'fetchClosedOrders': {
356
- 'marginMode': false,
357
- 'limit': 100,
358
- 'daysBack': 100000,
359
- 'daysBackCanceled': 1,
360
- 'untilDays': 100000,
361
- 'trigger': false,
362
- 'trailing': false,
363
- 'symbolRequired': false,
364
- },
365
- 'fetchOHLCV': {
366
- 'limit': undefined,
367
- },
368
- },
369
- 'swap': {
370
- 'linear': undefined,
371
- 'inverse': undefined,
372
- },
373
- 'future': {
374
- 'linear': undefined,
375
- 'inverse': undefined,
376
- },
377
- },
378
- });
379
- }
380
- /**
381
- * @method
382
- * @name timex#fetchTime
383
- * @description fetches the current integer timestamp in milliseconds from the exchange server
384
- * @param {object} [params] extra parameters specific to the exchange API endpoint
385
- * @returns {int} the current integer timestamp in milliseconds from the exchange server
386
- */
387
- async fetchTime(params = {}) {
388
- const response = await this.tradingviewGetTime(params);
389
- //
390
- // 1708682617
391
- //
392
- return this.parseToInt(response) * 1000;
393
- }
394
- /**
395
- * @method
396
- * @name timex#fetchMarkets
397
- * @description retrieves data on all markets for timex
398
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/listMarkets
399
- * @param {object} [params] extra parameters specific to the exchange API endpoint
400
- * @returns {object[]} an array of objects representing market data
401
- */
402
- async fetchMarkets(params = {}) {
403
- const response = await this.publicGetMarkets(params);
404
- //
405
- // [
406
- // {
407
- // "symbol": "ETHBTC",
408
- // "name": "ETH/BTC",
409
- // "baseCurrency": "ETH",
410
- // "baseTokenAddress": "0x45932db54b38af1f5a57136302eeba66a5975c15",
411
- // "quoteCurrency": "BTC",
412
- // "quoteTokenAddress": "0x8370fbc6ddec1e18b4e41e72ed943e238458487c",
413
- // "feeCurrency": "BTC",
414
- // "feeTokenAddress": "0x8370fbc6ddec1e18b4e41e72ed943e238458487c",
415
- // "quantityIncrement": "0.0000001",
416
- // "takerFee": "0.005",
417
- // "makerFee": "0.0025",
418
- // "tickSize": "0.00000001",
419
- // "baseMinSize": "0.0001",
420
- // "quoteMinSize": "0.00001",
421
- // "locked": false
422
- // }
423
- // ]
424
- //
425
- return this.parseMarkets(response);
426
- }
427
- /**
428
- * @method
429
- * @name timex#fetchCurrencies
430
- * @description fetches all available currencies on an exchange
431
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/listCurrencies
432
- * @param {object} [params] extra parameters specific to the exchange API endpoint
433
- * @returns {object} an associative dictionary of currencies
434
- */
435
- async fetchCurrencies(params = {}) {
436
- const response = await this.publicGetCurrencies(params);
437
- //
438
- // [
439
- // {
440
- // "symbol": "BTC",
441
- // "name": "Bitcoin",
442
- // "address": "0x8370fbc6ddec1e18b4e41e72ed943e238458487c",
443
- // "icon": "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNjAiIGhlaWdodD0iNjAiIHZpZXdCb3g9IjAgMCA2MCA2MCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggb3BhY2l0eT0iMC41IiBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTMwIDUzQzQyLjcwMjUgNTMgNTMgNDIuNzAyNSA1MyAzMEM1MyAxNy4yOTc1IDQyLjcwMjUgNyAzMCA3QzE3LjI5NzUgNyA3IDE3LjI5NzUgNyAzMEM3IDQyLjcwMjUgMTcuMjk3NSA1MyAzMCA1M1pNMzAgNTVDNDMuODA3MSA1NSA1NSA0My44MDcxIDU1IDMwQzU1IDE2LjE5MjkgNDMuODA3MSA1IDMwIDVDMTYuMTkyOSA1IDUgMTYuMTkyOSA1IDMwQzUgNDMuODA3MSAxNi4xOTI5IDU1IDMwIDU1WiIvPgo8cGF0aCBkPSJNNDAuOTQyNSAyNi42NTg1QzQxLjQwMDMgMjMuNjExMyAzOS4wNzA1IDIxLjk3MzIgMzUuODg0OCAyMC44ODA0TDM2LjkxODIgMTYuNzUyNkwzNC4zOTUxIDE2LjEyNjRMMzMuMzg5IDIwLjE0NTVDMzIuNzI1OCAxOS45ODA5IDMyLjA0NDUgMTkuODI1NiAzMS4zNjc1IDE5LjY3MTdMMzIuMzgwOCAxNS42MjYyTDI5Ljg1OTEgMTVMMjguODI1IDE5LjEyNjRDMjguMjc2IDE5LjAwMTkgMjcuNzM3IDE4Ljg3ODggMjcuMjEzOSAxOC43NDkzTDI3LjIxNjggMTguNzM2NEwyMy43MzcyIDE3Ljg3MTJMMjMuMDY2IDIwLjU1NDhDMjMuMDY2IDIwLjU1NDggMjQuOTM4IDIwLjk4MjEgMjQuODk4NSAyMS4wMDg1QzI1LjkyMDQgMjEuMjYyNiAyNi4xMDUgMjEuOTM2IDI2LjA3NDEgMjIuNDY5OUwyNC44OTcgMjcuMTcyNEMyNC45Njc1IDI3LjE5MDMgMjUuMDU4NyAyNy4yMTYgMjUuMTU5MyAyNy4yNTYxQzI1LjA3NTMgMjcuMjM1NCAyNC45ODU0IDI3LjIxMjQgMjQuODkyNyAyNy4xOTAzTDIzLjI0MjggMzMuNzc3OEMyMy4xMTc3IDM0LjA4NjkgMjIuODAwOCAzNC41NTA2IDIyLjA4NjUgMzQuMzc0NkMyMi4xMTE3IDM0LjQxMTEgMjAuMjUyNiAzMy45MTg3IDIwLjI1MjYgMzMuOTE4N0wxOSAzNi43OTQ5TDIyLjI4MzQgMzcuNjFDMjIuODk0MiAzNy43NjI0IDIzLjQ5MjggMzcuOTIyIDI0LjA4MjEgMzguMDcyM0wyMy4wMzggNDIuMjQ3NEwyNS41NTgyIDQyLjg3MzZMMjYuNTkyMyAzOC43NDI5QzI3LjI4MDcgMzguOTI5IDI3Ljk0OSAzOS4xMDA3IDI4LjYwMyAzOS4yNjI0TDI3LjU3MjUgNDMuMzczOEwzMC4wOTU2IDQ0TDMxLjEzOTcgMzkuODMyOEMzNS40NDIyIDQwLjY0MzYgMzguNjc3NCA0MC4zMTY2IDQwLjAzOTIgMzYuNDQxNEM0MS4xMzY1IDMzLjMyMTIgMzkuOTg0NiAzMS41MjEzIDM3LjcyMDkgMzAuMzQ3N0MzOS4zNjk0IDI5Ljk2OTEgNDAuNjExMiAyOC44ODkyIDQwLjk0MjUgMjYuNjU4NVYyNi42NTg1Wk0zNS4xNzc3IDM0LjcwODhDMzQuMzk4IDM3LjgyOSAyOS4xMjI2IDM2LjE0MjIgMjcuNDEyMiAzNS43MTkzTDI4Ljc5NzcgMzAuMTg4MUMzMC41MDgxIDMwLjYxMzIgMzUuOTkyNiAzMS40NTQ4IDM1LjE3NzcgMzQuNzA4OFpNMzUuOTU4MSAyNi42MTM0QzM1LjI0NjcgMjkuNDUxNyAzMC44NTU5IDI4LjAwOTcgMjkuNDMxNiAyNy42NTYxTDMwLjY4NzcgMjIuNjM5NUMzMi4xMTIgMjIuOTkzIDM2LjY5OSAyMy42NTI4IDM1Ljk1ODEgMjYuNjEzNFoiLz4KPC9zdmc+Cg==",
444
- // "background": "transparent",
445
- // "fiatSymbol": "BTC",
446
- // "decimals": 8,
447
- // "tradeDecimals": 20,
448
- // "displayDecimals": 4,
449
- // "crypto": true,
450
- // "depositEnabled": true,
451
- // "withdrawalEnabled": true,
452
- // "transferEnabled": true,
453
- // "buyEnabled": false,
454
- // "purchaseEnabled": false,
455
- // "redeemEnabled": false,
456
- // "active": true,
457
- // "withdrawalFee": "50000000000000000",
458
- // "purchaseCommissions": []
459
- // },
460
- // ]
461
- //
462
- return this.parseCurrencies(response);
463
- }
464
- /**
465
- * @method
466
- * @name timex#fetchDeposits
467
- * @description fetch all deposits made to an account
468
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Manager/getDeposits
469
- * @param {string} code unified currency code
470
- * @param {int} [since] the earliest time in ms to fetch deposits for
471
- * @param {int} [limit] the maximum number of deposits structures to retrieve
472
- * @param {object} [params] extra parameters specific to the exchange API endpoint
473
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
474
- */
475
- async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
476
- const address = this.safeString(params, 'address');
477
- params = this.omit(params, 'address');
478
- if (address === undefined) {
479
- throw new errors.ArgumentsRequired(this.id + ' fetchDeposits() requires an address parameter');
480
- }
481
- const request = {
482
- 'address': address,
483
- };
484
- const response = await this.managerGetDeposits(this.extend(request, params));
485
- //
486
- // [
487
- // {
488
- // "from": "0x1134cc86b45039cc211c6d1d2e4b3c77f60207ed",
489
- // "timestamp": "2022-01-01T00:00:00Z",
490
- // "to": "0x1134cc86b45039cc211c6d1d2e4b3c77f60207ed",
491
- // "token": "0x6baad3fe5d0fd4be604420e728adbd68d67e119e",
492
- // "transferHash": "0x5464cdff35448314e178b8677ea41e670ea0f2533f4e52bfbd4e4a6cfcdef4c2",
493
- // "value": "100"
494
- // }
495
- // ]
496
- //
497
- const currency = this.safeCurrency(code);
498
- return this.parseTransactions(response, currency, since, limit);
499
- }
500
- /**
501
- * @method
502
- * @name timex#fetchWithdrawals
503
- * @description fetch all withdrawals made to an account
504
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Manager/getWithdraws
505
- * @param {string} code unified currency code
506
- * @param {int} [since] the earliest time in ms to fetch withdrawals for
507
- * @param {int} [limit] the maximum number of transaction structures to retrieve
508
- * @param {object} [params] extra parameters specific to the exchange API endpoint
509
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
510
- */
511
- async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
512
- const address = this.safeString(params, 'address');
513
- params = this.omit(params, 'address');
514
- if (address === undefined) {
515
- throw new errors.ArgumentsRequired(this.id + ' fetchDeposits() requires an address parameter');
516
- }
517
- const request = {
518
- 'address': address,
519
- };
520
- const response = await this.managerGetWithdrawals(this.extend(request, params));
521
- //
522
- // [
523
- // {
524
- // "from": "0x1134cc86b45039cc211c6d1d2e4b3c77f60207ed",
525
- // "timestamp": "2022-01-01T00:00:00Z",
526
- // "to": "0x1134cc86b45039cc211c6d1d2e4b3c77f60207ed",
527
- // "token": "0x6baad3fe5d0fd4be604420e728adbd68d67e119e",
528
- // "transferHash": "0x5464cdff35448314e178b8677ea41e670ea0f2533f4e52bfbd4e4a6cfcdef4c2",
529
- // "value": "100"
530
- // }
531
- // ]
532
- //
533
- const currency = this.safeCurrency(code);
534
- return this.parseTransactions(response, currency, since, limit);
535
- }
536
- getCurrencyByAddress(address) {
537
- const currencies = this.currencies;
538
- for (let i = 0; i < currencies.length; i++) {
539
- const currency = currencies[i];
540
- const info = this.safeValue(currency, 'info', {});
541
- const a = this.safeString(info, 'address');
542
- if (a === address) {
543
- return currency;
544
- }
545
- }
546
- return undefined;
547
- }
548
- parseTransaction(transaction, currency = undefined) {
549
- //
550
- // {
551
- // "from": "0x1134cc86b45039cc211c6d1d2e4b3c77f60207ed",
552
- // "timestamp": "2022-01-01T00:00:00Z",
553
- // "to": "0x1134cc86b45039cc211c6d1d2e4b3c77f60207ed",
554
- // "token": "0x6baad3fe5d0fd4be604420e728adbd68d67e119e",
555
- // "transferHash": "0x5464cdff35448314e178b8677ea41e670ea0f2533f4e52bfbd4e4a6cfcdef4c2",
556
- // "value": "100"
557
- // }
558
- //
559
- const datetime = this.safeString(transaction, 'timestamp');
560
- const currencyAddresss = this.safeString(transaction, 'token', '');
561
- currency = this.getCurrencyByAddress(currencyAddresss);
562
- return {
563
- 'info': transaction,
564
- 'id': this.safeString(transaction, 'transferHash'),
565
- 'txid': this.safeString(transaction, 'txid'),
566
- 'timestamp': this.parse8601(datetime),
567
- 'datetime': datetime,
568
- 'network': undefined,
569
- 'address': undefined,
570
- 'addressTo': this.safeString(transaction, 'to'),
571
- 'addressFrom': this.safeString(transaction, 'from'),
572
- 'tag': undefined,
573
- 'tagTo': undefined,
574
- 'tagFrom': undefined,
575
- 'type': undefined,
576
- 'amount': this.safeNumber(transaction, 'value'),
577
- 'currency': this.safeCurrencyCode(undefined, currency),
578
- 'status': 'ok',
579
- 'updated': undefined,
580
- 'internal': undefined,
581
- 'comment': undefined,
582
- 'fee': undefined,
583
- };
584
- }
585
- /**
586
- * @method
587
- * @name timex#fetchTickers
588
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
589
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/listTickers
590
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
591
- * @param {object} [params] extra parameters specific to the exchange API endpoint
592
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
593
- */
594
- async fetchTickers(symbols = undefined, params = {}) {
595
- await this.loadMarkets();
596
- const period = this.safeString(this.options['fetchTickers'], 'period', '1d');
597
- const request = {
598
- 'period': this.timeframes[period], // I1, I5, I15, I30, H1, H2, H4, H6, H12, D1, W1
599
- };
600
- const response = await this.publicGetTickers(this.extend(request, params));
601
- //
602
- // [
603
- // {
604
- // "ask": 0.017,
605
- // "bid": 0.016,
606
- // "high": 0.019,
607
- // "last": 0.017,
608
- // "low": 0.015,
609
- // "market": "TIME/ETH",
610
- // "open": 0.016,
611
- // "period": "H1",
612
- // "timestamp": "2018-12-14T20:50:36.134Z",
613
- // "volume": 4.57,
614
- // "volumeQuote": 0.07312
615
- // }
616
- // ]
617
- //
618
- return this.parseTickers(response, symbols);
619
- }
620
- /**
621
- * @method
622
- * @name timex#fetchTicker
623
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
624
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/listTickers
625
- * @param {string} symbol unified symbol of the market to fetch the ticker for
626
- * @param {object} [params] extra parameters specific to the exchange API endpoint
627
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
628
- */
629
- async fetchTicker(symbol, params = {}) {
630
- await this.loadMarkets();
631
- const market = this.market(symbol);
632
- const period = this.safeString(this.options['fetchTickers'], 'period', '1d');
633
- const request = {
634
- 'market': market['id'],
635
- 'period': this.timeframes[period], // I1, I5, I15, I30, H1, H2, H4, H6, H12, D1, W1
636
- };
637
- const response = await this.publicGetTickers(this.extend(request, params));
638
- //
639
- // [
640
- // {
641
- // "ask": 0.017,
642
- // "bid": 0.016,
643
- // "high": 0.019,
644
- // "last": 0.017,
645
- // "low": 0.015,
646
- // "market": "TIME/ETH",
647
- // "open": 0.016,
648
- // "period": "H1",
649
- // "timestamp": "2018-12-14T20:50:36.134Z",
650
- // "volume": 4.57,
651
- // "volumeQuote": 0.07312
652
- // }
653
- // ]
654
- //
655
- const ticker = this.safeDict(response, 0);
656
- return this.parseTicker(ticker, market);
657
- }
658
- /**
659
- * @method
660
- * @name timex#fetchOrderBook
661
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
662
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/orderbookV2
663
- * @param {string} symbol unified symbol of the market to fetch the order book for
664
- * @param {int} [limit] the maximum amount of order book entries to return
665
- * @param {object} [params] extra parameters specific to the exchange API endpoint
666
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
667
- */
668
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
669
- await this.loadMarkets();
670
- const market = this.market(symbol);
671
- const request = {
672
- 'market': market['id'],
673
- };
674
- if (limit !== undefined) {
675
- request['limit'] = limit;
676
- }
677
- const response = await this.publicGetOrderbookV2(this.extend(request, params));
678
- //
679
- // {
680
- // "timestamp":"2019-12-05T00:21:09.538",
681
- // "bid":[
682
- // {
683
- // "index":"2",
684
- // "price":"0.02024007",
685
- // "baseTokenAmount":"0.0096894",
686
- // "baseTokenCumulativeAmount":"0.0096894",
687
- // "quoteTokenAmount":"0.000196114134258",
688
- // "quoteTokenCumulativeAmount":"0.000196114134258"
689
- // },
690
- // "ask":[
691
- // {
692
- // "index":"-3",
693
- // "price":"0.02024012",
694
- // "baseTokenAmount":"0.005",
695
- // "baseTokenCumulativeAmount":"0.005",
696
- // "quoteTokenAmount":"0.0001012006",
697
- // "quoteTokenCumulativeAmount":"0.0001012006"
698
- // },
699
- // ]
700
- // }
701
- //
702
- const timestamp = this.parse8601(this.safeString(response, 'timestamp'));
703
- return this.parseOrderBook(response, symbol, timestamp, 'bid', 'ask', 'price', 'baseTokenAmount');
704
- }
705
- /**
706
- * @method
707
- * @name timex#fetchTrades
708
- * @description get the list of most recent trades for a particular symbol
709
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/listTrades
710
- * @param {string} symbol unified symbol of the market to fetch trades for
711
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
712
- * @param {int} [limit] the maximum amount of trades to fetch
713
- * @param {object} [params] extra parameters specific to the exchange API endpoint
714
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
715
- */
716
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
717
- await this.loadMarkets();
718
- const market = this.market(symbol);
719
- const options = this.safeValue(this.options, 'fetchTrades', {});
720
- const defaultSort = this.safeValue(options, 'sort', 'timestamp,asc');
721
- const sort = this.safeString(params, 'sort', defaultSort);
722
- const query = this.omit(params, 'sort');
723
- const request = {
724
- // 'address': 'string', // trade’s member account (?)
725
- // 'cursor': 1234, // int64 (?)
726
- // 'from': this.iso8601 (since),
727
- 'market': market['id'],
728
- // 'page': 0, // results page you want to retrieve 0 .. N
729
- // 'size': limit, // number of records per page, 100 by default
730
- 'sort': sort, // array[string], sorting criteria in the format "property,asc" or "property,desc", default is ascending
731
- // 'till': this.iso8601 (this.milliseconds ()),
732
- };
733
- if (since !== undefined) {
734
- request['from'] = this.iso8601(since);
735
- }
736
- if (limit !== undefined) {
737
- request['size'] = limit; // default is 100
738
- }
739
- const response = await this.publicGetTrades(this.extend(request, query));
740
- //
741
- // [
742
- // {
743
- // "id":1,
744
- // "timestamp":"2019-06-25T17:01:50.309",
745
- // "direction":"BUY",
746
- // "price":"0.027",
747
- // "quantity":"0.001"
748
- // }
749
- // ]
750
- //
751
- return this.parseTrades(response, market, since, limit);
752
- }
753
- /**
754
- * @method
755
- * @name timex#fetchOHLCV
756
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
757
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Public/listCandles
758
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
759
- * @param {string} timeframe the length of time each candle represents
760
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
761
- * @param {int} [limit] the maximum amount of candles to fetch
762
- * @param {object} [params] extra parameters specific to the exchange API endpoint
763
- * @param {int} [params.until] timestamp in ms of the latest candle to fetch
764
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
765
- */
766
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
767
- await this.loadMarkets();
768
- const market = this.market(symbol);
769
- const request = {
770
- 'market': market['id'],
771
- 'period': this.safeString(this.timeframes, timeframe, timeframe),
772
- };
773
- // if since and limit are not specified
774
- const duration = this.parseTimeframe(timeframe);
775
- const until = this.safeInteger(params, 'until');
776
- if (limit === undefined) {
777
- limit = 1000; // exchange provides tens of thousands of data, but we set generous default value
778
- }
779
- if (since !== undefined) {
780
- request['from'] = this.iso8601(since);
781
- if (until === undefined) {
782
- request['till'] = this.iso8601(this.sum(since, this.sum(limit, 1) * duration * 1000));
783
- }
784
- else {
785
- request['till'] = this.iso8601(until);
786
- }
787
- }
788
- else if (until !== undefined) {
789
- request['till'] = this.iso8601(until);
790
- const fromTimestamp = until - this.sum(limit, 1) * duration * 1000;
791
- request['from'] = this.iso8601(fromTimestamp);
792
- }
793
- else {
794
- const now = this.milliseconds();
795
- request['till'] = this.iso8601(now);
796
- request['from'] = this.iso8601(now - this.sum(limit, 1) * duration * 1000 - 1);
797
- }
798
- params = this.omit(params, 'until');
799
- const response = await this.publicGetCandles(this.extend(request, params));
800
- //
801
- // [
802
- // {
803
- // "timestamp":"2019-12-04T23:00:00",
804
- // "open":"0.02024009",
805
- // "high":"0.02024009",
806
- // "low":"0.02024009",
807
- // "close":"0.02024009",
808
- // "volume":"0.00008096036",
809
- // "volumeQuote":"0.004",
810
- // },
811
- // ]
812
- //
813
- return this.parseOHLCVs(response, market, timeframe, since, limit);
814
- }
815
- parseBalance(response) {
816
- const result = {
817
- 'info': response,
818
- 'timestamp': undefined,
819
- 'datetime': undefined,
820
- };
821
- for (let i = 0; i < response.length; i++) {
822
- const balance = response[i];
823
- const currencyId = this.safeString(balance, 'currency');
824
- const code = this.safeCurrencyCode(currencyId);
825
- const account = this.account();
826
- account['total'] = this.safeString(balance, 'totalBalance');
827
- account['used'] = this.safeString(balance, 'lockedBalance');
828
- result[code] = account;
829
- }
830
- return this.safeBalance(result);
831
- }
832
- /**
833
- * @method
834
- * @name timex#fetchBalance
835
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
836
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Trading/getBalances
837
- * @param {object} [params] extra parameters specific to the exchange API endpoint
838
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
839
- */
840
- async fetchBalance(params = {}) {
841
- await this.loadMarkets();
842
- const response = await this.tradingGetBalances(params);
843
- //
844
- // [
845
- // {"currency":"BTC","totalBalance":"0","lockedBalance":"0"},
846
- // {"currency":"AUDT","totalBalance":"0","lockedBalance":"0"},
847
- // {"currency":"ETH","totalBalance":"0","lockedBalance":"0"},
848
- // {"currency":"TIME","totalBalance":"0","lockedBalance":"0"},
849
- // {"currency":"USDT","totalBalance":"0","lockedBalance":"0"}
850
- // ]
851
- //
852
- return this.parseBalance(response);
853
- }
854
- /**
855
- * @method
856
- * @name timex#createOrder
857
- * @description create a trade order
858
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Trading/createOrder
859
- * @param {string} symbol unified symbol of the market to create an order in
860
- * @param {string} type 'market' or 'limit'
861
- * @param {string} side 'buy' or 'sell'
862
- * @param {float} amount how much of currency you want to trade in units of base currency
863
- * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
864
- * @param {object} [params] extra parameters specific to the exchange API endpoint
865
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
866
- */
867
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
868
- await this.loadMarkets();
869
- const market = this.market(symbol);
870
- const uppercaseSide = side.toUpperCase();
871
- let uppercaseType = type.toUpperCase();
872
- const postOnly = this.safeBool(params, 'postOnly', false);
873
- if (postOnly) {
874
- uppercaseType = 'POST_ONLY';
875
- params = this.omit(params, ['postOnly']);
876
- }
877
- const request = {
878
- 'symbol': market['id'],
879
- 'quantity': this.amountToPrecision(symbol, amount),
880
- 'side': uppercaseSide,
881
- 'orderTypes': uppercaseType,
882
- // 'clientOrderId': '123',
883
- // 'expireIn': 1575523308, // in seconds
884
- // 'expireTime': 1575523308, // unix timestamp
885
- };
886
- let query = params;
887
- if ((uppercaseType === 'LIMIT') || (uppercaseType === 'POST_ONLY')) {
888
- request['price'] = this.priceToPrecision(symbol, price);
889
- const defaultExpireIn = this.safeInteger(this.options, 'expireIn');
890
- const expireTime = this.safeValue(params, 'expireTime');
891
- const expireIn = this.safeValue(params, 'expireIn', defaultExpireIn);
892
- if (expireTime !== undefined) {
893
- request['expireTime'] = expireTime;
894
- }
895
- else if (expireIn !== undefined) {
896
- request['expireIn'] = expireIn;
897
- }
898
- else {
899
- throw new errors.InvalidOrder(this.id + ' createOrder() method requires a expireTime or expireIn param for a ' + type + ' order, you can also set the expireIn exchange-wide option');
900
- }
901
- query = this.omit(params, ['expireTime', 'expireIn']);
902
- }
903
- else {
904
- request['price'] = 0;
905
- }
906
- const response = await this.tradingPostOrders(this.extend(request, query));
907
- //
908
- // {
909
- // "orders": [
910
- // {
911
- // "cancelledQuantity": "0.3",
912
- // "clientOrderId": "my-order-1",
913
- // "createdAt": "1970-01-01T00:00:00",
914
- // "cursorId": 50,
915
- // "expireTime": "1970-01-01T00:00:00",
916
- // "filledQuantity": "0.3",
917
- // "id": "string",
918
- // "price": "0.017",
919
- // "quantity": "0.3",
920
- // "side": "BUY",
921
- // "symbol": "TIMEETH",
922
- // "type": "LIMIT",
923
- // "updatedAt": "1970-01-01T00:00:00"
924
- // }
925
- // ]
926
- // }
927
- //
928
- const orders = this.safeValue(response, 'orders', []);
929
- const order = this.safeDict(orders, 0, {});
930
- return this.parseOrder(order, market);
931
- }
932
- async editOrder(id, symbol, type, side, amount = undefined, price = undefined, params = {}) {
933
- await this.loadMarkets();
934
- const market = this.market(symbol);
935
- const request = {
936
- 'id': id,
937
- };
938
- if (amount !== undefined) {
939
- request['quantity'] = this.amountToPrecision(symbol, amount);
940
- }
941
- if (price !== undefined) {
942
- request['price'] = this.priceToPrecision(symbol, price);
943
- }
944
- const response = await this.tradingPutOrders(this.extend(request, params));
945
- //
946
- // {
947
- // "changedOrders": [
948
- // {
949
- // "newOrder": {
950
- // "cancelledQuantity": "0.3",
951
- // "clientOrderId": "my-order-1",
952
- // "createdAt": "1970-01-01T00:00:00",
953
- // "cursorId": 50,
954
- // "expireTime": "1970-01-01T00:00:00",
955
- // "filledQuantity": "0.3",
956
- // "id": "string",
957
- // "price": "0.017",
958
- // "quantity": "0.3",
959
- // "side": "BUY",
960
- // "symbol": "TIMEETH",
961
- // "type": "LIMIT",
962
- // "updatedAt": "1970-01-01T00:00:00"
963
- // },
964
- // "oldId": "string",
965
- // },
966
- // ],
967
- // "unchangedOrders": [ "string" ],
968
- // }
969
- //
970
- if ('unchangedOrders' in response) {
971
- const orderIds = this.safeValue(response, 'unchangedOrders', []);
972
- const orderId = this.safeString(orderIds, 0);
973
- return this.safeOrder({
974
- 'id': orderId,
975
- 'info': response,
976
- });
977
- }
978
- const orders = this.safeValue(response, 'changedOrders', []);
979
- const firstOrder = this.safeValue(orders, 0, {});
980
- const order = this.safeDict(firstOrder, 'newOrder', {});
981
- return this.parseOrder(order, market);
982
- }
983
- /**
984
- * @method
985
- * @name timex#cancelOrder
986
- * @description cancels an open order
987
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Trading/deleteOrders
988
- * @param {string} id order id
989
- * @param {string} symbol not used by timex cancelOrder ()
990
- * @param {object} [params] extra parameters specific to the exchange API endpoint
991
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
992
- */
993
- async cancelOrder(id, symbol = undefined, params = {}) {
994
- await this.loadMarkets();
995
- const orders = await this.cancelOrders([id], symbol, params);
996
- return this.safeDict(orders, 0);
997
- }
998
- /**
999
- * @method
1000
- * @name timex#cancelOrders
1001
- * @description cancel multiple orders
1002
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Trading/deleteOrders
1003
- * @param {string[]} ids order ids
1004
- * @param {string} symbol unified market symbol, default is undefined
1005
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1006
- * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
1007
- */
1008
- async cancelOrders(ids, symbol = undefined, params = {}) {
1009
- await this.loadMarkets();
1010
- const request = {
1011
- 'id': ids,
1012
- };
1013
- const response = await this.tradingDeleteOrders(this.extend(request, params));
1014
- //
1015
- // {
1016
- // "changedOrders": [
1017
- // {
1018
- // "newOrder": {
1019
- // "cancelledQuantity": "0.3",
1020
- // "clientOrderId": "my-order-1",
1021
- // "createdAt": "1970-01-01T00:00:00",
1022
- // "cursorId": 50,
1023
- // "expireTime": "1970-01-01T00:00:00",
1024
- // "filledQuantity": "0.3",
1025
- // "id": "string",
1026
- // "price": "0.017",
1027
- // "quantity": "0.3",
1028
- // "side": "BUY",
1029
- // "symbol": "TIMEETH",
1030
- // "type": "LIMIT",
1031
- // "updatedAt": "1970-01-01T00:00:00"
1032
- // },
1033
- // "oldId": "string",
1034
- // },
1035
- // ],
1036
- // "unchangedOrders": [ "string" ],
1037
- // }
1038
- //
1039
- const changedOrders = this.safeList(response, 'changedOrders', []);
1040
- const unchangedOrders = this.safeList(response, 'unchangedOrders', []);
1041
- const orders = [];
1042
- for (let i = 0; i < changedOrders.length; i++) {
1043
- const newOrder = this.safeDict(changedOrders[i], 'newOrder');
1044
- orders.push(this.parseOrder(newOrder));
1045
- }
1046
- for (let i = 0; i < unchangedOrders.length; i++) {
1047
- orders.push(this.safeOrder({
1048
- 'info': unchangedOrders[i],
1049
- 'id': unchangedOrders[i],
1050
- 'status': 'unchanged',
1051
- }));
1052
- }
1053
- return orders;
1054
- }
1055
- /**
1056
- * @method
1057
- * @name timex#fetchOrder
1058
- * @description fetches information on an order made by the user
1059
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/History/getOrderDetails
1060
- * @param {string} id order id
1061
- * @param {string} symbol not used by timex fetchOrder
1062
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1063
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
1064
- */
1065
- async fetchOrder(id, symbol = undefined, params = {}) {
1066
- await this.loadMarkets();
1067
- const request = {
1068
- 'orderHash': id,
1069
- };
1070
- const response = await this.historyGetOrdersDetails(request);
1071
- //
1072
- // {
1073
- // "order": {
1074
- // "cancelledQuantity": "0.3",
1075
- // "clientOrderId": "my-order-1",
1076
- // "createdAt": "1970-01-01T00:00:00",
1077
- // "cursorId": 50,
1078
- // "expireTime": "1970-01-01T00:00:00",
1079
- // "filledQuantity": "0.3",
1080
- // "id": "string",
1081
- // "price": "0.017",
1082
- // "quantity": "0.3",
1083
- // "side": "BUY",
1084
- // "symbol": "TIMEETH",
1085
- // "type": "LIMIT",
1086
- // "updatedAt": "1970-01-01T00:00:00"
1087
- // },
1088
- // "trades": [
1089
- // {
1090
- // "fee": "0.3",
1091
- // "id": 100,
1092
- // "makerOrTaker": "MAKER",
1093
- // "makerOrderId": "string",
1094
- // "price": "0.017",
1095
- // "quantity": "0.3",
1096
- // "side": "BUY",
1097
- // "symbol": "TIMEETH",
1098
- // "takerOrderId": "string",
1099
- // "timestamp": "2019-12-05T07:48:26.310Z"
1100
- // }
1101
- // ]
1102
- // }
1103
- //
1104
- const order = this.safeValue(response, 'order', {});
1105
- const trades = this.safeList(response, 'trades', []);
1106
- return this.parseOrder(this.extend(order, { 'trades': trades }));
1107
- }
1108
- /**
1109
- * @method
1110
- * @name timex#fetchOpenOrders
1111
- * @description fetch all unfilled currently open orders
1112
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Trading/getOpenOrders
1113
- * @param {string} symbol unified market symbol
1114
- * @param {int} [since] the earliest time in ms to fetch open orders for
1115
- * @param {int} [limit] the maximum number of open orders structures to retrieve
1116
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1117
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
1118
- */
1119
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1120
- await this.loadMarkets();
1121
- const options = this.safeValue(this.options, 'fetchOpenOrders', {});
1122
- const defaultSort = this.safeValue(options, 'sort', 'createdAt,asc');
1123
- const sort = this.safeString(params, 'sort', defaultSort);
1124
- const query = this.omit(params, 'sort');
1125
- const request = {
1126
- // 'clientOrderId': '123', // order’s client id list for filter
1127
- // page: 0, // results page you want to retrieve (0 .. N)
1128
- 'sort': sort, // sorting criteria in the format "property,asc" or "property,desc", default order is ascending, multiple sort criteria are supported
1129
- };
1130
- let market = undefined;
1131
- if (symbol !== undefined) {
1132
- market = this.market(symbol);
1133
- request['symbol'] = market['id'];
1134
- }
1135
- if (limit !== undefined) {
1136
- request['size'] = limit;
1137
- }
1138
- const response = await this.tradingGetOrders(this.extend(request, query));
1139
- //
1140
- // {
1141
- // "orders": [
1142
- // {
1143
- // "cancelledQuantity": "0.3",
1144
- // "clientOrderId": "my-order-1",
1145
- // "createdAt": "1970-01-01T00:00:00",
1146
- // "cursorId": 50,
1147
- // "expireTime": "1970-01-01T00:00:00",
1148
- // "filledQuantity": "0.3",
1149
- // "id": "string",
1150
- // "price": "0.017",
1151
- // "quantity": "0.3",
1152
- // "side": "BUY",
1153
- // "symbol": "TIMEETH",
1154
- // "type": "LIMIT",
1155
- // "updatedAt": "1970-01-01T00:00:00"
1156
- // }
1157
- // ]
1158
- // }
1159
- //
1160
- const orders = this.safeList(response, 'orders', []);
1161
- return this.parseOrders(orders, market, since, limit);
1162
- }
1163
- /**
1164
- * @method
1165
- * @name timex#fetchClosedOrders
1166
- * @description fetches information on multiple closed orders made by the user
1167
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/History/getOrders
1168
- * @param {string} symbol unified market symbol of the market orders were made in
1169
- * @param {int} [since] the earliest time in ms to fetch orders for
1170
- * @param {int} [limit] the maximum number of order structures to retrieve
1171
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1172
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
1173
- */
1174
- async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1175
- await this.loadMarkets();
1176
- const options = this.safeValue(this.options, 'fetchClosedOrders', {});
1177
- const defaultSort = this.safeValue(options, 'sort', 'createdAt,asc');
1178
- const sort = this.safeString(params, 'sort', defaultSort);
1179
- const query = this.omit(params, 'sort');
1180
- const request = {
1181
- // 'clientOrderId': '123', // order’s client id list for filter
1182
- // page: 0, // results page you want to retrieve (0 .. N)
1183
- 'sort': sort,
1184
- 'side': 'BUY', // or 'SELL'
1185
- // 'till': this.iso8601 (this.milliseconds ()),
1186
- };
1187
- let market = undefined;
1188
- if (symbol !== undefined) {
1189
- market = this.market(symbol);
1190
- request['symbol'] = market['id'];
1191
- }
1192
- if (since !== undefined) {
1193
- request['from'] = this.iso8601(since);
1194
- }
1195
- if (limit !== undefined) {
1196
- request['size'] = limit;
1197
- }
1198
- const response = await this.historyGetOrders(this.extend(request, query));
1199
- //
1200
- // {
1201
- // "orders": [
1202
- // {
1203
- // "cancelledQuantity": "0.3",
1204
- // "clientOrderId": "my-order-1",
1205
- // "createdAt": "1970-01-01T00:00:00",
1206
- // "cursorId": 50,
1207
- // "expireTime": "1970-01-01T00:00:00",
1208
- // "filledQuantity": "0.3",
1209
- // "id": "string",
1210
- // "price": "0.017",
1211
- // "quantity": "0.3",
1212
- // "side": "BUY",
1213
- // "symbol": "TIMEETH",
1214
- // "type": "LIMIT",
1215
- // "updatedAt": "1970-01-01T00:00:00"
1216
- // }
1217
- // ]
1218
- // }
1219
- //
1220
- const orders = this.safeList(response, 'orders', []);
1221
- return this.parseOrders(orders, market, since, limit);
1222
- }
1223
- /**
1224
- * @method
1225
- * @name timex#fetchMyTrades
1226
- * @description fetch all trades made by the user
1227
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/History/getTrades_1
1228
- * @param {string} symbol unified market symbol
1229
- * @param {int} [since] the earliest time in ms to fetch trades for
1230
- * @param {int} [limit] the maximum number of trades structures to retrieve
1231
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1232
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
1233
- */
1234
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1235
- await this.loadMarkets();
1236
- const options = this.safeValue(this.options, 'fetchMyTrades', {});
1237
- const defaultSort = this.safeValue(options, 'sort', 'timestamp,asc');
1238
- const sort = this.safeString(params, 'sort', defaultSort);
1239
- const query = this.omit(params, 'sort');
1240
- const request = {
1241
- // 'cursorId': 123, // int64 (?)
1242
- // 'from': this.iso8601 (since),
1243
- // 'makerOrderId': '1234', // maker order hash
1244
- // 'owner': '...', // owner address (?)
1245
- // 'page': 0, // results page you want to retrieve (0 .. N)
1246
- // 'side': 'BUY', // or 'SELL'
1247
- // 'size': limit,
1248
- 'sort': sort, // sorting criteria in the format "property,asc" or "property,desc", default order is ascending, multiple sort criteria are supported
1249
- // 'symbol': market['id'],
1250
- // 'takerOrderId': '1234',
1251
- // 'till': this.iso8601 (this.milliseconds ()),
1252
- };
1253
- let market = undefined;
1254
- if (symbol !== undefined) {
1255
- market = this.market(symbol);
1256
- request['symbol'] = market['id'];
1257
- }
1258
- if (since !== undefined) {
1259
- request['from'] = this.iso8601(since);
1260
- }
1261
- if (limit !== undefined) {
1262
- request['size'] = limit;
1263
- }
1264
- const response = await this.historyGetTrades(this.extend(request, query));
1265
- //
1266
- // {
1267
- // "trades": [
1268
- // {
1269
- // "fee": "0.3",
1270
- // "id": 100,
1271
- // "makerOrTaker": "MAKER",
1272
- // "makerOrderId": "string",
1273
- // "price": "0.017",
1274
- // "quantity": "0.3",
1275
- // "side": "BUY",
1276
- // "symbol": "TIMEETH",
1277
- // "takerOrderId": "string",
1278
- // "timestamp": "2019-12-08T04:54:11.171Z"
1279
- // }
1280
- // ]
1281
- // }
1282
- //
1283
- const trades = this.safeList(response, 'trades', []);
1284
- return this.parseTrades(trades, market, since, limit);
1285
- }
1286
- parseTradingFee(fee, market = undefined) {
1287
- //
1288
- // {
1289
- // "fee": 0.0075,
1290
- // "market": "ETHBTC"
1291
- // }
1292
- //
1293
- const marketId = this.safeString(fee, 'market');
1294
- const rate = this.safeNumber(fee, 'fee');
1295
- return {
1296
- 'info': fee,
1297
- 'symbol': this.safeSymbol(marketId, market),
1298
- 'maker': rate,
1299
- 'taker': rate,
1300
- 'percentage': undefined,
1301
- 'tierBased': undefined,
1302
- };
1303
- }
1304
- /**
1305
- * @method
1306
- * @name timex#fetchTradingFee
1307
- * @description fetch the trading fees for a market
1308
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Trading/getFees
1309
- * @param {string} symbol unified market symbol
1310
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1311
- * @returns {object} a [fee structure]{@link https://docs.ccxt.com/?id=fee-structure}
1312
- */
1313
- async fetchTradingFee(symbol, params = {}) {
1314
- await this.loadMarkets();
1315
- const market = this.market(symbol);
1316
- const request = {
1317
- 'markets': market['id'],
1318
- };
1319
- const response = await this.tradingGetFees(this.extend(request, params));
1320
- //
1321
- // [
1322
- // {
1323
- // "fee": 0.0075,
1324
- // "market": "ETHBTC"
1325
- // }
1326
- // ]
1327
- //
1328
- const result = this.safeValue(response, 0, {});
1329
- return this.parseTradingFee(result, market);
1330
- }
1331
- parseMarket(market) {
1332
- //
1333
- // {
1334
- // "symbol": "ETHBTC",
1335
- // "name": "ETH/BTC",
1336
- // "baseCurrency": "ETH",
1337
- // "baseTokenAddress": "0x45932db54b38af1f5a57136302eeba66a5975c15",
1338
- // "quoteCurrency": "BTC",
1339
- // "quoteTokenAddress": "0x8370fbc6ddec1e18b4e41e72ed943e238458487c",
1340
- // "feeCurrency": "BTC",
1341
- // "feeTokenAddress": "0x8370fbc6ddec1e18b4e41e72ed943e238458487c",
1342
- // "quantityIncrement": "0.0000001",
1343
- // "takerFee": "0.005",
1344
- // "makerFee": "0.0025",
1345
- // "tickSize": "0.00000001",
1346
- // "baseMinSize": "0.0001",
1347
- // "quoteMinSize": "0.00001",
1348
- // "locked": false
1349
- // }
1350
- //
1351
- const locked = this.safeValue(market, 'locked');
1352
- const id = this.safeString(market, 'symbol');
1353
- const baseId = this.safeString(market, 'baseCurrency');
1354
- const quoteId = this.safeString(market, 'quoteCurrency');
1355
- const base = this.safeCurrencyCode(baseId);
1356
- const quote = this.safeCurrencyCode(quoteId);
1357
- const amountIncrement = this.safeString(market, 'quantityIncrement');
1358
- const minBase = this.safeString(market, 'baseMinSize');
1359
- const minAmount = Precise["default"].stringMax(amountIncrement, minBase);
1360
- const priceIncrement = this.safeString(market, 'tickSize');
1361
- const minCost = this.safeNumber(market, 'quoteMinSize');
1362
- return {
1363
- 'id': id,
1364
- 'symbol': base + '/' + quote,
1365
- 'base': base,
1366
- 'quote': quote,
1367
- 'settle': undefined,
1368
- 'baseId': baseId,
1369
- 'quoteId': quoteId,
1370
- 'settleId': undefined,
1371
- 'type': 'spot',
1372
- 'spot': true,
1373
- 'margin': false,
1374
- 'swap': false,
1375
- 'future': false,
1376
- 'option': false,
1377
- 'active': !locked,
1378
- 'contract': false,
1379
- 'linear': undefined,
1380
- 'inverse': undefined,
1381
- 'taker': this.safeNumber(market, 'takerFee'),
1382
- 'maker': this.safeNumber(market, 'makerFee'),
1383
- 'contractSize': undefined,
1384
- 'expiry': undefined,
1385
- 'expiryDatetime': undefined,
1386
- 'strike': undefined,
1387
- 'optionType': undefined,
1388
- 'precision': {
1389
- 'amount': this.safeNumber(market, 'quantityIncrement'),
1390
- 'price': this.safeNumber(market, 'tickSize'),
1391
- },
1392
- 'limits': {
1393
- 'leverage': {
1394
- 'min': undefined,
1395
- 'max': undefined,
1396
- },
1397
- 'amount': {
1398
- 'min': this.parseNumber(minAmount),
1399
- 'max': undefined,
1400
- },
1401
- 'price': {
1402
- 'min': this.parseNumber(priceIncrement),
1403
- 'max': undefined,
1404
- },
1405
- 'cost': {
1406
- 'min': minCost,
1407
- 'max': undefined,
1408
- },
1409
- },
1410
- 'created': undefined,
1411
- 'info': market,
1412
- };
1413
- }
1414
- parseCurrency(currency) {
1415
- //
1416
- // {
1417
- // "symbol": "BTC",
1418
- // "name": "Bitcoin",
1419
- // "address": "0x8370fbc6ddec1e18b4e41e72ed943e238458487c",
1420
- // "icon": "data:image/svg+xml;base64,PHN2ZyB3aWR...mc+Cg==",
1421
- // "background": "transparent",
1422
- // "fiatSymbol": "BTC",
1423
- // "decimals": 8,
1424
- // "tradeDecimals": 20,
1425
- // "displayDecimals": 4,
1426
- // "crypto": true,
1427
- // "depositEnabled": true,
1428
- // "withdrawalEnabled": true,
1429
- // "transferEnabled": true,
1430
- // "buyEnabled": false,
1431
- // "purchaseEnabled": false,
1432
- // "redeemEnabled": false,
1433
- // "active": true,
1434
- // "withdrawalFee": "50000000000000000",
1435
- // "purchaseCommissions": []
1436
- // }
1437
- //
1438
- // https://github.com/ccxt/ccxt/issues/6878
1439
- //
1440
- // {
1441
- // "symbol":"XRP",
1442
- // "name":"Ripple",
1443
- // "address":"0x0dc8882914f3ddeebf4cec6dc20edb99df3def6c",
1444
- // "decimals":6,
1445
- // "tradeDecimals":16,
1446
- // "depositEnabled":true,
1447
- // "withdrawalEnabled":true,
1448
- // "transferEnabled":true,
1449
- // "active":true
1450
- // }
1451
- //
1452
- const id = this.safeString(currency, 'symbol');
1453
- const code = this.safeCurrencyCode(id);
1454
- // const fee = this.safeNumber (currency, 'withdrawalFee');
1455
- const feeString = this.safeString(currency, 'withdrawalFee');
1456
- const tradeDecimals = this.safeInteger(currency, 'tradeDecimals');
1457
- let fee = undefined;
1458
- if ((feeString !== undefined) && (tradeDecimals !== undefined)) {
1459
- const feeStringLen = feeString.length;
1460
- const dotIndex = feeStringLen - tradeDecimals;
1461
- if (dotIndex > 0) {
1462
- const whole = feeString.slice(0, dotIndex);
1463
- const fraction = feeString.slice(-dotIndex);
1464
- fee = this.parseNumber(whole + '.' + fraction);
1465
- }
1466
- else {
1467
- let fraction = '.';
1468
- for (let i = 0; i < -dotIndex; i++) {
1469
- fraction += '0';
1470
- }
1471
- fee = this.parseNumber(fraction + feeString);
1472
- }
1473
- }
1474
- return this.safeCurrencyStructure({
1475
- 'id': code,
1476
- 'code': code,
1477
- 'info': currency,
1478
- 'type': undefined,
1479
- 'name': this.safeString(currency, 'name'),
1480
- 'active': this.safeBool(currency, 'active'),
1481
- 'deposit': this.safeBool(currency, 'depositEnabled'),
1482
- 'withdraw': this.safeBool(currency, 'withdrawalEnabled'),
1483
- 'fee': fee,
1484
- 'precision': this.parseNumber(this.parsePrecision(this.safeString(currency, 'decimals'))),
1485
- 'limits': {
1486
- 'withdraw': { 'min': undefined, 'max': undefined },
1487
- 'amount': { 'min': undefined, 'max': undefined },
1488
- },
1489
- 'networks': {},
1490
- });
1491
- }
1492
- parseTicker(ticker, market = undefined) {
1493
- //
1494
- // {
1495
- // "ask": 0.017,
1496
- // "bid": 0.016,
1497
- // "high": 0.019,
1498
- // "last": 0.017,
1499
- // "low": 0.015,
1500
- // "market": "TIME/ETH",
1501
- // "open": 0.016,
1502
- // "period": "H1",
1503
- // "timestamp": "2018-12-14T20:50:36.134Z",
1504
- // "volume": 4.57,
1505
- // "volumeQuote": 0.07312
1506
- // }
1507
- //
1508
- const marketId = this.safeString(ticker, 'market');
1509
- const symbol = this.safeSymbol(marketId, market, '/');
1510
- const timestamp = this.parse8601(this.safeString(ticker, 'timestamp'));
1511
- const last = this.safeString(ticker, 'last');
1512
- const open = this.safeString(ticker, 'open');
1513
- return this.safeTicker({
1514
- 'symbol': symbol,
1515
- 'info': ticker,
1516
- 'timestamp': timestamp,
1517
- 'datetime': this.iso8601(timestamp),
1518
- 'high': this.safeString(ticker, 'high'),
1519
- 'low': this.safeString(ticker, 'low'),
1520
- 'bid': this.safeString(ticker, 'bid'),
1521
- 'bidVolume': undefined,
1522
- 'ask': this.safeString(ticker, 'ask'),
1523
- 'askVolume': undefined,
1524
- 'vwap': undefined,
1525
- 'open': open,
1526
- 'close': last,
1527
- 'last': last,
1528
- 'previousClose': undefined,
1529
- 'change': undefined,
1530
- 'percentage': undefined,
1531
- 'average': undefined,
1532
- 'baseVolume': this.safeString(ticker, 'volume'),
1533
- 'quoteVolume': this.safeString(ticker, 'volumeQuote'),
1534
- }, market);
1535
- }
1536
- parseTrade(trade, market = undefined) {
1537
- //
1538
- // fetchTrades (public)
1539
- //
1540
- // {
1541
- // "id":1,
1542
- // "timestamp":"2019-06-25T17:01:50.309",
1543
- // "direction":"BUY",
1544
- // "price":"0.027",
1545
- // "quantity":"0.001"
1546
- // }
1547
- //
1548
- // fetchMyTrades, fetchOrder (private)
1549
- //
1550
- // {
1551
- // "id": "7613414",
1552
- // "makerOrderId": "0x8420af060722f560098f786a2894d4358079b6ea5d14b395969ed77bc87a623a",
1553
- // "takerOrderId": "0x1235ef158a361815b54c9988b6241c85aedcbc1fe81caf8df8587d5ab0373d1a",
1554
- // "symbol": "LTCUSDT",
1555
- // "side": "BUY",
1556
- // "quantity": "0.2",
1557
- // "fee": "0.22685",
1558
- // "feeToken": "USDT",
1559
- // "price": "226.85",
1560
- // "makerOrTaker": "TAKER",
1561
- // "timestamp": "2021-04-09T15:39:45.608"
1562
- // }
1563
- //
1564
- const marketId = this.safeString(trade, 'symbol');
1565
- const symbol = this.safeSymbol(marketId, market);
1566
- const timestamp = this.parse8601(this.safeString(trade, 'timestamp'));
1567
- const priceString = this.safeString(trade, 'price');
1568
- const amountString = this.safeString(trade, 'quantity');
1569
- const price = this.parseNumber(priceString);
1570
- const amount = this.parseNumber(amountString);
1571
- const cost = this.parseNumber(Precise["default"].stringMul(priceString, amountString));
1572
- const id = this.safeString(trade, 'id');
1573
- const side = this.safeStringLower2(trade, 'direction', 'side');
1574
- const takerOrMaker = this.safeStringLower(trade, 'makerOrTaker');
1575
- let orderId = undefined;
1576
- if (takerOrMaker !== undefined) {
1577
- orderId = this.safeString(trade, takerOrMaker + 'OrderId');
1578
- }
1579
- let fee = undefined;
1580
- const feeCost = this.safeNumber(trade, 'fee');
1581
- const feeCurrency = this.safeCurrencyCode(this.safeString(trade, 'feeToken'));
1582
- if (feeCost !== undefined) {
1583
- fee = {
1584
- 'cost': feeCost,
1585
- 'currency': feeCurrency,
1586
- };
1587
- }
1588
- return this.safeTrade({
1589
- 'info': trade,
1590
- 'id': id,
1591
- 'timestamp': timestamp,
1592
- 'datetime': this.iso8601(timestamp),
1593
- 'symbol': symbol,
1594
- 'order': orderId,
1595
- 'type': undefined,
1596
- 'side': side,
1597
- 'price': price,
1598
- 'amount': amount,
1599
- 'cost': cost,
1600
- 'takerOrMaker': takerOrMaker,
1601
- 'fee': fee,
1602
- });
1603
- }
1604
- parseOHLCV(ohlcv, market = undefined) {
1605
- //
1606
- // {
1607
- // "timestamp":"2019-12-04T23:00:00",
1608
- // "open":"0.02024009",
1609
- // "high":"0.02024009",
1610
- // "low":"0.02024009",
1611
- // "close":"0.02024009",
1612
- // "volume":"0.00008096036",
1613
- // "volumeQuote":"0.004",
1614
- // }
1615
- //
1616
- return [
1617
- this.parse8601(this.safeString(ohlcv, 'timestamp')),
1618
- this.safeNumber(ohlcv, 'open'),
1619
- this.safeNumber(ohlcv, 'high'),
1620
- this.safeNumber(ohlcv, 'low'),
1621
- this.safeNumber(ohlcv, 'close'),
1622
- this.safeNumber(ohlcv, 'volume'),
1623
- ];
1624
- }
1625
- parseOrder(order, market = undefined) {
1626
- //
1627
- // fetchOrder, createOrder, cancelOrder, cancelOrders, fetchOpenOrders, fetchClosedOrders
1628
- //
1629
- // {
1630
- // "cancelledQuantity": "0.3",
1631
- // "clientOrderId": "my-order-1",
1632
- // "createdAt": "1970-01-01T00:00:00",
1633
- // "cursorId": 50,
1634
- // "expireTime": "1970-01-01T00:00:00",
1635
- // "filledQuantity": "0.3",
1636
- // "id": "string",
1637
- // "price": "0.017",
1638
- // "quantity": "0.3",
1639
- // "side": "BUY",
1640
- // "symbol": "TIMEETH",
1641
- // "type": "LIMIT",
1642
- // "updatedAt": "1970-01-01T00:00:00"
1643
- // "trades": [], // injected from the outside
1644
- // }
1645
- //
1646
- const id = this.safeString(order, 'id');
1647
- const type = this.safeStringLower(order, 'type');
1648
- const side = this.safeStringLower(order, 'side');
1649
- const marketId = this.safeString(order, 'symbol');
1650
- const symbol = this.safeSymbol(marketId, market);
1651
- const timestamp = this.parse8601(this.safeString(order, 'createdAt'));
1652
- const price = this.safeString(order, 'price');
1653
- const amount = this.safeString(order, 'quantity');
1654
- const filled = this.safeString(order, 'filledQuantity');
1655
- const canceledQuantity = this.omitZero(this.safeString(order, 'cancelledQuantity'));
1656
- let status;
1657
- if (Precise["default"].stringEquals(filled, amount)) {
1658
- status = 'closed';
1659
- }
1660
- else if (canceledQuantity !== undefined) {
1661
- status = 'canceled';
1662
- }
1663
- else {
1664
- status = 'open';
1665
- }
1666
- const rawTrades = this.safeValue(order, 'trades', []);
1667
- const clientOrderId = this.safeString(order, 'clientOrderId');
1668
- return this.safeOrder({
1669
- 'info': order,
1670
- 'id': id,
1671
- 'clientOrderId': clientOrderId,
1672
- 'timestamp': timestamp,
1673
- 'datetime': this.iso8601(timestamp),
1674
- 'lastTradeTimestamp': undefined,
1675
- 'symbol': symbol,
1676
- 'type': type,
1677
- 'timeInForce': undefined,
1678
- 'postOnly': undefined,
1679
- 'side': side,
1680
- 'price': price,
1681
- 'triggerPrice': undefined,
1682
- 'amount': amount,
1683
- 'cost': undefined,
1684
- 'average': undefined,
1685
- 'filled': filled,
1686
- 'remaining': undefined,
1687
- 'status': status,
1688
- 'fee': undefined,
1689
- 'trades': rawTrades,
1690
- }, market);
1691
- }
1692
- /**
1693
- * @method
1694
- * @name timex#fetchDepositAddress
1695
- * @description fetch the deposit address for a currency associated with this account, does not accept params["network"]
1696
- * @see https://plasma-relay-backend.timex.io/swagger-ui/index.html?urls.primaryName=Relay#/Currency/selectCurrencyBySymbol
1697
- * @param {string} code unified currency code
1698
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1699
- * @returns {object} an [address structure]{@link https://docs.ccxt.com/?id=address-structure}
1700
- */
1701
- async fetchDepositAddress(code, params = {}) {
1702
- await this.loadMarkets();
1703
- const currency = this.currency(code);
1704
- const request = {
1705
- 'symbol': currency['code'],
1706
- };
1707
- const response = await this.currenciesGetSSymbol(this.extend(request, params));
1708
- //
1709
- // {
1710
- // id: '1',
1711
- // currency: {
1712
- // symbol: 'BTC',
1713
- // name: 'Bitcoin',
1714
- // address: '0x8370fbc6ddec1e18b4e41e72ed943e238458487c',
1715
- // decimals: '8',
1716
- // tradeDecimals: '20',
1717
- // fiatSymbol: 'BTC',
1718
- // depositEnabled: true,
1719
- // withdrawalEnabled: true,
1720
- // transferEnabled: true,
1721
- // active: true
1722
- // }
1723
- // }
1724
- //
1725
- const data = this.safeDict(response, 'currency', {});
1726
- return this.parseDepositAddress(data, currency);
1727
- }
1728
- parseDepositAddress(depositAddress, currency = undefined) {
1729
- //
1730
- // {
1731
- // symbol: 'BTC',
1732
- // name: 'Bitcoin',
1733
- // address: '0x8370fbc6ddec1e18b4e41e72ed943e238458487c',
1734
- // decimals: '8',
1735
- // tradeDecimals: '20',
1736
- // fiatSymbol: 'BTC',
1737
- // depositEnabled: true,
1738
- // withdrawalEnabled: true,
1739
- // transferEnabled: true,
1740
- // active: true
1741
- // }
1742
- //
1743
- const currencyId = this.safeString(depositAddress, 'symbol');
1744
- return {
1745
- 'info': depositAddress,
1746
- 'currency': this.safeCurrencyCode(currencyId, currency),
1747
- 'network': undefined,
1748
- 'address': this.safeString(depositAddress, 'address'),
1749
- 'tag': undefined,
1750
- };
1751
- }
1752
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1753
- const paramsToExtract = this.extractParams(path);
1754
- path = this.implodeParams(path, params);
1755
- params = this.omit(params, paramsToExtract);
1756
- let url = this.urls['api']['rest'] + '/' + api + '/' + path;
1757
- if (Object.keys(params).length) {
1758
- url += '?' + this.urlencodeWithArrayRepeat(params);
1759
- }
1760
- if (api !== 'public' && api !== 'tradingview') {
1761
- this.checkRequiredCredentials();
1762
- const auth = this.stringToBase64(this.apiKey + ':' + this.secret);
1763
- const secret = 'Basic ' + auth;
1764
- headers = { 'authorization': secret };
1765
- }
1766
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1767
- }
1768
- handleErrors(statusCode, statusText, url, method, responseHeaders, responseBody, response, requestHeaders, requestBody) {
1769
- if (response === undefined) {
1770
- return undefined;
1771
- }
1772
- if (statusCode >= 400) {
1773
- //
1774
- // {"error":{"timestamp":"05.12.2019T05:25:43.584+0000","status":"BAD_REQUEST","message":"Insufficient ETH balance. Required: 1, actual: 0.","code":4001}}
1775
- // {"error":{"timestamp":"05.12.2019T04:03:25.419+0000","status":"FORBIDDEN","message":"Access denied","code":4300}}
1776
- //
1777
- const feedback = this.id + ' ' + responseBody;
1778
- let error = this.safeValue(response, 'error');
1779
- if (error === undefined) {
1780
- error = response;
1781
- }
1782
- const code = this.safeString2(error, 'code', 'status');
1783
- const message = this.safeString2(error, 'message', 'debugMessage');
1784
- this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
1785
- this.throwExactlyMatchedException(this.exceptions['exact'], code, feedback);
1786
- this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
1787
- throw new errors.ExchangeError(feedback);
1788
- }
1789
- return undefined;
1790
- }
1791
- }
1792
-
1793
- exports["default"] = timex;