Google Finance Statistics UserScript
A powerful UserScript that enhances Google Finance portfolio pages by displaying comprehensive portfolio statistics in a clean, easy-to-read overlay.
Features
- Real-time Portfolio Analysis: Automatically calculates and displays key portfolio metrics
- Comprehensive Statistics: Shows portfolio value, total invested, realized/unrealized gains, and percentage returns
- Smart Activity Tab Detection: Automatically refreshes statistics when switching to the Activity tab to include realized gains/losses
- Watchlist Page Compatibility: Intelligently skips calculations on watchlist pages where they're not applicable
- Single Page Application (SPA) Support: Handles Google Finance's dynamic navigation seamlessly
- Clean UI: Non-intrusive overlay with modern styling and easy dismissal
Installation
Prerequisites
- A UserScript manager extension such as:
Installation Steps
- Install a UserScript manager extension in your browser
- Copy the UserScript code from
google-finance-statistics.user.js
- Create a new script in your UserScript manager
- Paste the code and save
- The script will automatically activate on Google Finance portfolio pages
Usage
Basic Usage
- Navigate to your Google Finance portfolio:
https://www.google.com/finance/portfolio/[your-portfolio-id]
- The script will automatically display a statistics overlay in the top-right corner
- Click the
×
button to dismiss the overlay if needed
For Realized Gains/Losses
If you have sold assets and want to see your realized profits/losses:
- Navigate to your portfolio page
- Click on the Activity tab
- The script will automatically detect the tab change and refresh the statistics to include realized gains/losses
Statistics Displayed
The overlay shows the following metrics:
Metric |
Description |
🏦 Portfolio Value |
Current total value of your portfolio |
💵 Total Invested |
Total amount you've invested (calculated) |
🌱 Unrealized Gain |
Profit/loss from holdings you still own |
📊 Pct Unrealized |
Unrealized gain as a percentage of total invested |
📈 Realized Gain |
Profit/loss from assets you've sold |
📊 Pct Realized |
Realized gain as a percentage of total invested |
💰 Total Gain |
Combined realized and unrealized gains |
🚀 Pct Total Gain |
Total gain as a percentage of total invested |
How It Works
Calculation Logic
The script extracts data from Google Finance's interface and performs the following calculations:
Total Invested = Portfolio Value - Unrealized Gain - Realized Gain
Total Gain = Realized Gain + Unrealized Gain
Percentage Returns = (Gain / Total Invested) × 100
Data Sources
- Portfolio Value: Extracted from Google Finance's portfolio summary
- Unrealized Gain: Pulled from the unrealized gains display
- Realized Gain: Calculated from activity data when Activity tab is selected
Smart Features
- Watchlist Detection: Automatically skips calculations on watchlist pages
- Activity Tab Monitoring: Detects when you switch to the Activity tab and refreshes data
- SPA Navigation: Handles Google Finance's dynamic page changes
- Error Handling: Gracefully handles missing data or page loading issues
Troubleshooting
Common Issues
Statistics not appearing:
- Ensure you're on a portfolio page (not watchlist)
- Wait a moment for the page to fully load
- Check that your UserScript manager is enabled
Realized gains showing as 0:
- Make sure you've clicked on the Activity tab
- Ensure you actually have realized gains/losses (sold positions)
- Wait for the Activity tab data to load completely
Incorrect calculations:
- This can happen if Google Finance changes their page structure
- Check the browser console for error messages
- Consider updating the script if a new version is available
Compatibility
- Browsers: Chrome, Firefox, Safari, Edge (with UserScript manager)
- Google Finance: Works with the current Google Finance interface
- Languages: Supports portfolios in different currencies (€, $, etc.)
Privacy & Security
- The script runs entirely in your browser
- No data is sent to external servers
- Only reads data from Google Finance pages you're already viewing
- Does not access or store any personal information
Contributing
If you encounter issues or have suggestions for improvements:
- Check the browser console for error messages
- Note your browser and UserScript manager versions
- Describe the steps to reproduce any issues
- Consider submitting bug reports or feature requests
License
MIT
Disclaimer
This script is not affiliated with Google. It's a third-party enhancement that may stop working if Google changes their interface. Use at your own discretion.