From fb5a0e9705cfbf60cb7bf2bca9c720dbf27e867b Mon Sep 17 00:00:00 2001 From: Maxim Andreev Date: Tue, 24 Nov 2020 20:17:34 +0300 Subject: [PATCH] open broker: fix FR parser for new reports, add GDR TickerKind --- investments/report_parsers/open_fr.py | 6 +++++- investments/ticker.py | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/investments/report_parsers/open_fr.py b/investments/report_parsers/open_fr.py index c5b9472..fa34dd0 100644 --- a/investments/report_parsers/open_fr.py +++ b/investments/report_parsers/open_fr.py @@ -21,6 +21,8 @@ def _parse_tickerkind(strval: str): return TickerKind.Rdr if strval == 'Облигации': return TickerKind.Bond + if strval == 'GDR': + return TickerKind.Gdr raise ValueError(strval) @@ -105,6 +107,8 @@ def parse_xml(self, xml_file_name: str): def _parse_tickers(self, xml_tree: ET.ElementTree): for rec in xml_tree.findall('spot_portfolio_security_params/item'): f = rec.attrib + if 'ticker' not in f and f['isin'] == 'JE00B5BCW814': + f['ticker'] = 'RUAL' self._tickers.put( symbol=f['ticker'], kind=_parse_tickerkind(f['security_type']), @@ -115,7 +119,7 @@ def _parse_tickers(self, xml_tree: ET.ElementTree): def _parse_cb_convertation(self, f): # WARNING: lost price information, do not use for tax calculation! - qnty = int(f['quantity']) + qnty = int(float(f['quantity'])) assert float(f['quantity']) == qnty ticker = self._tickers.get(name=f['security_name']) dt = _parse_datetime(f['operation_date']) diff --git a/investments/ticker.py b/investments/ticker.py index 5748cd9..e4f8d3e 100644 --- a/investments/ticker.py +++ b/investments/ticker.py @@ -10,6 +10,7 @@ class TickerKind(Enum): Forex = 5 Rdr = 6 Index = 7 + Gdr = 8 def __str__(self): return self.name