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