ccxt 4.5.30 → 4.5.31

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