ccxt-ir 4.7.0__py2.py3-none-any.whl → 4.9.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,319 @@
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.kcex import ImplicitAPI
8
+ from ccxt.base.types import Any, Market, Strings, Ticker, Tickers
9
+ from typing import List
10
+
11
+
12
+ class kcex(Exchange, ImplicitAPI):
13
+
14
+ def describe(self) -> Any:
15
+ return self.deep_extend(super(kcex, self).describe(), {
16
+ 'id': 'kcex',
17
+ 'name': 'Kcex',
18
+ 'countries': ['SC'],
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': False,
28
+ 'future': True,
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
+ 'fetchL3OrderBook': False,
59
+ 'fetchLedger': False,
60
+ 'fetchLedgerEntry': False,
61
+ 'fetchLeverageTiers': False,
62
+ 'fetchMarkets': True,
63
+ 'fetchMarkOHLCV': False,
64
+ 'fetchMyTrades': False,
65
+ 'fetchOHLCV': True,
66
+ 'fetchOpenInterestHistory': False,
67
+ 'fetchOpenOrders': False,
68
+ 'fetchOrder': False,
69
+ 'fetchOrderBook': True,
70
+ 'fetchOrders': False,
71
+ 'fetchOrderTrades': 'emulated',
72
+ 'fetchPositions': False,
73
+ 'fetchPremiumIndexOHLCV': False,
74
+ 'fetchTicker': True,
75
+ 'fetchTickers': True,
76
+ 'fetchTime': False,
77
+ 'fetchTrades': False,
78
+ 'fetchTradingFee': False,
79
+ 'fetchTradingFees': False,
80
+ 'fetchWithdrawals': False,
81
+ 'setLeverage': False,
82
+ 'setMarginMode': False,
83
+ 'transfer': False,
84
+ 'withdraw': False,
85
+ },
86
+ 'comment': 'This comment is optional',
87
+ 'urls': {
88
+ 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/kcex/64x64.png',
89
+ 'api': {
90
+ 'public': 'https://www.kcex.com/spot/api',
91
+ },
92
+ 'www': 'https://www.kcex.com',
93
+ 'doc': [
94
+ 'https://www.kcex.com',
95
+ ],
96
+ },
97
+ 'timeframes': {
98
+ '1m': '1',
99
+ '1h': '60',
100
+ '3h': '180',
101
+ '6h': '360',
102
+ '12h': '720',
103
+ '1d': '1D',
104
+ },
105
+ 'api': {
106
+ 'public': {
107
+ 'get': {
108
+ 'market-2/spot/market/v2/web/symbols': 1,
109
+ 'market-2/spot/market/v2/web/tickers': 1,
110
+ 'market-2/spot/market/v2/web/symbol/ticker': 1,
111
+ },
112
+ },
113
+ },
114
+ # 'fees': {
115
+ # 'trading': {
116
+ # 'tierBased': False,
117
+ # 'percentage': True,
118
+ # 'maker': self.parse_number('0.001'),
119
+ # 'taker': self.parse_number('0.001'),
120
+ # },
121
+ # },
122
+ })
123
+
124
+ async def fetch_markets(self, params={}) -> List[Market]:
125
+ """
126
+ retrieves data on all markets for kcex
127
+ https://api-docs.kcex.ir/#be8d9c51a2
128
+ :param dict [params]: extra parameters specific to the exchange API endpoint
129
+ :returns dict[]: an array of objects representing market data
130
+ """
131
+ response = await self.publicGetMarket2SpotMarketV2WebSymbols(params)
132
+ data = self.safe_dict(response, 'data')
133
+ USDTmarketList = self.safe_list(data, 'USDT')
134
+ USDCmarketList = self.safe_list(data, 'USDC')
135
+ marketList = self.array_concat(USDTmarketList, USDCmarketList)
136
+ result = []
137
+ for i in range(0, len(marketList)):
138
+ market = self.parse_market(marketList[i])
139
+ result.append(market)
140
+ return result
141
+
142
+ def parse_market(self, market) -> Market:
143
+ # {
144
+ # id: "e16a2713c7a44bac9d1d4ef98467e75b",
145
+ # mcd: "20f24a571c8544c0b1362794b1804456",
146
+ # mnm: "USDT",
147
+ # cd: "18f40e5428054a4b9c69ddb0cce486f3",
148
+ # vn: "AP",
149
+ # fn: "AMERICA PARTY",
150
+ # srt: 322,
151
+ # sts: 1,
152
+ # in: "F20250607111147267iXgSHIElFbibIQ",
153
+ # fot: 1749247200000,
154
+ # ot: 1749267000000,
155
+ # cp: [
156
+ # "common_section_meme",
157
+ # "common_section_solana"
158
+ # ],
159
+ # ps: 7,
160
+ # qs: 2,
161
+ # cdm: 1
162
+ # }
163
+ id = self.safe_string(market, 'id')
164
+ baseId = self.safe_string(market, 'vn')
165
+ quoteId = self.safe_string(market, 'mnm')
166
+ base = self.safe_currency_code(baseId)
167
+ quote = self.safe_currency_code(quoteId)
168
+ baseId = baseId.lower()
169
+ quoteId = quoteId.lower()
170
+ return {
171
+ 'id': id,
172
+ 'symbol': base + '/' + quote,
173
+ 'base': base,
174
+ 'quote': quote,
175
+ 'settle': None,
176
+ 'baseId': baseId,
177
+ 'quoteId': quoteId,
178
+ 'settleId': None,
179
+ 'type': 'spot',
180
+ 'spot': True,
181
+ 'margin': False,
182
+ 'swap': False,
183
+ 'future': False,
184
+ 'option': False,
185
+ 'active': True,
186
+ 'contract': False,
187
+ 'linear': None,
188
+ 'inverse': None,
189
+ 'contractSize': None,
190
+ 'expiry': None,
191
+ 'expiryDatetime': None,
192
+ 'strike': None,
193
+ 'optionType': None,
194
+ 'precision': {
195
+ 'amount': None,
196
+ 'price': None,
197
+ },
198
+ 'limits': {
199
+ 'leverage': {
200
+ 'min': None,
201
+ 'max': None,
202
+ },
203
+ 'amount': {
204
+ 'min': None,
205
+ 'max': None,
206
+ },
207
+ 'price': {
208
+ 'min': None,
209
+ 'max': None,
210
+ },
211
+ 'cost': {
212
+ 'min': None,
213
+ 'max': None,
214
+ },
215
+ },
216
+ 'created': None,
217
+ 'info': market,
218
+ }
219
+
220
+ async def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
221
+ """
222
+ fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
223
+ https://api-docs.kcex.ir/#be8d9c51a2
224
+ :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
225
+ :param dict [params]: extra parameters specific to the exchange API endpoint
226
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
227
+ """
228
+ await self.load_markets()
229
+ if symbols is not None:
230
+ symbols = self.market_symbols(symbols)
231
+ response = await self.publicGetMarket2SpotMarketV2WebTickers(params)
232
+ tickers = self.safe_list(response, 'data')
233
+ timestamp = self.safe_integer(response, 'timestamp')
234
+ result = {}
235
+ idToMarket = {}
236
+ marketList = list(self.markets.values())
237
+ for i in range(0, len(marketList)):
238
+ market = marketList[i]
239
+ idToMarket[market['id']] = market
240
+ for i in range(0, len(tickers)):
241
+ ticker = tickers[i]
242
+ id = self.safe_string(ticker, 'id')
243
+ market = idToMarket[id]
244
+ ticker['timestamp'] = timestamp
245
+ if market is not None:
246
+ parsedTicker = self.parse_ticker(ticker, market)
247
+ symbol = parsedTicker['symbol']
248
+ result[symbol] = parsedTicker
249
+ return self.filter_by_array_tickers(result, 'symbol', symbols)
250
+
251
+ async def fetch_ticker(self, symbol: str, params={}) -> Ticker:
252
+ """
253
+ fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
254
+ https://api-docs.kcex.ir/#be8d9c51a2
255
+ :param str symbol: unified symbol of the market to fetch the ticker for
256
+ :param dict [params]: extra parameters specific to the exchange API endpoint
257
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
258
+ """
259
+ await self.load_markets()
260
+ market = self.market(symbol)
261
+ request = {
262
+ 'symbol': market['base'] + '_' + market['quote'],
263
+ }
264
+ response = await self.publicGetMarket2SpotMarketV2WebSymbolTicker(request)
265
+ tickerdata = self.safe_dict(response, 'data')
266
+ ticker = self.parse_ticker(tickerdata, market)
267
+ return ticker
268
+
269
+ def parse_ticker(self, ticker, market: Market = None) -> Ticker:
270
+ # {
271
+ # id: "e16a2713c7a44bac9d1d4ef98467e75b",
272
+ # r8: "-0.0261",
273
+ # tzr: "-0.0261",
274
+ # c: "0.0004552",
275
+ # h: "0.0005745",
276
+ # l: "0.0004552",
277
+ # a: "136545.934217",
278
+ # q: "281221205.24",
279
+ # o: "0.0004674",
280
+ # ot: 1749247200000
281
+ # }
282
+ symbol = market['symbol']
283
+ high = self.safe_float(ticker, 'h', 0)
284
+ low = self.safe_float(ticker, 'l', 0)
285
+ open = self.safe_float(ticker, 'o', 0)
286
+ last = self.safe_float(ticker, 'c', 0)
287
+ quoteVolume = self.safe_float(ticker, 'a', 0)
288
+ baseVolume = self.safe_float(ticker, 'q', 0)
289
+ timestamp = self.safe_integer(ticker, 'timestamp', 0)
290
+ return self.safe_ticker({
291
+ 'symbol': symbol,
292
+ 'timestamp': timestamp,
293
+ 'datetime': self.iso8601(timestamp),
294
+ 'high': high,
295
+ 'low': low,
296
+ 'bid': None,
297
+ 'bidVolume': None,
298
+ 'ask': None,
299
+ 'askVolume': None,
300
+ 'vwap': None,
301
+ 'open': open,
302
+ 'close': last,
303
+ 'last': last,
304
+ 'previousClose': None,
305
+ 'change': None,
306
+ 'percentage': None,
307
+ 'average': None,
308
+ 'baseVolume': baseVolume,
309
+ 'quoteVolume': quoteVolume,
310
+ 'info': ticker,
311
+ }, market)
312
+
313
+ def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
314
+ query = self.omit(params, self.extract_params(path))
315
+ url = self.urls['api']['public'] + '/' + path
316
+ if path == 'market-2/spot/market/v2/web/symbol/ticker':
317
+ url = url + '?' + self.urlencode(query)
318
+ headers = {'Content-Type': 'application/json'}
319
+ return {'url': url, 'method': method, 'body': body, 'headers': headers}
ccxt/async_support/xt.py CHANGED
@@ -1610,7 +1610,7 @@ class xt(Exchange, ImplicitAPI):
1610
1610
  elif market['inverse']:
1611
1611
  response = await self.publicInverseGetFutureMarketV1PublicQAggTicker(self.extend(request, params))
1612
1612
  else:
1613
- response = await self.publicSpotGetTicker24h(self.extend(request, params))
1613
+ response = await self.publicSpotGetTicker(self.extend(request, params))
1614
1614
  #
1615
1615
  # spot
1616
1616
  #
@@ -1862,7 +1862,7 @@ class xt(Exchange, ImplicitAPI):
1862
1862
  'change': self.safe_number(ticker, 'cv'),
1863
1863
  'percentage': self.parse_number(percentage),
1864
1864
  'average': None,
1865
- 'baseVolume': None,
1865
+ 'baseVolume': self.safe_number_2(ticker, 'a', 'q'),
1866
1866
  'quoteVolume': self.safe_number_2(ticker, 'a', 'v'),
1867
1867
  'info': ticker,
1868
1868
  }, market)
ccxt/base/exchange.py CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  # -----------------------------------------------------------------------------
6
6
 
7
- __version__ = '4.7.0'
7
+ __version__ = '4.9.0'
8
8
 
9
9
  # -----------------------------------------------------------------------------
10
10
 
ccxt/bitunix.py ADDED
@@ -0,0 +1,311 @@
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.bitunix import ImplicitAPI
8
+ from ccxt.base.types import Any, Market, Strings, Ticker, Tickers
9
+ from typing import List
10
+
11
+
12
+ class bitunix(Exchange, ImplicitAPI):
13
+
14
+ def describe(self) -> Any:
15
+ return self.deep_extend(super(bitunix, self).describe(), {
16
+ 'id': 'bitunix',
17
+ 'name': 'bitunix',
18
+ 'countries': ['IR'],
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': False,
28
+ 'future': True,
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
+ 'fetchL3OrderBook': False,
59
+ 'fetchLedger': False,
60
+ 'fetchLedgerEntry': False,
61
+ 'fetchLeverageTiers': False,
62
+ 'fetchMarkets': True,
63
+ 'fetchMarkOHLCV': False,
64
+ 'fetchMyTrades': False,
65
+ 'fetchOHLCV': True,
66
+ 'fetchOpenInterestHistory': False,
67
+ 'fetchOpenOrders': False,
68
+ 'fetchOrder': False,
69
+ 'fetchOrderBook': True,
70
+ 'fetchOrders': False,
71
+ 'fetchOrderTrades': 'emulated',
72
+ 'fetchPositions': False,
73
+ 'fetchPremiumIndexOHLCV': False,
74
+ 'fetchTicker': True,
75
+ 'fetchTickers': True,
76
+ 'fetchTime': False,
77
+ 'fetchTrades': False,
78
+ 'fetchTradingFee': False,
79
+ 'fetchTradingFees': False,
80
+ 'fetchWithdrawals': False,
81
+ 'setLeverage': False,
82
+ 'setMarginMode': False,
83
+ 'transfer': False,
84
+ 'withdraw': False,
85
+ },
86
+ 'comment': 'This comment is optional',
87
+ 'urls': {
88
+ 'logo': 'https://cdn.arz.digital/cr-odin/img/exchanges/bitunix/64x64.png',
89
+ 'api': {
90
+ 'market': 'https://openapi.bitunix.com/',
91
+ 'tickers': 'https://api.bitunix.com/',
92
+ },
93
+ 'www': 'https://www.bitunix.com/',
94
+ 'doc': [
95
+ 'https://openapidoc.bitunix.com/',
96
+ ],
97
+ },
98
+ 'timeframes': {
99
+ '1m': '1',
100
+ '5m': '5',
101
+ '15m': '15',
102
+ '30m': '30',
103
+ '1h': '60',
104
+ '3h': '180',
105
+ '4h': '240',
106
+ '12h': '720',
107
+ '1d': '1D',
108
+ '1w': '1W',
109
+ },
110
+ 'api': {
111
+ 'public': {
112
+ 'get': {
113
+ 'api/spot/v1/common/coin_pair/list/': 1,
114
+ 'web/api/v1/common/tickers/': 1,
115
+ },
116
+ },
117
+ },
118
+ 'fees': {
119
+ 'trading': {
120
+ 'tierBased': False,
121
+ 'percentage': True,
122
+ 'maker': self.parse_number('0.001'),
123
+ 'taker': self.parse_number('0.001'),
124
+ },
125
+ },
126
+ })
127
+
128
+ def fetch_markets(self, params={}) -> List[Market]:
129
+ """
130
+ retrieves data on all markets for bitunix
131
+ https://api-docs.bitunix.ir/#be8d9c51a2
132
+ :param dict [params]: extra parameters specific to the exchange API endpoint
133
+ :returns dict[]: an array of objects representing market data
134
+ """
135
+ response = self.publicGetApiSpotV1CommonCoinPairList(params)
136
+ markets = self.safe_list(response, 'data')
137
+ result = []
138
+ for i in range(0, len(markets)):
139
+ market = self.parse_market(markets[i])
140
+ result.append(market)
141
+ return result
142
+
143
+ def parse_market(self, market) -> Market:
144
+ # {
145
+ # id: 1,
146
+ # symbol: "btcusdt",
147
+ # base: "BTC",
148
+ # baseIcon: "https://img.bitunix.com/config/kv/228408.png",
149
+ # quote: "USDT",
150
+ # quoteIcon: "https://img.bitunix.com/config/coin/USDT.png",
151
+ # basePrecision: 5,
152
+ # quotePrecision: 2,
153
+ # minPrice: "10.0000000000000000",
154
+ # minVolume: "0.0000500000000000",
155
+ # maxAmount: "500000.0000000000000000",
156
+ # minAmount: "0.0000000000000000",
157
+ # maxLimitOrderAmount: "1500000.0000000000000000",
158
+ # maxMarketOrderAmount: "2000000.0000000000000000",
159
+ # maxSlippage: "0.0500",
160
+ # premiumFactor: "0.0500",
161
+ # minBuyPriceOffset: "-0.8000",
162
+ # maxSellPriceOffset: "50.0000",
163
+ # isOpen: 1,
164
+ # isHot: 1,
165
+ # isRecommend: 1,
166
+ # isShow: 1,
167
+ # tradeArea: "USDT",
168
+ # sort: 1,
169
+ # openTime: null,
170
+ # ctime: "2023-05-12T18:03:08Z",
171
+ # precisions: [
172
+ # "0.0100000000000000",
173
+ # "0.1000000000000000",
174
+ # "1.0000000000000000",
175
+ # "10.0000000000000000",
176
+ # "100.0000000000000000"
177
+ # ]
178
+ # }
179
+ baseId = self.safe_string(market, 'base')
180
+ quoteId = self.safe_string(market, 'quote')
181
+ base = self.safe_currency_code(baseId)
182
+ quote = self.safe_currency_code(quoteId)
183
+ id = (base + quote)
184
+ return {
185
+ 'id': id,
186
+ 'symbol': base + '/' + quote,
187
+ 'base': base,
188
+ 'quote': quote,
189
+ 'settle': None,
190
+ 'baseId': baseId,
191
+ 'quoteId': quoteId,
192
+ 'settleId': None,
193
+ 'type': 'spot',
194
+ 'spot': True,
195
+ 'margin': False,
196
+ 'swap': False,
197
+ 'future': False,
198
+ 'option': False,
199
+ 'active': True,
200
+ 'contract': False,
201
+ 'linear': None,
202
+ 'inverse': None,
203
+ 'contractSize': None,
204
+ 'expiry': None,
205
+ 'expiryDatetime': None,
206
+ 'strike': None,
207
+ 'optionType': None,
208
+ 'precision': {
209
+ 'amount': None,
210
+ 'price': None,
211
+ },
212
+ 'limits': {
213
+ 'leverage': {
214
+ 'min': None,
215
+ 'max': None,
216
+ },
217
+ 'amount': {
218
+ 'min': None,
219
+ 'max': None,
220
+ },
221
+ 'price': {
222
+ 'min': None,
223
+ 'max': None,
224
+ },
225
+ 'cost': {
226
+ 'min': None,
227
+ 'max': None,
228
+ },
229
+ },
230
+ 'created': None,
231
+ 'info': market,
232
+ }
233
+
234
+ def fetch_tickers(self, symbols: Strings = None, params={}) -> Tickers:
235
+ """
236
+ fetches price tickers for multiple markets, statistical information calculated over the past 24 hours for each market
237
+ https://api-docs.bitunix.ir/#be8d9c51a2
238
+ :param str[]|None symbols: unified symbols of the markets to fetch the ticker for, all market tickers are returned if not assigned
239
+ :param dict [params]: extra parameters specific to the exchange API endpoint
240
+ :returns dict: a dictionary of `ticker structures <https://docs.ccxt.com/#/?id=ticker-structure>`
241
+ """
242
+ self.load_markets()
243
+ if symbols is not None:
244
+ symbols = self.market_symbols(symbols)
245
+ response = self.publicGetWebApiV1CommonTickers()
246
+ markets = self.safe_list(response, 'data')
247
+ result = {}
248
+ for i in range(0, len(markets)):
249
+ ticker = self.parse_ticker(markets[i])
250
+ symbol = ticker['symbol']
251
+ result[symbol] = ticker
252
+ return self.filter_by_array_tickers(result, 'symbol', symbols)
253
+
254
+ def fetch_ticker(self, symbol: str, params={}) -> Ticker:
255
+ """
256
+ fetches a price ticker, a statistical calculation with the information calculated over the past 24 hours for a specific market
257
+ https://api-docs.bitunix.ir/#be8d9c51a2
258
+ :param str symbol: unified symbol of the market to fetch the ticker for
259
+ :param dict [params]: extra parameters specific to the exchange API endpoint
260
+ :returns dict: a `ticker structure <https://docs.ccxt.com/#/?id=ticker-structure>`
261
+ """
262
+ ticker = self.fetch_tickers([symbol])
263
+ return ticker[symbol]
264
+
265
+ def parse_ticker(self, ticker, market: Market = None) -> Ticker:
266
+ # {
267
+ # symbol: "BTCUSDT",
268
+ # base: "BTC",
269
+ # quote: "USDT",
270
+ # close: "112832.34",
271
+ # rose24h: "0.2276416293",
272
+ # volume: "228310106.7861019"
273
+ # },
274
+ marketType = 'spot'
275
+ marketId = self.safe_string(ticker, 'symbol')
276
+ symbol = self.safe_symbol(marketId, market, None, marketType)
277
+ last = self.safe_float(ticker, 'close', 0)
278
+ change = self.safe_float(ticker, 'rose24h', 0)
279
+ quoteVolume = self.safe_float(ticker, 'volume', 0)
280
+ baseVolume = 0
281
+ if last != 0:
282
+ baseVolume = quoteVolume / last
283
+ return self.safe_ticker({
284
+ 'symbol': symbol,
285
+ 'timestamp': None,
286
+ 'datetime': None,
287
+ 'high': None,
288
+ 'low': None,
289
+ 'bid': None,
290
+ 'bidVolume': None,
291
+ 'ask': None,
292
+ 'askVolume': None,
293
+ 'vwap': None,
294
+ 'open': None,
295
+ 'close': last,
296
+ 'last': last,
297
+ 'previousClose': None,
298
+ 'change': change,
299
+ 'percentage': change,
300
+ 'average': None,
301
+ 'baseVolume': baseVolume,
302
+ 'quoteVolume': quoteVolume,
303
+ 'info': ticker,
304
+ }, market)
305
+
306
+ def sign(self, path, api='public', method='GET', params={}, headers=None, body=None):
307
+ url = self.urls['api']['market'] + '/' + path
308
+ if path == 'web/api/v1/common/tickers/':
309
+ url = self.urls['api']['tickers'] + '/' + path
310
+ headers = {'Content-Type': 'application/json'}
311
+ return {'url': url, 'method': method, 'body': body, 'headers': headers}