Skip to content

Commit

Permalink
open broker: fix FR parser for new reports, add GDR TickerKind
Browse files Browse the repository at this point in the history
  • Loading branch information
cdump committed Nov 24, 2020
1 parent f8cb343 commit fb5a0e9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
6 changes: 5 additions & 1 deletion investments/report_parsers/open_fr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down Expand Up @@ -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']),
Expand All @@ -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'])
Expand Down
1 change: 1 addition & 0 deletions investments/ticker.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class TickerKind(Enum):
Forex = 5
Rdr = 6
Index = 7
Gdr = 8

def __str__(self):
return self.name
Expand Down

0 comments on commit fb5a0e9

Please sign in to comment.