{"id":17082277,"url":"https://github.com/jkirkby3/fypy","last_synced_at":"2026-05-21T12:30:19.555Z","repository":{"id":93248287,"uuid":"361240945","full_name":"jkirkby3/fypy","owner":"jkirkby3","description":"Vanilla and exotic option pricing library to support quantitative R\u0026D. Focus on pricing interesting/useful models  and contracts (including and beyond Black-Scholes), as well as calibration of financial models to market data.","archived":false,"fork":false,"pushed_at":"2025-02-02T22:35:21.000Z","size":504,"stargazers_count":87,"open_issues_count":0,"forks_count":22,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-02T23:23:23.303Z","etag":null,"topics":["black-scholes","calibration","finance","fourier","heston","levy","levy-processes","option-pricing","options-pricing","pricing","python","quant","quantitative-finance","quantitative-trading","sabr","stochastic-volatility","variance-gamma"],"latest_commit_sha":null,"homepage":"","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/jkirkby3.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-24T18:46:26.000Z","updated_at":"2025-01-23T05:06:14.000Z","dependencies_parsed_at":"2023-10-17T05:51:47.892Z","dependency_job_id":"29c88122-cced-472b-aa87-0daf6582a250","html_url":"https://github.com/jkirkby3/fypy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkirkby3%2Ffypy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkirkby3%2Ffypy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkirkby3%2Ffypy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jkirkby3%2Ffypy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jkirkby3","download_url":"https://codeload.github.com/jkirkby3/fypy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240131743,"owners_count":19752725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["black-scholes","calibration","finance","fourier","heston","levy","levy-processes","option-pricing","options-pricing","pricing","python","quant","quantitative-finance","quantitative-trading","sabr","stochastic-volatility","variance-gamma"],"created_at":"2024-10-14T13:00:24.143Z","updated_at":"2026-05-21T12:30:17.452Z","avatar_url":"https://github.com/jkirkby3.png","language":"Python","funding_links":[],"categories":["Recently Updated","Python","Python：量化金融第一生态"],"sub_categories":["[Oct 14, 2024](/content/2024/10/14/README.md)","Financial Instruments and Pricing","二、金融工具定价与估值"],"readme":"\n# FyPy\n\nVanilla and exotic option pricing library to support quantitative R\u0026D. Focus on pricing interesting/useful models \nand contracts (including and beyond Black-Scholes), as well as calibration of financial models to market data.\n\nThis library is under active development, although the currently posted features are relatively stable.\n## Currently Supported\n### Models\n\n- Black-Scholes\n- Jump Diffusions: Merton, Kou (Double Exponential)\n- Levy: (VG, NIG, CGMY/KoBoL, MJD, Kou, Tempered-Stable, Bilateral Gamma, etc)\n- Stochastic Volatility: Heston\n- SVJ: Bates, Heston + Double Expo Jumps\n- SLV: SABR\n\n### Pricing Methods\n- Analytical: closed form pricing when available, e.g. Black Scholes\n- Fourier: PROJ (Frame Projection), Lewis, Gil-Peleaz, Carr-Madan, Hilbert Transform\n- More in progress (PDE, Monte Carlo, etc) ...\n\n### Model Calibration\n- Levy Model Calibration (VG, NIG, CGMY, MJD, Kou, Tempered-Stable, Bilateral Gamma, etc)\n- Heston Stochastic Volatility Model Calibration\n- Stochastic Volatility with Jumps Model Calibration\n- SABR Model calibration\n\n### Contract types supported (single underlying):\n- European Options\n- Barrier Options (Single/Double barrier, and rebates)\n- Asian Options (Discrete/Continuous)\n- Discrete Variance Swaps, Variance/Volatility Options\n- Bermudan/American early-exercise Options\n- Parisian Options (Cumulative and resetting Parisian barrier options)\n- Cliquets/Equity Indexed Annuities (Additive/Multiplicative)\n- Step (Soft Barrier) Options\n- Lookback/Hindsight Options\n- Fader/Range-Accrual Options\n\n## Coming Soon !\n- More Exotic Option Pricing\n- Models: Stochastic Volatility, Stochastic Local Vol\n- Additional pricing methods, such as Mellin Series, PDE, Monte Carlo, etc.\n- Regime Switching Calibration\n- Many of the exotic pricing algorithms will be translated into python from:\nhttps://github.com/jkirkby3/PROJ_Option_Pricing_Matlab\n\n\n## User installation\n\npip install git+https://github.com/jkirkby3/fypy.git\n\n## Dependencies\n\n\nfypy requires:\n\n- Python (\u003e= 3.7)\n- NumPy (tested with 1.20.2)\n- py_lets_be_rational (implied volatility)\n\n## Source code\n\n\nYou can check the latest sources with the command\n\n    git clone https://github.com/jkirkby3/fypy.git\n\n## Test Suite\n\nYou can run the full test suite with this command,\n\n    python tests/test_runner.py\n\n    \n\n## Example: Price Variance Gamma / Black-Scholes Models with PROJ (Fourier) Method\n\n```python\n\n\"\"\"\nThis example shows how to price using a Fourier pricing method (PROJ)\nWe include two examples:  1) Black Scholes 2) Variance Gamma\n\"\"\"\nfrom fypy.pricing.fourier.ProjEuropeanPricer import ProjEuropeanPricer\nfrom fypy.model.levy.BlackScholes import *\nfrom fypy.model.levy.VarianceGamma import *\nfrom fypy.termstructures.DiscountCurve import DiscountCurve_ConstRate\nfrom fypy.termstructures.EquityForward import EquityForward\nfrom fypy.volatility.implied.ImpliedVolCalculator import ImpliedVolCalculator_Black76\nimport matplotlib.pyplot as plt\n\n# ============================\n# Set Common Parameters\n# ============================\nS0 = 100  # Initial stock price\nr = 0.01  # Interest rate\nq = 0.03  # Dividend yield\nT = 1  # Time to maturity of option\n\n# ============================\n# Set Term Structures\n# ============================\ndisc_curve = DiscountCurve_ConstRate(rate=r)\ndiv_disc = DiscountCurve_ConstRate(rate=q)\nfwd = EquityForward(S0=S0, discount=disc_curve, divDiscount=div_disc)\n\n# ============================\n# Create Black-Scholes Model\n# ============================\nmodel = BlackScholes(sigma=0.2, forwardCurve=fwd, discountCurve=fwd.discountCurve)\npricer = ProjEuropeanPricer(model=model, N=2 ** 10)\n\n# Price a set of strikes\nstrikes = np.arange(50, 150, 1)\nprices = pricer.price_strikes(T=T, K=strikes, is_calls=np.ones(len(strikes), dtype=bool))\n\n# Plot\nplt.plot(strikes, prices, label='Black Scholes')\n\n# ============================\n# Create Variance Gamma Model\n# ============================\nmodel = VarianceGamma(sigma=0.2, theta=0.1, nu=0.8, forwardCurve=fwd, discountCurve=fwd.discountCurve)\npricer = ProjEuropeanPricer(model=model, N=2 ** 10)\n\n# Price a set of strikes\nstrikes = np.arange(50, 150, 1)\nis_calls = np.ones(len(strikes), dtype=bool)\nprices = pricer.price_strikes(T=T, K=strikes, is_calls=is_calls)\n\n# Plot\nplt.plot(strikes, prices, label='Variance Gamma')\nplt.legend()\nplt.xlabel(r'strike, $K$')\nplt.ylabel('price')\nplt.show()\n\n# Compute Implied Volatilities\nivc = ImpliedVolCalculator_Black76(disc_curve=disc_curve, fwd_curve=fwd)\nvols = ivc.imply_vols(strikes=strikes, prices=prices, is_calls=is_calls, ttm=T)\n\n# Plot Implied Vols\nplt.plot(strikes, vols, label='Variance Gamma')\nplt.legend()\nplt.xlabel(r'strike, $K$')\nplt.ylabel('implied vol')\nplt.show()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkirkby3%2Ffypy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjkirkby3%2Ffypy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjkirkby3%2Ffypy/lists"}