ccxt 4.4.75 → 4.4.78

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 (114) hide show
  1. package/README.md +3 -3
  2. package/dist/ccxt.browser.min.js +7 -7
  3. package/dist/cjs/ccxt.js +8 -4
  4. package/dist/cjs/src/abstract/apex.js +9 -0
  5. package/dist/cjs/src/apex.js +1949 -0
  6. package/dist/cjs/src/base/Exchange.js +49 -3
  7. package/dist/cjs/src/binance.js +44 -220
  8. package/dist/cjs/src/bitget.js +139 -71
  9. package/dist/cjs/src/bitmex.js +4 -4
  10. package/dist/cjs/src/bitrue.js +48 -0
  11. package/dist/cjs/src/cex.js +1 -1
  12. package/dist/cjs/src/coinbase.js +32 -3
  13. package/dist/cjs/src/coincatch.js +68 -0
  14. package/dist/cjs/src/coinex.js +3 -0
  15. package/dist/cjs/src/coinlist.js +85 -1
  16. package/dist/cjs/src/hitbtc.js +3 -0
  17. package/dist/cjs/src/hyperliquid.js +13 -4
  18. package/dist/cjs/src/mexc.js +50 -57
  19. package/dist/cjs/src/okx.js +23 -8
  20. package/dist/cjs/src/paradex.js +3 -12
  21. package/dist/cjs/src/phemex.js +2 -1
  22. package/dist/cjs/src/poloniex.js +1 -1
  23. package/dist/cjs/src/pro/apex.js +1043 -0
  24. package/dist/cjs/src/pro/coinbase.js +4 -8
  25. package/dist/cjs/src/pro/gate.js +27 -2
  26. package/dist/cjs/src/pro/hollaex.js +2 -2
  27. package/dist/cjs/src/pro/hyperliquid.js +1 -1
  28. package/dist/cjs/src/pro/p2b.js +2 -2
  29. package/dist/cjs/src/pro/tradeogre.js +283 -0
  30. package/dist/cjs/src/probit.js +1 -0
  31. package/dist/cjs/src/static_dependencies/zklink/zklink-sdk-web.js +2645 -0
  32. package/dist/cjs/src/tradeogre.js +2 -1
  33. package/dist/cjs/src/upbit.js +299 -93
  34. package/dist/cjs/src/whitebit.js +1 -0
  35. package/dist/cjs/src/woo.js +3 -1
  36. package/dist/cjs/src/xt.js +131 -4
  37. package/js/ccxt.d.ts +11 -5
  38. package/js/ccxt.js +8 -4
  39. package/js/src/abstract/apex.d.ts +34 -0
  40. package/js/src/abstract/myokx.d.ts +4 -0
  41. package/js/src/abstract/okx.d.ts +4 -0
  42. package/js/src/abstract/upbit.d.ts +15 -1
  43. package/js/src/abstract/xt.d.ts +3 -0
  44. package/js/src/apex.d.ts +333 -0
  45. package/js/src/apex.js +1951 -0
  46. package/js/src/ascendex.d.ts +3 -3
  47. package/js/src/base/Exchange.d.ts +3 -0
  48. package/js/src/base/Exchange.js +49 -2
  49. package/js/src/binance.d.ts +9 -7
  50. package/js/src/binance.js +44 -220
  51. package/js/src/bitfinex.d.ts +3 -3
  52. package/js/src/bitflyer.d.ts +2 -2
  53. package/js/src/bitget.d.ts +2 -0
  54. package/js/src/bitget.js +139 -71
  55. package/js/src/bitmart.d.ts +4 -4
  56. package/js/src/bitmex.d.ts +3 -3
  57. package/js/src/bitmex.js +4 -4
  58. package/js/src/bitrue.js +48 -0
  59. package/js/src/cex.js +1 -1
  60. package/js/src/coinbase.d.ts +6 -4
  61. package/js/src/coinbase.js +32 -3
  62. package/js/src/coinbaseexchange.d.ts +1 -1
  63. package/js/src/coincatch.d.ts +11 -0
  64. package/js/src/coincatch.js +68 -0
  65. package/js/src/coinex.js +3 -0
  66. package/js/src/coinlist.d.ts +12 -1
  67. package/js/src/coinlist.js +85 -1
  68. package/js/src/cryptocom.d.ts +4 -4
  69. package/js/src/deribit.d.ts +4 -4
  70. package/js/src/derive.d.ts +3 -3
  71. package/js/src/digifinex.d.ts +4 -4
  72. package/js/src/hitbtc.js +3 -0
  73. package/js/src/htx.d.ts +4 -4
  74. package/js/src/hyperliquid.d.ts +1 -0
  75. package/js/src/hyperliquid.js +13 -4
  76. package/js/src/kraken.d.ts +3 -3
  77. package/js/src/krakenfutures.d.ts +2 -2
  78. package/js/src/kucoinfutures.d.ts +5 -5
  79. package/js/src/mexc.d.ts +1 -0
  80. package/js/src/mexc.js +50 -57
  81. package/js/src/okx.js +23 -8
  82. package/js/src/oxfun.d.ts +3 -3
  83. package/js/src/paradex.js +3 -12
  84. package/js/src/phemex.d.ts +3 -3
  85. package/js/src/phemex.js +2 -1
  86. package/js/src/poloniex.d.ts +3 -3
  87. package/js/src/poloniex.js +1 -1
  88. package/js/src/pro/apex.d.ts +160 -0
  89. package/js/src/pro/apex.js +1044 -0
  90. package/js/src/pro/coinbase.js +4 -8
  91. package/js/src/pro/gate.js +27 -2
  92. package/js/src/pro/hollaex.js +2 -2
  93. package/js/src/pro/hyperliquid.js +1 -1
  94. package/js/src/pro/p2b.js +2 -2
  95. package/js/src/pro/tradeogre.d.ts +49 -0
  96. package/js/src/pro/tradeogre.js +284 -0
  97. package/js/src/probit.js +1 -0
  98. package/js/src/static_dependencies/zklink/zklink-sdk-web.d.ts +1279 -0
  99. package/js/src/static_dependencies/zklink/zklink-sdk-web.js +4282 -0
  100. package/js/src/tradeogre.js +2 -1
  101. package/js/src/upbit.d.ts +34 -4
  102. package/js/src/upbit.js +299 -93
  103. package/js/src/vertex.d.ts +3 -3
  104. package/js/src/whitebit.js +1 -0
  105. package/js/src/woo.d.ts +4 -4
  106. package/js/src/woo.js +3 -1
  107. package/js/src/woofipro.d.ts +4 -4
  108. package/js/src/xt.d.ts +23 -4
  109. package/js/src/xt.js +131 -4
  110. package/package.json +2 -2
  111. package/js/src/abstract/ace.d.ts +0 -18
  112. package/js/src/ace.d.ts +0 -158
  113. package/js/src/ace.js +0 -1181
  114. /package/js/src/abstract/{ace.js → apex.js} +0 -0
package/js/src/ace.js DELETED
@@ -1,1181 +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/ace.js';
9
- import { BadRequest, AuthenticationError, InsufficientFunds, InvalidOrder, ArgumentsRequired } from './base/errors.js';
10
- import { Precise } from './base/Precise.js';
11
- import { TICK_SIZE } from './base/functions/number.js';
12
- import { sha256 } from './static_dependencies/noble-hashes/sha256.js';
13
- // ---------------------------------------------------------------------------
14
- /**
15
- * @class ace
16
- * @augments Exchange
17
- */
18
- export default class ace extends Exchange {
19
- describe() {
20
- return this.deepExtend(super.describe(), {
21
- 'id': 'ace',
22
- 'name': 'ACE',
23
- 'countries': ['TW'],
24
- 'version': 'v2',
25
- 'rateLimit': 100,
26
- 'pro': false,
27
- 'has': {
28
- 'CORS': undefined,
29
- 'spot': true,
30
- 'margin': false,
31
- 'swap': false,
32
- 'future': false,
33
- 'option': false,
34
- 'addMargin': false,
35
- 'borrowCrossMargin': false,
36
- 'borrowIsolatedMargin': false,
37
- 'borrowMargin': false,
38
- 'cancelAllOrders': false,
39
- 'cancelOrder': true,
40
- 'cancelOrders': false,
41
- 'closeAllPositions': false,
42
- 'closePosition': false,
43
- 'createOrder': true,
44
- 'createOrderWithTakeProfitAndStopLoss': false,
45
- 'createOrderWithTakeProfitAndStopLossWs': false,
46
- 'createReduceOnlyOrder': false,
47
- 'editOrder': false,
48
- 'fetchBalance': true,
49
- 'fetchBorrowInterest': false,
50
- 'fetchBorrowRate': false,
51
- 'fetchBorrowRateHistories': false,
52
- 'fetchBorrowRateHistory': false,
53
- 'fetchBorrowRates': false,
54
- 'fetchBorrowRatesPerSymbol': false,
55
- 'fetchClosedOrders': false,
56
- 'fetchCrossBorrowRate': false,
57
- 'fetchCrossBorrowRates': false,
58
- 'fetchCurrencies': false,
59
- 'fetchDepositAddress': false,
60
- 'fetchDeposits': false,
61
- 'fetchFundingHistory': false,
62
- 'fetchFundingInterval': false,
63
- 'fetchFundingIntervals': false,
64
- 'fetchFundingRate': false,
65
- 'fetchFundingRateHistory': false,
66
- 'fetchFundingRates': false,
67
- 'fetchGreeks': false,
68
- 'fetchIndexOHLCV': false,
69
- 'fetchIsolatedBorrowRate': false,
70
- 'fetchIsolatedBorrowRates': false,
71
- 'fetchIsolatedPositions': false,
72
- 'fetchLeverage': false,
73
- 'fetchLeverages': false,
74
- 'fetchLeverageTiers': false,
75
- 'fetchLiquidations': false,
76
- 'fetchLongShortRatio': false,
77
- 'fetchLongShortRatioHistory': false,
78
- 'fetchMarginAdjustmentHistory': false,
79
- 'fetchMarginMode': false,
80
- 'fetchMarginModes': false,
81
- 'fetchMarketLeverageTiers': false,
82
- 'fetchMarkets': true,
83
- 'fetchMarkOHLCV': false,
84
- 'fetchMarkPrices': false,
85
- 'fetchMyLiquidations': false,
86
- 'fetchMySettlementHistory': false,
87
- 'fetchMyTrades': true,
88
- 'fetchOHLCV': true,
89
- 'fetchOpenInterest': false,
90
- 'fetchOpenInterestHistory': false,
91
- 'fetchOpenInterests': false,
92
- 'fetchOpenOrders': true,
93
- 'fetchOption': false,
94
- 'fetchOptionChain': false,
95
- 'fetchOrder': true,
96
- 'fetchOrderBook': true,
97
- 'fetchOrders': false,
98
- 'fetchOrderTrades': true,
99
- 'fetchPosition': false,
100
- 'fetchPositionHistory': false,
101
- 'fetchPositionMode': false,
102
- 'fetchPositions': false,
103
- 'fetchPositionsForSymbol': false,
104
- 'fetchPositionsHistory': false,
105
- 'fetchPositionsRisk': false,
106
- 'fetchPremiumIndexOHLCV': false,
107
- 'fetchSettlementHistory': false,
108
- 'fetchTicker': true,
109
- 'fetchTickers': true,
110
- 'fetchTime': false,
111
- 'fetchTrades': false,
112
- 'fetchTradingFee': false,
113
- 'fetchTradingFees': false,
114
- 'fetchTransactionFees': false,
115
- 'fetchTransactions': false,
116
- 'fetchTransfer': false,
117
- 'fetchTransfers': false,
118
- 'fetchVolatilityHistory': false,
119
- 'fetchWithdrawal': false,
120
- 'fetchWithdrawals': false,
121
- 'reduceMargin': false,
122
- 'repayCrossMargin': false,
123
- 'repayIsolatedMargin': false,
124
- 'setLeverage': false,
125
- 'setMargin': false,
126
- 'setMarginMode': false,
127
- 'setPositionMode': false,
128
- 'transfer': false,
129
- 'withdraw': false,
130
- 'ws': false,
131
- },
132
- 'timeframes': {
133
- '1m': 1,
134
- '5m': 5,
135
- '10m': 10,
136
- '30m': 10,
137
- '1h': 60,
138
- '2h': 120,
139
- '4h': 240,
140
- '8h': 480,
141
- '12h': 720,
142
- '1d': 24,
143
- '1w': 70,
144
- '1M': 31,
145
- },
146
- 'urls': {
147
- 'logo': 'https://github.com/user-attachments/assets/115f1e4a-0fd0-4b76-85d5-a49ebf64d1c8',
148
- 'api': {
149
- 'public': 'https://ace.io/polarisex',
150
- 'private': 'https://ace.io/polarisex/open',
151
- },
152
- 'www': 'https://ace.io/',
153
- 'doc': [
154
- 'https://github.com/ace-exchange/ace-offical-api-docs',
155
- ],
156
- 'fees': 'https://helpcenter.ace.io/hc/zh-tw/articles/360018609132-%E8%B2%BB%E7%8E%87%E8%AA%AA%E6%98%8E',
157
- },
158
- 'requiredCredentials': {
159
- 'apiKey': true,
160
- 'secret': true,
161
- },
162
- 'api': {
163
- 'public': {
164
- 'get': [
165
- 'oapi/v2/list/tradePrice',
166
- 'oapi/v2/list/marketPair',
167
- 'open/v2/public/getOrderBook',
168
- ],
169
- },
170
- 'private': {
171
- 'post': [
172
- 'v2/coin/customerAccount',
173
- 'v2/kline/getKline',
174
- 'v2/order/order',
175
- 'v2/order/cancel',
176
- 'v2/order/getOrderList',
177
- 'v2/order/showOrderStatus',
178
- 'v2/order/showOrderHistory',
179
- 'v2/order/getTradeList',
180
- ],
181
- },
182
- },
183
- 'fees': {
184
- 'trading': {
185
- 'percentage': true,
186
- 'maker': this.parseNumber('0.0005'),
187
- 'taker': this.parseNumber('0.001'),
188
- },
189
- },
190
- 'options': {
191
- 'brokerId': 'ccxt',
192
- },
193
- 'features': {
194
- 'spot': {
195
- 'sandbox': false,
196
- 'createOrder': {
197
- 'marginMode': false,
198
- 'triggerPrice': false,
199
- 'triggerPriceType': undefined,
200
- 'triggerDirection': false,
201
- 'stopLossPrice': false,
202
- 'takeProfitPrice': false,
203
- 'attachedStopLossTakeProfit': undefined,
204
- 'timeInForce': {
205
- 'IOC': false,
206
- 'FOK': false,
207
- 'PO': false,
208
- 'GTD': false,
209
- },
210
- 'hedged': false,
211
- 'leverage': false,
212
- 'marketBuyRequiresPrice': false,
213
- 'marketBuyByCost': false,
214
- 'selfTradePrevention': false,
215
- 'trailing': false,
216
- 'iceberg': false,
217
- },
218
- 'createOrders': undefined,
219
- 'fetchMyTrades': {
220
- 'marginMode': false,
221
- 'limit': 500,
222
- 'daysBack': undefined,
223
- 'untilDays': undefined,
224
- 'symbolRequired': true,
225
- },
226
- 'fetchOrder': {
227
- 'marginMode': false,
228
- 'trigger': false,
229
- 'trailing': false,
230
- 'symbolRequired': false,
231
- },
232
- 'fetchOpenOrders': {
233
- 'marginMode': false,
234
- 'limit': undefined,
235
- 'trigger': false,
236
- 'trailing': false,
237
- 'symbolRequired': false,
238
- },
239
- 'fetchOrders': undefined,
240
- 'fetchClosedOrders': undefined,
241
- 'fetchOHLCV': {
242
- 'limit': 2000,
243
- },
244
- },
245
- 'swap': {
246
- 'linear': undefined,
247
- 'inverse': undefined,
248
- },
249
- 'future': {
250
- 'linear': undefined,
251
- 'inverse': undefined,
252
- },
253
- },
254
- 'precisionMode': TICK_SIZE,
255
- 'exceptions': {
256
- 'exact': {
257
- '2003': InvalidOrder,
258
- '2004': InvalidOrder,
259
- '2005': InvalidOrder,
260
- '2021': InsufficientFunds,
261
- '2036': InvalidOrder,
262
- '2039': InvalidOrder,
263
- '2053': InvalidOrder,
264
- '2061': BadRequest,
265
- '2063': InvalidOrder,
266
- '9996': BadRequest,
267
- '10012': AuthenticationError,
268
- '20182': AuthenticationError,
269
- '20183': InvalidOrder,
270
- },
271
- 'broad': {},
272
- },
273
- 'commonCurrencies': {},
274
- });
275
- }
276
- /**
277
- * @method
278
- * @name ace#fetchMarkets
279
- * @description retrieves data on all markets for ace
280
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#oapi-api---market-pair
281
- * @param {object} [params] extra parameters specific to the exchange API endpoint
282
- * @returns {object[]} an array of objects representing market data
283
- */
284
- async fetchMarkets(params = {}) {
285
- const response = await this.publicGetOapiV2ListMarketPair();
286
- //
287
- // [
288
- // {
289
- // "symbol":"BTC/USDT",
290
- // "base":"btc",
291
- // "baseCurrencyId": "122"
292
- // "quote":"usdt",
293
- // "basePrecision":"8",
294
- // "quotePrecision":"5",
295
- // "minLimitBaseAmount":"0.1",
296
- // "maxLimitBaseAmount":"480286"
297
- // }
298
- // ]
299
- //
300
- return this.parseMarkets(response);
301
- }
302
- parseMarket(market) {
303
- //
304
- // {
305
- // "symbol": "ADA/TWD",
306
- // "base": "ADA",
307
- // "baseCurrencyId": "122",
308
- // "quote": "TWD",
309
- // "quoteCurrencyId": "1",
310
- // "basePrecision": "2",
311
- // "quotePrecision": "3",
312
- // "minLimitBaseAmount": "1.0",
313
- // "maxLimitBaseAmount": "150000.0"
314
- // }
315
- //
316
- const baseId = this.safeString(market, 'baseCurrencyId');
317
- const base = this.safeCurrencyCode(this.safeString(market, 'base'));
318
- const quoteId = this.safeString(market, 'quoteCurrencyId');
319
- const quote = this.safeCurrencyCode(this.safeString(market, 'quote'));
320
- const symbol = base + '/' + quote;
321
- return {
322
- 'id': this.safeString(market, 'symbol'),
323
- 'uppercaseId': undefined,
324
- 'symbol': symbol,
325
- 'base': base,
326
- 'baseId': baseId,
327
- 'quote': quote,
328
- 'quoteId': quoteId,
329
- 'settle': undefined,
330
- 'settleId': undefined,
331
- 'type': 'spot',
332
- 'spot': true,
333
- 'margin': false,
334
- 'swap': false,
335
- 'future': false,
336
- 'option': false,
337
- 'contract': false,
338
- 'linear': undefined,
339
- 'inverse': undefined,
340
- 'contractSize': undefined,
341
- 'expiry': undefined,
342
- 'expiryDatetime': undefined,
343
- 'strike': undefined,
344
- 'optionType': undefined,
345
- 'limits': {
346
- 'amount': {
347
- 'min': this.safeNumber(market, 'minLimitBaseAmount'),
348
- 'max': this.safeNumber(market, 'maxLimitBaseAmount'),
349
- },
350
- 'price': {
351
- 'min': undefined,
352
- 'max': undefined,
353
- },
354
- 'cost': {
355
- 'min': undefined,
356
- 'max': undefined,
357
- },
358
- 'leverage': {
359
- 'min': undefined,
360
- 'max': undefined,
361
- },
362
- },
363
- 'precision': {
364
- 'price': this.parseNumber(this.parsePrecision(this.safeString(market, 'quotePrecision'))),
365
- 'amount': this.parseNumber(this.parsePrecision(this.safeString(market, 'basePrecision'))),
366
- },
367
- 'active': undefined,
368
- 'created': undefined,
369
- 'info': market,
370
- };
371
- }
372
- parseTicker(ticker, market = undefined) {
373
- //
374
- // {
375
- // "base_volume":229196.34035399999,
376
- // "last_price":11881.06,
377
- // "quote_volume":19.2909
378
- // }
379
- //
380
- const marketId = this.safeString(ticker, 'id');
381
- const symbol = this.safeSymbol(marketId, market);
382
- return this.safeTicker({
383
- 'symbol': symbol,
384
- 'timestamp': undefined,
385
- 'datetime': undefined,
386
- 'high': undefined,
387
- 'low': undefined,
388
- 'bid': undefined,
389
- 'bidVolume': undefined,
390
- 'ask': undefined,
391
- 'askVolume': undefined,
392
- 'vwap': undefined,
393
- 'open': undefined,
394
- 'close': this.safeString(ticker, 'last_price'),
395
- 'last': this.safeString(ticker, 'last_price'),
396
- 'previousClose': undefined,
397
- 'change': undefined,
398
- 'percentage': undefined,
399
- 'average': undefined,
400
- 'baseVolume': this.safeString(ticker, 'base_volume'),
401
- 'quoteVolume': this.safeString(ticker, 'quote_volume'),
402
- 'info': ticker,
403
- }, market);
404
- }
405
- /**
406
- * @method
407
- * @name ace#fetchTicker
408
- * @description fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
409
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#oapi-api---trade-data
410
- * @param {string} symbol unified symbol of the market to fetch the ticker for
411
- * @param {object} [params] extra parameters specific to the exchange API endpoint
412
- * @returns {object} a [ticker structure]{@link https://docs.ccxt.com/#/?id=ticker-structure}
413
- */
414
- async fetchTicker(symbol, params = {}) {
415
- await this.loadMarkets();
416
- const market = this.market(symbol);
417
- const response = await this.publicGetOapiV2ListTradePrice(params);
418
- const marketId = market['id'];
419
- const ticker = this.safeDict(response, marketId, {});
420
- //
421
- // {
422
- // "BTC/USDT":{
423
- // "base_volume":229196.34035399999,
424
- // "last_price":11881.06,
425
- // "quote_volume":19.2909
426
- // }
427
- // }
428
- //
429
- return this.parseTicker(ticker, market);
430
- }
431
- /**
432
- * @method
433
- * @name ace#fetchTickers
434
- * @description fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
435
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#oapi-api---trade-data
436
- * @param {string[]|undefined} symbols unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
437
- * @param {object} [params] extra parameters specific to the exchange API endpoint
438
- * @returns {object} a dictionary of [ticker structures]{@link https://docs.ccxt.com/#/?id=ticker-structure}
439
- */
440
- async fetchTickers(symbols = undefined, params = {}) {
441
- await this.loadMarkets();
442
- const response = await this.publicGetOapiV2ListTradePrice();
443
- //
444
- // {
445
- // "BTC/USDT":{
446
- // "base_volume":229196.34035399999,
447
- // "last_price":11881.06,
448
- // "quote_volume":19.2909
449
- // }
450
- // }
451
- //
452
- const tickers = [];
453
- const pairs = Object.keys(response);
454
- for (let i = 0; i < pairs.length; i++) {
455
- const marketId = pairs[i];
456
- const market = this.safeMarket(marketId);
457
- const rawTicker = this.safeDict(response, marketId, {});
458
- const ticker = this.parseTicker(rawTicker, market);
459
- tickers.push(ticker);
460
- }
461
- return this.filterByArrayTickers(tickers, 'symbol', symbols);
462
- }
463
- /**
464
- * @method
465
- * @name ace#fetchOrderBook
466
- * @description fetches information on open orders with bid (buy) and ask (sell) prices, volumes and other data
467
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#open-api---order-books
468
- * @param {string} symbol unified symbol of the market to fetch the order book for
469
- * @param {int} [limit] the maximum amount of order book entries to return
470
- * @param {object} [params] extra parameters specific to the exchange API endpoint
471
- * @returns {object} A dictionary of [order book structures]{@link https://docs.ccxt.com/#/?id=order-book-structure} indexed by market symbols
472
- */
473
- async fetchOrderBook(symbol, limit = undefined, params = {}) {
474
- await this.loadMarkets();
475
- const market = this.market(symbol);
476
- const request = {
477
- 'quoteCurrencyId': market['quoteId'],
478
- 'baseCurrencyId': market['baseId'],
479
- };
480
- if (limit !== undefined) {
481
- request['depth'] = limit;
482
- }
483
- const response = await this.publicGetOpenV2PublicGetOrderBook(this.extend(request, params));
484
- //
485
- // {
486
- // "attachment": {
487
- // "baseCurrencyId": "2",
488
- // "quoteCurrencyId": "14",
489
- // "baseCurrencyName": "BTC",
490
- // "quoteCurrencyName": "USDT",
491
- // "bids": [
492
- // [
493
- // "0.0009",
494
- // "19993.53"
495
- // ],
496
- // [
497
- // "0.001",
498
- // "19675.33"
499
- // ],
500
- // [
501
- // "0.001",
502
- // "19357.13"
503
- // ]
504
- // ],
505
- // "asks": [
506
- // [
507
- // "0.001",
508
- // "20629.92"
509
- // ],
510
- // [
511
- // "0.001",
512
- // "20948.13"
513
- // ]
514
- // ]
515
- // },
516
- // "message": null,
517
- // "parameters": null,
518
- // "status": 200
519
- // }
520
- //
521
- const orderBook = this.safeDict(response, 'attachment');
522
- return this.parseOrderBook(orderBook, market['symbol'], undefined, 'bids', 'asks', 1, 0);
523
- }
524
- parseOHLCV(ohlcv, market = undefined) {
525
- //
526
- // {
527
- // "changeRate": 0,
528
- // "volume": 0,
529
- // "closePrice": 101000.0,
530
- // "lowPrice": 101000.0,
531
- // "highPrice": 101000.0,
532
- // "highPrice": 1573195740000L,
533
- // "openPrice": 101000.0,
534
- // "current": 101000.0,
535
- // "currentTime": "2019-11-08 14:49:00",
536
- // "createTime": "2019-11-08 14:49:00"
537
- // }
538
- //
539
- const dateTime = this.safeString(ohlcv, 'createTime');
540
- let timestamp = this.parse8601(dateTime);
541
- if (timestamp !== undefined) {
542
- timestamp = timestamp - 28800000; // 8 hours
543
- }
544
- return [
545
- timestamp,
546
- this.safeNumber(ohlcv, 'openPrice'),
547
- this.safeNumber(ohlcv, 'highPrice'),
548
- this.safeNumber(ohlcv, 'lowPrice'),
549
- this.safeNumber(ohlcv, 'closePrice'),
550
- this.safeNumber(ohlcv, 'volume'),
551
- ];
552
- }
553
- /**
554
- * @method
555
- * @name ace#fetchOHLCV
556
- * @description fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
557
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#open-api---klinecandlestick-data
558
- * @param {string} symbol unified symbol of the market to fetch OHLCV data for
559
- * @param {string} timeframe the length of time each candle represents
560
- * @param {int} [since] timestamp in ms of the earliest candle to fetch
561
- * @param {int} [limit] the maximum amount of candles to fetch
562
- * @param {object} [params] extra parameters specific to the exchange API endpoint
563
- * @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
564
- */
565
- async fetchOHLCV(symbol, timeframe = '1m', since = undefined, limit = undefined, params = {}) {
566
- await this.loadMarkets();
567
- const market = this.market(symbol);
568
- const request = {
569
- 'duration': this.timeframes[timeframe],
570
- 'quoteCurrencyId': market['quoteId'],
571
- 'baseCurrencyId': market['baseId'],
572
- };
573
- if (limit !== undefined) {
574
- request['limit'] = limit;
575
- }
576
- if (since !== undefined) {
577
- request['startTime'] = since;
578
- }
579
- const response = await this.privatePostV2KlineGetKline(this.extend(request, params));
580
- const data = this.safeList(response, 'attachment', []);
581
- //
582
- // {
583
- // "attachment":[
584
- // {
585
- // "changeRate": 0,
586
- // "closePrice": 101000.0,
587
- // "volume": 0,
588
- // "lowPrice": 101000.0,
589
- // "highPrice": 101000.0,
590
- // "highPrice": 1573195740000L,
591
- // "openPrice": 101000.0,
592
- // "current": 101000.0,
593
- // "currentTime": "2019-11-08 14:49:00",
594
- // "createTime": "2019-11-08 14:49:00"
595
- // }
596
- // ]
597
- // }
598
- //
599
- return this.parseOHLCVs(data, market, timeframe, since, limit);
600
- }
601
- parseOrderStatus(status) {
602
- const statuses = {
603
- '0': 'open',
604
- '1': 'open',
605
- '2': 'closed',
606
- '4': 'canceled',
607
- '5': 'canceled',
608
- };
609
- return this.safeString(statuses, status, undefined);
610
- }
611
- parseOrder(order, market = undefined) {
612
- //
613
- // createOrder
614
- // "15697850529570392100421100482693"
615
- //
616
- // fetchOpenOrders
617
- // {
618
- // "uid": 0,
619
- // "orderNo": "16113081376560890227301101413941",
620
- // "orderTime": "2021-01-22 17:35:37",
621
- // "orderTimeStamp": 1611308137656,
622
- // "baseCurrencyId": 1,
623
- // "baseCurrencyName": "TWD",
624
- // "quoteCurrencyId": 14,
625
- // "quoteCurrencyName": "USDT",
626
- // "buyOrSell": "1",
627
- // "num": "6.0000000000000000",
628
- // "price": "32.5880000000000000",
629
- // "remainNum": "2.0000000000000000",
630
- // "tradeNum": "4.0000000000000000",
631
- // "tradePrice": "31.19800000000000000000",
632
- // "tradeAmount": "124.7920000000000000",
633
- // "tradeRate": "0.66666666666666666667",
634
- // "status": 1,
635
- // "type": 1
636
- // }
637
- //
638
- let id;
639
- let timestamp = undefined;
640
- let symbol = undefined;
641
- let price = undefined;
642
- let amount = undefined;
643
- let side = undefined;
644
- let type = undefined;
645
- let status = undefined;
646
- let filled = undefined;
647
- let remaining = undefined;
648
- let average = undefined;
649
- if (typeof order === 'string') {
650
- id = order;
651
- }
652
- else {
653
- id = this.safeString(order, 'orderNo');
654
- timestamp = this.safeInteger(order, 'orderTimeStamp');
655
- if (timestamp === undefined) {
656
- const dateTime = this.safeString(order, 'orderTime');
657
- if (dateTime !== undefined) {
658
- timestamp = this.parse8601(dateTime);
659
- timestamp = timestamp - 28800000; // 8 hours
660
- }
661
- }
662
- const orderSide = this.safeString(order, 'buyOrSell');
663
- if (orderSide !== undefined) {
664
- side = (orderSide === '1') ? 'buy' : 'sell';
665
- }
666
- amount = this.safeString(order, 'num');
667
- price = this.safeString(order, 'price');
668
- const quoteId = this.safeString(order, 'quoteCurrencyName');
669
- const baseId = this.safeString(order, 'baseCurrencyName');
670
- if (quoteId !== undefined && baseId !== undefined) {
671
- symbol = baseId + '/' + quoteId;
672
- }
673
- const orderType = this.safeString(order, 'type');
674
- if (orderType !== undefined) {
675
- type = (orderType === '1') ? 'limit' : 'market';
676
- }
677
- filled = this.safeString(order, 'tradeNum');
678
- remaining = this.safeString(order, 'remainNum');
679
- status = this.parseOrderStatus(this.safeString(order, 'status'));
680
- average = this.safeString(order, 'averagePrice');
681
- }
682
- return this.safeOrder({
683
- 'id': id,
684
- 'clientOrderId': undefined,
685
- 'timestamp': timestamp,
686
- 'datetime': this.iso8601(timestamp),
687
- 'lastTradeTimestamp': undefined,
688
- 'symbol': symbol,
689
- 'type': type,
690
- 'timeInForce': undefined,
691
- 'postOnly': undefined,
692
- 'side': side,
693
- 'price': price,
694
- 'triggerPrice': undefined,
695
- 'amount': amount,
696
- 'cost': undefined,
697
- 'average': average,
698
- 'filled': filled,
699
- 'remaining': remaining,
700
- 'status': status,
701
- 'fee': undefined,
702
- 'trades': undefined,
703
- 'info': order,
704
- }, market);
705
- }
706
- /**
707
- * @method
708
- * @name ace#createOrder
709
- * @description create a trade order
710
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#open-api---new-order
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 orderType = type.toUpperCase();
723
- const orderSide = side.toUpperCase();
724
- const request = {
725
- 'baseCurrencyId': market['baseId'],
726
- 'quoteCurrencyId': market['quoteId'],
727
- 'type': (orderType === 'LIMIT') ? 1 : 2,
728
- 'buyOrSell': (orderSide === 'BUY') ? 1 : 2,
729
- 'num': this.amountToPrecision(symbol, amount),
730
- };
731
- if (type === 'limit') {
732
- request['price'] = this.priceToPrecision(symbol, price);
733
- }
734
- const response = await this.privatePostV2OrderOrder(this.extend(request, params));
735
- //
736
- // {
737
- // "attachment": "15697850529570392100421100482693",
738
- // "message": null,
739
- // "parameters": null,
740
- // "status": 200
741
- // }
742
- //
743
- const data = this.safeDict(response, 'attachment');
744
- return this.parseOrder(data, market);
745
- }
746
- /**
747
- * @method
748
- * @name ace#cancelOrder
749
- * @description cancels an open order
750
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#open-api---cancel-order
751
- * @param {string} id order id
752
- * @param {string} symbol unified symbol of the market the order was made in
753
- * @param {object} [params] extra parameters specific to the exchange API endpoint
754
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
755
- */
756
- async cancelOrder(id, symbol = undefined, params = {}) {
757
- await this.loadMarkets();
758
- const request = {
759
- 'orderNo': id,
760
- };
761
- const response = await this.privatePostV2OrderCancel(this.extend(request, params));
762
- //
763
- // {
764
- // "attachment": 200,
765
- // "message": null,
766
- // "parameters": null,
767
- // "status": 200
768
- // }
769
- //
770
- return response;
771
- }
772
- /**
773
- * @method
774
- * @name ace#fetchOrder
775
- * @description fetches information on an order made by the user
776
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#open-api---order-status
777
- * @param {string} id the order id
778
- * @param {string} symbol unified symbol of the market the order was made in
779
- * @param {object} [params] extra parameters specific to the exchange API endpoint
780
- * @returns {object} An [order structure]{@link https://docs.ccxt.com/#/?id=order-structure}
781
- */
782
- async fetchOrder(id, symbol = undefined, params = {}) {
783
- await this.loadMarkets();
784
- const request = {
785
- 'orderNo': id,
786
- };
787
- const response = await this.privatePostV2OrderShowOrderStatus(this.extend(request, params));
788
- //
789
- // {
790
- // "attachment": {
791
- // "buyOrSell": 1,
792
- // "averagePrice": "490849.75000000",
793
- // "num": "0.00000000",
794
- // "orderTime": "2022-11-29 18:03:06.318",
795
- // "price": "490849.75000000",
796
- // "status": 4,
797
- // "tradeNum": "0.02697000",
798
- // "remainNum": "0.97303000",
799
- // "baseCurrencyId": 2,
800
- // "baseCurrencyName": "BTC",
801
- // "quoteCurrencyId": 1,
802
- // "quoteCurrencyName": "TWD",
803
- // "orderNo": "16697161898600391472461100244406"
804
- // },
805
- // "message": null,
806
- // "parameters": null,
807
- // "status": 200
808
- // }
809
- //
810
- const data = this.safeDict(response, 'attachment');
811
- return this.parseOrder(data, undefined);
812
- }
813
- /**
814
- * @method
815
- * @name ace#fetchOpenOrders
816
- * @description fetch all unfilled currently open orders
817
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#open-api---order-list
818
- * @param {string} symbol unified market symbol of the market orders were made in
819
- * @param {int} [since] the earliest time in ms to fetch orders for
820
- * @param {int} [limit] the maximum number of order structures to retrieve
821
- * @param {object} [params] extra parameters specific to the exchange API endpoint
822
- * @returns {Order[]} a list of [order structures]{@link https://docs.ccxt.com/#/?id=order-structure}
823
- */
824
- async fetchOpenOrders(symbol = undefined, since = undefined, limit = undefined, params = {}) {
825
- if (symbol === undefined) {
826
- throw new ArgumentsRequired(this.id + ' fetchOpenOrders() requires a symbol argument');
827
- }
828
- await this.loadMarkets();
829
- const market = this.market(symbol);
830
- const request = {
831
- 'quoteCurrencyId': market['quoteId'],
832
- 'baseCurrencyId': market['baseId'],
833
- // 'start': 0,
834
- };
835
- if (limit !== undefined) {
836
- request['size'] = limit;
837
- }
838
- const response = await this.privatePostV2OrderGetOrderList(this.extend(request, params));
839
- const orders = this.safeList(response, 'attachment');
840
- //
841
- // {
842
- // "attachment": [
843
- // {
844
- // "uid": 0,
845
- // "orderNo": "16113081376560890227301101413941",
846
- // "orderTime": "2021-01-22 17:35:37",
847
- // "orderTimeStamp": 1611308137656,
848
- // "baseCurrencyId": 1,
849
- // "baseCurrencyName": "TWD",
850
- // "quoteCurrencyId": 14,
851
- // "quoteCurrencyName": "USDT",
852
- // "buyOrSell": "1",
853
- // "num": "6.0000000000000000",
854
- // "price": "32.5880000000000000",
855
- // "remainNum": "2.0000000000000000",
856
- // "tradeNum": "4.0000000000000000",
857
- // "tradePrice": "31.19800000000000000000",
858
- // "tradeAmount": "124.7920000000000000",
859
- // "tradeRate": "0.66666666666666666667",
860
- // "status": 1,
861
- // "type": 1
862
- // }
863
- // ],
864
- // "message": null,
865
- // "parameters": null,
866
- // "status": 200
867
- // }
868
- //
869
- return this.parseOrders(orders, market, since, limit);
870
- }
871
- parseTrade(trade, market = undefined) {
872
- //
873
- // fetchOrderTrades
874
- // {
875
- // "amount": 0.0030965,
876
- // "tradeNo": "15681920522485652100751000417788",
877
- // "price": "0.03096500",
878
- // "num": "0.10000000",
879
- // "bi": 1,
880
- // "time": "2019-09-11 16:54:12.248"
881
- // }
882
- //
883
- // fetchMyTrades
884
- // {
885
- // "buyOrSell": 1,
886
- // "orderNo": "16708156853695560053601100247906",
887
- // "num": "1",
888
- // "price": "16895",
889
- // "orderAmount": "16895",
890
- // "tradeNum": "0.1",
891
- // "tradePrice": "16895",
892
- // "tradeAmount": "1689.5",
893
- // "fee": "0",
894
- // "feeSave": "0",
895
- // "status": 1,
896
- // "isSelf": false,
897
- // "tradeNo": "16708186395087940051961000274150",
898
- // "tradeTime": "2022-12-12 12:17:19",
899
- // "tradeTimestamp": 1670818639508,
900
- // "quoteCurrencyId": 14,
901
- // "quoteCurrencyName": "USDT",
902
- // "baseCurrencyId": 2,
903
- // "baseCurrencyName": "BTC"
904
- // }
905
- const id = this.safeString(trade, 'tradeNo');
906
- const price = this.safeString(trade, 'price');
907
- const amount = this.safeString(trade, 'num');
908
- let timestamp = this.safeInteger(trade, 'tradeTimestamp');
909
- if (timestamp === undefined) {
910
- const datetime = this.safeString2(trade, 'time', 'tradeTime');
911
- timestamp = this.parse8601(datetime);
912
- timestamp = timestamp - 28800000; // 8 hours normalize timestamp
913
- }
914
- let symbol = market['symbol'];
915
- const quoteId = this.safeString(trade, 'quoteCurrencyName');
916
- const baseId = this.safeString(trade, 'baseCurrencyName');
917
- if (quoteId !== undefined && baseId !== undefined) {
918
- symbol = baseId + '/' + quoteId;
919
- }
920
- let side = undefined;
921
- const tradeSide = this.safeInteger(trade, 'buyOrSell');
922
- if (tradeSide !== undefined) {
923
- side = (tradeSide === 1) ? 'buy' : 'sell';
924
- }
925
- const feeString = this.safeString(trade, 'fee');
926
- let fee = undefined;
927
- if (feeString !== undefined) {
928
- const feeSaveString = this.safeString(trade, 'feeSave');
929
- fee = {
930
- 'cost': Precise.stringSub(feeString, feeSaveString),
931
- 'currency': quoteId,
932
- };
933
- }
934
- return this.safeTrade({
935
- 'info': trade,
936
- 'id': id,
937
- 'order': this.safeString(trade, 'orderNo'),
938
- 'symbol': symbol,
939
- 'side': side,
940
- 'type': undefined,
941
- 'takerOrMaker': undefined,
942
- 'price': price,
943
- 'amount': amount,
944
- 'cost': undefined,
945
- 'fee': fee,
946
- 'timestamp': timestamp,
947
- 'datetime': this.iso8601(timestamp),
948
- }, market);
949
- }
950
- /**
951
- * @method
952
- * @name ace#fetchOrderTrades
953
- * @description fetch all the trades made from a single order
954
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#open-api---order-history
955
- * @param {string} id order id
956
- * @param {string} symbol unified market symbol
957
- * @param {int} [since] the earliest time in ms to fetch trades for
958
- * @param {int} [limit] the maximum number of trades to retrieve
959
- * @param {object} [params] extra parameters specific to the exchange API endpoint
960
- * @returns {object[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=trade-structure}
961
- */
962
- async fetchOrderTrades(id, symbol = undefined, since = undefined, limit = undefined, params = {}) {
963
- await this.loadMarkets();
964
- const market = this.safeMarket(symbol);
965
- const request = {
966
- 'orderNo': id,
967
- };
968
- const response = await this.privatePostV2OrderShowOrderHistory(this.extend(request, params));
969
- //
970
- // {
971
- // "attachment": {
972
- // "order": {
973
- // "buyOrSell": 1,
974
- // "averagePrice": "491343.74000000",
975
- // "num": "1.00000000",
976
- // "orderTime": "2022-11-29 18:32:22.232",
977
- // "price": "491343.74000000",
978
- // "status": 1,
979
- // "tradeNum": "0.01622200",
980
- // "remainNum": "0.98377800",
981
- // "baseCurrencyId": 2,
982
- // "baseCurrencyName": "BTC",
983
- // "quoteCurrencyId": 1,
984
- // "quoteCurrencyName": "TWD",
985
- // "orderNo": "16697179457740441472471100214402"
986
- // },
987
- // "trades": [
988
- // {
989
- // "price": "491343.74000000",
990
- // "num": "0.01622200",
991
- // "time": "2022-11-29 18:32:25.789",
992
- // "tradeNo": "16697179457897791471461000223437",
993
- // "amount": "7970.57815028"
994
- // }
995
- // ]
996
- // },
997
- // "message": null,
998
- // "parameters": null,
999
- // "status": 200
1000
- // }
1001
- //
1002
- const data = this.safeDict(response, 'attachment');
1003
- const trades = this.safeList(data, 'trades', []);
1004
- return this.parseTrades(trades, market, since, limit);
1005
- }
1006
- /**
1007
- * @method
1008
- * @name ace#fetchMyTrades
1009
- * @description fetch all trades made by the user
1010
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#open-api---trade-list
1011
- * @param {string} symbol unified symbol of the market to fetch trades for
1012
- * @param {int} [since] timestamp in ms of the earliest trade to fetch
1013
- * @param {int} [limit] the maximum amount of trades to fetch
1014
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1015
- * @returns {Trade[]} a list of [trade structures]{@link https://docs.ccxt.com/#/?id=public-trades}
1016
- */
1017
- async fetchMyTrades(symbol = undefined, since = undefined, limit = undefined, params = {}) {
1018
- await this.loadMarkets();
1019
- const market = this.safeMarket(symbol);
1020
- const request = {
1021
- // 'buyOrSell': 1,
1022
- // 'start': 0,
1023
- };
1024
- if (market['id'] !== undefined) {
1025
- request['quoteCurrencyId'] = market['quoteId'];
1026
- request['baseCurrencyId'] = market['baseId'];
1027
- }
1028
- if (limit !== undefined) {
1029
- request['size'] = limit; // default 10, max 500
1030
- }
1031
- const response = await this.privatePostV2OrderGetTradeList(this.extend(request, params));
1032
- //
1033
- // {
1034
- // "attachment": [
1035
- // {
1036
- // "buyOrSell": 1,
1037
- // "orderNo": "16708156853695560053601100247906",
1038
- // "num": "1",
1039
- // "price": "16895",
1040
- // "orderAmount": "16895",
1041
- // "tradeNum": "0.1",
1042
- // "tradePrice": "16895",
1043
- // "tradeAmount": "1689.5",
1044
- // "fee": "0",
1045
- // "feeSave": "0",
1046
- // "status": 1,
1047
- // "isSelf": false,
1048
- // "tradeNo": "16708186395087940051961000274150",
1049
- // "tradeTime": "2022-12-12 12:17:19",
1050
- // "tradeTimestamp": 1670818639508,
1051
- // "quoteCurrencyId": 14,
1052
- // "quoteCurrencyName": "USDT",
1053
- // "baseCurrencyId": 2,
1054
- // "baseCurrencyName": "BTC"
1055
- // }
1056
- // ],
1057
- // "message": null,
1058
- // "parameters": null,
1059
- // "status": 200
1060
- // }
1061
- //
1062
- const trades = this.safeList(response, 'attachment', []);
1063
- return this.parseTrades(trades, market, since, limit);
1064
- }
1065
- parseBalance(response) {
1066
- //
1067
- // [
1068
- // {
1069
- // "currencyId": 4,
1070
- // "amount": 6.896,
1071
- // "cashAmount": 6.3855,
1072
- // "uid": 123,
1073
- // "currencyName": "BTC"
1074
- // }
1075
- // ]
1076
- //
1077
- const result = {
1078
- 'info': response,
1079
- };
1080
- for (let i = 0; i < response.length; i++) {
1081
- const balance = response[i];
1082
- const currencyId = this.safeString(balance, 'currencyName');
1083
- const code = this.safeCurrencyCode(currencyId);
1084
- const amount = this.safeString(balance, 'amount');
1085
- const available = this.safeString(balance, 'cashAmount');
1086
- const account = {
1087
- 'free': available,
1088
- 'total': amount,
1089
- };
1090
- result[code] = account;
1091
- }
1092
- return this.safeBalance(result);
1093
- }
1094
- /**
1095
- * @method
1096
- * @name ace#fetchBalance
1097
- * @description query for balance and get the amount of funds available for trading or funds locked in orders
1098
- * @see https://github.com/ace-exchange/ace-official-api-docs/blob/master/api_v2.md#open-api---account-balance
1099
- * @param {object} [params] extra parameters specific to the exchange API endpoint
1100
- * @returns {object} a [balance structure]{@link https://docs.ccxt.com/#/?id=balance-structure}
1101
- */
1102
- async fetchBalance(params = {}) {
1103
- await this.loadMarkets();
1104
- const response = await this.privatePostV2CoinCustomerAccount(params);
1105
- const balances = this.safeList(response, 'attachment', []);
1106
- //
1107
- // {
1108
- // "attachment":[
1109
- // {
1110
- // "currencyId": 4,
1111
- // "amount": 6.896,
1112
- // "cashAmount": 6.3855,
1113
- // "uid": 123,
1114
- // "currencyName": "BTC"
1115
- // }
1116
- // ],
1117
- // "message": null,
1118
- // "parameters": null,
1119
- // "status": "200"
1120
- // }
1121
- //
1122
- return this.parseBalance(balances);
1123
- }
1124
- sign(path, api = 'public', method = 'GET', params = {}, headers = undefined, body = undefined) {
1125
- let url = '/' + this.implodeParams(path, params);
1126
- const query = this.omit(params, this.extractParams(path));
1127
- if (headers === undefined) {
1128
- headers = {};
1129
- }
1130
- if (api === 'private') {
1131
- this.checkRequiredCredentials();
1132
- const nonce = this.milliseconds();
1133
- let auth = 'ACE_SIGN' + this.secret;
1134
- const data = this.extend({
1135
- 'apiKey': this.apiKey,
1136
- 'timeStamp': this.numberToString(nonce),
1137
- }, params);
1138
- const sortedData = this.keysort(data);
1139
- const values = Object.values(sortedData);
1140
- const stringifiedValues = [];
1141
- for (let i = 0; i < values.length; i++) {
1142
- const value = values[i];
1143
- const strValue = value.toString();
1144
- stringifiedValues.push(strValue);
1145
- }
1146
- auth += stringifiedValues.join('');
1147
- const signature = this.hash(this.encode(auth), sha256, 'hex');
1148
- data['signKey'] = signature;
1149
- headers = {
1150
- 'Content-Type': 'application/x-www-form-urlencoded',
1151
- };
1152
- if (method === 'POST') {
1153
- const brokerId = this.safeString(this.options, 'brokerId');
1154
- if (brokerId !== undefined) {
1155
- headers['Referer'] = brokerId;
1156
- }
1157
- }
1158
- body = this.urlencode(data);
1159
- }
1160
- else if (api === 'public' && method === 'GET') {
1161
- if (Object.keys(query).length) {
1162
- url += '?' + this.urlencode(query);
1163
- }
1164
- }
1165
- url = this.urls['api'][api] + url;
1166
- return { 'url': url, 'method': method, 'body': body, 'headers': headers };
1167
- }
1168
- handleErrors(code, reason, url, method, headers, body, response, requestHeaders, requestBody) {
1169
- if (response === undefined) {
1170
- return undefined; // fallback to the default error handler
1171
- }
1172
- const feedback = this.id + ' ' + body;
1173
- const status = this.safeNumber(response, 'status', 200);
1174
- if (status > 200) {
1175
- const statusStr = status.toString();
1176
- this.throwExactlyMatchedException(this.exceptions['exact'], statusStr, feedback);
1177
- this.throwBroadlyMatchedException(this.exceptions['broad'], statusStr, feedback);
1178
- }
1179
- return undefined;
1180
- }
1181
- }