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
{
“username”: “usernamehere”,
“password”: “passw0rdh3r3”
}

#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 json
import robin_stocks as rh


content = open(‘config.json’).read()
config = json.loads(content)
rh.login(config[‘username’], config[‘password’])
rh.export_completed_stock_orders(“.”)

#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
stock_orders_Jan-08-2021.csv

#Here’s what it looks like!
$ head stock_orders_Jan-08-2021.csv
symbol,date,order_type,side,fees,quantity,average_price
VNE,2021-01-07T17:42:58.730000Z,limit,buy,0.00,2.00000000,20.55000000
KBNT,2021-01-07T14:30:10.837000Z,market,sell,0.00,10.00000000,5.44000000
BNGO,2021-01-06T19:26:02.112000Z,limit,buy,0.00,12.00000000,5.05500000
PLTR,2021-01-04T14:37:28.082000Z,limit,buy,0.00,9.00000000,22.55000000
PLTR,2020-12-31T16:33:27.710000Z,market,sell,0.00,9.00000000,23.87110000
VSTO,2020-12-31T14:33:02.565000Z,limit,buy,0.00,5.00000000,23.98000000
FUBO,2021-01-04T14:36:31.806000Z,limit,buy,0.00,4.00000000,27.00000000
FUBO,2020-12-28T14:19:39.850000Z,limit,sell,0.00,3.00000000,40.46000000
UUUU,2020-12-29T14:59:36.264000Z,limit,buy,0.00,3.00000000,4.15000000

After this I simply loaded it into a spreadsheet and was able to sort and easily calculate gains and losses!

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

required

Just making sure you\'re human! * Time limit is exhausted. Please reload CAPTCHA.