Optionscope
Comprehensive web app designed to help options traders analyze trading history, understand their trading behavior, and strategize better for future trades. It securely fetches options trading data from Robinhood or allows uploads via CSV files, providing in-depth analytics, interactive visualizations, and a platform for reflection & note taking
Install / Use
/learn @Manojbhat09/OptionscopeREADME
Supercharge your Robinhood options trading strategy with data-driven insights! 🚀 The Options Trading Analysis Dashboard is a powerful web application designed for options traders who want to understand and improve their trading performance. By securely fetching your options trading data directly from Robinhood, this dashboard provides in-depth analytics, interactive visualizations, and a platform for you to reflect, take notes, and develop better trading strategies.
Whether you're a seasoned options trader or just getting started, this tool helps you:
- Analyze your trading history in detail.
- Visualize profit and loss trends over time.
- Identify your most profitable instruments and strategies.
- Keep track of your thoughts and strategies with integrated note-taking.
🌟 Features
🔮 Update
- Chatbot Integration: Interact with a chatbot to get quick answers and assistance on using the dashboard. Knows your data & plots.
- Screenshots stored locally in
backend/screenshotsfolder. - Default model set to
meta-llama/llama-3.2-11b-vision-instruct:freeinbackend/chatbot_service.py. Change as fit.
- Screenshots stored locally in
- 📈 Secure Data Fetching: Log in with your Robinhood credentials to fetch your options trading history within a specified date range.
- 🏆 Comprehensive Analytics:
- Total Profit/Loss calculations.
- Win Rate and Total Trades overview.
- Profit/Loss by Instrument: Identify which assets are driving your performance.
- Profit/Loss by Option Type: Understand whether calls or puts are more profitable for you.
- Revenue Analysis by Instrument.
- Cumulative Profit/Loss Over Time: See how your P/L evolves.
- Top Profitable and Loss-Making Trades: Learn from your best and worst trades.
- 📊 Interactive Visualizations: Utilize charts and graphs powered by Recharts for an intuitive analysis experience.
- 🗓️ Customizable Date Range: Focus your analysis on specific periods to see how strategies performed over time.
- 📝 Trading Notes:
- Integrated note-taking section with Markdown support.
- Export notes as Markdown files.
- Save and load notes for continuous strategizing and refer back when needed.
- 💾 CSV Upload Option: Alternatively, upload your trading data via CSV if you prefer not to connect your Robinhood account.
- 💹 Responsive Design: Access the dashboard from desktop or mobile devices.
Prerequisites
- Node.js (v14 or higher) -> 18.12.1
- Python (v3.6 or higher)
- Robinhood Account Credentials
🚀 Quick Start
-
Clone the repository:
git clone git@github.com:Manojbhat09/optionscope.git -
Install dependencies:
cd optionscope pip install -r backend/requirements.txt npm run build npm install # make sure to use correct nodejs, 'nvm use 18.12.1' & 'npm audit --fix' -
Start the development server:
npm start -
Open your browser and navigate to
http://localhost:3000
🚀 Elaborate Installing and Running the Flask Python Backend
Prerequisites:
- Python 3.7+ should be installed
- Pip (Python package manager) should be available
Steps:
-
Clone or Copy the Code
- Place the backend code (the files you showed) in a directory on your machine.
-
Create a Virtual Environment (recommended):
python3 -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate -
Install Python Dependencies:
- You need to install Flask, Flask-CORS, pandas, numpy, robin_stocks, yfinance, python-dotenv, tqdm, pillow, requests (and possibly others).
- The simplest way is to create a
requirements.txtfile or just run:pip install flask flask-cors pandas numpy yfinance robin_stocks python-dotenv tqdm pillow requests - If you already have a
requirements.txtfile, use:pip install -r requirements.txt
-
Set Up Environment Variables:
- Create a
.envfile in your backend directory with the required variables, e.g.:REACT_APP_OPENROUTER_API_KEY=your_api_key_here - Replace
your_api_key_herewith your real key. - Or use export and put in ~/.bashrc
export REACT_APP_OPENROUTER_API_KEY=sk-
- Create a
-
Run the Flask App:
cd backend python app.py- The server will run on
http://127.0.0.1:5000/by default.
- The server will run on
🟢 Using with Node.js (e.g., React, Next.js Frontend)
If you use nvm (Node Version Manager), you can update as follows:
nvm install --lts
nvm use --lts
node -v # Should show v18.x, v20.x, etc.
Or, to get a specific version (example: v20):
nvm install 20
nvm use 20
- You do not "install" Python code with Node. Instead, you run your backend and frontend separately, and connect them via HTTP APIs.
- You can set up a Node.js frontend (React, Next.js, etc) in a separate folder, and call your Flask backend at
http://localhost:5000/api/...endpoints.- For creating a React app:
npx create-react-app frontend cd frontend npm start - Then, fetch data from your Flask backend using AJAX/fetch/axios in your React code.
- For creating a React app:
🔗 Summary Table
| Part | How to install/run | Notes |
|-------------|----------------------------------|-------------------------------------------|
| Flask Backend | pip install ... then python app.py | Python 3, use a virtualenv, set .env |
| Node Frontend | npm install, npm start (if using) | Kept separate; frontend calls backend API |
🖥️ Usage
Fetching Data from Robinhood
-
Enter Credentials:
- Username: Your Robinhood account email.
- Password: Your Robinhood account password.
- Start Date: The beginning date for your trading data.
- End Date: The ending date for your trading data.
-
Fetch Data:
- Click the "Fetch Data" button.
- The app will securely authenticate with Robinhood and retrieve your options trading history.
Analyzing Your Trades
Once data is fetched:
-
Summary Overview:
- Total Profit/Loss: Net earnings from your trades.
- Total Profit: Sum of all profitable trades.
- Total Loss: Sum of all losing trades.
- Win Rate: Percentage of trades that were profitable.
- Total Trades: Number of trades made.
-
Charts and Graphs:
- Profit/Loss by Instrument: Bar chart showing P/L for each traded instrument.
- Revenue by Instrument: Understand which instruments generate the most revenue.
- Profit/Loss by Option Type: Pie chart comparing calls vs. puts.
- Cumulative Profit/Loss Over Time: Line chart of your P/L progression.
- Holding Period Analysis: Insights into the duration of your trades.
-
Top Trades:
- Top Profitable Trades: Review your best trades.
- Top Loss-Making Trades: Identify and learn from your biggest losses.
Reviewing Individual Trades
Scroll down to view a detailed table containing all your trades, including:
- Activity Date
- Instrument
- Description
- Transaction Code
- Quantity
- Strike Price
- Price
- Amount
Trading Notes
-
Edit Notes:
- Click on "Edit" to modify your trading notes.
- Notes support Markdown formatting for rich text features.
-
Save Notes:
- After editing, click "Save" to store your notes locally.
-
Export Notes:
- Click "Export as MD" to download your notes as a Markdown file.
-
Reset or Clear Notes:
- Reset to Default: Restore the original sample notes.
- Clear Notes: Remove all notes.
Adjusting Data Range
- Use the row sliders to adjust the range of data analyzed.
- Date range and row numbers are displayed for clarity.
Uploading CSV Data (Optional)
- Click on "Upload CSV" to select and upload a CSV file containing your trading data.
- The CSV should have columns similar to those fetched from Robinhood.
Security Notice
-
Credentials Usage:
- Your Robinhood username and password are used only to fetch your trading data.
- Credentials are not stored on any server or sent to any third party.
- Data fetching happens over secure connections directly with Robinhood's API.
-
Data Privacy:
- All fetched data is processed locally on your machine.
- No trading data is uploaded or stored externally.
-
Important:
- Always ensure you trust the application before entering your credentials.
- Review the source code if in doubt, particularly
backend/app.pyandbackend/get_rh_options_app.py.
🔮 Future Features
We're constantly working to improve the Options Trading Analysis Dashboard. Here are some exciting features on our roadmap:
