moexapi 1.6.46__tar.gz → 1.6.48__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.
- {moexapi-1.6.46 → moexapi-1.6.48}/PKG-INFO +1 -1
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi/candles.py +12 -8
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi/changeover.py +1 -1
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi/history.py +3 -2
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi/tickers.py +9 -3
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi.egg-info/PKG-INFO +1 -1
- {moexapi-1.6.46 → moexapi-1.6.48}/pyproject.toml +1 -1
- {moexapi-1.6.46 → moexapi-1.6.48}/LICENSE +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/README.md +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi/__init__.py +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi/bonds.py +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi/dividends.py +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi/exchange.py +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi/markets.py +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi/splits.py +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi/utils.py +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi.egg-info/SOURCES.txt +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi.egg-info/dependency_links.txt +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi.egg-info/requires.txt +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/moexapi.egg-info/top_level.txt +0 -0
- {moexapi-1.6.46 → moexapi-1.6.48}/setup.cfg +0 -0
|
@@ -57,7 +57,7 @@ class Candle:
|
|
|
57
57
|
volume=first.volume + second.volume,
|
|
58
58
|
value=first.value + second.value,
|
|
59
59
|
)
|
|
60
|
-
|
|
60
|
+
|
|
61
61
|
def mult(self, mult: float) -> None:
|
|
62
62
|
self.low *= mult
|
|
63
63
|
self.high *= mult
|
|
@@ -100,11 +100,15 @@ def _merge_candles_list(candles: list[list[Candle]]) -> list[Candle]:
|
|
|
100
100
|
def _parse_candles_one_board(
|
|
101
101
|
ticker: tickers.Ticker,
|
|
102
102
|
board: str,
|
|
103
|
-
start_date: T.Optional[datetime.datetime] = None,
|
|
104
|
-
end_date: T.Optional[datetime.datetime] = None,
|
|
103
|
+
start_date: T.Optional[T.Union[datetime.datetime, str]] = None,
|
|
104
|
+
end_date: T.Optional[T.Union[datetime.datetime, str]] = None,
|
|
105
105
|
interval: T.Optional[int] = None,
|
|
106
106
|
) -> list[Candle]:
|
|
107
107
|
result = []
|
|
108
|
+
if isinstance(start_date, str):
|
|
109
|
+
start_date = datetime.datetime.fromisoformat(start_date)
|
|
110
|
+
if isinstance(end_date, str):
|
|
111
|
+
end_date = datetime.datetime.fromisoformat(end_date)
|
|
108
112
|
while True:
|
|
109
113
|
start_str = f"from={start_date.isoformat()}" if start_date else ""
|
|
110
114
|
end_str = f"till={end_date.isoformat()}" if end_date else ""
|
|
@@ -145,8 +149,8 @@ def _parse_candles_one_board(
|
|
|
145
149
|
|
|
146
150
|
def _parse_candles(
|
|
147
151
|
ticker: tickers.Ticker,
|
|
148
|
-
start_date: T.Optional[datetime.datetime] = None,
|
|
149
|
-
end_date: T.Optional[datetime.datetime] = None,
|
|
152
|
+
start_date: T.Optional[T.Union[datetime.datetime, str]] = None,
|
|
153
|
+
end_date: T.Optional[T.Union[datetime.datetime, str]] = None,
|
|
150
154
|
interval: T.Optional[int] = None,
|
|
151
155
|
):
|
|
152
156
|
candles = []
|
|
@@ -159,8 +163,8 @@ def _parse_candles(
|
|
|
159
163
|
|
|
160
164
|
def get_candles(
|
|
161
165
|
ticker: tickers.Ticker,
|
|
162
|
-
start_date: T.Optional[datetime.datetime] = None,
|
|
163
|
-
end_date: T.Optional[datetime.datetime] = None,
|
|
166
|
+
start_date: T.Optional[T.Union[datetime.datetime, str]] = None,
|
|
167
|
+
end_date: T.Optional[T.Union[datetime.datetime, str]] = None,
|
|
164
168
|
interval: T.Optional[int] = None,
|
|
165
169
|
):
|
|
166
170
|
ticker = changeover.get_current_ticker(ticker)
|
|
@@ -172,6 +176,6 @@ def get_candles(
|
|
|
172
176
|
result = _merge_candles_list(candles)
|
|
173
177
|
for split in ticker_splits:
|
|
174
178
|
for candle in result:
|
|
175
|
-
if candle.end < split.date:
|
|
179
|
+
if candle.end.date() < split.date:
|
|
176
180
|
candle.mult(1 / split.mult)
|
|
177
181
|
return result
|
|
@@ -45,7 +45,7 @@ def get_prev_tickers(ticker: tickers.Ticker) -> list[tickers.Ticker]:
|
|
|
45
45
|
for line in changeovers:
|
|
46
46
|
if line.new_secid == result[-1].secid:
|
|
47
47
|
try:
|
|
48
|
-
result.insert(0, tickers.get_ticker(line.old_secid, market=ticker.market))
|
|
48
|
+
result.insert(0, tickers.get_ticker(line.old_secid, market=ticker.market, allow_delisted=True))
|
|
49
49
|
except tickers.NotFindTicker as ex:
|
|
50
50
|
logger.warning(f"Can't find old version {ex.ticker} for {ticker}")
|
|
51
51
|
return result
|
|
@@ -64,14 +64,15 @@ class History:
|
|
|
64
64
|
volume=_maybe_sum(first.volume, second.volume),
|
|
65
65
|
value=_maybe_sum(first.value, second.value),
|
|
66
66
|
)
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
def mult(self, mult: float) -> None:
|
|
69
69
|
self.low *= mult
|
|
70
70
|
self.high *= mult
|
|
71
71
|
self.open *= mult
|
|
72
72
|
self.close *= mult
|
|
73
73
|
self.mid_price *= mult
|
|
74
|
-
self.value
|
|
74
|
+
if self.value is not None:
|
|
75
|
+
self.value *= mult
|
|
75
76
|
|
|
76
77
|
|
|
77
78
|
def _merge_history(first: list[History], second: list[History]) -> list[History]:
|
|
@@ -215,7 +215,7 @@ class Ticker:
|
|
|
215
215
|
return result
|
|
216
216
|
|
|
217
217
|
@classmethod
|
|
218
|
-
def from_secid(cls, secid: str, market: markets.Market = markets.Markets.ALL) -> "Ticker":
|
|
218
|
+
def from_secid(cls, secid: str, market: markets.Market = markets.Markets.ALL, allow_delisted: bool = False) -> "Ticker":
|
|
219
219
|
parsed_tickers = _parse_tickers(market=market)
|
|
220
220
|
tickers = [cls.from_listing(ticker) for ticker in parsed_tickers if ticker.secid == secid]
|
|
221
221
|
if len([ticker for ticker in tickers if ticker.is_traded]) == 0:
|
|
@@ -255,6 +255,12 @@ class Ticker:
|
|
|
255
255
|
if len(tickers) != 1:
|
|
256
256
|
if len(tickers) > 1:
|
|
257
257
|
logger.error(f'Find too many tickers for {secid}: {tickers}')
|
|
258
|
+
if allow_delisted and len(tickers) == 0:
|
|
259
|
+
info = TickerInfo.from_secid(secid, market)
|
|
260
|
+
response = utils.json_api_call(f"https://iss.moex.com/iss/securities/{secid}.json")
|
|
261
|
+
boards = [line["boardid"] for line in utils.prepare_dict(response, "boards")]
|
|
262
|
+
if boards:
|
|
263
|
+
return cls(secid=secid, alias=secid, is_traded=False, market=market, shortname=info.shortname, isin=info.isin, subtype=info.subtype, listlevel=info.listlevel, boards=boards, listed_till=info.listed_till)
|
|
258
264
|
raise NotFindTicker(secid, len(tickers))
|
|
259
265
|
tickers[0].alias = secid
|
|
260
266
|
return tickers[0]
|
|
@@ -292,8 +298,8 @@ def _parse_tickers(market: markets.Market = markets.Markets.ALL) -> list[Listing
|
|
|
292
298
|
return list(tickers.values())
|
|
293
299
|
|
|
294
300
|
|
|
295
|
-
def get_ticker(secid: str, market: markets.Market = markets.Markets.ALL) -> Ticker:
|
|
296
|
-
return Ticker.from_secid(secid, market=market)
|
|
301
|
+
def get_ticker(secid: str, market: markets.Market = markets.Markets.ALL, allow_delisted: bool = False) -> Ticker:
|
|
302
|
+
return Ticker.from_secid(secid, market=market, allow_delisted=allow_delisted)
|
|
297
303
|
|
|
298
304
|
|
|
299
305
|
def get_tickers(
|
|
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
|
|
File without changes
|