I just shared / checked-in some code that can use the Ameritrade API and convert a list of transactions to Beancount:
https://github.com/blais/ameritrade/commit/1b5ddae18ba3abbff19a9538e2e4f1cab3fed84a
This has worked a lot better for me than parsing the CSV downloads they provide (I switched at some point).
The API yields structured data in JSON that's reasonably straightforward to use.
Hopefully this is useful for someone else,