Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better missing security reporting #43

Merged
merged 5 commits into from
Jan 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
27 changes: 26 additions & 1 deletion beancount_reds_importers/libtransactionbuilder/investments.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,32 @@ def get_ticker_info_from_id(self, security_id):
if s in k:
securities_missing.remove(s)
# securities_missing = [s for s in securities if s not in self.funds_db]
print(f"List of securities without fund info: {securities_missing}", file=sys.stderr)

# try to extract security info from ofx
ofx_securities = dict()
try:
for o in self.ofx.security_list:
# It seems that because of the way investment transactions are reported
# in ofx the securities returned by self.get_security_list() are a list
# of cusip codes. In the section of the ofx that lists all securities
# and is found in self.ofx.security_list these codes are generally
# referred to as UNIQUEID (though the presence of another key called
# UNIQUEIDTYPE suggests that UNIQUEID is not always a cusip).
# because of this the key for the ofx_securities dict is uniqueid which
# corresponds to the items in the securities_missing list. The values
# of this dict are the best guess at what an entry for fund_info.py should
# be: a tuple of (ticker, cusip, name). Note in the case of bonds the
# ticker will match the cusip (at least in examples I have) and not be
# literally usable as a beancount symbol
ofx_securities[o.uniqueid] = (o.ticker, o.uniqueid, o.name)
except AttributeError:
# ofx doesn't have a security list
pass

print("List of securities without fund info:", file=sys.stderr)
for m in securities_missing:
print("%s: %s" % (m, ofx_securities.get(m, "???")), file=sys.stderr)
# print(f"List of securities without fund info: {securities_missing}", file=sys.stderr)
# import pdb; pdb.set_trace()
sys.exit(1)
return ticker, ticker_long_name
Expand Down