Brokerage Web Portfolio Diversification Badge
Free to download on every platform. Comes pre-installed on BotFone, BotPad and BotFlip — with extra free apps included.
About this app
WHAT IT DOES
This userscript transforms your brokerage account's portfolio page into an instant diversification dashboard. It automatically reads your current holdings, calculates key risk metrics, and displays a prominent letter grade (A through F) that summarizes your portfolio's overall diversification health. The script evaluates three core dimensions: the number of unique positions (penalizing portfolios with too few holdings), the concentration of your largest position (flagging over-reliance on a single security), and sector diversification (measuring how spread out your investments are across different industries). The result is a clear, actionable grade that helps you identify concentration risks before they become problems. Additionally, the panel shows detailed breakdowns including total portfolio value, percentage allocation to each sector, and a visual bar chart of your sector exposure. If your largest position or top sector exceeds a user-defined threshold, the script can trigger a desktop notification to alert you immediately.
WHERE IT RUNS
The script runs on all brokerage website pages matching the pattern *://*.brokerage.com/*. It automatically detects when you're viewing your portfolio or holdings page by scanning for table structures, position lists, and common data-test attributes used by modern trading platforms. The script works on both traditional multi-page brokerage sites and modern single-page applications (SPAs) by detecting URL changes and DOM mutations. It adapts to different brokerage interfaces by trying multiple common selectors for position data, including .position-row, .holding-row, .portfolio-table, and various data-test attributes. The script is designed to work with most major brokerage platforms that display portfolio holdings in tabular format.
HOW TO USE
Simply install the script via the BotGentz extension and navigate to your brokerage's portfolio or holdings page. The diversification badge panel will appear automatically once holdings are detected. The panel displays your grade prominently at the top, followed by key metrics: number of positions, top holding weight, number of sectors represented, and largest sector concentration. Below this, you'll find a detailed sector breakdown with color-coded bars showing exact percentages. You can toggle the sector breakdown on or off using the checkbox in the panel. Use the "Alert at % concentration" setting to set a threshold (default 30%) - if your top position or largest sector exceeds this percentage, the script will show a desktop notification. Click "Refresh Data" to manually rescan the page for updated holdings after making trades. The panel is fully draggable and can be collapsed to a small icon when not in use.
THE MECHANISM - DOM PARSING AND METRIC CALCULATION
Unlike portfolio tracking apps that require API access or manual data entry, this script works entirely by parsing the visual DOM that your brokerage already renders. It first identifies position rows using a cascading selector strategy: starting with specific data-test attributes used by major brokerage platforms, then falling back to common class names (.position-row, .holding-row), and finally scanning all tables on the page for rows containing value-related headers. For each position found, the script extracts the security name, market value, and attempts to determine the sector by scanning for sector labels, asset class indicators, or inferring from the security name using a keyword dictionary. Values are parsed robustly by stripping currency symbols and non-numeric characters. The script then calculates diversification metrics using a proprietary scoring algorithm that combines position count (weighted 40%), top position concentration (weighted 35%), and sector concentration (weighted 25%). Each metric is scored on a scale, summed, and mapped to a letter grade. This multi-factor approach provides a more nuanced assessment than simple counting or single-metric analysis.
THE PANEL
The panel appears as a floating, draggable element on your portfolio page. Drag it by its header to reposition it anywhere on the screen. The position is saved per site using GM_setValue, so it stays where you left it across page loads. Release the panel near any edge and it snaps into place, keeping your workspace tidy. Click the panel header to collapse the entire panel into a small bubble showing only the emoji icon (📊) - perfect for minimizing distraction while still keeping the tool accessible. Drag from the bubble to restore the full panel. The panel automatically resizes to accommodate its content, with the sector breakdown section expandable or collapsible based on your preference. Press the Escape key to quickly collapse the panel to its minimized state.
PLEASE NOTE
This script requires the free BotGentz extension to function. It is designed for educational and analytical purposes - the diversification grade is a simplified metric and should not be the sole basis for investment decisions. Always consult with a qualified financial advisor for professional portfolio guidance. The script works by reading the DOM structure of your brokerage page; if the site updates its layout, the script may need to be updated to match new selectors. This script collects no data - all processing happens locally in your browser. All settings (show sectors toggle, alert threshold, panel position) are stored locally using GM_setValue and never transmitted. The script reads only visible position data and does not access passwords, hidden fields, or any sensitive form inputs. It does not perform any network requests beyond the page itself.