ccxt 4.5.30 → 4.5.32

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 (73) hide show
  1. package/README.md +4 -4
  2. package/dist/ccxt.browser.min.js +18 -18
  3. package/dist/cjs/ccxt.js +6 -4
  4. package/dist/cjs/src/aster.js +3802 -0
  5. package/dist/cjs/src/backpack.js +1 -1
  6. package/dist/cjs/src/base/Exchange.js +35 -2
  7. package/dist/cjs/src/base/ws/WsClient.js +1 -0
  8. package/dist/cjs/src/bigone.js +1 -1
  9. package/dist/cjs/src/binance.js +1 -0
  10. package/dist/cjs/src/bingx.js +73 -0
  11. package/dist/cjs/src/cryptomus.js +1 -1
  12. package/dist/cjs/src/gate.js +52 -6
  13. package/dist/cjs/src/hyperliquid.js +9 -1
  14. package/dist/cjs/src/kucoin.js +63 -64
  15. package/dist/cjs/src/okx.js +14 -5
  16. package/dist/cjs/src/pro/apex.js +2 -2
  17. package/dist/cjs/src/pro/ascendex.js +1 -1
  18. package/dist/cjs/src/pro/aster.js +1046 -0
  19. package/dist/cjs/src/pro/bingx.js +1 -1
  20. package/dist/cjs/src/pro/bybit.js +1 -1
  21. package/dist/cjs/src/pro/cryptocom.js +1 -1
  22. package/dist/cjs/src/pro/dydx.js +1 -1
  23. package/dist/cjs/src/pro/htx.js +1 -1
  24. package/dist/cjs/src/pro/hyperliquid.js +1 -1
  25. package/dist/cjs/src/pro/p2b.js +1 -1
  26. package/dist/cjs/src/pro/toobit.js +1 -1
  27. package/js/ccxt.d.ts +8 -5
  28. package/js/ccxt.js +6 -4
  29. package/js/src/abstract/aster.d.ts +88 -0
  30. package/js/src/abstract/binance.d.ts +1 -0
  31. package/js/src/abstract/binancecoinm.d.ts +1 -0
  32. package/js/src/abstract/binanceus.d.ts +1 -0
  33. package/js/src/abstract/binanceusdm.d.ts +1 -0
  34. package/js/src/abstract/kucoin.d.ts +2 -0
  35. package/js/src/abstract/kucoinfutures.d.ts +2 -0
  36. package/js/src/aster.d.ts +563 -0
  37. package/js/src/aster.js +3801 -0
  38. package/js/src/backpack.js +1 -1
  39. package/js/src/base/Exchange.d.ts +4 -0
  40. package/js/src/base/Exchange.js +35 -1
  41. package/js/src/base/ws/WsClient.js +1 -0
  42. package/js/src/bigone.js +1 -1
  43. package/js/src/binance.d.ts +1 -1
  44. package/js/src/binance.js +1 -0
  45. package/js/src/bingx.d.ts +12 -1
  46. package/js/src/bingx.js +73 -0
  47. package/js/src/cryptomus.js +1 -1
  48. package/js/src/exmo.d.ts +1 -1
  49. package/js/src/gate.js +52 -6
  50. package/js/src/hyperliquid.d.ts +1 -0
  51. package/js/src/hyperliquid.js +9 -1
  52. package/js/src/kucoin.d.ts +5 -3
  53. package/js/src/kucoin.js +63 -64
  54. package/js/src/okx.js +14 -5
  55. package/js/src/pro/apex.js +2 -2
  56. package/js/src/pro/ascendex.js +1 -1
  57. package/js/src/pro/aster.d.ts +273 -0
  58. package/js/src/pro/aster.js +1045 -0
  59. package/js/src/pro/bingx.js +1 -1
  60. package/js/src/pro/bybit.js +1 -1
  61. package/js/src/pro/cryptocom.js +1 -1
  62. package/js/src/pro/dydx.js +1 -1
  63. package/js/src/pro/htx.js +1 -1
  64. package/js/src/pro/hyperliquid.js +1 -1
  65. package/js/src/pro/p2b.js +1 -1
  66. package/js/src/pro/toobit.js +1 -1
  67. package/package.json +1 -1
  68. package/dist/cjs/src/oceanex.js +0 -1125
  69. package/js/src/abstract/oceanex.d.ts +0 -30
  70. package/js/src/oceanex.d.ts +0 -231
  71. package/js/src/oceanex.js +0 -1124
  72. /package/dist/cjs/src/abstract/{oceanex.js → aster.js} +0 -0
  73. /package/js/src/abstract/{oceanex.js → aster.js} +0 -0
@@ -1,1125 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var oceanex$1 = require('./abstract/oceanex.js');
6
- var errors = require('./base/errors.js');
7
- var number = require('./base/functions/number.js');
8
- var sha256 = require('./static_dependencies/noble-hashes/sha256.js');
9
- var rsa = require('./base/functions/rsa.js');
10
-
11
- // ----------------------------------------------------------------------------
12
- // ---------------------------------------------------------------------------
13
- /**
14
- * @class oceanex
15
- * @augments Exchange
16
- */
17
- class oceanex extends oceanex$1["default"] {
18
- describe() {
19
- return this.deepExtend(super.describe(), {
20
- 'id': 'oceanex',
21
- 'name': 'OceanEx',
22
- 'countries': ['BS'],
23
- 'version': 'v1',
24
- 'rateLimit': 3000,
25
- 'urls': {
26
- 'logo': 'https://user-images.githubusercontent.com/1294454/58385970-794e2d80-8001-11e9-889c-0567cd79b78e.jpg',
27
- 'api': {
28
- 'rest': 'https://api.oceanex.pro',
29
- },
30
- 'www': 'https://www.oceanex.pro.com',
31
- 'doc': 'https://api.oceanex.pro/doc/v1',
32
- 'referral': 'https://oceanex.pro/signup?referral=VE24QX',
33
- },
34
- 'has': {
35
- 'CORS': undefined,
36
- 'spot': true,
37
- 'margin': false,
38
- 'swap': undefined,
39
- 'future': undefined,
40
- 'option': undefined,
41
- 'cancelAllOrders': true,
42
- 'cancelOrder': true,
43
- 'cancelOrders': true,
44
- 'createMarketOrder': true,
45
- 'createOrder': true,
46
- 'fetchBalance': true,
47
- 'fetchBorrowRateHistories': false,
48
- 'fetchBorrowRateHistory': false,
49
- 'fetchClosedOrders': true,
50
- 'fetchCrossBorrowRate': false,
51
- 'fetchCrossBorrowRates': false,
52
- 'fetchCurrencies': false,
53
- 'fetchDepositAddress': 'emulated',
54
- 'fetchDepositAddresses': undefined,
55
- 'fetchDepositAddressesByNetwork': true,
56
- 'fetchFundingRateHistory': false,
57
- 'fetchFundingRates': false,
58
- 'fetchIsolatedBorrowRate': false,
59
- 'fetchIsolatedBorrowRates': false,
60
- 'fetchMarkets': true,
61
- 'fetchOHLCV': true,
62
- 'fetchOpenOrders': true,
63
- 'fetchOrder': true,
64
- 'fetchOrderBook': true,
65
- 'fetchOrderBooks': true,
66
- 'fetchOrders': true,
67
- 'fetchTicker': true,
68
- 'fetchTickers': true,
69
- 'fetchTime': true,
70
- 'fetchTrades': true,
71
- 'fetchTradingFee': false,
72
- 'fetchTradingFees': true,
73
- 'fetchTransactionFees': undefined,
74
- },
75
- 'timeframes': {
76
- '1m': '1',
77
- '5m': '5',
78
- '15m': '15',
79
- '30m': '30',
80
- '1h': '60',
81
- '2h': '120',
82
- '4h': '240',
83
- '6h': '360',
84
- '12h': '720',
85
- '1d': '1440',
86
- '3d': '4320',
87
- '1w': '10080',
88
- },
89
- 'api': {
90
- 'public': {
91
- 'get': [
92
- 'markets',
93
- 'tickers/{pair}',
94
- 'tickers_multi',
95
- 'order_book',
96
- 'order_book/multi',
97
- 'fees/trading',
98
- 'trades',
99
- 'timestamp',
100
- ],
101
- 'post': [
102
- 'k',
103
- ],
104
- },
105
- 'private': {
106
- 'get': [
107
- 'key',
108
- 'members/me',
109
- 'orders',
110
- 'orders/filter',
111
- ],
112
- 'post': [
113
- 'orders',
114
- 'orders/multi',
115
- 'order/delete',
116
- 'order/delete/multi',
117
- 'orders/clear',
118
- '/withdraws/special/new',
119
- '/deposit_address',
120
- '/deposit_addresses',
121
- '/deposit_history',
122
- '/withdraw_history',
123
- ],
124
- },
125
- },
126
- 'fees': {
127
- 'trading': {
128
- 'tierBased': false,
129
- 'percentage': true,
130
- 'maker': this.parseNumber('0.001'),
131
- 'taker': this.parseNumber('0.001'),
132
- },
133
- },
134
- 'commonCurrencies': {
135
- 'PLA': 'Plair',
136
- },
137
- 'precisionMode': number.TICK_SIZE,
138
- 'features': {
139
- 'spot': {
140
- 'sandbox': false,
141
- 'createOrder': {
142
- 'marginMode': false,
143
- 'triggerPrice': true,
144
- 'triggerDirection': true,
145
- 'triggerPriceType': undefined,
146
- 'stopLossPrice': false,
147
- 'takeProfitPrice': false,
148
- 'attachedStopLossTakeProfit': undefined,
149
- 'timeInForce': {
150
- 'IOC': false,
151
- 'FOK': false,
152
- 'PO': false,
153
- 'GTD': false,
154
- },
155
- 'hedged': false,
156
- 'trailing': false,
157
- 'leverage': false,
158
- 'marketBuyByCost': false,
159
- 'marketBuyRequiresPrice': false,
160
- 'selfTradePrevention': false,
161
- 'iceberg': false,
162
- },
163
- 'createOrders': undefined,
164
- 'fetchMyTrades': undefined,
165
- 'fetchOrder': {
166
- 'marginMode': false,
167
- 'trigger': false,
168
- 'trailing': false,
169
- 'symbolRequired': false,
170
- },
171
- 'fetchOpenOrders': {
172
- 'marginMode': false,
173
- 'limit': 100,
174
- 'trigger': false,
175
- 'trailing': false,
176
- 'symbolRequired': false,
177
- },
178
- 'fetchOrders': {
179
- 'marginMode': false,
180
- 'limit': 100,
181
- 'daysBack': 100000,
182
- 'untilDays': 100000,
183
- 'trigger': false,
184
- 'trailing': false,
185
- 'symbolRequired': false,
186
- },
187
- 'fetchClosedOrders': {
188
- 'marginMode': false,
189
- 'limit': 100,
190
- 'daysBack': 100000,
191
- 'daysBackCanceled': 1,
192
- 'untilDays': 100000,
193
- 'trigger': false,
194
- 'trailing': false,
195
- 'symbolRequired': false,
196
- },
197
- 'fetchOHLCV': {
198
- 'limit': 100,
199
- },
200
- },
201
- // todo implement swap
202
- 'swap': {
203
- 'linear': undefined,
204
- 'inverse': undefined,
205
- },
206
- 'future': {
207
- 'linear': undefined,
208
- 'inverse': undefined,
209
- },
210
- },
211
- 'exceptions': {
212
- 'codes': {
213
- '-1': errors.BadRequest,
214
- '-2': errors.BadRequest,
215
- '1001': errors.BadRequest,
216
- '1004': errors.ArgumentsRequired,
217
- '1006': errors.AuthenticationError,
218
- '1008': errors.AuthenticationError,
219
- '1010': errors.AuthenticationError,
220
- '1011': errors.PermissionDenied,
221
- '2001': errors.AuthenticationError,
222
- '2002': errors.InvalidOrder,
223
- '2004': errors.OrderNotFound,
224
- '9003': errors.PermissionDenied,
225
- },
226
- 'exact': {
227
- 'market does not have a valid value': errors.BadRequest,
228
- 'side does not have a valid value': errors.BadRequest,
229
- 'Account::AccountError: Cannot lock funds': errors.InsufficientFunds,
230
- 'The account does not exist': errors.AuthenticationError,
231
- },
232
- },
233
- });
234
- }
235
- /**
236
- * @method
237
- * @name oceanex#fetchMarkets
238
- * @description retrieves data on all markets for oceanex
239
- * @see https://api.oceanex.pro/doc/v1/#markets-post
240
- * @param {object} [params] extra parameters specific to the exchange API endpoint
241
- * @returns {object[]} an array of objects representing market data
242
- */
243
- async fetchMarkets(params = {}) {
244
- const request = { 'show_details': true };
245
- const response = await this.publicGetMarkets(this.extend(request, params));
246
- //
247
- // {
248
- // "id": "xtzusdt",
249
- // "name": "XTZ/USDT",
250
- // "ask_precision": "8",
251
- // "bid_precision": "8",
252
- // "enabled": true,
253
- // "price_precision": "4",
254
- // "amount_precision": "3",
255
- // "usd_precision": "4",
256
- // "minimum_trading_amount": "1.0"
257
- // },
258
- //
259
- const markets = this.safeValue(response, 'data', []);
260
- return this.parseMarkets(markets);
261
- }
262
- parseMarket(market) {
263
- const id = this.safeValue(market, 'id');
264
- const name = this.safeValue(market, 'name');
265
- let [baseId, quoteId] = name.split('/');
266
- const base = this.safeCurrencyCode(baseId);
267
- const quote = this.safeCurrencyCode(quoteId);
268
- baseId = baseId.toLowerCase();
269
- quoteId = quoteId.toLowerCase();
270
- const symbol = base + '/' + quote;
271
- return {
272
- 'id': id,
273
- 'symbol': symbol,
274
- 'base': base,
275
- 'quote': quote,
276
- 'settle': undefined,
277
- 'baseId': baseId,
278
- 'quoteId': quoteId,
279
- 'settleId': undefined,
280
- 'type': 'spot',
281
- 'spot': true,
282
- 'margin': false,
283
- 'swap': false,
284
- 'future': false,
285
- 'option': false,
286
- 'active': undefined,
287
- 'contract': false,
288
- 'linear': undefined,
289
- 'inverse': undefined,
290
- 'contractSize': undefined,
291
- 'expiry': undefined,
292
- 'expiryDatetime': undefined,
293
- 'strike': undefined,
294
- 'optionType': undefined,
295
- 'precision': {
296
- 'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'amount_precision'))),
297
- 'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'price_precision'))),
298
- },
299
- 'limits': {
300
- 'leverage': {
301
- 'min': undefined,
302
- 'max': undefined,
303
- },
304
- 'amount': {
305
- 'min': undefined,
306
- 'max': undefined,
307
- },
308
- 'price': {
309
- 'min': undefined,
310
- 'max': undefined,
311
- },
312
- 'cost': {
313
- 'min': this.safeNumber(market, 'minimum_trading_amount'),
314
- 'max': undefined,
315
- },
316
- },
317
- 'created': undefined,
318
- 'info': market,
319
- };
320
- }
321
- /**
322
- * @method
323
- * @name oceanex#fetchTicker
324
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
325
- * @see https://api.oceanex.pro/doc/v1/#ticker-post
326
- * @param {string} symbol unified symbol of the market to fetch the ticker for
327
- * @param {object} [params] extra parameters specific to the exchange API endpoint
328
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/?id=ticker-structure}
329
- */
330
- async fetchTicker(symbol, params = {}) {
331
- await this.loadMarkets();
332
- const market = this.market(symbol);
333
- const request = {
334
- 'pair': market['id'],
335
- };
336
- const response = await this.publicGetTickersPair(this.extend(request, params));
337
- //
338
- // {
339
- // "code":0,
340
- // "message":"Operation successful",
341
- // "data": {
342
- // "at":1559431729,
343
- // "ticker": {
344
- // "buy":"0.0065",
345
- // "sell":"0.00677",
346
- // "low":"0.00677",
347
- // "high":"0.00677",
348
- // "last":"0.00677",
349
- // "vol":"2000.0"
350
- // }
351
- // }
352
- // }
353
- //
354
- const data = this.safeDict(response, 'data', {});
355
- return this.parseTicker(data, market);
356
- }
357
- /**
358
- * @method
359
- * @name oceanex#fetchTickers
360
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
361
- * @see https://api.oceanex.pro/doc/v1/#multiple-tickers-post
362
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
363
- * @param {object} [params] extra parameters specific to the exchange API endpoint
364
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/?id=ticker-structure}
365
- */
366
- async fetchTickers(symbols = undefined, params = {}) {
367
- await this.loadMarkets();
368
- symbols = this.marketSymbols(symbols);
369
- if (symbols === undefined) {
370
- symbols = this.symbols;
371
- }
372
- const marketIds = this.marketIds(symbols);
373
- const request = { 'markets': marketIds };
374
- const response = await this.publicGetTickersMulti(this.extend(request, params));
375
- //
376
- // {
377
- // "code":0,
378
- // "message":"Operation successful",
379
- // "data": {
380
- // "at":1559431729,
381
- // "ticker": {
382
- // "buy":"0.0065",
383
- // "sell":"0.00677",
384
- // "low":"0.00677",
385
- // "high":"0.00677",
386
- // "last":"0.00677",
387
- // "vol":"2000.0"
388
- // }
389
- // }
390
- // }
391
- //
392
- const data = this.safeValue(response, 'data', []);
393
- const result = {};
394
- for (let i = 0; i < data.length; i++) {
395
- const ticker = data[i];
396
- const marketId = this.safeString(ticker, 'market');
397
- const market = this.safeMarket(marketId);
398
- const symbol = market['symbol'];
399
- result[symbol] = this.parseTicker(ticker, market);
400
- }
401
- return this.filterByArrayTickers(result, 'symbol', symbols);
402
- }
403
- parseTicker(data, market = undefined) {
404
- //
405
- // {
406
- // "at":1559431729,
407
- // "ticker": {
408
- // "buy":"0.0065",
409
- // "sell":"0.00677",
410
- // "low":"0.00677",
411
- // "high":"0.00677",
412
- // "last":"0.00677",
413
- // "vol":"2000.0"
414
- // }
415
- // }
416
- //
417
- const ticker = this.safeValue(data, 'ticker', {});
418
- const timestamp = this.safeTimestamp(data, 'at');
419
- const symbol = this.safeSymbol(undefined, market);
420
- return this.safeTicker({
421
- 'symbol': symbol,
422
- 'timestamp': timestamp,
423
- 'datetime': this.iso8601(timestamp),
424
- 'high': this.safeString(ticker, 'high'),
425
- 'low': this.safeString(ticker, 'low'),
426
- 'bid': this.safeString(ticker, 'buy'),
427
- 'bidVolume': undefined,
428
- 'ask': this.safeString(ticker, 'sell'),
429
- 'askVolume': undefined,
430
- 'vwap': undefined,
431
- 'open': undefined,
432
- 'close': this.safeString(ticker, 'last'),
433
- 'last': this.safeString(ticker, 'last'),
434
- 'previousClose': undefined,
435
- 'change': undefined,
436
- 'percentage': undefined,
437
- 'average': undefined,
438
- 'baseVolume': this.safeString(ticker, 'volume'),
439
- 'quoteVolume': undefined,
440
- 'info': ticker,
441
- }, market);
442
- }
443
- /**
444
- * @method
445
- * @name oceanex#fetchOrderBook
446
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
447
- * @see https://api.oceanex.pro/doc/v1/#order-book-post
448
- * @param {string} symbol unified symbol of the market to fetch the order book for
449
- * @param {int} [limit] the maximum amount of order book entries to return
450
- * @param {object} [params] extra parameters specific to the exchange API endpoint
451
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbols
452
- */
453
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
454
- await this.loadMarkets();
455
- const market = this.market(symbol);
456
- const request = {
457
- 'market': market['id'],
458
- };
459
- if (limit !== undefined) {
460
- request['limit'] = limit;
461
- }
462
- const response = await this.publicGetOrderBook(this.extend(request, params));
463
- //
464
- // {
465
- // "code":0,
466
- // "message":"Operation successful",
467
- // "data": {
468
- // "timestamp":1559433057,
469
- // "asks": [
470
- // ["100.0","20.0"],
471
- // ["4.74","2000.0"],
472
- // ["1.74","4000.0"],
473
- // ],
474
- // "bids":[
475
- // ["0.0065","5482873.4"],
476
- // ["0.00649","4781956.2"],
477
- // ["0.00648","2876006.8"],
478
- // ],
479
- // }
480
- // }
481
- //
482
- const orderbook = this.safeValue(response, 'data', {});
483
- const timestamp = this.safeTimestamp(orderbook, 'timestamp');
484
- return this.parseOrderBook(orderbook, symbol, timestamp);
485
- }
486
- /**
487
- * @method
488
- * @name oceanex#fetchOrderBooks
489
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data for multiple markets
490
- * @see https://api.oceanex.pro/doc/v1/#multiple-order-books-post
491
- * @param {string[]|undefined} symbols list of unified market symbols, all symbols fetched if undefined, default is undefined
492
- * @param {int} [limit] max number of entries per orderbook to return, default is undefined
493
- * @param {object} [params] extra parameters specific to the exchange API endpoint
494
- * @returns {object} a dictionary of [order book structures]{@link https://docs.ccxt.com/?id=order-book-structure} indexed by market symbol
495
- */
496
- async fetchOrderBooks(symbols = undefined, limit = undefined, params = {}) {
497
- await this.loadMarkets();
498
- if (symbols === undefined) {
499
- symbols = this.symbols;
500
- }
501
- const marketIds = this.marketIds(symbols);
502
- const request = {
503
- 'markets': marketIds,
504
- };
505
- if (limit !== undefined) {
506
- request['limit'] = limit;
507
- }
508
- const response = await this.publicGetOrderBookMulti(this.extend(request, params));
509
- //
510
- // {
511
- // "code":0,
512
- // "message":"Operation successful",
513
- // "data": [
514
- // {
515
- // "timestamp":1559433057,
516
- // "market": "bagvet",
517
- // "asks": [
518
- // ["100.0","20.0"],
519
- // ["4.74","2000.0"],
520
- // ["1.74","4000.0"],
521
- // ],
522
- // "bids":[
523
- // ["0.0065","5482873.4"],
524
- // ["0.00649","4781956.2"],
525
- // ["0.00648","2876006.8"],
526
- // ],
527
- // },
528
- // ...,
529
- // ],
530
- // }
531
- //
532
- const data = this.safeValue(response, 'data', []);
533
- const result = {};
534
- for (let i = 0; i < data.length; i++) {
535
- const orderbook = data[i];
536
- const marketId = this.safeString(orderbook, 'market');
537
- const symbol = this.safeSymbol(marketId);
538
- const timestamp = this.safeTimestamp(orderbook, 'timestamp');
539
- result[symbol] = this.parseOrderBook(orderbook, symbol, timestamp);
540
- }
541
- return result;
542
- }
543
- /**
544
- * @method
545
- * @name oceanex#fetchTrades
546
- * @description get the list of most recent trades for a particular symbol
547
- * @see https://api.oceanex.pro/doc/v1/#trades-post
548
- * @param {string} symbol unified symbol of the market to fetch trades for
549
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
550
- * @param {int} [limit] the maximum amount of trades to fetch
551
- * @param {object} [params] extra parameters specific to the exchange API endpoint
552
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/?id=public-trades}
553
- */
554
- async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
555
- await this.loadMarkets();
556
- const market = this.market(symbol);
557
- const request = {
558
- 'market': market['id'],
559
- };
560
- if (limit !== undefined) {
561
- request['limit'] = Math.min(limit, 1000);
562
- }
563
- const response = await this.publicGetTrades(this.extend(request, params));
564
- //
565
- // {
566
- // "code":0,
567
- // "message":"Operation successful",
568
- // "data": [
569
- // {
570
- // "id":220247666,
571
- // "price":"3098.62",
572
- // "volume":"0.00196",
573
- // "funds":"6.0732952",
574
- // "market":"ethusdt",
575
- // "created_at":"2022-04-19T19:03:15Z",
576
- // "created_on":1650394994,
577
- // "side":"bid"
578
- // },
579
- // ]
580
- // }
581
- //
582
- const data = this.safeList(response, 'data');
583
- return this.parseTrades(data, market, since, limit);
584
- }
585
- parseTrade(trade, market = undefined) {
586
- //
587
- // fetchTrades (public)
588
- //
589
- // {
590
- // "id":220247666,
591
- // "price":"3098.62",
592
- // "volume":"0.00196",
593
- // "funds":"6.0732952",
594
- // "market":"ethusdt",
595
- // "created_at":"2022-04-19T19:03:15Z",
596
- // "created_on":1650394995,
597
- // "side":"bid"
598
- // }
599
- //
600
- let side = this.safeValue(trade, 'side');
601
- if (side === 'bid') {
602
- side = 'buy';
603
- }
604
- else if (side === 'ask') {
605
- side = 'sell';
606
- }
607
- const marketId = this.safeValue(trade, 'market');
608
- const symbol = this.safeSymbol(marketId, market);
609
- let timestamp = this.safeTimestamp(trade, 'created_on');
610
- if (timestamp === undefined) {
611
- timestamp = this.parse8601(this.safeString(trade, 'created_at'));
612
- }
613
- const priceString = this.safeString(trade, 'price');
614
- const amountString = this.safeString(trade, 'volume');
615
- return this.safeTrade({
616
- 'info': trade,
617
- 'timestamp': timestamp,
618
- 'datetime': this.iso8601(timestamp),
619
- 'symbol': symbol,
620
- 'id': this.safeString(trade, 'id'),
621
- 'order': undefined,
622
- 'type': 'limit',
623
- 'takerOrMaker': undefined,
624
- 'side': side,
625
- 'price': priceString,
626
- 'amount': amountString,
627
- 'cost': undefined,
628
- 'fee': undefined,
629
- }, market);
630
- }
631
- /**
632
- * @method
633
- * @name oceanex#fetchTime
634
- * @description fetches the current integer timestamp in milliseconds from the exchange server
635
- * @see https://api.oceanex.pro/doc/v1/#api-server-time-post
636
- * @param {object} [params] extra parameters specific to the exchange API endpoint
637
- * @returns {int} the current integer timestamp in milliseconds from the exchange server
638
- */
639
- async fetchTime(params = {}) {
640
- const response = await this.publicGetTimestamp(params);
641
- //
642
- // {"code":0,"message":"Operation successful","data":1559433420}
643
- //
644
- return this.safeTimestamp(response, 'data');
645
- }
646
- /**
647
- * @method
648
- * @name oceanex#fetchTradingFees
649
- * @description fetch the trading fees for multiple markets
650
- * @see https://api.oceanex.pro/doc/v1/#trading-fees-post
651
- * @param {object} [params] extra parameters specific to the exchange API endpoint
652
- * @returns {object} a dictionary of [fee structures]{@link https://docs.ccxt.com/?id=fee-structure} indexed by market symbols
653
- */
654
- async fetchTradingFees(params = {}) {
655
- const response = await this.publicGetFeesTrading(params);
656
- const data = this.safeValue(response, 'data', []);
657
- const result = {};
658
- for (let i = 0; i < data.length; i++) {
659
- const group = data[i];
660
- const maker = this.safeValue(group, 'ask_fee', {});
661
- const taker = this.safeValue(group, 'bid_fee', {});
662
- const marketId = this.safeString(group, 'market');
663
- const symbol = this.safeSymbol(marketId);
664
- result[symbol] = {
665
- 'info': group,
666
- 'symbol': symbol,
667
- 'maker': this.safeNumber(maker, 'value'),
668
- 'taker': this.safeNumber(taker, 'value'),
669
- 'percentage': true,
670
- };
671
- }
672
- return result;
673
- }
674
- async fetchKey(params = {}) {
675
- const response = await this.privateGetKey(params);
676
- return this.safeValue(response, 'data');
677
- }
678
- parseBalance(response) {
679
- const data = this.safeValue(response, 'data');
680
- const balances = this.safeValue(data, 'accounts', []);
681
- const result = { 'info': response };
682
- for (let i = 0; i < balances.length; i++) {
683
- const balance = balances[i];
684
- const currencyId = this.safeValue(balance, 'currency');
685
- const code = this.safeCurrencyCode(currencyId);
686
- const account = this.account();
687
- account['free'] = this.safeString(balance, 'balance');
688
- account['used'] = this.safeString(balance, 'locked');
689
- result[code] = account;
690
- }
691
- return this.safeBalance(result);
692
- }
693
- /**
694
- * @method
695
- * @name oceanex#fetchBalance
696
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
697
- * @see https://api.oceanex.pro/doc/v1/#account-info-post
698
- * @param {object} [params] extra parameters specific to the exchange API endpoint
699
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/?id=balance-structure}
700
- */
701
- async fetchBalance(params = {}) {
702
- await this.loadMarkets();
703
- const response = await this.privateGetMembersMe(params);
704
- return this.parseBalance(response);
705
- }
706
- /**
707
- * @method
708
- * @name oceanex#createOrder
709
- * @description create a trade order
710
- * @see https://api.oceanex.pro/doc/v1/#new-order-post
711
- * @param {string} symbol unified symbol of the market to create an order in
712
- * @param {string} type 'market' or 'limit'
713
- * @param {string} side 'buy' or 'sell'
714
- * @param {float} amount how much of currency you want to trade in units of base currency
715
- * @param {float} [price] the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
716
- * @param {object} [params] extra parameters specific to the exchange API endpoint
717
- * @returns {object} an [order structure]{@link https://docs.ccxt.com/?id=order-structure}
718
- */
719
- async createOrder(symbol, type, side, amount, price = undefined, params = {}) {
720
- await this.loadMarkets();
721
- const market = this.market(symbol);
722
- const request = {
723
- 'market': market['id'],
724
- 'side': side,
725
- 'ord_type': type,
726
- 'volume': this.amountToPrecision(symbol, amount),
727
- };
728
- if (type === 'limit') {
729
- request['price'] = this.priceToPrecision(symbol, price);
730
- }
731
- const response = await this.privatePostOrders(this.extend(request, params));
732
- const data = this.safeDict(response, 'data');
733
- return this.parseOrder(data, market);
734
- }
735
- /**
736
- * @method
737
- * @name oceanex#fetchOrder
738
- * @description fetches information on an order made by the user
739
- * @see https://api.oceanex.pro/doc/v1/#order-status-get
740
- * @param {string} id order id
741
- * @param {string} symbol unified symbol of the market the order was made in
742
- * @param {object} [params] extra parameters specific to the exchange API endpoint
743
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
744
- */
745
- async fetchOrder(id, symbol = undefined, params = {}) {
746
- await this.loadMarkets();
747
- let market = undefined;
748
- if (symbol !== undefined) {
749
- market = this.market(symbol);
750
- }
751
- const ids = [id];
752
- const request = { 'ids': ids };
753
- const response = await this.privateGetOrders(this.extend(request, params));
754
- const data = this.safeValue(response, 'data');
755
- const dataLength = data.length;
756
- if (data === undefined) {
757
- throw new errors.OrderNotFound(this.id + ' could not found matching order');
758
- }
759
- if (Array.isArray(id)) {
760
- const orders = this.parseOrders(data, market);
761
- return orders[0];
762
- }
763
- if (dataLength === 0) {
764
- throw new errors.OrderNotFound(this.id + ' could not found matching order');
765
- }
766
- return this.parseOrder(data[0], market);
767
- }
768
- /**
769
- * @method
770
- * @name oceanex#fetchOpenOrders
771
- * @description fetch all unfilled currently open orders
772
- * @see https://api.oceanex.pro/doc/v1/#order-status-get
773
- * @param {string} symbol unified market symbol
774
- * @param {int} [since] the earliest time in ms to fetch open orders for
775
- * @param {int} [limit] the maximum number of open orders structures to retrieve
776
- * @param {object} [params] extra parameters specific to the exchange API endpoint
777
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
778
- */
779
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
780
- const request = {
781
- 'states': ['wait'],
782
- };
783
- return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
784
- }
785
- /**
786
- * @method
787
- * @name oceanex#fetchClosedOrders
788
- * @description fetches information on multiple closed orders made by the user
789
- * @see https://api.oceanex.pro/doc/v1/#order-status-get
790
- * @param {string} symbol unified market symbol of the market orders were made in
791
- * @param {int} [since] the earliest time in ms to fetch orders for
792
- * @param {int} [limit] the maximum number of order structures to retrieve
793
- * @param {object} [params] extra parameters specific to the exchange API endpoint
794
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
795
- */
796
- async fetchClosedOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
797
- const request = {
798
- 'states': ['done', 'cancel'],
799
- };
800
- return await this.fetchOrders(symbol, since, limit, this.extend(request, params));
801
- }
802
- /**
803
- * @method
804
- * @name oceanex#fetchOrders
805
- * @description fetches information on multiple orders made by the user
806
- * @see https://api.oceanex.pro/doc/v1/#order-status-with-filters-post
807
- * @param {string} symbol unified market symbol of the market orders were made in
808
- * @param {int} [since] the earliest time in ms to fetch orders for
809
- * @param {int} [limit] the maximum number of order structures to retrieve
810
- * @param {object} [params] extra parameters specific to the exchange API endpoint
811
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
812
- */
813
- async fetchOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
814
- if (symbol === undefined) {
815
- throw new errors.ArgumentsRequired(this.id + ' fetchOrders() requires a symbol argument');
816
- }
817
- await this.loadMarkets();
818
- const market = this.market(symbol);
819
- const states = this.safeValue(params, 'states', ['wait', 'done', 'cancel']);
820
- const query = this.omit(params, 'states');
821
- const request = {
822
- 'market': market['id'],
823
- 'states': states,
824
- 'need_price': 'True',
825
- };
826
- if (limit !== undefined) {
827
- request['limit'] = limit;
828
- }
829
- const response = await this.privateGetOrdersFilter(this.extend(request, query));
830
- const data = this.safeValue(response, 'data', []);
831
- let result = [];
832
- for (let i = 0; i < data.length; i++) {
833
- const orders = this.safeValue(data[i], 'orders', []);
834
- const status = this.parseOrderStatus(this.safeValue(data[i], 'state'));
835
- const parsedOrders = this.parseOrders(orders, market, since, limit, { 'status': status });
836
- result = this.arrayConcat(result, parsedOrders);
837
- }
838
- return result;
839
- }
840
- parseOHLCV(ohlcv, market = undefined) {
841
- // [
842
- // 1559232000,
843
- // 8889.22,
844
- // 9028.52,
845
- // 8889.22,
846
- // 9028.52
847
- // 0.3121
848
- // ]
849
- return [
850
- this.safeTimestamp(ohlcv, 0),
851
- this.safeNumber(ohlcv, 1),
852
- this.safeNumber(ohlcv, 2),
853
- this.safeNumber(ohlcv, 3),
854
- this.safeNumber(ohlcv, 4),
855
- this.safeNumber(ohlcv, 5),
856
- ];
857
- }
858
- /**
859
- * @method
860
- * @name oceanex#fetchOHLCV
861
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
862
- * @see https://api.oceanex.pro/doc/v1/#k-line-post
863
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
864
- * @param {string} timeframe the length of time each candle represents
865
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
866
- * @param {int} [limit] the maximum amount of candles to fetch
867
- * @param {object} [params] extra parameters specific to the exchange API endpoint
868
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
869
- */
870
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
871
- await this.loadMarkets();
872
- const market = this.market(symbol);
873
- const request = {
874
- 'market': market['id'],
875
- 'period': this.safeString(this.timeframes, timeframe, timeframe),
876
- };
877
- if (since !== undefined) {
878
- request['timestamp'] = since;
879
- }
880
- if (limit !== undefined) {
881
- request['limit'] = Math.min(limit, 10000);
882
- }
883
- const response = await this.publicPostK(this.extend(request, params));
884
- const ohlcvs = this.safeList(response, 'data', []);
885
- return this.parseOHLCVs(ohlcvs, market, timeframe, since, limit);
886
- }
887
- parseOrder(order, market = undefined) {
888
- //
889
- // {
890
- // "created_at": "2019-01-18T00:38:18Z",
891
- // "trades_count": 0,
892
- // "remaining_volume": "0.2",
893
- // "price": "1001.0",
894
- // "created_on": "1547771898",
895
- // "side": "buy",
896
- // "volume": "0.2",
897
- // "state": "wait",
898
- // "ord_type": "limit",
899
- // "avg_price": "0.0",
900
- // "executed_volume": "0.0",
901
- // "id": 473797,
902
- // "market": "veteth"
903
- // }
904
- //
905
- const status = this.parseOrderStatus(this.safeValue(order, 'state'));
906
- const marketId = this.safeString2(order, 'market', 'market_id');
907
- const symbol = this.safeSymbol(marketId, market);
908
- let timestamp = this.safeTimestamp(order, 'created_on');
909
- if (timestamp === undefined) {
910
- timestamp = this.parse8601(this.safeString(order, 'created_at'));
911
- }
912
- const price = this.safeString(order, 'price');
913
- const average = this.safeString(order, 'avg_price');
914
- const amount = this.safeString(order, 'volume');
915
- const remaining = this.safeString(order, 'remaining_volume');
916
- const filled = this.safeString(order, 'executed_volume');
917
- return this.safeOrder({
918
- 'info': order,
919
- 'id': this.safeString(order, 'id'),
920
- 'clientOrderId': undefined,
921
- 'timestamp': timestamp,
922
- 'datetime': this.iso8601(timestamp),
923
- 'lastTradeTimestamp': undefined,
924
- 'symbol': symbol,
925
- 'type': this.safeValue(order, 'ord_type'),
926
- 'timeInForce': undefined,
927
- 'postOnly': undefined,
928
- 'side': this.safeValue(order, 'side'),
929
- 'price': price,
930
- 'triggerPrice': undefined,
931
- 'average': average,
932
- 'amount': amount,
933
- 'remaining': remaining,
934
- 'filled': filled,
935
- 'status': status,
936
- 'cost': undefined,
937
- 'trades': undefined,
938
- 'fee': undefined,
939
- }, market);
940
- }
941
- parseOrderStatus(status) {
942
- const statuses = {
943
- 'wait': 'open',
944
- 'done': 'closed',
945
- 'cancel': 'canceled',
946
- };
947
- return this.safeString(statuses, status, status);
948
- }
949
- /**
950
- * @method
951
- * @name oceanex#cancelOrder
952
- * @description cancels an open order
953
- * @see https://api.oceanex.pro/doc/v1/#cancel-order-post
954
- * @param {string} id order id
955
- * @param {string} symbol not used by oceanex cancelOrder ()
956
- * @param {object} [params] extra parameters specific to the exchange API endpoint
957
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/?id=order-structure}
958
- */
959
- async cancelOrder(id, symbol = undefined, params = {}) {
960
- await this.loadMarkets();
961
- const response = await this.privatePostOrderDelete(this.extend({ 'id': id }, params));
962
- const data = this.safeDict(response, 'data');
963
- return this.parseOrder(data);
964
- }
965
- /**
966
- * @method
967
- * @name oceanex#cancelOrders
968
- * @description cancel multiple orders
969
- * @see https://api.oceanex.pro/doc/v1/#cancel-multiple-orders-post
970
- * @param {string[]} ids order ids
971
- * @param {string} symbol not used by oceanex cancelOrders ()
972
- * @param {object} [params] extra parameters specific to the exchange API endpoint
973
- * @returns {object} an list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
974
- */
975
- async cancelOrders(ids, symbol = undefined, params = {}) {
976
- await this.loadMarkets();
977
- const response = await this.privatePostOrderDeleteMulti(this.extend({ 'ids': ids }, params));
978
- const data = this.safeList(response, 'data');
979
- return this.parseOrders(data);
980
- }
981
- /**
982
- * @method
983
- * @name oceanex#cancelAllOrders
984
- * @description cancel all open orders
985
- * @see https://api.oceanex.pro/doc/v1/#cancel-all-orders-post
986
- * @param {string} symbol unified market symbol, only orders in the market of this symbol are cancelled when symbol is not undefined
987
- * @param {object} [params] extra parameters specific to the exchange API endpoint
988
- * @returns {object[]} a list of [order structures]{@link https://docs.ccxt.com/?id=order-structure}
989
- */
990
- async cancelAllOrders(symbol = undefined, params = {}) {
991
- await this.loadMarkets();
992
- const response = await this.privatePostOrdersClear(params);
993
- const data = this.safeList(response, 'data');
994
- return this.parseOrders(data);
995
- }
996
- /**
997
- * @method
998
- * @name oceanex#fetchDepositAddressesByNetwork
999
- * @description fetch the deposit addresses for a currency associated with this account
1000
- * @see https://api.oceanex.pro/doc/v1/#deposit-addresses-post
1001
- * @param {string} code unified currency code
1002
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1003
- * @returns {object} a dictionary [address structures]{@link https://docs.ccxt.com/?id=address-structure}, indexed by the network
1004
- */
1005
- async fetchDepositAddressesByNetwork(code, params = {}) {
1006
- await this.loadMarkets();
1007
- const currency = this.currency(code);
1008
- const request = {
1009
- 'currency': currency['id'],
1010
- };
1011
- const response = await this.privatePostDepositAddresses(this.extend(request, params));
1012
- //
1013
- // {
1014
- // code: '0',
1015
- // message: 'Operation successful',
1016
- // data: {
1017
- // data: {
1018
- // currency_id: 'usdt',
1019
- // display_name: 'USDT',
1020
- // num_of_resources: '3',
1021
- // resources: [
1022
- // {
1023
- // chain_name: 'TRC20',
1024
- // currency_id: 'usdt',
1025
- // address: 'TPcS7VgKMFmpRrWY82GbJzDeMnemWxEbpg',
1026
- // memo: '',
1027
- // deposit_status: 'enabled'
1028
- // },
1029
- // ...
1030
- // ]
1031
- // }
1032
- // }
1033
- // }
1034
- //
1035
- const data = this.safeDict(response, 'data', {});
1036
- const data2 = this.safeDict(data, 'data', {});
1037
- const resources = this.safeList(data2, 'resources', []);
1038
- const result = {};
1039
- for (let i = 0; i < resources.length; i++) {
1040
- const resource = resources[i];
1041
- const enabled = this.safeString(resource, 'deposit_status');
1042
- if (enabled === 'enabled') {
1043
- const parsedAddress = this.parseDepositAddress(resource, currency);
1044
- result[parsedAddress['currency']] = parsedAddress;
1045
- }
1046
- }
1047
- return result;
1048
- }
1049
- parseDepositAddress(depositAddress, currency = undefined) {
1050
- //
1051
- // {
1052
- // chain_name: 'TRC20',
1053
- // currency_id: 'usdt',
1054
- // address: 'TPcS7VgKMFmpRrWY82GbJzDeMnemWxEbpg',
1055
- // memo: '',
1056
- // deposit_status: 'enabled'
1057
- // }
1058
- //
1059
- const address = this.safeString(depositAddress, 'address');
1060
- this.checkAddress(address);
1061
- const currencyId = this.safeString(depositAddress, 'currency_id');
1062
- const networkId = this.safeString(depositAddress, 'chain_name');
1063
- return {
1064
- 'info': depositAddress,
1065
- 'currency': this.safeCurrencyCode(currencyId, currency),
1066
- 'network': this.networkIdToCode(networkId),
1067
- 'address': address,
1068
- 'tag': this.safeString(depositAddress, 'memo'),
1069
- };
1070
- }
1071
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1072
- let url = this.urls['api']['rest'] + '/' + this.version + '/' + this.implodeParams(path, params);
1073
- const query = this.omit(params, this.extractParams(path));
1074
- if (api === 'public') {
1075
- if (path === 'tickers_multi' || path === 'order_book/multi') {
1076
- let request = '?';
1077
- const markets = this.safeValue(params, 'markets');
1078
- for (let i = 0; i < markets.length; i++) {
1079
- request += 'markets[]=' + markets[i] + '&';
1080
- }
1081
- const limit = this.safeValue(params, 'limit');
1082
- if (limit !== undefined) {
1083
- request += 'limit=' + limit;
1084
- }
1085
- url += request;
1086
- }
1087
- else if (Object.keys(query).length) {
1088
- url += '?' + this.urlencode(query);
1089
- }
1090
- }
1091
- else if (api === 'private') {
1092
- this.checkRequiredCredentials();
1093
- const request = {
1094
- 'uid': this.apiKey,
1095
- 'data': query,
1096
- };
1097
- // to set the private key:
1098
- // const fs = require ('fs')
1099
- // exchange.secret = fs.readFileSync ('oceanex.pem', 'utf8')
1100
- const jwt_token = rsa.jwt(request, this.encode(this.secret), sha256.sha256, true);
1101
- url += '?user_jwt=' + jwt_token;
1102
- }
1103
- headers = { 'Content-Type': 'application/json' };
1104
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1105
- }
1106
- handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1107
- //
1108
- // {"code":1011,"message":"This IP 'x.x.x.x' is not allowed","data":{}}
1109
- //
1110
- if (response === undefined) {
1111
- return undefined;
1112
- }
1113
- const errorCode = this.safeString(response, 'code');
1114
- const message = this.safeString(response, 'message');
1115
- if ((errorCode !== undefined) && (errorCode !== '0')) {
1116
- const feedback = this.id + ' ' + body;
1117
- this.throwExactlyMatchedException(this.exceptions['codes'], errorCode, feedback);
1118
- this.throwExactlyMatchedException(this.exceptions['exact'], message, feedback);
1119
- throw new errors.ExchangeError(feedback);
1120
- }
1121
- return undefined;
1122
- }
1123
- }
1124
-
1125
- exports["default"] = oceanex;