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

Errors with IBKR importer #115

Open
kaiwei opened this issue Dec 11, 2024 · 1 comment
Open

Errors with IBKR importer #115

kaiwei opened this issue Dec 11, 2024 · 1 comment

Comments

@kaiwei
Copy link

kaiwei commented Dec 11, 2024

Hi,

I am trying to use the IBKR importer where (I think) I got the config all correctly done, but ran into the below error code when importing ibkr.xml. Any hints on what I may be doing wrong?

Config setup

from beancount_reds_importers.importers import ibkr


    apply_hooks(ibkr.Importer({
    'main_account': 'Assets:Investments:IBKR',
    'account_number': 'XXXXXX',
    'currency': 'USD',
    'cash_account': 'Assets:Investments:IBKR:USD',  # Replace with your cash account in Beancount
    'dividends': 'Income:Dividends:IBKR',    # Replace with your IBKR dividends account
    'capgainsd_lt': 'Income:Capital-Gains:IBKR',    # Replace with your IBKR long term capital gains account
    'capgainsd_st': 'Income:Capital-Gains:IBKR',    # Replace with your IBKR short term capital gains account
    'interest': 'Income:Interest:IBKR',    # Replace with your IBKR interest account
    'fees': 'Expenses:Financial:Fees-Charges',    # Replace with your IBKR fees account
    'rounding_error': 'Equity:Rounding-Errors:Imports',
    'fund_info': {
        'money_market': [],  # No money market funds
        'fund_data': {
            ('HK-3690', 'KYG596691041', 'Meituan Dianping'),
            ('HK-0700', 'KYG875721634', 'Tencent Holdings Ltd'),
            ('HK-9618', 'KYG8208B1014', 'JD.com Inc'),
            ('ABNB', 'US0090661010', 'Airbnb Inc'),
        }
    }

Error output from CLI

**** /mnt/c/Users/kaiwei/beancount/ingest/ibkr.xml
Importer:    beancount_reds_importers.importers.ibkr.Importer
Account:     Assets:Investments:IBKR

ERROR:root:Importer beancount_reds_importers.importers.ibkr.Importer.extract() raised an unexpected error: Unknown entry type
Traceback (most recent call last):
  File "/mnt/c/Users/kaiwei/beancount/.venv/lib/python3.11/site-packages/beancount/ingest/extract.py", line 187, in extract
    new_entries = extract_from_file(
                  ^^^^^^^^^^^^^^^^^^
  File "/mnt/c/Users/kaiwei/beancount/.venv/lib/python3.11/site-packages/beancount/ingest/extract.py", line 71, in extract_from_file
    new_entries = importer.extract(file, **kwargs)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/c/Users/kaiwei/beancount/.venv/lib/python3.11/site-packages/smart_importer/hooks.py", line 41, in patched_extract_method
    imported_entries = unpatched_extract(
                       ^^^^^^^^^^^^^^^^^^
  File "/mnt/c/Users/kaiwei/beancount/.venv/lib/python3.11/site-packages/beancount_reds_importers/libtransactionbuilder/investments.py", line 558, in extract
    new_entries += self.extract_transactions(file, counter)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/mnt/c/Users/kaiwei/beancount/.venv/lib/python3.11/site-packages/beancount_reds_importers/libtransactionbuilder/investments.py", line 474, in extract_transactions
    raise Exception("Unknown entry type")
Exception: Unknown entry type
**** /mnt/c/Users/kaiwei/beancount/ingest/ibkr.xml
Importer:    beancount_reds_importers.importers.ibkr.Importer
Account:     Assets:Investments:IBKR
Date:        2024-12-11 (from mtime)
Destination: /mnt/c/Users/kaiwei/beancount/ingest/filings/Assets/Investments/IBKR/2024-12-11.ibkr.xml
@redstreet
Copy link
Owner

redstreet commented Dec 11, 2024

It means that a particular transaction type was not recognized. Right before that error message, there should've been a ERROR: unknown entry type: XXX in your stdout. If you have stdout piped or redirected, you might've missed it. Try running it again without redirecting, and you should see it. See this line for more context.

Once you see it, you'll have to add that transaction type to the appropriate place in investments.py. Feel free to post the type here, along with the (anonymized) transaction from your .xml if you need help.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants