ccxt 4.5.63 → 4.5.64

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 (124) hide show
  1. package/README.md +6 -8
  2. package/dist/ccxt.browser.min.js +4 -4
  3. package/dist/cjs/ccxt.js +6 -12
  4. package/dist/cjs/src/aster.js +2 -2
  5. package/dist/cjs/src/base/Exchange.js +34 -3
  6. package/dist/cjs/src/bitget.js +5 -3
  7. package/dist/cjs/src/bitmex.js +1 -1
  8. package/dist/cjs/src/bitstamp.js +2 -1
  9. package/dist/cjs/src/bitvavo.js +1 -0
  10. package/dist/cjs/src/btcbox.js +1 -1
  11. package/dist/cjs/src/bullish.js +1 -1
  12. package/dist/cjs/src/bybiteu.js +3 -0
  13. package/dist/cjs/src/coinbase.js +3 -2
  14. package/dist/cjs/src/coinbaseinternational.js +1 -1
  15. package/dist/cjs/src/delta.js +23 -1
  16. package/dist/cjs/src/derive.js +1 -1
  17. package/dist/cjs/src/digifinex.js +12 -0
  18. package/dist/cjs/src/dydx.js +2 -2
  19. package/dist/cjs/src/extended.js +1 -1
  20. package/dist/cjs/src/gateeu.js +1 -0
  21. package/dist/cjs/src/grvt.js +1 -1
  22. package/dist/cjs/src/hashkey.js +127 -6
  23. package/dist/cjs/src/hibachi.js +20 -10
  24. package/dist/cjs/src/hyperliquid.js +1 -1
  25. package/dist/cjs/src/kraken.js +2 -0
  26. package/dist/cjs/src/kucoin.js +1 -1
  27. package/dist/cjs/src/kucoineu.js +3 -0
  28. package/dist/cjs/src/lighter.js +6 -4
  29. package/dist/cjs/src/mudrex.js +1328 -0
  30. package/dist/cjs/src/myokx.js +3 -0
  31. package/dist/cjs/src/okxus.js +1 -5
  32. package/dist/cjs/src/onetrading.js +1 -0
  33. package/dist/cjs/src/pacifica.js +1 -1
  34. package/dist/cjs/src/poloniex.js +1 -1
  35. package/dist/cjs/src/pro/bingx.js +4 -2
  36. package/dist/cjs/src/pro/bitget.js +9 -7
  37. package/dist/cjs/src/pro/grvt.js +1 -1
  38. package/dist/cjs/src/pro/hashkey.js +1 -1
  39. package/dist/cjs/src/pro/kraken.js +1 -1
  40. package/dist/cjs/src/pro/mudrex.js +226 -0
  41. package/dist/cjs/src/pro/okxus.js +1 -1
  42. package/js/ccxt.d.ts +8 -14
  43. package/js/ccxt.js +6 -10
  44. package/js/src/abstract/binance.d.ts +3 -0
  45. package/js/src/abstract/binancecoinm.d.ts +3 -0
  46. package/js/src/abstract/binanceus.d.ts +3 -0
  47. package/js/src/abstract/binanceusdm.d.ts +3 -0
  48. package/js/src/abstract/bybit.d.ts +39 -0
  49. package/js/src/abstract/bybiteu.d.ts +39 -0
  50. package/js/src/abstract/coincheck.d.ts +3 -0
  51. package/js/src/abstract/coinsph.d.ts +8 -1
  52. package/js/src/abstract/kucoineu.js +0 -6
  53. package/js/src/abstract/mudrex.d.ts +33 -0
  54. package/js/src/aster.js +2 -2
  55. package/js/src/base/Exchange.d.ts +10 -1
  56. package/js/src/base/Exchange.js +34 -3
  57. package/js/src/bitget.js +5 -3
  58. package/js/src/bitmex.js +1 -1
  59. package/js/src/bitstamp.js +2 -1
  60. package/js/src/bitvavo.js +1 -0
  61. package/js/src/btcbox.js +1 -1
  62. package/js/src/bullish.js +1 -1
  63. package/js/src/bybiteu.js +3 -0
  64. package/js/src/coinbase.js +3 -2
  65. package/js/src/coinbaseinternational.js +1 -1
  66. package/js/src/delta.d.ts +12 -0
  67. package/js/src/delta.js +23 -1
  68. package/js/src/derive.js +1 -1
  69. package/js/src/digifinex.d.ts +12 -0
  70. package/js/src/digifinex.js +12 -0
  71. package/js/src/dydx.d.ts +2 -2
  72. package/js/src/dydx.js +2 -2
  73. package/js/src/extended.js +1 -1
  74. package/js/src/gateeu.js +1 -0
  75. package/js/src/grvt.d.ts +1 -1
  76. package/js/src/grvt.js +1 -1
  77. package/js/src/hashkey.d.ts +40 -3
  78. package/js/src/hashkey.js +127 -6
  79. package/js/src/hibachi.d.ts +9 -5
  80. package/js/src/hibachi.js +20 -10
  81. package/js/src/hyperliquid.js +1 -1
  82. package/js/src/kraken.js +2 -0
  83. package/js/src/kucoin.js +1 -1
  84. package/js/src/kucoineu.js +3 -0
  85. package/js/src/lighter.js +6 -4
  86. package/js/src/mudrex.d.ts +310 -0
  87. package/js/src/mudrex.js +1321 -0
  88. package/js/src/myokx.js +3 -0
  89. package/js/src/okxus.js +1 -5
  90. package/js/src/onetrading.js +1 -0
  91. package/js/src/pacifica.js +1 -1
  92. package/js/src/poloniex.js +1 -1
  93. package/js/src/pro/bingx.js +4 -2
  94. package/js/src/pro/bitget.js +9 -7
  95. package/js/src/pro/grvt.d.ts +1 -1
  96. package/js/src/pro/grvt.js +1 -1
  97. package/js/src/pro/hashkey.d.ts +1 -1
  98. package/js/src/pro/hashkey.js +1 -1
  99. package/js/src/pro/kraken.js +1 -1
  100. package/js/src/pro/mudrex.d.ts +23 -0
  101. package/js/src/pro/mudrex.js +219 -0
  102. package/js/src/pro/okxus.js +1 -1
  103. package/package.json +3 -3
  104. package/dist/cjs/src/abstract/coinmetro.js +0 -11
  105. package/dist/cjs/src/abstract/novadax.js +0 -11
  106. package/dist/cjs/src/ascendex.js +0 -3780
  107. package/dist/cjs/src/coinmetro.js +0 -2030
  108. package/dist/cjs/src/novadax.js +0 -1678
  109. package/dist/cjs/src/pro/ascendex.js +0 -1013
  110. package/js/src/abstract/ascendex.d.ts +0 -80
  111. package/js/src/abstract/coinmetro.d.ts +0 -37
  112. package/js/src/abstract/coinmetro.js +0 -5
  113. package/js/src/abstract/novadax.d.ts +0 -32
  114. package/js/src/abstract/novadax.js +0 -5
  115. package/js/src/ascendex.d.ts +0 -436
  116. package/js/src/ascendex.js +0 -3773
  117. package/js/src/coinmetro.d.ts +0 -245
  118. package/js/src/coinmetro.js +0 -2023
  119. package/js/src/novadax.d.ts +0 -279
  120. package/js/src/novadax.js +0 -1671
  121. package/js/src/pro/ascendex.d.ts +0 -99
  122. package/js/src/pro/ascendex.js +0 -1006
  123. /package/dist/cjs/src/abstract/{ascendex.js → mudrex.js} +0 -0
  124. /package/js/src/abstract/{ascendex.js → mudrex.js} +0 -0
package/js/src/novadax.js DELETED
@@ -1,1671 +0,0 @@
1
- // ---------------------------------------------------------------------------
2
- import { sha256 } from '@noble/hashes/sha2.js';
3
- import { md5 } from '@noble/hashes/legacy.js';
4
- import Exchange from './abstract/novadax.js';
5
- import { AuthenticationError, ExchangeError, PermissionDenied, BadRequest, CancelPending, OrderNotFound, InsufficientFunds, RateLimitExceeded, InvalidOrder, AccountSuspended, BadSymbol, OnMaintenance, ArgumentsRequired, AccountNotEnabled } from './base/errors.js';
6
- import { Precise } from './base/Precise.js';
7
- import { TICK_SIZE } from './base/functions/number.js';
8
- // ---------------------------------------------------------------------------
9
- /**
10
- * @class novadax
11
- * @augments Exchange
12
- */
13
- export default class novadax extends Exchange {
14
- describe() {
15
- return this.deepExtend(super.describe(), {
16
- 'id': 'novadax',
17
- 'name': 'NovaDAX',
18
- 'countries': ['BR'], // Brazil
19
- // 6000 weight per min => 100 weight per second => min weight = 1
20
- // 100 requests per second => ( 1000ms / 100 ) = 10 ms between requests on average
21
- 'rateLimit': 10,
22
- 'version': 'v1',
23
- // new metainfo interface
24
- 'has': {
25
- 'CORS': undefined,
26
- 'spot': true,
27
- 'margin': false,
28
- 'swap': false,
29
- 'future': false,
30
- 'option': false,
31
- 'addMargin': false,
32
- 'borrowCrossMargin': false,
33
- 'borrowIsolatedMargin': false,
34
- 'borrowMargin': false,
35
- 'cancelOrder': true,
36
- 'closeAllPositions': false,
37
- 'closePosition': false,
38
- 'createMarketBuyOrderWithCost': true,
39
- 'createMarketOrderWithCost': false,
40
- 'createMarketSellOrderWithCost': false,
41
- 'createOrder': true,
42
- 'createReduceOnlyOrder': false,
43
- 'createStopLimitOrder': true,
44
- 'createStopMarketOrder': true,
45
- 'createStopOrder': true,
46
- 'fetchAccounts': true,
47
- 'fetchAllGreeks': false,
48
- 'fetchBalance': true,
49
- 'fetchBorrowInterest': false,
50
- 'fetchBorrowRate': false,
51
- 'fetchBorrowRateHistories': false,
52
- 'fetchBorrowRateHistory': false,
53
- 'fetchBorrowRates': false,
54
- 'fetchBorrowRatesPerSymbol': false,
55
- 'fetchClosedOrders': true,
56
- 'fetchCrossBorrowRate': false,
57
- 'fetchCrossBorrowRates': false,
58
- 'fetchCurrencies': false,
59
- 'fetchDepositAddress': false,
60
- 'fetchDepositAddresses': false,
61
- 'fetchDepositAddressesByNetwork': false,
62
- 'fetchDeposits': true,
63
- 'fetchDepositsWithdrawals': true,
64
- 'fetchFundingHistory': false,
65
- 'fetchFundingInterval': false,
66
- 'fetchFundingIntervals': false,
67
- 'fetchFundingRate': false,
68
- 'fetchFundingRateHistory': false,
69
- 'fetchFundingRates': false,
70
- 'fetchGreeks': false,
71
- 'fetchIndexOHLCV': false,
72
- 'fetchIsolatedBorrowRate': false,
73
- 'fetchIsolatedBorrowRates': false,
74
- 'fetchIsolatedPositions': false,
75
- 'fetchLeverage': false,
76
- 'fetchLeverages': false,
77
- 'fetchLeverageTiers': false,
78
- 'fetchLiquidations': false,
79
- 'fetchLongShortRatio': false,
80
- 'fetchLongShortRatioHistory': false,
81
- 'fetchMarginAdjustmentHistory': false,
82
- 'fetchMarginMode': false,
83
- 'fetchMarginModes': false,
84
- 'fetchMarketLeverageTiers': false,
85
- 'fetchMarkets': true,
86
- 'fetchMarkOHLCV': false,
87
- 'fetchMarkPrice': false,
88
- 'fetchMarkPrices': false,
89
- 'fetchMyLiquidations': false,
90
- 'fetchMySettlementHistory': false,
91
- 'fetchMyTrades': true,
92
- 'fetchOHLCV': true,
93
- 'fetchOpenInterest': false,
94
- 'fetchOpenInterestHistory': false,
95
- 'fetchOpenInterests': false,
96
- 'fetchOpenOrders': true,
97
- 'fetchOption': false,
98
- 'fetchOptionChain': false,
99
- 'fetchOrder': true,
100
- 'fetchOrderBook': true,
101
- 'fetchOrders': true,
102
- 'fetchOrderTrades': true,
103
- 'fetchPosition': false,
104
- 'fetchPositionHistory': false,
105
- 'fetchPositionMode': false,
106
- 'fetchPositions': false,
107
- 'fetchPositionsForSymbol': false,
108
- 'fetchPositionsHistory': false,
109
- 'fetchPositionsRisk': false,
110
- 'fetchPremiumIndexOHLCV': false,
111
- 'fetchSettlementHistory': false,
112
- 'fetchTicker': true,
113
- 'fetchTickers': true,
114
- 'fetchTime': true,
115
- 'fetchTrades': true,
116
- 'fetchTradingFee': false,
117
- 'fetchTradingFees': false,
118
- 'fetchTransactions': 'emulated',
119
- 'fetchUnderlyingAssets': false,
120
- 'fetchVolatilityHistory': false,
121
- 'fetchWithdrawals': true,
122
- 'reduceMargin': false,
123
- 'repayCrossMargin': false,
124
- 'repayIsolatedMargin': false,
125
- 'setLeverage': false,
126
- 'setMargin': false,
127
- 'setMarginMode': false,
128
- 'setPositionMode': false,
129
- 'transfer': true,
130
- 'withdraw': true,
131
- },
132
- 'timeframes': {
133
- '1m': 'ONE_MIN',
134
- '5m': 'FIVE_MIN',
135
- '15m': 'FIFTEEN_MIN',
136
- '30m': 'HALF_HOU',
137
- '1h': 'ONE_HOU',
138
- '1d': 'ONE_DAY',
139
- '1w': 'ONE_WEE',
140
- '1M': 'ONE_MON',
141
- },
142
- 'urls': {
143
- 'logo': 'https://user-images.githubusercontent.com/1294454/92337550-2b085500-f0b3-11ea-98e7-5794fb07dd3b.jpg',
144
- 'api': {
145
- 'public': 'https://api.novadax.com',
146
- 'private': 'https://api.novadax.com',
147
- },
148
- 'www': 'https://www.novadax.com.br',
149
- 'doc': [
150
- 'https://doc.novadax.com/pt-BR/',
151
- ],
152
- 'fees': 'https://www.novadax.com.br/fees-and-limits',
153
- 'referral': 'https://www.novadax.com.br/?s=ccxt',
154
- },
155
- 'api': {
156
- 'public': {
157
- 'get': {
158
- 'common/symbol': 1,
159
- 'common/symbols': 1,
160
- 'common/timestamp': 1,
161
- 'market/tickers': 5,
162
- 'market/ticker': 1,
163
- 'market/depth': 1,
164
- 'market/trades': 5,
165
- 'market/kline/history': 5,
166
- },
167
- },
168
- 'private': {
169
- 'get': {
170
- 'orders/get': 1,
171
- 'orders/list': 10,
172
- 'orders/fill': 3, // not found in doc
173
- 'orders/fills': 10,
174
- 'account/getBalance': 1,
175
- 'account/subs': 1,
176
- 'account/subs/balance': 1,
177
- 'account/subs/transfer/record': 10,
178
- 'wallet/query/deposit-withdraw': 3,
179
- },
180
- 'post': {
181
- 'orders/create': 5,
182
- 'orders/batch-create': 50,
183
- 'orders/cancel': 1,
184
- 'orders/batch-cancel': 10,
185
- 'orders/cancel-by-symbol': 10,
186
- 'account/subs/transfer': 5,
187
- 'wallet/withdraw/coin': 3,
188
- 'account/withdraw/coin': 3, // not found in doc
189
- },
190
- },
191
- },
192
- 'fees': {
193
- 'trading': {
194
- 'tierBased': false,
195
- 'percentage': true,
196
- 'taker': this.parseNumber('0.005'),
197
- 'maker': this.parseNumber('0.0025'),
198
- },
199
- },
200
- 'requiredCredentials': {
201
- 'apiKey': true,
202
- 'secret': true,
203
- },
204
- 'precisionMode': TICK_SIZE,
205
- 'exceptions': {
206
- 'exact': {
207
- 'A99999': ExchangeError, // 500 Failed Internal error
208
- // 'A10000': ExchangeError, // 200 Success Successful request
209
- 'A10001': BadRequest, // 400 Params error Parameter is invalid
210
- 'A10002': ExchangeError, // 404 Api not found API used is irrelevant
211
- 'A10003': AuthenticationError, // 403 Authentication failed Authentication is failed
212
- 'A10004': RateLimitExceeded, // 429 Too many requests Too many requests are made
213
- 'A10005': PermissionDenied, // 403 Kyc required Need to complete KYC firstly
214
- 'A10006': AccountSuspended, // 403 Customer canceled Account is canceled
215
- 'A10007': AccountNotEnabled, // 400 Account not exist Sub account does not exist
216
- 'A10011': BadSymbol, // 400 Symbol not exist Trading symbol does not exist
217
- 'A10012': BadSymbol, // 400 Symbol not trading Trading symbol is temporarily not available
218
- 'A10013': OnMaintenance, // 503 Symbol maintain Trading symbol is in maintain
219
- 'A30001': OrderNotFound, // 400 Order not found Queried order is not found
220
- 'A30002': InvalidOrder, // 400 Order amount is too small Order amount is too small
221
- 'A30003': InvalidOrder, // 400 Order amount is invalid Order amount is invalid
222
- 'A30004': InvalidOrder, // 400 Order value is too small Order value is too small
223
- 'A30005': InvalidOrder, // 400 Order value is invalid Order value is invalid
224
- 'A30006': InvalidOrder, // 400 Order price is invalid Order price is invalid
225
- 'A30007': InsufficientFunds, // 400 Insufficient balance The balance is insufficient
226
- 'A30008': InvalidOrder, // 400 Order was closed The order has been executed
227
- 'A30009': InvalidOrder, // 400 Order canceled The order has been cancelled
228
- 'A30010': CancelPending, // 400 Order cancelling The order is being cancelled
229
- 'A30011': InvalidOrder, // 400 Order price too high The order price is too high
230
- 'A30012': InvalidOrder, // 400 Order price too low The order price is too low
231
- 'A40004': InsufficientFunds, // {"code":"A40004","data":[],"message":"sub account balance Insufficient"}
232
- },
233
- 'broad': {},
234
- },
235
- 'options': {
236
- 'fetchOHLCV': {
237
- 'volume': 'amount', // 'amount' for base volume or 'vol' for quote volume
238
- },
239
- 'transfer': {
240
- 'fillResponseFromRequest': true,
241
- },
242
- },
243
- 'features': {
244
- 'spot': {
245
- 'sandbox': false,
246
- 'createOrder': {
247
- 'marginMode': false,
248
- 'triggerPrice': true,
249
- 'triggerDirection': true, // todo
250
- 'triggerPriceType': undefined,
251
- 'stopLossPrice': false, // todo
252
- 'takeProfitPrice': false, // todo
253
- 'attachedStopLossTakeProfit': undefined,
254
- // todo
255
- 'timeInForce': {
256
- 'IOC': false,
257
- 'FOK': false,
258
- 'PO': false,
259
- 'GTD': false,
260
- },
261
- 'hedged': false,
262
- 'trailing': false,
263
- 'leverage': false,
264
- 'marketBuyByCost': true,
265
- 'marketBuyRequiresPrice': false,
266
- 'selfTradePrevention': false,
267
- 'iceberg': true, // todo
268
- },
269
- 'createOrders': undefined, // todo: add implementation
270
- 'fetchMyTrades': {
271
- 'marginMode': false,
272
- 'limit': 100,
273
- 'daysBack': 100000, // todo
274
- 'untilDays': 100000, // todo
275
- 'symbolRequired': false,
276
- },
277
- 'fetchOrder': {
278
- 'marginMode': false,
279
- 'trigger': false,
280
- 'trailing': false,
281
- 'symbolRequired': false,
282
- },
283
- 'fetchOpenOrders': {
284
- 'marginMode': false,
285
- 'limit': undefined,
286
- 'trigger': false,
287
- 'trailing': false,
288
- 'symbolRequired': false,
289
- },
290
- 'fetchOrders': {
291
- 'marginMode': false,
292
- 'limit': 100,
293
- 'daysBack': 100000, // todo
294
- 'untilDays': 100000, // todo
295
- 'trigger': false,
296
- 'trailing': false,
297
- 'symbolRequired': false,
298
- },
299
- 'fetchClosedOrders': {
300
- 'marginMode': false,
301
- 'limit': 100,
302
- 'daysBack': 100000, // todo
303
- 'daysBackCanceled': 1, // todo
304
- 'untilDays': 100000, // todo
305
- 'trigger': false,
306
- 'trailing': false,
307
- 'symbolRequired': false,
308
- },
309
- 'fetchOHLCV': {
310
- 'limit': undefined, // todo max 3000
311
- },
312
- },
313
- 'swap': {
314
- 'linear': undefined,
315
- 'inverse': undefined,
316
- },
317
- 'future': {
318
- 'linear': undefined,
319
- 'inverse': undefined,
320
- },
321
- },
322
- });
323
- }
324
- /**
325
- * @method
326
- * @name novadax#fetchTime
327
- * @description fetches the current integer timestamp in milliseconds from the exchange server
328
- * @see https://doc.novadax.com/en-US/#get-current-system-time
329
- * @param {object} [params] extra parameters specific to the exchange API endpoint
330
- * @returns {int} the current integer timestamp in milliseconds from the exchange server
331
- */
332
- async fetchTime(params = {}) {
333
- const response = await this.publicGetCommonTimestamp(params);
334
- //
335
- // {
336
- // "code":"A10000",
337
- // "data":1599090512080,
338
- // "message":"Success"
339
- // }
340
- //
341
- return this.safeInteger(response, 'data');
342
- }
343
- /**
344
- * @method
345
- * @name novadax#fetchMarkets
346
- * @description retrieves data on all markets for novadax
347
- * @see https://doc.novadax.com/en-US/#get-all-supported-trading-symbol
348
- * @param {object} [params] extra parameters specific to the exchange API endpoint
349
- * @returns {object[]} an array of objects representing market data
350
- */
351
- async fetchMarkets(params = {}) {
352
- const response = await this.publicGetCommonSymbols(params);
353
- //
354
- // {
355
- // "code":"A10000",
356
- // "data":[
357
- // {
358
- // "amountPrecision":8,
359
- // "baseCurrency":"BTC",
360
- // "minOrderAmount":"0.001",
361
- // "minOrderValue":"25",
362
- // "pricePrecision":2,
363
- // "quoteCurrency":"BRL",
364
- // "status":"ONLINE",
365
- // "symbol":"BTC_BRL",
366
- // "valuePrecision":2
367
- // },
368
- // ],
369
- // "message":"Success"
370
- // }
371
- //
372
- const data = this.safeValue(response, 'data', []);
373
- return this.parseMarkets(data);
374
- }
375
- parseMarket(market) {
376
- const baseId = this.safeString(market, 'baseCurrency');
377
- const quoteId = this.safeString(market, 'quoteCurrency');
378
- const id = this.safeString(market, 'symbol');
379
- const base = this.safeCurrencyCode(baseId);
380
- const quote = this.safeCurrencyCode(quoteId);
381
- const status = this.safeString(market, 'status');
382
- return {
383
- 'id': id,
384
- 'symbol': base + '/' + quote,
385
- 'base': base,
386
- 'quote': quote,
387
- 'settle': undefined,
388
- 'baseId': baseId,
389
- 'quoteId': quoteId,
390
- 'settleId': undefined,
391
- 'type': 'spot',
392
- 'spot': true,
393
- 'margin': false,
394
- 'swap': false,
395
- 'future': false,
396
- 'option': false,
397
- 'active': (status === 'ONLINE'),
398
- 'contract': false,
399
- 'linear': undefined,
400
- 'inverse': undefined,
401
- 'contractSize': undefined,
402
- 'expiry': undefined,
403
- 'expiryDatetime': undefined,
404
- 'strike': undefined,
405
- 'optionType': undefined,
406
- 'precision': {
407
- 'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'amountPrecision'))),
408
- 'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'pricePrecision'))),
409
- // 'cost': this.parseNumber (this.parsePrecision (this.safeString (market, 'valuePrecision'))),
410
- },
411
- 'limits': {
412
- 'leverage': {
413
- 'min': undefined,
414
- 'max': undefined,
415
- },
416
- 'amount': {
417
- 'min': this.safeNumber(market, 'minOrderAmount'),
418
- 'max': undefined,
419
- },
420
- 'price': {
421
- 'min': undefined,
422
- 'max': undefined,
423
- },
424
- 'cost': {
425
- 'min': this.safeNumber(market, 'minOrderValue'),
426
- 'max': undefined,
427
- },
428
- },
429
- 'created': undefined,
430
- 'info': market,
431
- };
432
- }
433
- parseTicker(ticker, market = undefined) {
434
- //
435
- // fetchTicker, fetchTickers
436
- //
437
- // {
438
- // "ask":"61946.1",
439
- // "baseVolume24h":"164.41930186",
440
- // "bid":"61815",
441
- // "high24h":"64930.72",
442
- // "lastPrice":"61928.41",
443
- // "low24h":"61156.32",
444
- // "open24h":"64512.46",
445
- // "quoteVolume24h":"10308157.95",
446
- // "symbol":"BTC_BRL",
447
- // "timestamp":1599091115090
448
- // }
449
- //
450
- const timestamp = this.safeInteger(ticker, 'timestamp');
451
- const marketId = this.safeString(ticker, 'symbol');
452
- const symbol = this.safeSymbol(marketId, market, '_');
453
- const open = this.safeString(ticker, 'open24h');
454
- const last = this.safeString(ticker, 'lastPrice');
455
- const baseVolume = this.safeString(ticker, 'baseVolume24h');
456
- const quoteVolume = this.safeString(ticker, 'quoteVolume24h');
457
- return this.safeTicker({
458
- 'symbol': symbol,
459
- 'timestamp': timestamp,
460
- 'datetime': this.iso8601(timestamp),
461
- 'high': this.safeString(ticker, 'high24h'),
462
- 'low': this.safeString(ticker, 'low24h'),
463
- 'bid': this.safeString(ticker, 'bid'),
464
- 'bidVolume': undefined,
465
- 'ask': this.safeString(ticker, 'ask'),
466
- 'askVolume': undefined,
467
- 'vwap': undefined,
468
- 'open': open,
469
- 'close': last,
470
- 'last': last,
471
- 'previousClose': undefined,
472
- 'change': undefined,
473
- 'percentage': undefined,
474
- 'average': undefined,
475
- 'baseVolume': baseVolume,
476
- 'quoteVolume': quoteVolume,
477
- 'info': ticker,
478
- }, market);
479
- }
480
- /**
481
- * @method
482
- * @name novadax#fetchTicker
483
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
484
- * @see https://doc.novadax.com/en-US/#get-latest-ticker-for-specific-pair
485
- * @param {string} symbol unified symbol of the market to fetch the ticker for
486
- * @param {object} [params] extra parameters specific to the exchange API endpoint
487
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
488
- */
489
- async fetchTicker(symbol, params = {}) {
490
- await this.loadMarkets();
491
- const market = this.market(symbol);
492
- const request = {
493
- 'symbol': market['id'],
494
- };
495
- const response = await this.publicGetMarketTicker(this.extend(request, params));
496
- //
497
- // {
498
- // "code":"A10000",
499
- // "data":{
500
- // "ask":"61946.1",
501
- // "baseVolume24h":"164.41930186",
502
- // "bid":"61815",
503
- // "high24h":"64930.72",
504
- // "lastPrice":"61928.41",
505
- // "low24h":"61156.32",
506
- // "open24h":"64512.46",
507
- // "quoteVolume24h":"10308157.95",
508
- // "symbol":"BTC_BRL",
509
- // "timestamp":1599091115090
510
- // },
511
- // "message":"Success"
512
- // }
513
- //
514
- const data = this.safeDict(response, 'data', {});
515
- return this.parseTicker(data, market);
516
- }
517
- /**
518
- * @method
519
- * @name novadax#fetchTickers
520
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
521
- * @see https://doc.novadax.com/en-US/#get-latest-tickers-for-all-trading-pairs
522
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
523
- * @param {object} [params] extra parameters specific to the exchange API endpoint
524
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
525
- */
526
- async fetchTickers(symbols = undefined, params = {}) {
527
- await this.loadMarkets();
528
- symbols = this.marketSymbols(symbols);
529
- const response = await this.publicGetMarketTickers(params);
530
- //
531
- // {
532
- // "code":"A10000",
533
- // "data":[
534
- // {
535
- // "ask":"61879.36",
536
- // "baseVolume24h":"164.40955092",
537
- // "bid":"61815",
538
- // "high24h":"64930.72",
539
- // "lastPrice":"61820.04",
540
- // "low24h":"61156.32",
541
- // "open24h":"64624.19",
542
- // "quoteVolume24h":"10307493.92",
543
- // "symbol":"BTC_BRL",
544
- // "timestamp":1599091291083
545
- // },
546
- // ],
547
- // "message":"Success"
548
- // }
549
- //
550
- const data = this.safeValue(response, 'data', []);
551
- const result = {};
552
- for (let i = 0; i < data.length; i++) {
553
- const ticker = this.parseTicker(data[i]);
554
- const symbol = ticker['symbol'];
555
- result[symbol] = ticker;
556
- }
557
- return this.filterByArrayTickers(result, 'symbol', symbols);
558
- }
559
- /**
560
- * @method
561
- * @name novadax#fetchOrderBook
562
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
563
- * @see https://doc.novadax.com/en-US/#get-market-depth
564
- * @param {string} symbol unified symbol of the market to fetch the order book for
565
- * @param {int} [limit] the maximum amount of order book entries to return
566
- * @param {object} [params] extra parameters specific to the exchange API endpoint
567
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure}
568
- */
569
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
570
- await this.loadMarkets();
571
- const market = this.market(symbol);
572
- const request = {
573
- 'symbol': market['id'],
574
- };
575
- if (limit !== undefined) {
576
- request['limit'] = limit; // default 10, max 20
577
- }
578
- const response = await this.publicGetMarketDepth(this.extend(request, params));
579
- //
580
- // {
581
- // "code":"A10000",
582
- // "data":{
583
- // "asks":[
584
- // ["0.037159","0.3741"],
585
- // ["0.037215","0.2706"],
586
- // ["0.037222","1.8459"],
587
- // ],
588
- // "bids":[
589
- // ["0.037053","0.3857"],
590
- // ["0.036969","0.8101"],
591
- // ["0.036953","1.5226"],
592
- // ],
593
- // "timestamp":1599280414448
594
- // },
595
- // "message":"Success"
596
- // }
597
- //
598
- const data = this.safeValue(response, 'data', {});
599
- const timestamp = this.safeInteger(data, 'timestamp');
600
- return this.parseOrderBook(data, market['symbol'], timestamp, 'bids', 'asks');
601
- }
602
- parseTrade(trade, market = undefined) {
603
- //
604
- // public fetchTrades
605
- //
606
- // {
607
- // "amount":"0.0632",
608
- // "price":"0.037288",
609
- // "side":"BUY",
610
- // "timestamp":1599279694576
611
- // }
612
- //
613
- // private fetchOrderTrades
614
- //
615
- // {
616
- // "id": "608717046691139584",
617
- // "orderId": "608716957545402368",
618
- // "symbol": "BTC_BRL",
619
- // "side": "BUY",
620
- // "amount": "0.0988",
621
- // "price": "45514.76",
622
- // "fee": "0.0000988 BTC",
623
- // "feeAmount": "0.0000988",
624
- // "feeCurrency": "BTC",
625
- // "role": "MAKER",
626
- // "timestamp": 1565171053345
627
- // }
628
- //
629
- // private fetchMyTrades (same endpoint as fetchOrderTrades)
630
- //
631
- // {
632
- // "id": "608717046691139584",
633
- // "orderId": "608716957545402368",
634
- // "symbol": "BTC_BRL",
635
- // "side": "BUY",
636
- // "amount": "0.0988",
637
- // "price": "45514.76",
638
- // "fee": "0.0000988 BTC",
639
- // "feeAmount": "0.0000988",
640
- // "feeCurrency": "BTC",
641
- // "role": "MAKER",
642
- // "timestamp": 1565171053345
643
- // }
644
- //
645
- const id = this.safeString(trade, 'id');
646
- const orderId = this.safeString(trade, 'orderId');
647
- const timestamp = this.safeInteger(trade, 'timestamp');
648
- const side = this.safeStringLower(trade, 'side');
649
- const priceString = this.safeString(trade, 'price');
650
- const amountString = this.safeString(trade, 'amount');
651
- const marketId = this.safeString(trade, 'symbol');
652
- const symbol = this.safeSymbol(marketId, market, '_');
653
- const takerOrMaker = this.safeStringLower(trade, 'role');
654
- const feeString = this.safeString(trade, 'fee');
655
- let fee = undefined;
656
- if (feeString !== undefined) {
657
- const feeCurrencyId = this.safeString(trade, 'feeCurrency');
658
- const feeCurrencyCode = this.safeCurrencyCode(feeCurrencyId);
659
- fee = {
660
- 'cost': this.safeString(trade, 'feeAmount'),
661
- 'currency': feeCurrencyCode,
662
- };
663
- }
664
- return this.safeTrade({
665
- 'id': id,
666
- 'order': orderId,
667
- 'timestamp': timestamp,
668
- 'datetime': this.iso8601(timestamp),
669
- 'symbol': symbol,
670
- 'type': undefined,
671
- 'side': side,
672
- 'price': priceString,
673
- 'amount': amountString,
674
- 'cost': undefined,
675
- 'takerOrMaker': takerOrMaker,
676
- 'fee': fee,
677
- 'info': trade,
678
- }, market);
679
- }
680
- /**
681
- * @method
682
- * @name novadax#fetchTrades
683
- * @description get the list of most recent trades for a particular symbol
684
- * @see https://doc.novadax.com/en-US/#get-recent-trades
685
- * @param {string} symbol unified symbol of the market to fetch trades for
686
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
687
- * @param {int} [limit] the maximum amount of trades to fetch
688
- * @param {object} [params] extra parameters specific to the exchange API endpoint
689
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
690
- */
691
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
692
- await this.loadMarkets();
693
- const market = this.market(symbol);
694
- const request = {
695
- 'symbol': market['id'],
696
- };
697
- if (limit !== undefined) {
698
- request['limit'] = limit; // default 100
699
- }
700
- const response = await this.publicGetMarketTrades(this.extend(request, params));
701
- //
702
- // {
703
- // "code":"A10000",
704
- // "data":[
705
- // {"amount":"0.0632","price":"0.037288","side":"BUY","timestamp":1599279694576},
706
- // {"amount":"0.0052","price":"0.03715","side":"SELL","timestamp":1599276606852},
707
- // {"amount":"0.0058","price":"0.037188","side":"SELL","timestamp":1599275187812},
708
- // ],
709
- // "message":"Success"
710
- // }
711
- //
712
- const data = this.safeList(response, 'data', []);
713
- return this.parseTrades(data, market, since, limit);
714
- }
715
- /**
716
- * @method
717
- * @name novadax#fetchOHLCV
718
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
719
- * @see https://doc.novadax.com/en-US/#get-kline-data
720
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
721
- * @param {string} timeframe the length of time each candle represents
722
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
723
- * @param {int} [limit] the maximum amount of candles to fetch
724
- * @param {object} [params] extra parameters specific to the exchange API endpoint
725
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
726
- */
727
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
728
- await this.loadMarkets();
729
- const market = this.market(symbol);
730
- const request = {
731
- 'symbol': market['id'],
732
- 'unit': this.safeString(this.timeframes, timeframe, timeframe),
733
- };
734
- const duration = this.parseTimeframe(timeframe);
735
- const now = this.seconds();
736
- if (limit === undefined) {
737
- limit = 3000; // max
738
- }
739
- if (since === undefined) {
740
- request['from'] = now - limit * duration;
741
- request['to'] = now;
742
- }
743
- else {
744
- const startFrom = this.parseToInt(since / 1000);
745
- request['from'] = startFrom;
746
- request['to'] = this.sum(startFrom, limit * duration);
747
- }
748
- const response = await this.publicGetMarketKlineHistory(this.extend(request, params));
749
- //
750
- // {
751
- // "code": "A10000",
752
- // "data": [
753
- // {
754
- // "amount": 8.25709100,
755
- // "closePrice": 62553.20,
756
- // "count": 29,
757
- // "highPrice": 62592.87,
758
- // "lowPrice": 62553.20,
759
- // "openPrice": 62554.23,
760
- // "score": 1602501480,
761
- // "symbol": "BTC_BRL",
762
- // "vol": 516784.2504067500
763
- // }
764
- // ],
765
- // "message": "Success"
766
- // }
767
- //
768
- const data = this.safeList(response, 'data', []);
769
- return this.parseOHLCVs(data, market, timeframe, since, limit);
770
- }
771
- parseOHLCV(ohlcv, market = undefined) {
772
- //
773
- // {
774
- // "amount": 8.25709100,
775
- // "closePrice": 62553.20,
776
- // "count": 29,
777
- // "highPrice": 62592.87,
778
- // "lowPrice": 62553.20,
779
- // "openPrice": 62554.23,
780
- // "score": 1602501480,
781
- // "symbol": "BTC_BRL",
782
- // "vol": 516784.2504067500
783
- // }
784
- //
785
- const options = this.safeValue(this.options, 'fetchOHLCV', {});
786
- const volumeField = this.safeString(options, 'volume', 'amount'); // or vol
787
- return [
788
- this.safeTimestamp(ohlcv, 'score'),
789
- this.safeNumber(ohlcv, 'openPrice'),
790
- this.safeNumber(ohlcv, 'highPrice'),
791
- this.safeNumber(ohlcv, 'lowPrice'),
792
- this.safeNumber(ohlcv, 'closePrice'),
793
- this.safeNumber(ohlcv, volumeField),
794
- ];
795
- }
796
- parseBalance(response) {
797
- const data = this.safeValue(response, 'data', []);
798
- const result = {
799
- 'info': response,
800
- 'timestamp': undefined,
801
- 'datetime': undefined,
802
- };
803
- for (let i = 0; i < data.length; i++) {
804
- const balance = data[i];
805
- const currencyId = this.safeString(balance, 'currency');
806
- const code = this.safeCurrencyCode(currencyId);
807
- const account = this.account();
808
- account['total'] = this.safeString(balance, 'balance');
809
- account['free'] = this.safeString(balance, 'available');
810
- account['used'] = this.safeString(balance, 'hold');
811
- result[code] = account;
812
- }
813
- return this.safeBalance(result);
814
- }
815
- /**
816
- * @method
817
- * @name novadax#fetchBalance
818
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
819
- * @see https://doc.novadax.com/en-US/#get-account-balance
820
- * @param {object} [params] extra parameters specific to the exchange API endpoint
821
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
822
- */
823
- async fetchBalance(params = {}) {
824
- await this.loadMarkets();
825
- const response = await this.privateGetAccountGetBalance(params);
826
- //
827
- // {
828
- // "code": "A10000",
829
- // "data": [
830
- // {
831
- // "available": "1.23",
832
- // "balance": "0.23",
833
- // "currency": "BTC",
834
- // "hold": "1"
835
- // }
836
- // ],
837
- // "message": "Success"
838
- // }
839
- //
840
- return this.parseBalance(response);
841
- }
842
- /**
843
- * @method
844
- * @name novadax#createOrder
845
- * @description create a trade order
846
- * @see https://doc.novadax.com/en-US/#order-introduction
847
- * @param {string} symbol unified symbol of the market to create an order in
848
- * @param {string} type 'market' or 'limit'
849
- * @param {string} side 'buy' or 'sell'
850
- * @param {float} amount how much you want to trade in units of the base currency
851
- * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
852
- * @param {object} [params] extra parameters specific to the exchange API endpoint
853
- * @param {float} [params.cost] for spot market buy orders, the quote quantity that can be used as an alternative for the amount
854
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
855
- */
856
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
857
- await this.loadMarkets();
858
- const market = this.market(symbol);
859
- let uppercaseType = type.toUpperCase();
860
- const uppercaseSide = side.toUpperCase();
861
- const request = {
862
- 'symbol': market['id'],
863
- 'side': uppercaseSide, // or SELL
864
- // "amount": this.amountToPrecision (symbol, amount),
865
- // "price": "1234.5678", // required for LIMIT and STOP orders
866
- // "operator": "" // for stop orders, can be found in order introduction
867
- // "stopPrice": this.priceToPrecision (symbol, stopPrice),
868
- // "accountId": "...", // subaccount id, optional
869
- };
870
- const triggerPrice = this.safeValue2(params, 'triggerPrice', 'stopPrice');
871
- if (triggerPrice === undefined) {
872
- if ((uppercaseType === 'STOP_LIMIT') || (uppercaseType === 'STOP_MARKET')) {
873
- throw new ArgumentsRequired(this.id + ' createOrder() requires a stopPrice parameter for ' + uppercaseType + ' orders');
874
- }
875
- }
876
- else {
877
- if (uppercaseType === 'LIMIT') {
878
- uppercaseType = 'STOP_LIMIT';
879
- }
880
- else if (uppercaseType === 'MARKET') {
881
- uppercaseType = 'STOP_MARKET';
882
- }
883
- const defaultOperator = (uppercaseSide === 'BUY') ? 'LTE' : 'GTE';
884
- request['operator'] = this.safeString(params, 'operator', defaultOperator);
885
- request['stopPrice'] = this.priceToPrecision(symbol, triggerPrice);
886
- params = this.omit(params, ['triggerPrice', 'stopPrice']);
887
- }
888
- if ((uppercaseType === 'LIMIT') || (uppercaseType === 'STOP_LIMIT')) {
889
- request['price'] = this.priceToPrecision(symbol, price);
890
- request['amount'] = this.amountToPrecision(symbol, amount);
891
- }
892
- else if ((uppercaseType === 'MARKET') || (uppercaseType === 'STOP_MARKET')) {
893
- if (uppercaseSide === 'SELL') {
894
- request['amount'] = this.amountToPrecision(symbol, amount);
895
- }
896
- else if (uppercaseSide === 'BUY') {
897
- let quoteAmount = undefined;
898
- let createMarketBuyOrderRequiresPrice = true;
899
- [createMarketBuyOrderRequiresPrice, params] = this.handleOptionAndParams(params, 'createOrder', 'createMarketBuyOrderRequiresPrice', true);
900
- const cost = this.safeNumber2(params, 'cost', 'value');
901
- params = this.omit(params, 'cost');
902
- if (cost !== undefined) {
903
- quoteAmount = this.costToPrecision(symbol, cost);
904
- }
905
- else if (createMarketBuyOrderRequiresPrice) {
906
- if (price === undefined) {
907
- throw new InvalidOrder(this.id + ' createOrder() requires the price argument for market buy orders to calculate the total cost to spend (amount * price), alternatively set the createMarketBuyOrderRequiresPrice option or param to false and pass the cost to spend (quote quantity) in the amount argument');
908
- }
909
- else {
910
- const amountString = this.numberToString(amount);
911
- const priceString = this.numberToString(price);
912
- const costRequest = Precise.stringMul(amountString, priceString);
913
- quoteAmount = this.costToPrecision(symbol, costRequest);
914
- }
915
- }
916
- else {
917
- quoteAmount = this.costToPrecision(symbol, amount);
918
- }
919
- request['value'] = quoteAmount;
920
- }
921
- }
922
- request['type'] = uppercaseType;
923
- const response = await this.privatePostOrdersCreate(this.extend(request, params));
924
- //
925
- // {
926
- // "code": "A10000",
927
- // "data": {
928
- // "amount": "0.001",
929
- // "averagePrice": null,
930
- // "filledAmount": "0",
931
- // "filledFee": "0",
932
- // "filledValue": "0",
933
- // "id": "870613508008464384",
934
- // "operator": "GTE",
935
- // "price": "210000",
936
- // "side": "BUY",
937
- // "status": "SUBMITTED",
938
- // "stopPrice": "211000",
939
- // "symbol": "BTC_BRL",
940
- // "timestamp": 1627612035528,
941
- // "type": "STOP_LIMIT",
942
- // "value": "210"
943
- // },
944
- // "message": "Success"
945
- // }
946
- //
947
- const data = this.safeDict(response, 'data', {});
948
- return this.parseOrder(data, market);
949
- }
950
- /**
951
- * @method
952
- * @name novadax#cancelOrder
953
- * @description cancels an open order
954
- * @see https://doc.novadax.com/en-US/#cancel-an-order
955
- * @param {string} id order id
956
- * @param {string} symbol not used by novadax cancelOrder ()
957
- * @param {object} [params] extra parameters specific to the exchange API endpoint
958
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
959
- */
960
- async cancelOrder(id, symbol = undefined, params = {}) {
961
- await this.loadMarkets();
962
- const request = {
963
- 'id': id,
964
- };
965
- const response = await this.privatePostOrdersCancel(this.extend(request, params));
966
- //
967
- // {
968
- // "code": "A10000",
969
- // "data": {
970
- // "result": true
971
- // },
972
- // "message": "Success"
973
- // }
974
- //
975
- const data = this.safeDict(response, 'data', {});
976
- return this.parseOrder(data);
977
- }
978
- /**
979
- * @method
980
- * @name novadax#fetchOrder
981
- * @description fetches information on an order made by the user
982
- * @see https://doc.novadax.com/en-US/#get-order-details
983
- * @param {string} id order id
984
- * @param {string} symbol not used by novadax fetchOrder
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 fetchOrder(id, symbol = undefined, params = {}) {
989
- await this.loadMarkets();
990
- const request = {
991
- 'id': id,
992
- };
993
- const response = await this.privateGetOrdersGet(this.extend(request, params));
994
- //
995
- // {
996
- // "code": "A10000",
997
- // "data": {
998
- // "id": "608695623247466496",
999
- // "symbol": "BTC_BRL",
1000
- // "type": "MARKET",
1001
- // "side": "SELL",
1002
- // "price": null,
1003
- // "averagePrice": "0",
1004
- // "amount": "0.123",
1005
- // "filledAmount": "0",
1006
- // "value": null,
1007
- // "filledValue": "0",
1008
- // "filledFee": "0",
1009
- // "status": "REJECTED",
1010
- // "timestamp": 1565165945588
1011
- // },
1012
- // "message": "Success"
1013
- // }
1014
- //
1015
- const data = this.safeDict(response, 'data', {});
1016
- return this.parseOrder(data);
1017
- }
1018
- /**
1019
- * @method
1020
- * @name novadax#fetchOrders
1021
- * @description fetches information on multiple orders made by the user
1022
- * @see https://doc.novadax.com/en-US/#get-order-history
1023
- * @param {string} symbol unified market symbol of the market orders were made in
1024
- * @param {int} [since] the earliest time in ms to fetch orders for
1025
- * @param {int} [limit] the maximum number of order structures to retrieve
1026
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1027
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
1028
- */
1029
- async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1030
- await this.loadMarkets();
1031
- const request = {
1032
- // 'symbol': market['id'],
1033
- // 'status': 'SUBMITTED,PROCESSING', // SUBMITTED, PROCESSING, PARTIAL_FILLED, CANCELING, FILLED, CANCELED, REJECTED
1034
- // 'fromId': '...', // order id to begin with
1035
- // 'toId': '...', // order id to end up with
1036
- // 'fromTimestamp': since,
1037
- // 'toTimestamp': this.milliseconds (),
1038
- // 'limit': limit, // default 100, max 100
1039
- };
1040
- let market = undefined;
1041
- if (symbol !== undefined) {
1042
- market = this.market(symbol);
1043
- request['symbol'] = market['id'];
1044
- }
1045
- if (limit !== undefined) {
1046
- request['limit'] = limit; // default 100, max 100
1047
- }
1048
- if (since !== undefined) {
1049
- request['fromTimestamp'] = since;
1050
- }
1051
- const response = await this.privateGetOrdersList(this.extend(request, params));
1052
- //
1053
- // {
1054
- // "code": "A10000",
1055
- // "data": [
1056
- // {
1057
- // "id": "608695678650028032",
1058
- // "symbol": "BTC_BRL",
1059
- // "type": "MARKET",
1060
- // "side": "SELL",
1061
- // "price": null,
1062
- // "averagePrice": "0",
1063
- // "amount": "0.123",
1064
- // "filledAmount": "0",
1065
- // "value": null,
1066
- // "filledValue": "0",
1067
- // "filledFee": "0",
1068
- // "status": "REJECTED",
1069
- // "timestamp": 1565165958796
1070
- // },
1071
- // ],
1072
- // "message": "Success"
1073
- // }
1074
- //
1075
- const data = this.safeList(response, 'data', []);
1076
- return this.parseOrders(data, market, since, limit);
1077
- }
1078
- /**
1079
- * @method
1080
- * @name novadax#fetchOpenOrders
1081
- * @description fetch all unfilled currently open orders
1082
- * @see https://doc.novadax.com/en-US/#get-order-history
1083
- * @param {string} symbol unified market symbol
1084
- * @param {int} [since] the earliest time in ms to fetch open orders for
1085
- * @param {int} [limit] the maximum number of open orders structures to retrieve
1086
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1087
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
1088
- */
1089
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1090
- const request = {
1091
- 'status': 'SUBMITTED,PROCESSING,PARTIAL_FILLED,CANCELING',
1092
- };
1093
- return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
1094
- }
1095
- /**
1096
- * @method
1097
- * @name novadax#fetchClosedOrders
1098
- * @description fetches information on multiple closed orders made by the user
1099
- * @see https://doc.novadax.com/en-US/#get-order-history
1100
- * @param {string} symbol unified market symbol of the market orders were made in
1101
- * @param {int} [since] the earliest time in ms to fetch orders for
1102
- * @param {int} [limit] the maximum number of order structures to retrieve
1103
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1104
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
1105
- */
1106
- async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1107
- const request = {
1108
- 'status': 'FILLED,CANCELED,REJECTED',
1109
- };
1110
- return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
1111
- }
1112
- /**
1113
- * @method
1114
- * @name novadax#fetchOrderTrades
1115
- * @description fetch all the trades made from a single order
1116
- * @see https://doc.novadax.com/en-US/#get-order-match-details
1117
- * @param {string} id order id
1118
- * @param {string} symbol unified market symbol
1119
- * @param {int} [since] the earliest time in ms to fetch trades for
1120
- * @param {int} [limit] the maximum number of trades to retrieve
1121
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1122
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
1123
- */
1124
- async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
1125
- await this.loadMarkets();
1126
- const request = {
1127
- 'id': id,
1128
- };
1129
- const response = await this.privateGetOrdersFill(this.extend(request, params));
1130
- let market = undefined;
1131
- if (symbol !== undefined) {
1132
- market = this.market(symbol);
1133
- }
1134
- const data = this.safeValue(response, 'data', []);
1135
- //
1136
- // {
1137
- // "code": "A10000",
1138
- // "data": [
1139
- // {
1140
- // "id": "608717046691139584",
1141
- // "orderId": "608716957545402368",
1142
- // "symbol": "BTC_BRL",
1143
- // "side": "BUY",
1144
- // "amount": "0.0988",
1145
- // "price": "45514.76",
1146
- // "fee": "0.0000988 BTC",
1147
- // "feeAmount": "0.0000988",
1148
- // "feeCurrency": "BTC",
1149
- // "role": "MAKER",
1150
- // "timestamp": 1565171053345
1151
- // },
1152
- // ],
1153
- // "message": "Success"
1154
- // }
1155
- //
1156
- return this.parseTrades(data, market, since, limit);
1157
- }
1158
- parseOrderStatus(status) {
1159
- const statuses = {
1160
- 'SUBMITTED': 'open',
1161
- 'PROCESSING': 'open',
1162
- 'PARTIAL_FILLED': 'open',
1163
- 'CANCELING': 'open',
1164
- 'FILLED': 'closed',
1165
- 'CANCELED': 'canceled',
1166
- 'REJECTED': 'rejected',
1167
- };
1168
- return this.safeString(statuses, status, status);
1169
- }
1170
- parseOrder(order, market = undefined) {
1171
- //
1172
- // createOrder, fetchOrders, fetchOrder
1173
- //
1174
- // {
1175
- // "amount": "0.001",
1176
- // "averagePrice": null,
1177
- // "filledAmount": "0",
1178
- // "filledFee": "0",
1179
- // "filledValue": "0",
1180
- // "id": "870613508008464384",
1181
- // "operator": "GTE",
1182
- // "price": "210000",
1183
- // "side": "BUY",
1184
- // "status": "SUBMITTED",
1185
- // "stopPrice": "211000",
1186
- // "symbol": "BTC_BRL",
1187
- // "timestamp": 1627612035528,
1188
- // "type": "STOP_LIMIT",
1189
- // "value": "210"
1190
- // }
1191
- //
1192
- // cancelOrder
1193
- //
1194
- // {
1195
- // "result": true
1196
- // }
1197
- //
1198
- const id = this.safeString(order, 'id');
1199
- const amount = this.safeString(order, 'amount');
1200
- const price = this.safeString(order, 'price');
1201
- const cost = this.safeString2(order, 'filledValue', 'value');
1202
- const type = this.safeStringLower(order, 'type');
1203
- const side = this.safeStringLower(order, 'side');
1204
- const status = this.parseOrderStatus(this.safeString(order, 'status'));
1205
- const timestamp = this.safeInteger(order, 'timestamp');
1206
- const average = this.safeString(order, 'averagePrice');
1207
- const filled = this.safeString(order, 'filledAmount');
1208
- let fee = undefined;
1209
- const feeCost = this.safeNumber(order, 'filledFee');
1210
- if (feeCost !== undefined) {
1211
- fee = {
1212
- 'cost': feeCost,
1213
- 'currency': undefined,
1214
- };
1215
- }
1216
- const marketId = this.safeString(order, 'symbol');
1217
- const symbol = this.safeSymbol(marketId, market, '_');
1218
- return this.safeOrder({
1219
- 'id': id,
1220
- 'clientOrderId': undefined,
1221
- 'info': order,
1222
- 'timestamp': timestamp,
1223
- 'datetime': this.iso8601(timestamp),
1224
- 'lastTradeTimestamp': undefined,
1225
- 'symbol': symbol,
1226
- 'type': type,
1227
- 'timeInForce': undefined,
1228
- 'postOnly': undefined,
1229
- 'side': side,
1230
- 'price': price,
1231
- 'triggerPrice': this.safeNumber(order, 'stopPrice'),
1232
- 'amount': amount,
1233
- 'cost': cost,
1234
- 'average': average,
1235
- 'filled': filled,
1236
- 'remaining': undefined,
1237
- 'status': status,
1238
- 'fee': fee,
1239
- 'trades': undefined,
1240
- }, market);
1241
- }
1242
- /**
1243
- * @method
1244
- * @name novadax#transfer
1245
- * @description transfer currency internally between wallets on the same account
1246
- * @see https://doc.novadax.com/en-US/#get-sub-account-transfer
1247
- * @param {string} code unified currency code
1248
- * @param {float} amount amount to transfer
1249
- * @param {string} fromAccount account to transfer from
1250
- * @param {string} toAccount account to transfer to
1251
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1252
- * @returns {object} a [transfer structure]{@link https://docs.ccxt.com/?id=transfer-structure}
1253
- */
1254
- async transfer(code, amount, fromAccount, toAccount, params = {}) {
1255
- await this.loadMarkets();
1256
- const currency = this.currency(code);
1257
- if (fromAccount !== 'main' && toAccount !== 'main') {
1258
- throw new ExchangeError(this.id + ' transfer() supports transfers between main account and subaccounts only');
1259
- }
1260
- // master-transfer-in = from master account to subaccount
1261
- // master-transfer-out = from subaccount to master account
1262
- const type = (fromAccount === 'main') ? 'master-transfer-in' : 'master-transfer-out';
1263
- const request = {
1264
- 'transferAmount': this.currencyToPrecision(code, amount),
1265
- 'currency': currency['id'],
1266
- 'subId': (type === 'master-transfer-in') ? toAccount : fromAccount,
1267
- 'transferType': type,
1268
- };
1269
- const response = await this.privatePostAccountSubsTransfer(this.extend(request, params));
1270
- //
1271
- // {
1272
- // "code":"A10000",
1273
- // "message":"Success",
1274
- // "data":40
1275
- // }
1276
- //
1277
- const transfer = this.parseTransfer(response, currency);
1278
- const transferOptions = this.safeValue(this.options, 'transfer', {});
1279
- const fillResponseFromRequest = this.safeBool(transferOptions, 'fillResponseFromRequest', true);
1280
- if (fillResponseFromRequest) {
1281
- transfer['fromAccount'] = fromAccount;
1282
- transfer['toAccount'] = toAccount;
1283
- transfer['amount'] = amount;
1284
- }
1285
- return transfer;
1286
- }
1287
- parseTransfer(transfer, currency = undefined) {
1288
- //
1289
- // {
1290
- // "code":"A10000",
1291
- // "message":"Success",
1292
- // "data":40
1293
- // }
1294
- //
1295
- const id = this.safeString(transfer, 'data');
1296
- const status = this.safeString(transfer, 'message');
1297
- const currencyCode = this.safeCurrencyCode(undefined, currency);
1298
- return {
1299
- 'info': transfer,
1300
- 'id': id,
1301
- 'amount': undefined,
1302
- 'currency': currencyCode,
1303
- 'fromAccount': undefined,
1304
- 'toAccount': undefined,
1305
- 'timestamp': undefined,
1306
- 'datetime': undefined,
1307
- 'status': status,
1308
- };
1309
- }
1310
- parseTransferStatus(status) {
1311
- const statuses = {
1312
- 'SUCCESS': 'pending',
1313
- };
1314
- return this.safeString(statuses, status, 'failed');
1315
- }
1316
- /**
1317
- * @method
1318
- * @name novadax#withdraw
1319
- * @description make a withdrawal
1320
- * @see https://doc.novadax.com/en-US/#send-cryptocurrencies
1321
- * @param {string} code unified currency code
1322
- * @param {float} amount the amount to withdraw
1323
- * @param {string} address the address to withdraw to
1324
- * @param {string} tag
1325
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1326
- * @returns {object} a [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
1327
- */
1328
- async withdraw(code, amount, address, tag = undefined, params = {}) {
1329
- [tag, params] = this.handleWithdrawTagAndParams(tag, params);
1330
- await this.loadMarkets();
1331
- const currency = this.currency(code);
1332
- const request = {
1333
- 'code': currency['id'],
1334
- 'amount': this.currencyToPrecision(code, amount),
1335
- 'wallet': address,
1336
- };
1337
- if (tag !== undefined) {
1338
- request['tag'] = tag;
1339
- }
1340
- const response = await this.privatePostAccountWithdrawCoin(this.extend(request, params));
1341
- //
1342
- // {
1343
- // "code":"A10000",
1344
- // "data": "DR123",
1345
- // "message":"Success"
1346
- // }
1347
- //
1348
- return this.parseTransaction(response, currency);
1349
- }
1350
- /**
1351
- * @method
1352
- * @name novadax#fetchAccounts
1353
- * @description fetch all the accounts associated with a profile
1354
- * @see https://doc.novadax.com/en-US/#get-sub-account-list
1355
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1356
- * @returns {object} a dictionary of [account structures]{@link https://docs.ccxt.com/?id=account-structure} indexed by the account type
1357
- */
1358
- async fetchAccounts(params = {}) {
1359
- const response = await this.privateGetAccountSubs(params);
1360
- //
1361
- // {
1362
- // "code": "A10000",
1363
- // "data": [
1364
- // {
1365
- // "subId": "CA648856083527372800",
1366
- // "state": "Normal",
1367
- // "subAccount": "003",
1368
- // "subIdentify": "003"
1369
- // }
1370
- // ],
1371
- // "message": "Success"
1372
- // }
1373
- //
1374
- const data = this.safeValue(response, 'data', []);
1375
- const result = [];
1376
- for (let i = 0; i < data.length; i++) {
1377
- const account = data[i];
1378
- const accountId = this.safeString(account, 'subId');
1379
- const type = this.safeString(account, 'subAccount');
1380
- result.push({
1381
- 'id': accountId,
1382
- 'type': type,
1383
- 'currency': undefined,
1384
- 'info': account,
1385
- });
1386
- }
1387
- return result;
1388
- }
1389
- /**
1390
- * @method
1391
- * @name novadax#fetchDeposits
1392
- * @description fetch all deposits made to an account
1393
- * @see https://doc.novadax.com/en-US/#wallet-records-of-deposits-and-withdraws
1394
- * @param {string} code unified currency code
1395
- * @param {int} [since] the earliest time in ms to fetch deposits for
1396
- * @param {int} [limit] the maximum number of deposits structures to retrieve
1397
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1398
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
1399
- */
1400
- async fetchDeposits(code = undefined, since = undefined, limit = undefined, params = {}) {
1401
- const request = {
1402
- 'type': 'coin_in',
1403
- };
1404
- return await this.fetchDepositsWithdrawals(code, since, limit, this.extend(request, params));
1405
- }
1406
- /**
1407
- * @method
1408
- * @name novadax#fetchWithdrawals
1409
- * @description fetch all withdrawals made from an account
1410
- * @see https://doc.novadax.com/en-US/#wallet-records-of-deposits-and-withdraws
1411
- * @param {string} code unified currency code
1412
- * @param {int} [since] the earliest time in ms to fetch withdrawals for
1413
- * @param {int} [limit] the maximum number of withdrawals structures to retrieve
1414
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1415
- * @returns {object[]} a list of [transaction structures]{@link https://docs.ccxt.com/?id=transaction-structure}
1416
- */
1417
- async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1418
- const request = {
1419
- 'type': 'coin_out',
1420
- };
1421
- return await this.fetchDepositsWithdrawals(code, since, limit, this.extend(request, params));
1422
- }
1423
- /**
1424
- * @method
1425
- * @name novadax#fetchDepositsWithdrawals
1426
- * @description fetch history of deposits and withdrawals
1427
- * @see https://doc.novadax.com/en-US/#wallet-records-of-deposits-and-withdraws
1428
- * @param {string} [code] unified currency code for the currency of the deposit/withdrawals, default is undefined
1429
- * @param {int} [since] timestamp in ms of the earliest deposit/withdrawal, default is undefined
1430
- * @param {int} [limit] max number of deposit/withdrawals to return, default is undefined
1431
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1432
- * @returns {object} a list of [transaction structure]{@link https://docs.ccxt.com/?id=transaction-structure}
1433
- */
1434
- async fetchDepositsWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
1435
- await this.loadMarkets();
1436
- const request = {
1437
- // 'currency': currency['id'],
1438
- // 'type': 'coin_in', // 'coin_out'
1439
- // 'direct': 'asc', // 'desc'
1440
- // 'size': limit, // default 100
1441
- // 'start': id, // offset id
1442
- };
1443
- let currency = undefined;
1444
- if (code !== undefined) {
1445
- currency = this.currency(code);
1446
- request['currency'] = currency['id'];
1447
- }
1448
- if (limit !== undefined) {
1449
- request['size'] = limit;
1450
- }
1451
- const response = await this.privateGetWalletQueryDepositWithdraw(this.extend(request, params));
1452
- //
1453
- // {
1454
- // "code": "A10000",
1455
- // "data": [
1456
- // {
1457
- // "id": "DR562339304588709888",
1458
- // "type": "COIN_IN",
1459
- // "currency": "XLM",
1460
- // "chain": "XLM",
1461
- // "address": "GCUTK7KHPJC3ZQJ3OMWWFHAK2OXIBRD4LNZQRCCOVE7A2XOPP2K5PU5Q",
1462
- // "addressTag": "1000009",
1463
- // "amount": 1.0,
1464
- // "state": "SUCCESS",
1465
- // "txHash": "39210645748822f8d4ce673c7559aa6622e6e9cdd7073bc0fcae14b1edfda5f4",
1466
- // "createdAt": 1554113737000,
1467
- // "updatedAt": 1601371273000
1468
- // }
1469
- // ],
1470
- // "message": "Success"
1471
- // }
1472
- //
1473
- const data = this.safeList(response, 'data', []);
1474
- return this.parseTransactions(data, currency, since, limit);
1475
- }
1476
- parseTransactionStatus(status) {
1477
- // Pending the record is wait broadcast to chain
1478
- // x/M confirming the comfirming state of tx, the M is total confirmings needed
1479
- // SUCCESS the record is success full
1480
- // FAIL the record failed
1481
- const parts = status.split(' ');
1482
- status = this.safeString(parts, 1, status);
1483
- const statuses = {
1484
- 'Pending': 'pending',
1485
- 'confirming': 'pending',
1486
- 'SUCCESS': 'ok',
1487
- 'FAIL': 'failed',
1488
- };
1489
- return this.safeString(statuses, status, status);
1490
- }
1491
- parseTransaction(transaction, currency = undefined) {
1492
- //
1493
- // withdraw
1494
- //
1495
- // {
1496
- // "code":"A10000",
1497
- // "data": "DR123",
1498
- // "message":"Success"
1499
- // }
1500
- //
1501
- // fetchDepositsWithdrawals
1502
- //
1503
- // {
1504
- // "id": "DR562339304588709888",
1505
- // "type": "COIN_IN",
1506
- // "currency": "XLM",
1507
- // "chain": "XLM",
1508
- // "address": "GCUTK7KHPJC3ZQJ3OMWWFHAK2OXIBRD4LNZQRCCOVE7A2XOPP2K5PU5Q",
1509
- // "addressTag": "1000009",
1510
- // "amount": 1.0,
1511
- // "state": "SUCCESS",
1512
- // "txHash": "39210645748822f8d4ce673c7559aa6622e6e9cdd7073bc0fcae14b1edfda5f4",
1513
- // "createdAt": 1554113737000,
1514
- // "updatedAt": 1601371273000
1515
- // }
1516
- //
1517
- const id = this.safeString2(transaction, 'id', 'data');
1518
- let type = this.safeString(transaction, 'type');
1519
- if (type === 'COIN_IN') {
1520
- type = 'deposit';
1521
- }
1522
- else if (type === 'COIN_OUT') {
1523
- type = 'withdraw';
1524
- }
1525
- const amount = this.safeNumber(transaction, 'amount');
1526
- const address = this.safeString(transaction, 'address');
1527
- const tag = this.safeString(transaction, 'addressTag');
1528
- const txid = this.safeString(transaction, 'txHash');
1529
- const timestamp = this.safeInteger(transaction, 'createdAt');
1530
- const updated = this.safeInteger(transaction, 'updatedAt');
1531
- const currencyId = this.safeString(transaction, 'currency');
1532
- const code = this.safeCurrencyCode(currencyId, currency);
1533
- const status = this.parseTransactionStatus(this.safeString(transaction, 'state'));
1534
- const network = this.safeString(transaction, 'chain');
1535
- return {
1536
- 'info': transaction,
1537
- 'id': id,
1538
- 'currency': code,
1539
- 'amount': amount,
1540
- 'network': network,
1541
- 'address': address,
1542
- 'addressTo': address,
1543
- 'addressFrom': undefined,
1544
- 'tag': tag,
1545
- 'tagTo': tag,
1546
- 'tagFrom': undefined,
1547
- 'status': status,
1548
- 'type': type,
1549
- 'updated': updated,
1550
- 'txid': txid,
1551
- 'timestamp': timestamp,
1552
- 'datetime': this.iso8601(timestamp),
1553
- 'comment': undefined,
1554
- 'internal': undefined,
1555
- 'fee': {
1556
- 'currency': undefined,
1557
- 'cost': undefined,
1558
- 'rate': undefined,
1559
- },
1560
- };
1561
- }
1562
- /**
1563
- * @method
1564
- * @name novadax#fetchMyTrades
1565
- * @description fetch all trades made by the user
1566
- * @see https://doc.novadax.com/en-US/#get-order-history
1567
- * @param {string} symbol unified market symbol
1568
- * @param {int} [since] the earliest time in ms to fetch trades for
1569
- * @param {int} [limit] the maximum number of trades structures to retrieve
1570
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1571
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=trade-structure}
1572
- */
1573
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1574
- await this.loadMarkets();
1575
- const request = {
1576
- // 'orderId': id, // Order ID, string
1577
- // 'symbol': market['id'], // The trading symbol, like BTC_BRL, string
1578
- // 'fromId': fromId, // Search fill id to begin with, string
1579
- // 'toId': toId, // Search fill id to end up with, string
1580
- // 'fromTimestamp': since, // Search order fill time to begin with, in milliseconds, string
1581
- // 'toTimestamp': this.milliseconds (), // Search order fill time to end up with, in milliseconds, string
1582
- // 'limit': limit, // The number of fills to return, default 100, max 100, string
1583
- // 'accountId': subaccountId, // Sub account ID, if not informed, the fills will be return under master account, string
1584
- };
1585
- let market = undefined;
1586
- if (symbol !== undefined) {
1587
- market = this.market(symbol);
1588
- request['symbol'] = market['id'];
1589
- }
1590
- if (limit !== undefined) {
1591
- request['limit'] = limit;
1592
- }
1593
- if (since !== undefined) {
1594
- request['fromTimestamp'] = since;
1595
- }
1596
- const response = await this.privateGetOrdersFills(this.extend(request, params));
1597
- //
1598
- // {
1599
- // "code": "A10000",
1600
- // "data": [
1601
- // {
1602
- // "id": "608717046691139584",
1603
- // "orderId": "608716957545402368",
1604
- // "symbol": "BTC_BRL",
1605
- // "side": "BUY",
1606
- // "amount": "0.0988",
1607
- // "price": "45514.76",
1608
- // "fee": "0.0000988 BTC",
1609
- // "feeAmount": "0.0000988",
1610
- // "feeCurrency": "BTC",
1611
- // "role": "MAKER",
1612
- // "timestamp": 1565171053345
1613
- // },
1614
- // ],
1615
- // "message": "Success"
1616
- // }
1617
- //
1618
- const data = this.safeList(response, 'data', []);
1619
- return this.parseTrades(data, market, since, limit);
1620
- }
1621
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1622
- const request = '/' + this.version + '/' + this.implodeParams(path, params);
1623
- let url = this.urls['api'][api] + request;
1624
- const query = this.omit(params, this.extractParams(path));
1625
- if (api === 'public') {
1626
- if (Object.keys(query).length) {
1627
- url += '?' + this.urlencode(query);
1628
- }
1629
- }
1630
- else if (api === 'private') {
1631
- this.checkRequiredCredentials();
1632
- const timestamp = this.milliseconds().toString();
1633
- headers = {
1634
- 'X-Nova-Access-Key': this.apiKey,
1635
- 'X-Nova-Timestamp': timestamp,
1636
- };
1637
- let queryString = undefined;
1638
- if (method === 'POST') {
1639
- body = this.json(query);
1640
- queryString = this.hash(this.encode(body), md5);
1641
- headers['Content-Type'] = 'application/json';
1642
- }
1643
- else {
1644
- if (Object.keys(query).length) {
1645
- url += '?' + this.urlencode(query);
1646
- }
1647
- queryString = this.urlencode(this.keysort(query));
1648
- }
1649
- const auth = method + "\n" + request + "\n" + queryString + "\n" + timestamp; // eslint-disable-line quotes
1650
- headers['X-Nova-Signature'] = this.hmac(this.encode(auth), this.encode(this.secret), sha256);
1651
- }
1652
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1653
- }
1654
- handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1655
- if (response === undefined) {
1656
- return undefined;
1657
- }
1658
- //
1659
- // {"code":"A10003","data":[],"message":"Authentication failed, Invalid accessKey."}
1660
- //
1661
- const errorCode = this.safeString(response, 'code');
1662
- if (errorCode !== 'A10000') {
1663
- const message = this.safeString(response, 'message');
1664
- const feedback = this.id + ' ' + body;
1665
- this.throwExactlyMatchedException(this.exceptions['exact'], errorCode, feedback);
1666
- this.throwBroadlyMatchedException(this.exceptions['broad'], message, feedback);
1667
- throw new ExchangeError(feedback); // unknown message
1668
- }
1669
- return undefined;
1670
- }
1671
- }