ccxt 4.5.44 → 4.5.46

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