A comprehensive web application for options pricing and risk assessment using mathematical models and Monte Carlo simulations.
- Black-Scholes Model - Theoretical European options pricing
- Monte Carlo Simulation - Stochastic price path modeling
- Real-time Calculations - Interactive parameter adjustments
- Option Greeks - Delta, Gamma, Theta, Vega sensitivity analysis
- Payoff Diagrams - Visual profit/loss at expiration
- Risk Metrics - Value at Risk (VaR) and Expected Shortfall (ES)
- Covered Call Strategy - Long stock + Short call position
- Protective Put Strategy - Long stock + Long put position
- Interactive Visualization - Real-time P&L charts
- Dark Theme - Professional financial dashboard aesthetic
- Interactive Charts - Plotly-powered visualizations
- Responsive Design - Clean, intuitive interface
- Educational Tooltips - Mathematical explanations and formulas
- Python 3.8 or higher
- pip package manager
-
Clone the repository
git clone https://github.com/dafahentra/options-pricing-tool.git cd options-pricing-tool -
Install dependencies
pip install -r requirements.txt
-
Run the application
streamlit run main.py
-
Open your browser and navigate to
http://localhost:8501
-
Set option parameters in the sidebar:
- Current stock price (S)
- Strike price (K)
- Time to maturity (T)
- Risk-free rate (r)
- Volatility (ฯ)
- Option type (Call/Put)
-
View calculated prices using both Black-Scholes and Monte Carlo methods
Monitor option sensitivities:
- Delta: Price sensitivity to underlying asset
- Gamma: Delta sensitivity to underlying asset
- Theta: Time decay effect
- Vega: Volatility sensitivity
- Select a strategy (Covered Call or Protective Put)
- Set strike prices and contract quantities
- Analyze profit/loss scenarios across different stock prices
- VaR (95%): Maximum expected loss at 95% confidence
- Expected Shortfall: Average loss beyond VaR threshold
- Price Distribution: Histogram of simulated future prices
options-pricing-tool/
โโโ main.py # Main Streamlit application
โโโ models.py # Mathematical models and calculations
โโโ chart_utils.py # Chart creation and styling utilities
โโโ requirements.txt # Python dependencies
โโโ .streamlit/
โ โโโ config.toml # Streamlit configuration and theming
โโโ README.md # Project documentation
โโโ LICENSE # MIT License
Call Option:
C = Sโ ร N(dโ) - K ร e^(-rT) ร N(dโ)
Put Option:
P = K ร e^(-rT) ร N(-dโ) - Sโ ร N(-dโ)
Where:
dโ = [ln(Sโ/K) + (r + ฯยฒ/2)T] / (ฯโT)dโ = dโ - ฯโT
S_T = Sโ ร exp[(r - ฯยฒ/2)T + ฯโT ร Z]
Where Z ~ N(0,1) is a standard normal random variable.
Modify .streamlit/config.toml to customize colors and appearance:
[theme]
base = "dark"
primaryColor = "#c584f7"
backgroundColor = "#1a1a1a"
secondaryBackgroundColor = "#2d2d2d"
textColor = "#ffffff"
font = "serif"Update chart_utils.py to modify chart colors and layouts.
- Caching: Expensive calculations cached with
@st.cache_data - Optimized Computing: Vectorized NumPy operations
- Efficient UI: Minimal re-renders and smart state management
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For questions, suggestions, or collaboration opportunities, please open an issue or reach out via GitHub.
โญ Star this repository if you find it helpful!