Skip to content

dafahentra/options-pricing-tool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

7 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ˆ Options Pricing & Risk Analysis Tool

A comprehensive web application for options pricing and risk assessment using mathematical models and Monte Carlo simulations.

Python Streamlit License

๐Ÿš€ Features

Core Pricing Models

  • Black-Scholes Model - Theoretical European options pricing
  • Monte Carlo Simulation - Stochastic price path modeling
  • Real-time Calculations - Interactive parameter adjustments

Advanced Analytics

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

Strategy Builder

  • Covered Call Strategy - Long stock + Short call position
  • Protective Put Strategy - Long stock + Long put position
  • Interactive Visualization - Real-time P&L charts

Enhanced UI/UX

  • Dark Theme - Professional financial dashboard aesthetic
  • Interactive Charts - Plotly-powered visualizations
  • Responsive Design - Clean, intuitive interface
  • Educational Tooltips - Mathematical explanations and formulas

๐Ÿ› ๏ธ Installation

Prerequisites

  • Python 3.8 or higher
  • pip package manager

Quick Start

  1. Clone the repository

    git clone https://github.com/dafahentra/options-pricing-tool.git
    cd options-pricing-tool
  2. Install dependencies

    pip install -r requirements.txt
  3. Run the application

    streamlit run main.py
  4. Open your browser and navigate to http://localhost:8501

๐Ÿ“Š Usage

Basic Options Pricing

  1. 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)
  2. View calculated prices using both Black-Scholes and Monte Carlo methods

Greeks Analysis

Monitor option sensitivities:

  • Delta: Price sensitivity to underlying asset
  • Gamma: Delta sensitivity to underlying asset
  • Theta: Time decay effect
  • Vega: Volatility sensitivity

Strategy Analysis

  1. Select a strategy (Covered Call or Protective Put)
  2. Set strike prices and contract quantities
  3. Analyze profit/loss scenarios across different stock prices

Risk Assessment

  • VaR (95%): Maximum expected loss at 95% confidence
  • Expected Shortfall: Average loss beyond VaR threshold
  • Price Distribution: Histogram of simulated future prices

๐Ÿ—๏ธ Project Structure

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

๐Ÿงฎ Mathematical Models

Black-Scholes Formula

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

Monte Carlo Simulation

S_T = Sโ‚€ ร— exp[(r - ฯƒยฒ/2)T + ฯƒโˆšT ร— Z]

Where Z ~ N(0,1) is a standard normal random variable.

๐ŸŽจ Customization

Theme Configuration

Modify .streamlit/config.toml to customize colors and appearance:

[theme]
base = "dark"
primaryColor = "#c584f7"
backgroundColor = "#1a1a1a"
secondaryBackgroundColor = "#2d2d2d"
textColor = "#ffffff"
font = "serif"

Chart Styling

Update chart_utils.py to modify chart colors and layouts.

๐Ÿ“ˆ Performance Features

  • Caching: Expensive calculations cached with @st.cache_data
  • Optimized Computing: Vectorized NumPy operations
  • Efficient UI: Minimal re-renders and smart state management

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ”— Resources

๐Ÿ“ง Contact

For questions, suggestions, or collaboration opportunities, please open an issue or reach out via GitHub.


โญ Star this repository if you find it helpful!

About

Comprehensive options pricing and risk analysis web application with Black-Scholes model, Monte Carlo simulations, Greeks calculation, and interactive strategy builder

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages