An interactive Streamlit app that provides a comprehensive tool for analyzing options pricing, profit & loss (P&L), and mispricing using the Black-Scholes model. The app integrates theoretical pricing with real market data to help users make informed decisions about options trading.
- Visualize theoretical call and put option prices across a range of:
- Spot Prices
- Volatilities
- Understand how option values behave under different market conditions.
- Calculate the profit & loss (P&L) for options based on user-defined purchase prices.
- Heatmaps color-coded:
- Green: Positive P&L.
- Red: Negative P&L.
- Compare theoretical Black-Scholes prices with real market data:
- Blue: Undervalued options (buying opportunities).
- Red: Overvalued options (selling or avoid opportunities).
- Analyze mispricing across a range of spot prices and volatilities.
- Fetch live market data, including:
- Spot Price
- Strike Price
- Implied Volatility
- Option Prices
- Ticker selection powered by Yahoo Finance.
To run this app locally, follow these steps:
Ensure you have Python 3.8 or later installed.
git clone https://github.com/your-repo-name/black-scholes-app.git
cd black-scholes-app
Install the required libraries using the provided requirements.txt
file:
pip install -r requirements.txt
Start the Streamlit app using:
streamlit run app.py
- Select Analysis Mode:
- Pricing Heatmaps
- P&L Analysis
- Mispricing Heatmaps
- Configure Inputs:
- Ticker symbol (e.g., SPY, AAPL).
- Spot price and volatility range.
- Purchase price for P&L mode.
- Interactive Results:
- Explore heatmaps to gain insights into options pricing dynamics.
The app depends on the following Python libraries:
- yfinance: For fetching live market data.
- numpy: For numerical computations.
- scipy: To calculate the Black-Scholes formula.
- pandas: For data manipulation.
- seaborn and matplotlib: For visualizing heatmaps.
- streamlit: For building the interactive web app.
black-scholes-app/
├── main.py # Main Streamlit app script
├── functions.py # Helper functions for calculations and data fetching
├── screenshots/ # Screenshots of the app
│ ├── pricing_heatmap.jpg
│ ├── pnl_heatmap.jpg
│ ├── mispricing_heatmap.jpg
├── requirements.txt # Dependencies for the project
├── LICENSE # Project license (MIT)
├── README.md # Documentation (this file)
- Pricing Heatmaps
Visualize call and put option prices for different spot prices and volatilities.
- P&L Heatmaps
Analyze profits and losses for various scenarios.
- Mispricing Visualization
Identify undervalued and overvalued options.
- Add 3D visualization for pricing and P&L surfaces.
- Include support for multiple tickers in one analysis.
- Extend functionality to analyze options strategies (e.g., spreads).
This project is licensed under the MIT License. See the LICENSE file for details.