Google Finance Statistics

Display comprehensive portfolio statistics on Google Finance

作者
MakMak
日安装量
0
总安装量
1
评分
0 0 0
版本
1.2
创建于
2025-07-06
更新于
2025-07-07
大小
22.9 KB
许可证
MIT
适用于

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

Installation Steps

  1. Install a UserScript manager extension in your browser
  2. Copy the UserScript code from google-finance-statistics.user.js
  3. Create a new script in your UserScript manager
  4. Paste the code and save
  5. The script will automatically activate on Google Finance portfolio pages

Usage

Basic Usage

  1. Navigate to your Google Finance portfolio: https://www.google.com/finance/portfolio/[your-portfolio-id]
  2. The script will automatically display a statistics overlay in the top-right corner
  3. 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:

  1. Navigate to your portfolio page
  2. Click on the Activity tab
  3. 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:

  1. Check the browser console for error messages
  2. Note your browser and UserScript manager versions
  3. Describe the steps to reproduce any issues
  4. 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.

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址