Thanks to Joshua Fernandes’ Robin_Stocks python module, you can download all your stock orders from RobinHood easily to a CSV file in order to calculate gains and losses to help when doing your taxes.
Below is a quick guide for how to do it in Linux, buy you can probably do it just as easily in Windows or on a Mac!
#First, install the module
$ sudo pip install robin_stocks
#Next, create a file to contain your user credentials, here’s an example
$ cat config.json
#Don’t worry, Robin_Stocks is smart enough to ask for your MFA code if you are using that feature
#Here’s the simple python program to make a CSV file and save it to your computer
$ cat download_stock_orders.py
import robin_stocks as rh
content = open(‘config.json’).read()
config = json.loads(content)
#Run it like this:
$ python3 download_stock_orders.py
Found Additional pages.
Loading page 2 …
Loading page 3 …
Loading page 4 …
#And here’s the resulting file dated with today’s date!
$ ls *.csv
#Here’s what it looks like!
$ head stock_orders_Jan-08-2021.csv
After this I simply loaded it into a spreadsheet and was able to sort and easily calculate gains and losses!