ccxt-ir 4.5.1__py2.py3-none-any.whl → 4.7.0__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.
@@ -0,0 +1,367 @@
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.async_support.base.exchange import Exchange
7
+ from ccxt.abstract.toobit import ImplicitAPI
8
+ from ccxt.base.types import Any, Int, Market, Strings, Ticker, Tickers
9
+ from typing import List
10
+
11
+
12
+ class toobit(Exchange, ImplicitAPI):
13
+
14
+ def describe(self) -> Any:
15
+ return self.deep_extend(super(toobit, self).describe(), {
16
+ 'id': 'toobit',
17
+ 'name': 'Toobit',
18
+ 'countries': ['KY'], # Cayman Islands
19
+ 'rateLimit': 1000,
20
+ 'version': '1',
21
+ 'certified': False,
22
+ 'pro': False,
23
+ 'has': {
24
+ 'CORS': None,
25
+ 'spot': True,
26
+ 'margin': False,
27
+ 'swap': True,
28
+ 'future': False,
29
+ 'option': False,
30
+ 'addMargin': False,
31
+ 'cancelAllOrders': False,
32
+ 'cancelOrder': False,
33
+ 'cancelOrders': False,
34
+ 'createDepositAddress': False,
35
+ 'createOrder': False,
36
+ 'createStopLimitOrder': False,
37
+ 'createStopMarketOrder': False,
38
+ 'createStopOrder': False,
39
+ 'editOrder': False,
40
+ 'fetchBalance': False,
41
+ 'fetchBorrowInterest': False,
42
+ 'fetchBorrowRateHistories': False,
43
+ 'fetchBorrowRateHistory': False,
44
+ 'fetchClosedOrders': False,
45
+ 'fetchCrossBorrowRate': False,
46
+ 'fetchCrossBorrowRates': False,
47
+ 'fetchCurrencies': False,
48
+ 'fetchDepositAddress': False,
49
+ 'fetchDeposits': False,
50
+ 'fetchFundingHistory': False,
51
+ 'fetchFundingRate': False,
52
+ 'fetchFundingRateHistory': False,
53
+ 'fetchFundingRates': False,
54
+ 'fetchIndexOHLCV': False,
55
+ 'fetchIsolatedBorrowRate': False,
56
+ 'fetchIsolatedBorrowRates': False,
57
+ 'fetchL2OrderBook': False,
58
+ 'fetchLedger': False,
59
+ 'fetchLedgerEntry': False,
60
+ 'fetchLeverageTiers': False,
61
+ 'fetchMarkets': True,
62
+ 'fetchMarkOHLCV': False,
63
+ 'fetchMyTrades': False,
64
+ 'fetchOHLCV': True,
65
+ 'fetchOpenInterestHistory': False,
66
+ 'fetchOpenOrders': False,
67
+ 'fetchOrder': False,
68
+ 'fetchOrderBook': True,
69
+ 'fetchOrders': False,
70
+ 'fetchOrderTrades': 'emulated',
71
+ 'fetchPositions': False,
72
+ 'fetchPremiumIndexOHLCV': False,
73
+ 'fetchTicker': True,
74
+ 'fetchTickers': True,
75
+ 'fetchTime': False,
76
+ 'fetchTrades': False,
77
+ 'fetchTradingFee': False,
78
+ 'fetchTradingFees': False,
79
+ 'fetchWithdrawals': False,
80
+ 'setLeverage': False,
81
+ 'setMarginMode': False,
82
+ 'transfer': False,
83
+ 'withdraw': False,
84
+ },
85
+ 'comment': 'This comment is optional',
86
+ 'urls': {
87
+ 'logo': 'https://toobit-docs.github.io/apidocs/spot/v1/en/images/logo.svg',
88
+ 'api': {
89
+ 'public': 'https://api.toobit.com',
90
+ },
91
+ 'www': 'https://www.toobit.com/',
92
+ 'doc': [
93
+ 'https://toobit-docs.github.io/apidocs/spot/v1/en/#change-log',
94
+ ],
95
+ },
96
+ 'timeframes': {
97
+ '1m': '1m',
98
+ '3m': '3m',
99
+ '5m': '5m',
100
+ '15m': '15m',
101
+ '30m': '30m',
102
+ '1h': '1h',
103
+ '2h': '2h',
104
+ '4h': '4h',
105
+ '6h': '6h',
106
+ '12h': '12h',
107
+ '1d': '1d',
108
+ '1w': '1w',
109
+ '1M': '1M',
110
+ },
111
+ 'api': {
112
+ 'public': {
113
+ 'get': {
114
+ 'quote/v1/ticker/24hr': 1,
115
+ 'quote/v1/klines': 1,
116
+ },
117
+ },
118
+ },
119
+ 'fees': {
120
+ 'trading': {
121
+ 'tierBased': False,
122
+ 'percentage': True,
123
+ 'maker': self.parse_number('0.001'),
124
+ 'taker': self.parse_number('0.001'),
125
+ },
126
+ },
127
+ })
128
+
129
+ async def fetch_markets(self, params={}) -> List[Market]:
130
+ """
131
+ retrieves data on all markets for toobit
132
+ https://apidocs.toobit.io/#tickers
133
+ :param dict [params]: extra parameters specific to the exchange API endpoint
134
+ :returns dict[]: an array of objects representing market data
135
+ """
136
+ response = await self.publicGetQuoteV1Ticker24hr()
137
+ result = []
138
+ for i in range(0, len(response)):
139
+ volume = self.safe_float(response[i], 'v')
140
+ symbol = self.safe_value(response[i], 's')
141
+ if volume == 0 or symbol == 'TESTA1S3TESTX8Z9':
142
+ continue
143
+ market = self.parse_market(response[i])
144
+ result.append(market)
145
+ return result
146
+
147
+ def parse_market(self, market) -> Market:
148
+ # {
149
+ # t: 1757164008834,
150
+ # s: "BTCUSDT",
151
+ # c: "110895.06",
152
+ # h: "113310.01",
153
+ # l: "110219.01",
154
+ # o: "112951.99",
155
+ # v: "3893.406649",
156
+ # qv: "433374169.27969515",
157
+ # pc: "-2056.93",
158
+ # pcp: "-0.0182"
159
+ # }
160
+ symbol = self.safe_value(market, 's')
161
+ baseId = symbol
162
+ quoteId = None
163
+ if symbol.endswith('USDT'):
164
+ baseId = symbol[0:-4]
165
+ quoteId = 'USDT'
166
+ elif symbol.endswith('USDC'):
167
+ baseId = symbol[0:-4]
168
+ quoteId = 'USDC'
169
+ id = symbol
170
+ base = self.safe_currency_code(baseId)
171
+ quote = self.safe_currency_code(quoteId)
172
+ baseId = baseId.lower()
173
+ quoteId = quoteId.lower()
174
+ return {
175
+ 'id': id,
176
+ 'symbol': base + '/' + quote,
177
+ 'base': base,
178
+ 'quote': quote,
179
+ 'settle': None,
180
+ 'baseId': baseId,
181
+ 'quoteId': quoteId,
182
+ 'settleId': None,
183
+ 'type': 'spot',
184
+ 'spot': True,
185
+ 'margin': False,
186
+ 'swap': False,
187
+ 'future': False,
188
+ 'option': False,
189
+ 'active': True,
190
+ 'contract': False,
191
+ 'linear': None,
192
+ 'inverse': None,
193
+ 'contractSize': None,
194
+ 'expiry': None,
195
+ 'expiryDatetime': None,
196
+ 'strike': None,
197
+ 'optionType': None,
198
+ 'precision': {
199
+ 'amount': None,
200
+ 'price': None,
201
+ },
202
+ 'limits': {
203
+ 'leverage': {
204
+ 'min': None,
205
+ 'max': None,
206
+ },
207
+ 'amount': {
208
+ 'min': None,
209
+ 'max': None,
210
+ },
211
+ 'price': {
212
+ 'min': None,
213
+ 'max': None,
214
+ },
215
+ 'cost': {
216
+ 'min': None,
217
+ 'max': None,
218
+ },
219
+ },
220
+ 'created': None,
221
+ 'info': market,
222
+ }
223
+
224
+ async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
225
+ """
226
+ fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
227
+ https://apidocs.toobit.io/#tickers
228
+ :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
229
+ :param dict [params]: extra parameters specific to the exchange API endpoint
230
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
231
+ """
232
+ await self.load_markets()
233
+ if symbols is not None:
234
+ symbols = self.market_symbols(symbols)
235
+ response = await self.publicGetQuoteV1Ticker24hr()
236
+ result = {}
237
+ for i in range(0, len(response)):
238
+ volume = self.safe_float(response[i], 'v')
239
+ if volume == 0:
240
+ continue
241
+ ticker = self.parse_ticker(response[i])
242
+ symbol = ticker['symbol']
243
+ result[symbol] = ticker
244
+ return self.filter_by_array_tickers(result, 'symbol', symbols)
245
+
246
+ async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
247
+ """
248
+ fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
249
+ https://apidocs.toobit.io/#ticker
250
+ :param str symbol: unified symbol of the market to fetch the ticker for
251
+ :param dict [params]: extra parameters specific to the exchange API endpoint
252
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
253
+ """
254
+ await self.load_markets()
255
+ market = self.market(symbol)
256
+ request = {
257
+ 'symbol': market['id'],
258
+ }
259
+ response = await self.publicGetQuoteV1Ticker24hr(request)
260
+ ticker = self.parse_ticker(response[0])
261
+ return ticker
262
+
263
+ def parse_ticker(self, ticker, market: Market = None) -> Ticker:
264
+ # {
265
+ # t: 1757164008834,
266
+ # s: "BTCUSDT",
267
+ # c: "110895.06",
268
+ # h: "113310.01",
269
+ # l: "110219.01",
270
+ # o: "112951.99",
271
+ # v: "3893.406649",
272
+ # qv: "433374169.27969515",
273
+ # pc: "-2056.93",
274
+ # pcp: "-0.0182"
275
+ # }
276
+ marketType = 'spot'
277
+ symbol = self.safe_value(ticker, 's')
278
+ marketId = symbol
279
+ symbol = self.safe_symbol(marketId, market, None, marketType)
280
+ high = self.safe_float(ticker, 'h')
281
+ low = self.safe_float(ticker, 'l')
282
+ open = self.safe_float(ticker, 'o')
283
+ close = self.safe_float(ticker, 'c')
284
+ last = self.safe_float(ticker, 'c')
285
+ change = self.safe_float(ticker, 'pcp')
286
+ priceChange = self.safe_float(ticker, 'pc')
287
+ baseVolume = self.safe_float(ticker, 'v')
288
+ quoteVolume = self.safe_float(ticker, 'qv')
289
+ datetime = self.safe_string(ticker, 't')
290
+ bid = self.safe_float(ticker, 'b', 0)
291
+ ask = self.safe_float(ticker, 'a', 0)
292
+ return self.safe_ticker({
293
+ 'symbol': symbol,
294
+ 'timestamp': datetime,
295
+ 'datetime': self.parse8601(datetime),
296
+ 'high': high,
297
+ 'low': low,
298
+ 'bid': bid,
299
+ 'bidVolume': None,
300
+ 'ask': ask,
301
+ 'askVolume': None,
302
+ 'vwap': None,
303
+ 'open': open,
304
+ 'close': close,
305
+ 'last': last,
306
+ 'previousClose': None,
307
+ 'change': priceChange,
308
+ 'percentage': change,
309
+ 'average': None,
310
+ 'baseVolume': baseVolume,
311
+ 'quoteVolume': quoteVolume,
312
+ 'info': ticker,
313
+ }, market)
314
+
315
+ async def fetch_ohlcv(self, symbol: str, timeframe='1h', since: Int = None, limit: Int = None, params={}) -> List[list]:
316
+ """
317
+ fetches historical candlestick data containing the open, high, low, and close price, and the volume of a market
318
+ https://apidocs.toobit.io/#chart
319
+ :param str symbol: unified symbol of the market to fetch OHLCV data for
320
+ :param str timeframe: the length of time each candle represents
321
+ :param int [since]: timestamp in ms of the earliest candle to fetch
322
+ :param int [limit]: the maximum amount of candles to fetch
323
+ :param dict [params]: extra parameters specific to the exchange API endpoint
324
+ :returns int[][]: A list of candles ordered, open, high, low, close, volume
325
+ """
326
+ await self.load_markets()
327
+ market = self.market(symbol)
328
+ endTime = Date.now()
329
+ request = {
330
+ 'symbol': market['id'],
331
+ 'from': (endTime - (24 * 60 * 60 * 1000)),
332
+ 'to': endTime,
333
+ 'interval': self.safe_string(self.timeframes, timeframe, timeframe),
334
+ }
335
+ if since is not None:
336
+ request['from'] = since
337
+ if timeframe is not None:
338
+ request['interval'] = self.safe_string(self.timeframes, timeframe, timeframe)
339
+ response = await self.publicGetQuoteV1Klines(request)
340
+ ohlcvs = []
341
+ for i in range(0, len(response)):
342
+ candle = response[i]
343
+ ts = self.safe_timestamp(candle, 0)
344
+ open = self.safe_float(candle, 1)
345
+ high = self.safe_float(candle, 2)
346
+ low = self.safe_float(candle, 3)
347
+ close = self.safe_float(candle, 4)
348
+ volume = self.safe_float(candle, 5)
349
+ ohlcvs.append([
350
+ ts,
351
+ open,
352
+ high,
353
+ low,
354
+ close,
355
+ volume,
356
+ ])
357
+ return self.parse_ohlcvs(ohlcvs, market, timeframe, since, limit)
358
+
359
+ def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
360
+ query = self.omit(params, self.extract_params(path))
361
+ url = self.urls['api']['public'] + '/' + path
362
+ if path == 'quote/v1/ticker/24hr':
363
+ url = url + '?' + self.urlencode(query)
364
+ if path == 'quote/v1/klines':
365
+ url = url + '?' + self.urlencode(query)
366
+ headers = {'Content-Type': 'application/json'}
367
+ return {'url': url, 'method': method, 'body': body, 'headers': headers}
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.5.1'
7
+ __version__ = '4.7.0'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10