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

Add Schwab bank support to schwab_csv importer #91

Merged
merged 7 commits into from Feb 14, 2021

Conversation

bayesianmind
Copy link
Contributor

I have quite a lot of activity / business with Schwab including a checking account so I brought in support for everything I could find in my own Schwab CSV files. In the spirit of #88 .

Other changes in the schwab_csv source: (apologies for not splitting these out, if that's a bother I can do the extra book keeping to get them into independent pull reqs).

  • Added support for 7 new BrokerageActions.
  • Added support for fractional shares, which Schwab added last year. You can get these in your account via dividend re-investment or the fractional share purchase feature. The source previously assume int for share quantities.
  • Make schwab_csv post cleared status for Schwab accounts. This lets uncleared transactions properly appear in the import webui.
  • Make the currency configurable just in case instead of hardcoding USD.
  • Added a dedicated interest type that we now use consistently for Checking account interest and "Bank interest" paid on brokerage account cash balances.
  • Tweaked some of the key regexps to work on the files I am getting from Schwab in addition to the testfiles.

Known caveats:

  • The banking CSVs indicate they may contain pending transactions in a special way. I didn't have any in my file to add support for. Likely the importer will import them the same whether they are pending or not. This could result in some extraneous imports for pending auth charges that would normally drop off. If someone donates a CSV with the format it would be easy to add support for it.
  • Does not support corporate equity awards accounts - for Google's at least it is quite different from the Brokerage format and I had written my own importer before schwab_csv was added. If there's interest I can open source the Google equity awards source.

@coveralls
Copy link

coveralls commented Jan 11, 2021

Pull Request Test Coverage Report for Build 241

  • 125 of 133 (93.98%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 0.0%

Changes Missing Coverage Covered Lines Changed/Added Lines %
beancount_import/source/ultipro_google_statement.py 0 3 0.0%
beancount_import/source/schwab_csv.py 125 130 96.15%
Totals Coverage Status
Change from base Build 234: 0.0%
Covered Lines: 0
Relevant Lines: 0

💛 - Coveralls

@Zburatorul
Copy link
Collaborator

Did you forget to include a commit with more code changes? I don't see the 7 new brokerage actions.

@bayesianmind
Copy link
Contributor Author

See line 134 and on. I didn't have to add new classes for them, they're similar enough to existing types.

Copy link
Collaborator

@carljm carljm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great overall! Thanks so much for the additions and improvements. Made a few comments but overall I think this is pretty close to ready.

One thing is I noticed a few bad type annotations; haven't tested but I would think these should cause a mypy failure. Can you verify that tox is green with your changes?

beancount_import/source/schwab_csv.py Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Show resolved Hide resolved
@carljm
Copy link
Collaborator

carljm commented Jan 20, 2021

I should also clarify that @jbms is the author and maintainer of beancount-import and the ultimate authority on whether this gets merged; just offering my review as the initial contributor of the Schwab CSV importer.

@bayesianmind
Copy link
Contributor Author

Thanks for the excellent review @carljm ! I will update this over the next few days as I have free cycles.

@bayesianmind bayesianmind marked this pull request as draft February 4, 2021 04:53
@@ -1077,10 +1319,10 @@ def _load_positions_csv(
symbol = STRIP_FROM_SYMBOL_RE.sub("", symbol)
quantity = _convert_int(row["Quantity"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The quantity of reinvested portfolios can be decimal. I need to replace this line with quantity = _convert_decimal(row["Quantity"]).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Made that change here as well.

I didn't realize I should be running tox checks and it turns out
the type inference engine wasn't able to correctly infer
non-nullability previously. Introducing a variable fixes the check.
Copy link
Contributor Author

@bayesianmind bayesianmind left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you both so much for your feedback. This PR is way better for it.
It's ready to go now. When combined with #96 tox is passing.

beancount_import/source/schwab_csv.py Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
beancount_import/source/schwab_csv.py Outdated Show resolved Hide resolved
@@ -1077,10 +1319,10 @@ def _load_positions_csv(
symbol = STRIP_FROM_SYMBOL_RE.sub("", symbol)
quantity = _convert_int(row["Quantity"])
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Made that change here as well.

@bayesianmind bayesianmind marked this pull request as ready for review February 14, 2021 04:57
@bayesianmind
Copy link
Contributor Author

@jbms This is ready to merge alongside #96 when you get a chance. Thanks!

@jbms jbms merged commit cc31dc7 into jbms:master Feb 14, 2021
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

Successfully merging this pull request may close these issues.

None yet

6 participants