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