{"id":34082417,"url":"https://github.com/diljit22/optpricing","last_synced_at":"2026-03-17T20:38:49.894Z","repository":{"id":259552181,"uuid":"878195469","full_name":"Diljit22/optpricing","owner":"Diljit22","description":"Pricing \u0026 calibration engine (15+ models; API + CLI + Streamlit UI)","archived":false,"fork":false,"pushed_at":"2025-07-28T05:01:04.000Z","size":26875,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-16T14:32:16.929Z","etag":null,"topics":["bates-model","black-scholes","carr-madan","cev-model","cgmy","derivatives-pricing","fast-fourier-transform","heston-stochastic-volatility","hyperbolic","implied-volatility","jump-diffusion","kou-jump-diffusion","monte-carlo-methods","option-pricing","sabr-model","stochastic-differential-equations","variance-reduction"],"latest_commit_sha":null,"homepage":"https://diljit22.github.io/optpricing/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Diljit22.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-10-25T00:00:15.000Z","updated_at":"2025-07-28T05:01:07.000Z","dependencies_parsed_at":"2025-02-21T01:27:46.379Z","dependency_job_id":"a9f77126-fc01-435f-b105-031e39d84d4f","html_url":"https://github.com/Diljit22/optpricing","commit_stats":null,"previous_names":["singh-diljit/opmodels","diljit22/opmodels","diljit22/quantfin","diljit22/optpricing"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/Diljit22/optpricing","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Diljit22%2Foptpricing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Diljit22%2Foptpricing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Diljit22%2Foptpricing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Diljit22%2Foptpricing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Diljit22","download_url":"https://codeload.github.com/Diljit22/optpricing/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Diljit22%2Foptpricing/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30631404,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-17T17:32:55.572Z","status":"ssl_error","status_checked_at":"2026-03-17T17:32:38.732Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bates-model","black-scholes","carr-madan","cev-model","cgmy","derivatives-pricing","fast-fourier-transform","heston-stochastic-volatility","hyperbolic","implied-volatility","jump-diffusion","kou-jump-diffusion","monte-carlo-methods","option-pricing","sabr-model","stochastic-differential-equations","variance-reduction"],"created_at":"2025-12-14T12:15:33.744Z","updated_at":"2026-03-17T20:38:49.889Z","avatar_url":"https://github.com/Diljit22.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# OptPricing: A Quantitative Finance Library for Derivative Pricing and Analysis\n\n[![Tests](https://img.shields.io/github/actions/workflow/status/diljit22/optpricing/ci.yml?branch=main\u0026label=tests)](https://github.com/diljit22/optpricing/actions/workflows/ci.yml)\n[![Coverage](https://codecov.io/gh/diljit22/optpricing/branch/main/graph/badge.svg)](https://codecov.io/gh/diljit22/optpricing)\n[![Ruff](https://img.shields.io/github/actions/workflow/status/diljit22/optpricing/ci.yml?branch=main\u0026label=ruff)](https://github.com/diljit22/optpricing/actions/workflows/ci.yml)\n[![Docs](https://img.shields.io/github/actions/workflow/status/diljit22/optpricing/ci.yml?branch=main\u0026label=docs)](https://github.com/diljit22/optpricing/actions/workflows/ci.yml)\n[![PyPI version](https://img.shields.io/pypi/v/optpricing.svg)](https://pypi.org/project/optpricing/)\n[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n`optpricing` is a Python library for pricing, calibrating, and analyzing financial derivatives. It is built with a focus on architectural clarity, model breadth, and practical usability through a robust API, command-line interface, and an interactive dashboard.\n\nDiljit Singh\n[LinkedIn](https://linkedin.com/in/singhdiljit/)\n\n---\n\n## Core Features\n\n* **Model Library**: Implements a comprehensive set of models, including:\n  * **Stochastic Volatility**: Heston, SABR\n  * **Jump-Diffusion**: Merton, Bates, Kou, SABR with Jumps\n  * **Pure Levy Processes**: Variance Gamma (VG), Normal Inverse Gaussian (NIG), CGMY, Hyperbolic\n  * **Interest Rate Models**: Vasicek, Cox-Ingersoll-Ross (CIR), Put-Call Parity Implied Rate\n  * **Local Volatility**: Dupire's Equation\n\n* **Pricing Engines**: Provides a suite of numerical methods, allowing for technique comparison and validation:\n  * Analytic closed-form solutions\n  * Numerical integration and FFT-based pricing via characteristic functions\n  * Finite difference (PDE) solver using a Crank-Nicolson scheme\n  * Binomial and trinomial tree methods (CRR, TOPM, Leisen-Reimer) for European and American options\n  * High-performance Monte Carlo engine for European and American options, accelerated with `numba`, featuring variance reduction techniques (e.g., antithetic variates, control variates, importance sampling)\n\n* **Interfaces**:\n  * **Programmatic API**: Use the package as a Python library to build custom financial models in your scripts. Define options, stocks, rates, and models programmatically to compute prices and other metrics.\n  * **Command-Line Interface (CLI)**: A robust CLI for live pricing, data management, model calibration, and historical backtesting.\n  * **Interactive Dashboard (UI)**: A Streamlit application for visual analysis of option chains, implied volatility surfaces, and model calibrations.\n\n* **Workflow Automation**: High-level classes that orchestrate complex tasks like daily calibration runs and out-of-sample performance evaluation.\n\n---\n\n## Quick Start\n\n`optpricing` is designed for a straightforward installation using `pip` and is compatible with Python 3.10 and higher.\n\n### 1. Install the Library\n\n```bash\npip install optpricing\n```\n\n### 2. Download Historical Data\n\nSome models require historical data (e.g., for calibration). Download data for a ticker like SPY:\n\n```bash\noptpricing data download --ticker SPY\n```\n\nFor more details, see the [Getting Started Guide](https://diljit22.github.io/optpricing/guide/getting_started/).\n\n### 3. Use the CLI\n\nPrice an option directly from the terminal. The command below fetches the live option chain for AAPL, retrieves the current dividend rate, calculates the implied risk-free rate from at-the-money contracts, and prices the contract with Heston’s model using its default pricing technique (FFT):\n\n```bash\noptpricing price --ticker AAPL --strike 630 --maturity 2025-12-19 --model Heston --param \"rho=-0.7\" --param \"vol_of_vol=0.5\"\n```\n\nTo price the same contract as an American Option use:\n\n```bash\noptpricing price -t AAPL -k 210 -T 2025-12-19 --style american --model Heston --param \"rho=-0.7\" --param \"vol_of_vol=0.5\"\n```\n\nFor more details, see the [CLI Guide](https://diljit22.github.io/optpricing/guide/CLI/).\n\n### 4. Launch the Dashboard\n\nVisualize option chains and model outputs, interact with a pricing calculator featuring 15 models and 10 techniques.\n\n```bash\noptpricing dashboard\n```\n\nFor more details, see the [Dashboard Guide](https://diljit22.github.io/optpricing/guide/dashboard/).\n\n### 5. Use the Programmatic API\n\nThe most powerful way to use the package is via the API, which provides customization of nearly every aspect of pricing:\n\n```python\nfrom optpricing import Option, OptionType, Rate, Stock, ZeroCouponBond\nfrom optpricing.models import BSMModel, CIRModel, VasicekModel\nfrom optpricing.techniques import ClosedFormTechnique\n\n# Define an option, underlying and rate\noption = Option(strike=105, maturity=1.0, option_type=OptionType.CALL)\nstock = Stock(spot=100, dividend=0.01)\nrate = Rate(rate=0.05)\n\n# Choose a model and technique\nbsm_model = BSMModel(params={\"sigma\": 0.20})\ncf_technique = ClosedFormTechnique()\n\nresult = cf_technique.price(option, stock, bsm_model, rate)\nprint(f\"The option price is: {result.price:.4f}\")\n\n\ndelta = cf_technique.delta(option, stock, bsm_model, rate)\ngamma = cf_technique.gamma(option, stock, bsm_model, rate)\nvega = cf_technique.vega(option, stock, bsm_model, rate)\n\nprint(f\"Delta: {delta:.4f}\")\nprint(f\"Gamma: {gamma:.4f}\")\nprint(f\"Vega:  {vega:.4f}\")\n\ntarget_price = 7.50\niv = cf_technique.implied_volatility(\n    option, stock, bsm_model, rate, target_price=target_price\n)\nprint(f\"Implied volatility for price ${target_price:.2f}: {iv:.4%}\")\n\n\n# Zero Coupon Bond\nbond = ZeroCouponBond(maturity=1.0)\nr0_stock = Stock(spot=0.05)  # initial short rate\ndummy_rate = Rate(rate=0.0)  # ignored by rate models\n\nvasicek = VasicekModel(params={\"kappa\": 0.86, \"theta\": 0.09, \"sigma\": 0.02})\ncir = CIRModel(params={\"kappa\": 0.86, \"theta\": 0.09, \"sigma\": 0.02})\n\np_vasi = cf_technique.price(bond, r0_stock, vasicek, dummy_rate).price\np_cir = cf_technique.price(bond, r0_stock, cir, dummy_rate).price\n\nprint(f\"Vasicek ZCB Price: {p_vasi:.4f}\")\nprint(f\"CIR ZCB Price:     {p_cir:.4f}\")\n```\n\nFor more details, see the [API Guide](https://diljit22.github.io/optpricing/guide/API/).\n\n---\n\n## Documentation\n\nThe full documentation includes installation instructions, user guides, examples, and a complete API reference.\n\n* **[View the Official Documentation](https://diljit22.github.io/optpricing/)**\n\n### Guides\n\n* [Introduction](https://diljit22.github.io/optpricing/guide/introduction/)\n* [Installation](https://diljit22.github.io/optpricing/guide/installation/)\n* [Getting Started](https://diljit22.github.io/optpricing/guide/getting_started/)\n* [CLI](https://diljit22.github.io/optpricing/guide/CLI/)\n* [Dashboard](https://diljit22.github.io/optpricing/guide/dashboard/)\n* [API](https://diljit22.github.io/optpricing/guide/API/)\n* [Examples](https://diljit22.github.io/optpricing/guide/examples/)\n* [API Reference](https://diljit22.github.io/optpricing/reference/)\n\n## Contributing\n\nContributions are welcome; see [CONTRIBUTING](/CONTRIBUTING.md) for details.\n\n## License\n\nThis project is licensed under the MIT License. See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiljit22%2Foptpricing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdiljit22%2Foptpricing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdiljit22%2Foptpricing/lists"}