A comprehensive tool for analyzing stock transactions and portfolio performance, specifically designed for integration with Robinhood. This project provides functionalities to filter and analyze stock trades, calculate outstanding stock quantities, and visualize historical stock prices. It integrates with Yahoo Finance to fetch current stock prices and plots various metrics to evaluate stock trading strategies and portfolio performance.
To enable MFA for your Robinhood account, you’ll need a Time-based One-Time Password (TOTP) application, such as Google Authenticator, Authy, or any other TOTP-compatible app.
robin_mfa
to .env
File.env
File: If you don’t already have a .env
file in your project directory, create one. This file will store your environment variables..env
file in a text editor.YOUR_TOTP_SECRET
with the secret key you copied earlier:When you run your application, the robin_mfa variable will be used to generate a TOTP code automatically, which is required for logging in to Robinhood.
Run your application and verify that it logs in successfully using the generated TOTP code. If you encounter any issues, double-check that the robin_mfa value in your .env file is correct.
Clone the Repository:
git clone https://github.com/uppusaikiran/robinhood_stock_analyzer.git
cd robinhood_stock_analyzer
Create a Virtual Environment (optional but recommended):
python -m venv venv
source venv/bin/activate # On Windows use `venv\Scripts\activate`
Install Dependencies:
Create a .env
file in the root directory with your Robinhood credentials and MFA code:
robin_username=your_robinhood_username
robin_password=your_robinhood_password
robin_mfa=your_robinhood_mfa_secret
Install the required packages:
pip install -r requirements.txt
Run the Analyzer:
Use command-line arguments to specify the stock symbol, start date, and CSV file path.
python stock_analyzer.py --symbol AAPL --start_date 2023-01-01
Arguments:
--symbol
: The stock symbol to analyze (e.g., AAPL).--start_date
: The start date for the analysis in YYYY-MM-DD format (optional).--file
: The path to the CSV file (optional, default is ./stock_orders.csv
).--generate_data
: Set to True
to generate new transaction data from Robinhood (requires environment variables).Output:
python stock_analyzer.py --symbol MSFT --start_date 2023-01-01 --file ./my_stock_orders.csv
Feel free to submit issues or pull requests. Contributions are welcome!
This project is licensed under the MIT License. See the LICENSE file for more details.