moexapi 1.6.36__tar.gz → 1.6.37__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moexapi
3
- Version: 1.6.36
3
+ Version: 1.6.37
4
4
  Summary: Python API for MOEX ISS
5
5
  Author-email: Aliaksei Rak <kventinel@gmail.com>
6
6
  License: MIT License
@@ -208,15 +208,12 @@ class Ticker:
208
208
  def from_secid(cls, secid: str, market: markets.Market = markets.Markets.ALL) -> "Ticker":
209
209
  parsed_tickers = _parse_tickers(market=market)
210
210
  tickers = [cls.from_listing(ticker) for ticker in parsed_tickers if ticker.secid == secid]
211
- tickers_length = len(tickers)
212
211
  if len([ticker for ticker in tickers if ticker.is_traded]) == 0:
213
212
  tickers.extend([
214
213
  cls.from_listing(ticker) for ticker in parsed_tickers if ticker.shortname.replace(' ', '') == secid
215
214
  ])
216
- tickers_length = tickers_length if tickers_length > 0 else len(tickers)
217
215
  if len([ticker for ticker in tickers if ticker.is_traded]) == 0:
218
216
  tickers.extend([cls.from_listing(ticker) for ticker in parsed_tickers if ticker.isin == secid])
219
- tickers_length = tickers_length if tickers_length > 0 else len(tickers)
220
217
  if (
221
218
  len([ticker for ticker in tickers if ticker.is_traded]) == 0 and
222
219
  len(secid) == 3 and
@@ -227,18 +224,13 @@ class Ticker:
227
224
  cls.from_listing(ticker)
228
225
  for ticker in parsed_tickers if ticker.secid == cur_secid and market.has(markets.Markets.CURRENCY)
229
226
  ])
230
- tickers_length = tickers_length if tickers_length > 0 else len(tickers)
231
227
  if len([ticker for ticker in tickers if ticker.is_traded]) == 0:
232
228
  tickers.extend([
233
229
  cls.from_listing(ticker) for ticker in parsed_tickers
234
230
  if ticker.shortname == cur_secid and market.has(markets.Markets.CURRENCY)
235
231
  ])
236
- tickers_length = tickers_length if tickers_length > 0 else len(tickers)
237
- if len(tickers) > 1:
238
- if len([ticker for ticker in tickers if ticker.is_traded]) != 0:
239
- tickers = [ticker for ticker in tickers if ticker.is_traded]
240
- else:
241
- tickers = tickers[:tickers_length]
232
+ if len(tickers) > 1 and len([ticker for ticker in tickers if ticker.is_traded]) != 0:
233
+ tickers = [ticker for ticker in tickers if ticker.is_traded]
242
234
  if len(tickers) != 1:
243
235
  if len(tickers) > 1:
244
236
  logger.error(f'Find too many tickers for {secid}: {tickers}')
@@ -282,6 +274,11 @@ def get_ticker(secid: str, market: markets.Market = markets.Markets.ALL) -> Tick
282
274
  return Ticker.from_secid(secid, market=market)
283
275
 
284
276
 
285
- def get_tickers(market: markets.Market = markets.Markets.ALL) -> list[Ticker]:
277
+ def get_tickers(market: markets.Market = markets.Markets.ALL, limit: int = None) -> list[Ticker]:
286
278
  tickers = _parse_tickers(market=market)
287
- return [Ticker.from_secid(secid=ticker.secid, market=ticker.market) for ticker in tickers]
279
+ result = []
280
+ for idx, ticker in enumerate(tickers):
281
+ if idx >= limit:
282
+ break
283
+ result.append(Ticker.from_secid(secid=ticker.secid, market=ticker.market))
284
+ return result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: moexapi
3
- Version: 1.6.36
3
+ Version: 1.6.37
4
4
  Summary: Python API for MOEX ISS
5
5
  Author-email: Aliaksei Rak <kventinel@gmail.com>
6
6
  License: MIT License
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "moexapi"
7
- version = "1.6.36"
7
+ version = "1.6.37"
8
8
  description = "Python API for MOEX ISS"
9
9
  readme = "README.md"
10
10
  authors = [{ name = "Aliaksei Rak", email = "kventinel@gmail.com" }]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes