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