This project is python scripts, which uses mainly Robinhood's private API and Dash feature from Plotly for creating visualized trading journal. You can varify and download to use it as personal trading journal for Robinhood.
Inspired and based on python projects, Josh Fraser's robinhood-to-csv, and Rohan Pai & Adithya Balaji's Robinhood Unofficial.
The reason behind creating is that new age invester's trading habits in robinhood is very risky and rewarding and there is no budget tool (there are some pricey tools that can extract robinhood trades and then some requiering you to have csv from robinhood as robinhood doesn't give until asked from one of thier representive!), this can calculute one's ongoing gains, the person can actually know how much profit/loss is made in one week, month or quarter.
Most useful case scenerio is paying one's quarterly estimated tax based on your estimated calculated gain using this.
Where as day trader or swing trader can analyze their trading habits using visulized trading journal, run the script on day's end to know net profit of the day.
Note: Python scripts are in python3.
The defalts endpoints to access robinhood api is in Robinhood_Base.py, one of the convienince I made in my script for login is that it is MFA app compatiable login, which means you can use your google code auth or duo to add MFA code to login. Although I haven't worked on more methods since that are not useful in regards to this project, but you can give it a try.
The Robin_hood.py scripts have methods on accessing order history for stocks and options, (will try to work on crypto later), current portfolio and dataframe of order history. Benefit of this script is that it accounts of stocks splits while calculating for profit/loss, if security was bought before split and sold after split. Although calculation are based on FIFO basis as per Robinhood's default cost basis. However, wash sale calculation are not accounted. Also options calculation were quite complicated so at moment it only accounts for bought and sold or expired. If there is covered sell meaning that you sold option contract based on stocks owned, and option excersiced are not accounted. Hence those entities are not included in calculations.
Each Layout file in dashApp/app folder is each webpage layout's python scripts, it consists dash bootstrap, container, and html components as well as callback methods regarding each webpage are in same corresponding python script. For further understanding look dash documentation
You can manually download zip file from here, click on Code and select Download Zip
Requirements: python 3+ Install Python
Optional: Git Install Git. If zip downloaded then directly go to step 3 and 4
Cloning this repo:
Change directory to desired location!!!
>> cd Documents
>> git clone https://github.com/virajkothari7/Robinhood-trading-journal.git
>> cd Robinhood-trading-journal
>> pip install -r requirements.txt
For detailed instruction look Instruction.txt
Getting data from Robinhood and have visualize it on local server using a web browser!!
>> cd [PATH]/Robinhood-trading-journal/dashApp
>> python Robin_hood.py #To get data from Robinhood
>> python index.py #Will open a local server, for best view results, try using google chrome, safari or edge
After getting data by running "Robin_hood.py" script, and running "index.py" to have local server running dash app.
Below is screen shots of final app, also stored in snapshots folder.
- plotly==5.1.0
- dash==1.21.0
- dash_table==4.12.0
- dash_core_components==1.17.1
- dash_html_components==1.1.4
- dash_bootstrap_components==0.12.2
- numpy==1.20.3
- pandas==1.3.0
- requests==2.25.1
- yfinance==0.1.63
- datetime
Project: pyrh - Unofficial Robinhood API
Copyright (c) 2020 Unofficial Robinhood Python API Developers
License (MIT) https://github.com/robinhood-unofficial/pyrh/blob/master/LICENSE
Project: Robinhood to CSV
Copyright (c) 2015 Josh Fraser
Copyright (c) 2015 Rohan Pai
License (MIT) https://github.com/joshfraser/robinhood-to-csv/blob/master/LICENSE
Project: Plotly-Dash
Copyright (c) 2021 Plotly, Inc
License (MIT) https://github.com/plotly/dash/blob/dev/LICENSE
Documentation : https://dash.plotly.com/
Author: Charming Data
Github Repo: Coding-with-Adam/Dash-by-Plotly
Youtube Link: https://www.youtube.com/channel/UCqBFsuAz41sqWcFjZkqmJqQ
Author: Gil Yehuda (credit for Credits Template)
Quora Link: https://www.quora.com/How-do-I-properly-credit-an-original-codes-developer-for-her-open-source-contribution
Community Credits: Python Community, Stack Exchange Community, Plolty Community, Web-Developers Community
This project is licensed under MIT. You are responsible for using robinhood's private api and all depending third-party libraries by running the scripts, look robinhood's and respective python libraries terms of use.