Mac Shortcut to scrape Fidelity trade history and convert to Beancount

234 views
Skip to first unread message

David Avraamides

unread,
Apr 6, 2023, 6:09:01 PM4/6/23
to Beancount
For the subset of this group that uses both a Mac and uses Fidelity, I wrote up a description of how I use a Shortcut to scrape trade history from Fidelity’s website, run it through a Python script to convert to Beancount’s ledger format, and then save it in the clipboard so I can paste it into a ledger file.

It is a little complicated to explain so I wrote it up on my website here: https://noisysignal.com/trade_hist_shortcut/

In any case, I found it a useful way of doing a one-time import of the history of all my open and closed trades and will probably use this technique for other financial accounts who do not provide an easy-to-parse format for all of my data (while Fidelity supports CSV export of trade activity, they only go back 5 years and I wanted to go back further in time).

Martin Blais

unread,
Apr 6, 2023, 10:37:12 PM4/6/23
to bean...@googlegroups.com
Thanks for sharing David.
Added to contribs doc.


--
You received this message because you are subscribed to the Google Groups "Beancount" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beancount+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beancount/96c9be7d-b897-4881-9779-0e688c87b3ben%40googlegroups.com.

fin

unread,
Apr 7, 2023, 8:21:15 AM4/7/23
to bean...@googlegroups.com
that sounds rather complicated. i looked into doing both
scraping and converting pdfs to text files to extract the
transaction information but in both cases it was easier for
me to type in the information into the csv format since i
already had that mostly working (i'd have needed two or
three versions for the account because it had gone through
several versions of pdfs and html captures i had done many
years ago).


fin

David Avraamides

unread,
Apr 7, 2023, 8:33:07 AM4/7/23
to Beancount
Yes, it did feel a little kludgy when I was creating it, but in the end the shortcut is just a few steps and the Python script is pretty simple. And it allowed me to capture the trade history for dozens of positions across six accounts in just a few minutes so for me was worth the effort. And it should be easy to repurpose to other sites/sources quite easily since most of what is unique to Fidelity is just two regular expressions.

It would have been much easier if Fidelity simply provided my full account history in CSV format, but unfortunately that wasn't an option.

Red S

unread,
Apr 9, 2023, 11:06:24 PM4/9/23
to Beancount
Related: there's a similar importer I have for screenscraped/copy-paste input from Vanguard here. Reason: Vanguard ofx does not include certain unsettled transactions (some stock trades, IIRC). When I'm submitting a bunch of transactions, typically while tax-loss-harvesting, I need Beancount to be up to date.

Not that it helps with your Fidelity importer, but just sharing another instance where the ofx importer is insufficient, csv is not an option, and one has to resort to screenscraping.

Speaking about which, for anyone using Fidelity, their ofx support is excellent (for now at least), including direct downloads.

savingsandloan

unread,
Aug 17, 2023, 7:35:26 PM8/17/23
to Beancount
This looks really cool David, particularly for scenarios of trying to get cost basis of really old accounts on Fidelity. Will have to try this soon.

P.S. Regarding Fidelity CSV support while it's rather ugly code, I still tinker and use this https://github.com/savingsandloan/beancount_reds_importers/tree/fidelity_csv_old (related discussion: https://github.com/redstreet/beancount_reds_importers/pull/17 - hoping to eventually refactor it)
Reply all
Reply to author
Forward
0 new messages