I currently have a short bias on the market and wanted to check the numbers to see if the data supports it.
With recent improvements to AI coding updates to Claude, the ability to "one shot" data science dashboards continues to get more powerful.
This week, I'll show you an analysis I did with AI to determine how "overheated" the S&P500 is.
Here's what we'll analyze into a clean dashboard:
Percent of S&P500 above 50 day moving average
Percent of S&P500 above 200 day moving average
Breakdown by sector of the above
Spread of the above
VIX
Here's the plan:
We will be using Cursor to create this mini dashboard
I have prepared for us a prompt to create this
Since we're handling a lot of data and views, you may need to do lite debugging (it's easy - just tell the AI what your errors are in plain English)
The Prompt
Paste this in Cursor (note that we include details of specific packages so it grabs the right data!):
Prompt to Create the Market Internals Dashboard
Primary Goal: Create a sophisticated, Python-based interactive web application named “S&P 500 Market Internals Dashboard.” The application will be built using Streamlit and is intended for experienced traders and investors who require a clear, verifiable, and data-driven snapshot of the market’s internal health.
Core Principles (These are non-negotiable): 1. 100% Verifiable Data: The only package used for fetching market data must be yfinance. Do not use any other data APIs, libraries requiring keys, or any form of simulated, dummy, hardcoded, or estimated data. All metrics must be calculated live from this raw data. 2. Focus on Market Breadth: The dashboard’s entire focus is on market internals. Do not include P/E ratios or any other valuation metrics. 3. User Experience: The application must be fast, intuitive, and provide clear feedback to the user, especially during data loading.
Detailed Functional Requirements:
1. Application Setup: - The application framework must be Streamlit. - The layout must be set to wide. - Create two final files: - A Python script for the application (e.g., market_internals_app.py). - A requirements.txt file listing all necessary dependencies (streamlit, pandas, yfinance, plotly, numpy).
2. Data Fetching and Processing: - Fetch the full list of S&P 500 companies and their corresponding “GICS Sector” from the relevant table on the Wikipedia page “List of S&P 500 companies”. - Crucially, during the data fetching loop for all 500+ stocks, display a prominent progress bar that updates in real-time to show the user that the application is working and not stuck. - For each stock in the S&P 500, calculate: - Its percentage distance from its 50-day Simple Moving Average (SMA). - Its percentage distance from its 200-day SMA. - Also, fetch the current level of the Volatility Index (VIX) using the ^VIX ticker.
3. Dashboard UI and Metrics Display: - At the top of the dashboard, display three key metrics in separate, styled “metric cards”: 1. The percentage of all S&P 500 stocks currently trading above their 50-day SMA. 2. The percentage of all S&P 500 stocks currently trading above their 200-day SMA. 3. The current VIX level.
4. Detailed Analysis Section (The Core of the Dashboard): - This section must be controlled by a single, horizontal radio button toggle that allows the user to select either “50-Day” or “200-Day” analysis. - The two charts below must be stacked vertically, not side-by-side, to ensure they are fully visible without being cut off. Both charts must update instantly based on the radio button selection. - Chart 1: Sector Strength (Horizontal Bar Chart): - Display the market breadth for each GICS sector. - The bars should show the percentage of stocks within that sector that are above the selected moving average (50-day or 200-day). - The chart should be sorted from the weakest sector to the strongest. - Chart 2: Overall Breadth Distribution (Histogram): - Display a histogram showing the distribution of all 500 stocks based on their percentage distance from the selected moving average. - The chart should have a clear vertical line at 0% to distinguish between stocks above and below their average.
5. Methodology Section: - At the bottom of the page, include a clear and concise “Methodology” section. - This section must explicitly state that the dashboard uses 100% real data from Yahoo Finance and does not use any simulated data. - Briefly explain how each metric (Market Breadth, Sector Breadth, VIX, and the Distribution Histogram) is calculated.
The Result:
Let's review the data....
~65% of stocks in SPY are above their 50D moving average, meaning we've definitely run up since tariffs; however, we're still near historical expectations on a longer time horizon 48% above 200D moving average. VIX is reasonable at 22 (neither max fear or max complacency)
Technology and Energy sectors have especially popped off. Defensive stocks (eg utilities, consumer staples) have lagged since tariffs.
The distribution is fairly symmetrical with right skew
My own overall interpretation on this data is - I think the market recognizes there are real risks (eg geopolitical, tariff impacts, etc) and has already adjusted positioning to account for this. But still is a net buyer of stocks.
I expect increased sensitivity to headline risk from market jitters since we are on the higher end of momentum but I doubt we revisit the April lows.
Not an area I personally am taking huge swings at but I'm watching for entries if we get a pull back.