Skip to main content

Python Financial Engineering

Project description

PyFENG: Python Financial ENGineering

PyPI version Documentation Status Downloads

PyFENG is the python implemention of the standard option pricing models in financial engineering.

Models implemented

  • Black-Scholes-Merton (and displaced diffusion) model
  • Bachelier (Normal) model
  • Constant-elasticity-of-variance (CEV) model
  • Stochastic-alpha-beta-rho (SABR) model
  • Hyperbolic normal stochastic volatility (NSVh) model
  • Heston model
  • Ornstein-Uhlenbeck driven stochastic volatility model

About the package

  • It assumes variables are numpy arrays. So the computations are naturally vectorized.
  • It is purely in Python (i.e., no C, C++, cython).
  • It is implemented with python class.
  • It is intended for, but not limited to, academic use. By providing reference models, it saves researchers' time.

Installation

pip install pyfeng

For upgrade,

pip install pyfeng --upgrade

Code Snippets

In [1]:

import numpy as np
import pyfeng as pf
m = pf.Bsm(sigma=0.2, intr=0.05, divr=0.1)
m.price(strike=np.arange(80, 121, 10), spot=100, texp=1.2)

Out [1]:

array([15.71361973,  9.69250803,  5.52948546,  2.94558338,  1.48139131])

In [2]:

sigma = np.array([[0.2], [0.5]])
m = pf.Bsm(sigma, intr=0.05, divr=0.1) # sigma in axis=0
m.price(strike=[90, 95, 100], spot=100, texp=1.2, cp=[-1,1,1])

Out [2]:

array([[ 5.75927238,  7.38869609,  5.52948546],
       [16.812035  , 18.83878533, 17.10541288]])

Author

Others

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyfeng-0.2.6.tar.gz (261.5 kB view hashes)

Uploaded Source

Built Distribution

pyfeng-0.2.6-py3-none-any.whl (279.9 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page