A comprehensive, production-ready Streamlit dashboard for financial market analysis. This application provides stock market analysis, economy overview, cryptocurrency tracking, options analysis, financial statements, technical indicators, news, earnings tracking, performance comparisons, and forecasting capabilities.
- Historical Price Data: Interactive charts with customizable date ranges and granularity (day, hour, week, month)
- Performance Metrics: Total return, annualized return, volatility, Sharpe ratio, max drawdown
- Key Metrics Dashboard: Current price, price changes, volume analysis
- 8 Comprehensive Tabs: Financial Statements, News, Forecast, Company Info, Calendar & Events, Dividends & Splits, Comparisons, Technical Indicators
- Treasury Yields: Historical U.S. Treasury yield data across multiple maturities (1-month to 30-year)
- Yield curve visualization
- Historical yield trends
- Latest yield metrics
- Inflation Data: Comprehensive inflation indicators
- CPI (Consumer Price Index) and Core CPI
- PCE (Personal Consumption Expenditures) and Core PCE
- Year-over-year inflation rates
- Historical inflation trends
- Inflation Expectations: Market-based and model-based inflation forecasts
- 5-year and 10-year market expectations
- Fed model predictions
- Forward inflation expectations
- OHLC Data: Historical Open, High, Low, Close price data for cryptocurrency pairs
- Performance Metrics: Returns, volatility, Sharpe ratio, max drawdown
- Price Charts: Interactive candlestick charts with volume
- Crypto Information: Detailed information about major cryptocurrencies including:
- Bitcoin (BTC), Ethereum (ETH), Ripple (XRP), Litecoin (LTC)
- Cardano (ADA), Solana (SOL), Polkadot (DOT), Polygon (MATIC)
- Avalanche (AVAX), Uniswap (UNI)
- Key features, consensus mechanisms, use cases, and market position
- Market Data: VWAP, trading statistics, price statistics, volume analysis
- Options Chain Data: View call and put options for any stock with available options data
- Black-Scholes Pricing: Theoretical option prices using the Black-Scholes model
- Greeks Analysis: Comprehensive Greeks calculations including:
- Delta: Price sensitivity to underlying asset movement
- Gamma: Rate of change of delta
- Theta: Time decay of option value
- Vega: Sensitivity to volatility changes
- Rho: Sensitivity to interest rate changes
- Implied Volatility: Calculate implied volatility from market prices using Newton-Raphson method
- Visualizations: Interactive charts showing Greeks across different strike prices
- Near-the-Money Filtering: Focus on options near current stock price
- Stock Information: Basic stock metrics integrated with options analysis
- Separate View Mode: Dedicated options analysis section independent from stock analysis
- Balance Sheets: Quarterly and annual balance sheet data
- Income Statements: Comprehensive income statement analysis with growth metrics
- Cash Flow Statements: Operating, investing, and financing cash flows
- Financial Ratios: Valuation, profitability, and financial health metrics including:
- P/E, P/B, P/S, PEG ratios
- ROE, ROA, ROIC
- Profit margins, EBITDA margins
- Debt-to-equity, current ratio, quick ratio
- And many more
- DuPont Analysis: ROE breakdown and component analysis
- AI-Powered Analysis: Gemini AI integration for financial statement insights
- Simple Moving Average (SMA): Configurable window sizes with beginner-friendly explanations
- Exponential Moving Average (EMA): Smoothing factor customization
- MACD: Moving Average Convergence Divergence with signal line and histogram
- RSI: Relative Strength Index with overbought/oversold levels
- Interactive Charts: Overlay indicators on price charts with subplots
- Educational Content: Parameter descriptions and best practices for beginners
- Market News: Latest news articles from multiple sources
- Company Information: Corporate overview, market cap, employees, industry
- Analyst Recommendations: Buy/sell/hold recommendations and summaries
- News Sentiment: Positive/negative/neutral sentiment analysis
- Earnings Calendar: Upcoming and historical earnings dates
- Earnings History: Beat/miss statistics, surprise percentages
- Future Earnings: Smart detection of next earnings dates using yfinance
- Corporate Actions: Dividends and stock splits tracking
- Earnings Trends: Visual charts showing actual vs. estimate earnings
- S&P 500 Benchmarking: Compare ticker performance vs. S&P 500
- Multiple Timeframes: YTD, 1Y, 3Y, 5Y return comparisons
- Performance Difference: Visual comparison of relative performance
- Automatic Fallback: Uses yfinance when Massive API doesn't support index tickers
- Simple Moving Average Forecast: Project future prices using SMA
- Linear Trend Forecast: Statistical trend analysis (requires scikit-learn)
- Exponential Smoothing: Time series forecasting
- Interactive Forecast Charts: Visualize predictions with confidence intervals
- Institutional Holders: Top institutional investors
- Major Holders: Major shareholders breakdown
- Insider Transactions: Insider buying and selling activity
- ESG/Sustainability: Environmental, social, and governance scores
- Gemini AI Integration: AI-powered financial statement analysis
- Custom Questions: Ask specific questions about financial health
- Comprehensive Insights: Detailed analysis of company performance
.
โโโ app/
โ โโโ streamlit_app.py # Main Streamlit application (UI orchestrator)
โ โโโ utils.py # Utility functions (API keys, formatting, etc.)
โ โโโ calculations/ # Calculation modules
โ โ โโโ __init__.py
โ โ โโโ returns.py # Return calculations
โ โ โโโ performance.py # Performance comparison calculations
โ โ โโโ financial_analysis.py # Financial analysis (growth, DuPont, AI)
โ โ โโโ options.py # Options pricing (Black-Scholes, Greeks)
โ โโโ data_fetchers/ # Data fetching modules
โ โ โโโ __init__.py
โ โ โโโ historical.py # Historical price data
โ โ โโโ financials.py # Financial statements and ratios
โ โ โโโ technical.py # Technical indicators (SMA, EMA, MACD, RSI)
โ โ โโโ news.py # News fetching
โ โ โโโ company.py # Company information
โ โ โโโ yfinance_extended.py # Extended yfinance features
โ โ โโโ economy.py # Economy data (Treasury Yields, Inflation)
โ โโโ charts/ # Chart creation modules
โ โ โโโ __init__.py
โ โ โโโ price_chart.py # Interactive price charts
โ โโโ tabs/ # Tab UI modules (for future expansion)
โโโ .streamlit/
โ โโโ secrets.toml # API key configuration (create from example)
โ โโโ secrets.toml.example # Example secrets file
โโโ config.py # Fallback API key configuration
โโโ requirements.txt # Python dependencies
โโโ README.md # This file
pip install -r requirements.txtOptional Dependencies:
scikit-learn: Required for Linear Trend forecasting method (optional, falls back to SMA if not installed)scipy>=1.10.0: Required for Black-Scholes options pricing calculations (already included in requirements.txt)
The app supports API keys via Streamlit secrets (recommended) or config file (fallback).
Method 1: Streamlit Secrets (Recommended)
-
Create the
.streamlitdirectory if it doesn't exist:mkdir -p .streamlit
-
Copy the example secrets file:
cp .streamlit/secrets.toml.example .streamlit/secrets.toml
-
Edit
.streamlit/secrets.tomland add your API keys:MASSIVE_API_KEY = "your_massive_api_key_here" GEMINI_API_KEY = "your_gemini_api_key_here" # Optional, for AI analysis GEMINI_MODEL = "gemini-2.5-flash" # Optional, specify preferred model
Method 2: Config File (Fallback)
Edit config.py and add:
api_key = "your_massive_api_key_here"
gemini_api_key = "your_gemini_api_key_here" # Optionalstreamlit run app/streamlit_app.pyThe dashboard will open in your default web browser at http://localhost:8501
- Home Screen: The dashboard starts with a welcome screen showing "Financial Assistant Dashboard" with quick access to all features
- Navigate Sections: Use the sidebar controls to access:
- ๐ Stock Analysis: Enter ticker symbol, select date range, and load analysis
- ๐ Economy Overview: Select historical period and load economy data
- โฟ Crypto Analysis: Enter crypto pair (e.g., BTCUSD) and load crypto data
- ๐ช Options Analysis: Enter ticker symbol, load options dates, select expiration, and analyze options
- Home Button: Click "๐ Home" in the sidebar to return to the starting screen
- Enter Ticker Symbol: Type a stock ticker symbol in the sidebar (e.g., "AAPL", "MSFT", "GOOGL")
- Select Date Range: Choose your analysis period (defaults to last year)
- Choose Granularity: Select data granularity (day, hour, week, month)
- Load Analysis: Click "๐ Load Analysis" to fetch and display data
The dashboard is organized into 8 tabs:
-
๐ Financial Statements
- View balance sheets, income statements, and cash flow statements
- Toggle between quarterly and annual data
- Analyze financial ratios and growth metrics
- DuPont analysis breakdown
- AI-powered financial analysis (requires Gemini API key)
-
๐ฐ News
- Latest news articles about the company
- Multiple news sources
- Sentiment analysis (positive/negative/neutral)
- Filter by date and relevance
-
๐ฎ Forecast
- Select forecasting method (SMA, Linear Trend, Exponential Smoothing)
- Configure forecast parameters
- View forecasted prices and confidence intervals
-
๐ข Company Info
- Company overview and description
- Market cap, employees, industry
- Analyst recommendations
- Options chain data
- Institutional and major holders
-
๐ Calendar & Events
- Earnings calendar with upcoming dates
- Historical earnings with beat/miss analysis
- Corporate actions timeline
- Earnings trends visualization
-
๐ฐ Dividends & Splits
- Dividend history and yield
- Stock split history
- All corporate actions
-
๐ Comparisons
- Performance vs. S&P 500
- YTD, 1Y, 3Y, 5Y comparisons
- Visual performance charts
-
๐ Technical Indicators
- Configure SMA, EMA, MACD, RSI parameters
- Beginner-friendly explanations
- Interactive charts with indicator overlays
- Subplot views for MACD and RSI
- Select Historical Period: Choose from 30 days to 5 years
- Load Economy Data: Click "๐ Load Economy Data" to fetch:
- Treasury Yields: Interest rates across different maturities
- Inflation Data: CPI and PCE inflation metrics
- Inflation Expectations: Market and model-based forecasts
What You'll See:
- Yield curve visualization
- Historical yield trends
- Inflation rate charts
- Inflation expectations over time
- Latest economic indicators
- Enter Crypto Pair: Type a cryptocurrency pair (e.g., "BTCUSD", "ETHUSD")
- Use format "X:BTCUSD" for full ticker, or just "BTCUSD"
- Select Date Range: Choose your analysis period
- Choose Granularity: Select data granularity (day, hour, week, month)
- Load Crypto Analysis: Click "โฟ Load Crypto Analysis" to fetch data
What You'll See:
- Performance Metrics: Returns, volatility, Sharpe ratio
- Price Charts: Interactive OHLC candlestick charts
- Crypto Information: Detailed info about the cryptocurrency including:
- Description and key features
- Launch date, consensus mechanism, max supply
- Use cases and market position
- Market Data: VWAP, trading statistics, price statistics, volume analysis
Supported Cryptocurrencies:
- Bitcoin (BTCUSD), Ethereum (ETHUSD), Ripple (XRPUSD)
- Litecoin (LTCUSD), Cardano (ADAUSD), Solana (SOLUSD)
- Polkadot (DOTUSD), Polygon (MATICUSD), Avalanche (AVAXUSD), Uniswap (UNIUSD)
- And many more major cryptocurrency pairs
- Enter Ticker Symbol: Type a stock ticker symbol (e.g., "AAPL", "TSLA", "MSFT")
- You can enter it in the sidebar or use the quick access on the home page
- Load Options Dates: Click "๐ Load Options Dates" to fetch available expiration dates
- Select Expiration Date: Choose from the available expiration dates
- Set Risk-Free Rate: Enter the risk-free rate (default: 4.5%, typically 10-year Treasury yield)
- Load Options Chain: Click "๐ช Load Options Chain" to load and analyze options data
What You'll See:
- Stock Information: Basic stock metrics including current price, market cap, P/E ratio, sector, and industry
- Options Parameters: Current price, expiration date, time to expiry, and risk-free rate
- Black-Scholes Parameters:
- Automatic implied volatility calculation from market prices
- Manual volatility input option
- Dividend yield adjustment
- Call Options Analysis:
- Summary statistics (total calls, average prices, implied volatility)
- Near-the-money options filtering
- Greeks visualization (Delta, Gamma, Theta, Vega)
- Full options chain with theoretical prices and Greeks
- Put Options Analysis:
- Summary statistics (total puts, average prices, implied volatility)
- Near-the-money options filtering
- Greeks visualization (Delta, Gamma, Theta, Vega)
- Full options chain with theoretical prices and Greeks
Features:
- Separate View Mode: Options analysis is completely independent from stock analysis
- Quick Access: Available directly from the home page
- Black-Scholes Calculations: Theoretical option pricing with all Greeks
- Implied Volatility: Automatically calculates implied volatility from market prices
- Interactive Visualizations: Charts showing how Greeks vary across strike prices
- Near-the-Money Focus: Filter options within a customizable percentage of current stock price
The application follows a modular architecture pattern:
- Separation of Concerns: UI logic, data fetching, calculations, and charting are separated into distinct modules
- Maintainability: Easy to add new features or modify existing ones
- Reusability: Functions can be imported and used independently
- Testability: Each module can be tested in isolation
- Massive API: Historical price data, technical indicators, news, economy data (Treasury Yields, Inflation, Inflation Expectations), crypto OHLC data
- Yahoo Finance (yfinance): Financial statements, earnings data, company info, dividends, splits, S&P 500 data (as fallback), options chain data
- Google Gemini API: AI-powered financial analysis (optional)
The application supports four main view modes:
- Stock Analysis: Full stock market analysis with 8 comprehensive tabs
- Economy Overview: Economic indicators and trends
- Crypto Analysis: Cryptocurrency market analysis
- Options Analysis: Options chain analysis with Black-Scholes calculations and Greeks
The title dynamically changes based on the active view:
- "Financial Assistant Dashboard" (home screen)
- "Stock Analysis Dashboard" (stock view)
- "Economy Overview" (economy view)
- "Crypto Analysis Dashboard" (crypto view)
- "Options Analysis Dashboard" (options view)
- Uses Streamlit's
@st.cache_datafor efficient data fetching - Configurable TTL (Time To Live) for different data types
- Reduces API calls and improves performance
- Comprehensive error handling throughout the application
- Graceful fallbacks when APIs are unavailable
- User-friendly error messages
- Logging for debugging
- Automatic fallback to yfinance when Massive API doesn't support certain tickers
- Large numbers (trillions) formatted with "T" suffix and 3 decimal places
- Billions and smaller numbers maintain original format
- Consistent formatting across all metrics
- MASSIVE_API_KEY: Required for historical data, technical indicators, news, economy data, and crypto data
- GEMINI_API_KEY: Optional, for AI financial analysis features
Stock Data:
- Historical aggregates:
/v2/aggs/ticker/{ticker}/range/... - Technical indicators:
/v1/indicators/{indicator}/{ticker} - News:
/v2/reference/news - Company info:
/v3/reference/tickers/{ticker}
Economy Data:
- Treasury Yields:
/fed/v1/treasury-yields - Inflation:
/fed/v1/inflation - Inflation Expectations:
/fed/v1/inflation-expectations
Crypto Data:
- Custom Bars (OHLC):
/v2/aggs/ticker/{cryptoTicker}/range/{multiplier}/{timespan}/{from}/{to}
streamlit>=1.28.0: Web application frameworkplotly>=5.17.0: Interactive chartspandas>=2.0.0: Data manipulationnumpy>=1.24.0: Numerical computationsscipy>=1.10.0: Scientific computing (required for Black-Scholes calculations)yfinance>=0.2.0: Yahoo Finance datamassive>=1.0.0: Massive API clientrequests>=2.31.0: HTTP requestsgoogle-generativeai>=0.3.0: Gemini AI integration (optional)scikit-learn: Linear trend forecasting (optional)
Issue: "ModuleNotFoundError: No module named 'app'"
- Solution: The app automatically handles this by adding the project root to
sys.path. If issues persist, ensure you're running from the project root directory.
Issue: "API key not found"
- Solution: Ensure
.streamlit/secrets.tomlexists and containsMASSIVE_API_KEY, or updateconfig.pywith your API key.
Issue: "No data available for this ticker"
- Solution: Verify the ticker symbol is correct. Some tickers may have limited data availability. For crypto, ensure you're using the correct pair format (e.g., BTCUSD or X:BTCUSD).
Issue: Technical indicators not loading
- Solution: Check your Massive API key has access to the indicators endpoint. Some indicators require sufficient historical data.
Issue: AI analysis not working
- Solution: Ensure
GEMINI_API_KEYis set in secrets or config. The feature gracefully degrades if not available.
Issue: S&P 500 comparison shows "N/A"
- Solution: The app automatically falls back to yfinance if Massive API doesn't support index tickers. This is expected behavior.
Issue: Economy data not loading
- Solution: Verify your Massive API key has access to the economy endpoints (
/fed/v1/*). Some API plans may not include economy data.
Issue: Crypto data not loading
- Solution: Ensure you're using the correct crypto pair format. Try both "BTCUSD" and "X:BTCUSD" formats. Verify your API key has access to crypto endpoints.
Issue: Options data not loading
- Solution: Verify the ticker symbol has available options data. Not all stocks have options. Ensure your internet connection is stable as yfinance fetches options data from Yahoo Finance.
- Additional technical indicators (Bollinger Bands, Stochastic, etc.)
- Portfolio analysis and comparison
- Custom watchlists
- Export data to CSV/Excel
- Email/SMS alerts for earnings
- More advanced forecasting models
- Sector and industry comparisons
- Advanced options strategies (spreads, straddles, etc.)
- Options profit/loss calculators
- Additional economy indicators (GDP, unemployment, etc.)
- More cryptocurrency information and analysis
- Real-time price alerts
Contributions are welcome! Please feel free to submit a Pull Request.
See LICENSE for license information.
For issues or questions, please open an issue in the repository.
