Skip to content

Commit

Permalink
add last split to company information, issue #7 (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnzsnz authored Sep 9, 2024
1 parent 144d359 commit affc2b6
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ib_fundamental/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
__copyright__ = "Copyright 2024 Gonzalo Sáenz"
__credits__ = ["Gonzalo Sáenz"]
__license__ = "Apache 2.0"
__version__ = "0.0.4"
__version__ = "0.0.5"
__maintainer__ = "Gonzalo Sáenz"


Expand Down
2 changes: 1 addition & 1 deletion ib_fundamental/fundamental.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def company_info(self) -> CompanyInfo:
try:
return self.__company_info
except AttributeError:
self.__company_info = self.parser.get_company_info()
self.__company_info: CompanyFinancials = self.parser.get_company_info()
return self.__company_info


Expand Down
2 changes: 2 additions & 0 deletions ib_fundamental/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ class CompanyInfo:
exchange_code: str
exchange: str
irs: str
last_split: datetime
stock_split: float


@dataclass(slots=True)
Expand Down
10 changes: 10 additions & 0 deletions ib_fundamental/xml_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,12 +396,22 @@ def get_company_info(self) -> CompanyInfo:
exchange_code = {
"code": r.attrib["Code"] for r in fs.findall("./Issues/Issue/Exchange")
}
last_split = {
"last_split": fromisoformat(r.attrib.get("Date"))
for r in fs.findall("./Issues/Issue/MostRecentSplit")
}
stock_split = {
"stock_split": float(r.text)
for r in fs.findall("./Issues/Issue/MostRecentSplit")
}
_company_info = CompanyInfo(
ticker=issue_id.get("Ticker"),
company_name=coids.get("CompanyName"),
cik=coids.get("CIKNo"),
exchange_code=exchange_code.get("code"),
exchange=exchange.get("Exchange"),
irs=coids.get("IRSNo"),
last_split=last_split.get("last_split"),
stock_split=stock_split.get("stock_split"),
)
return _company_info

0 comments on commit affc2b6

Please sign in to comment.