Closed raviolispy closed 5 months ago
They have a get account/get accounts API call that should be able to support this: https://developer.tdameritrade.com/account-access/apis
It is on our roadmap to provide these integrations (including many other brokers) so they can be directly imported inside the portfolio
menu for now. We are also happy to provide guidance if you wish to design this yourself.
Is there a template to follow?
If you are looking to contribute via a Pull Request, you can do so by following these steps:
Keeping note of our guidelines: https://github.com/OpenBB-finance/OpenBBTerminal/blob/main/CONTRIBUTING.md
I have actually had a look at this - the tricky part is that TD Ameritrade uses OAUTH 2.0 for their authentication.
It seems like the best/most popular TD Ameritrade python API is https://github.com/timkpaine/tdameritrade.
The TDA authentication flow requires users to create a developer account and developer app to get API keys, then use the API key to log in via browser and extract another token from the URL after they've granted their developer app access to their account. The API I linked above has the workflow automated as much as possible - you call an authenticate function with your API key, it opens your browser with selenium and gets and returns the token that way. In the terminal, we could have the user save the API key as an env var, run the auth function in the keys menu, and save the refresh token as a terminal config var.
The main issues I see are:
I suggest we start by making a helper script that uses the API to download positions into a CSV that is readable by the terminal in a way that's not fully supported/in "beta" and then move it into a terminal command when we're ready.
Thoughts @JerBouma?
In my opinion, it will require too many steps for the average user to get to work and we can not expect them to install some third party software (selenium) next to OpenBB. My suggestion would be that we allow support for loading in a CSV or Excel file containing the person's transactions that the user downloads directly from the TD Ameritrade website.
We are also in talks with Snaptrade (https://snaptrade.com/) which could be a neat integration at some point.
@JerBouma The python library is already in the requirements.txt so we're good there but ok Ubuntu 22.04 I had to download a zip file of selenium web drivers for chrome and place them where it told me to for it to work. Not sure what the experience is like on WSL (the majority of users I'm guessing.
Good thought with providing support for importing CSVs from their website although iirc they only allow for downloading 1 year of transactions at a time.
Do either of those change things?
As a first step, providing support for importing the CSVs is a good first step so perhaps I'll start working on that.
I think for now it is fine we provide support for the CSV even if it is limited. At a later stage we can extend this when there are more users interested. Would be awesome if you could work on that! :)
Don't assign it to me just yet but I'll take a stab and if I get somewhere with it I'll put in a (draft) PR
Feel free to ping me if you have any questions. I have my TD stuff setup so can check out.
Can we also setup OpenBB to get ticker information such as intraday candles and such?
What's the problem of not having this feature? I'd like to be able to import a TD Ameritrade portfolio automatically like Ally Invest.
Describe the solution you would like A description of what you think would be the best solution for this. From user inputs, to an output.
Describe alternatives you've considered If there are other alternatives (worth considering) to your solution, list them here.
Additional information https://github.com/areed1192/td-ameritrade-api