Skip to content

inor-w/Financial-Assistant-Dasboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

9 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Financial Assistant Dashboard

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.

Demo

Features

๐Ÿ“ˆ Stock Analysis

  • 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

๐ŸŒ Economy Overview

  • 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

โ‚ฟ Crypto Analysis

  • 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 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

๐Ÿ’ฐ Financial Statements

  • 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

๐Ÿ“ˆ Technical Indicators

  • 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

๐Ÿ“ฐ News & Information

  • 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

๐Ÿ“… Calendar & Events

  • 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

๐Ÿ“Š Performance Comparisons

  • 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

๐Ÿ”ฎ Forecasting

  • 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

๐Ÿข Company Details

  • Institutional Holders: Top institutional investors
  • Major Holders: Major shareholders breakdown
  • Insider Transactions: Insider buying and selling activity
  • ESG/Sustainability: Environmental, social, and governance scores

๐Ÿค– AI Financial Analysis

  • Gemini AI Integration: AI-powered financial statement analysis
  • Custom Questions: Ask specific questions about financial health
  • Comprehensive Insights: Detailed analysis of company performance

Project Structure

.
โ”œโ”€โ”€ 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

Setup Instructions

1. Install Dependencies

pip install -r requirements.txt

Optional 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)

2. Configure API Keys

The app supports API keys via Streamlit secrets (recommended) or config file (fallback).

Method 1: Streamlit Secrets (Recommended)

  1. Create the .streamlit directory if it doesn't exist:

    mkdir -p .streamlit
  2. Copy the example secrets file:

    cp .streamlit/secrets.toml.example .streamlit/secrets.toml
  3. Edit .streamlit/secrets.toml and 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"  # Optional

3. Run the Dashboard

streamlit run app/streamlit_app.py

The dashboard will open in your default web browser at http://localhost:8501

Usage

Getting Started

  1. Home Screen: The dashboard starts with a welcome screen showing "Financial Assistant Dashboard" with quick access to all features
  2. 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
  3. Home Button: Click "๐Ÿ  Home" in the sidebar to return to the starting screen

Stock Analysis

  1. Enter Ticker Symbol: Type a stock ticker symbol in the sidebar (e.g., "AAPL", "MSFT", "GOOGL")
  2. Select Date Range: Choose your analysis period (defaults to last year)
  3. Choose Granularity: Select data granularity (day, hour, week, month)
  4. Load Analysis: Click "๐Ÿ“ˆ Load Analysis" to fetch and display data

The dashboard is organized into 8 tabs:

  1. ๐Ÿ“Š 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)
  2. ๐Ÿ“ฐ News

    • Latest news articles about the company
    • Multiple news sources
    • Sentiment analysis (positive/negative/neutral)
    • Filter by date and relevance
  3. ๐Ÿ”ฎ Forecast

    • Select forecasting method (SMA, Linear Trend, Exponential Smoothing)
    • Configure forecast parameters
    • View forecasted prices and confidence intervals
  4. ๐Ÿข Company Info

    • Company overview and description
    • Market cap, employees, industry
    • Analyst recommendations
    • Options chain data
    • Institutional and major holders
  5. ๐Ÿ“… Calendar & Events

    • Earnings calendar with upcoming dates
    • Historical earnings with beat/miss analysis
    • Corporate actions timeline
    • Earnings trends visualization
  6. ๐Ÿ’ฐ Dividends & Splits

    • Dividend history and yield
    • Stock split history
    • All corporate actions
  7. ๐Ÿ“Š Comparisons

    • Performance vs. S&P 500
    • YTD, 1Y, 3Y, 5Y comparisons
    • Visual performance charts
  8. ๐Ÿ“ˆ Technical Indicators

    • Configure SMA, EMA, MACD, RSI parameters
    • Beginner-friendly explanations
    • Interactive charts with indicator overlays
    • Subplot views for MACD and RSI

Economy Overview

  1. Select Historical Period: Choose from 30 days to 5 years
  2. 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

Crypto Analysis

  1. Enter Crypto Pair: Type a cryptocurrency pair (e.g., "BTCUSD", "ETHUSD")
    • Use format "X:BTCUSD" for full ticker, or just "BTCUSD"
  2. Select Date Range: Choose your analysis period
  3. Choose Granularity: Select data granularity (day, hour, week, month)
  4. 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

Options Analysis

  1. 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
  2. Load Options Dates: Click "๐Ÿ“Š Load Options Dates" to fetch available expiration dates
  3. Select Expiration Date: Choose from the available expiration dates
  4. Set Risk-Free Rate: Enter the risk-free rate (default: 4.5%, typically 10-year Treasury yield)
  5. 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

Technical Details

Architecture

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

Data Sources

  • 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)

View Modes

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)

Caching Strategy

  • Uses Streamlit's @st.cache_data for efficient data fetching
  • Configurable TTL (Time To Live) for different data types
  • Reduces API calls and improves performance

Error Handling

  • 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

Number Formatting

  • Large numbers (trillions) formatted with "T" suffix and 3 decimal places
  • Billions and smaller numbers maintain original format
  • Consistent formatting across all metrics

API Reference

Required API Keys

  • MASSIVE_API_KEY: Required for historical data, technical indicators, news, economy data, and crypto data
  • GEMINI_API_KEY: Optional, for AI financial analysis features

Data Endpoints Used

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}

Dependencies

  • streamlit>=1.28.0: Web application framework
  • plotly>=5.17.0: Interactive charts
  • pandas>=2.0.0: Data manipulation
  • numpy>=1.24.0: Numerical computations
  • scipy>=1.10.0: Scientific computing (required for Black-Scholes calculations)
  • yfinance>=0.2.0: Yahoo Finance data
  • massive>=1.0.0: Massive API client
  • requests>=2.31.0: HTTP requests
  • google-generativeai>=0.3.0: Gemini AI integration (optional)
  • scikit-learn: Linear trend forecasting (optional)

Troubleshooting

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.toml exists and contains MASSIVE_API_KEY, or update config.py with 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_KEY is 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.

Future Enhancements

  • 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

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

See LICENSE for license information.

Support

For issues or questions, please open an issue in the repository.

About

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.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors