Python Financial Engineering
Project description
PyFENG: [Py]thon [F]inancial [ENG]ineering
PyFENG provides an implementation of the standard financial engineering models for derivative pricing.
Implemented Models
- Black-Scholes-Merton (BSM) and displaced BSM models:
- Analytic option price, Greeks, and implied volatility.
- Bachelier (Normal) model
- Analytic option price, Greeks, and implied volatility.
- Constant-elasticity-of-variance (CEV) model
- Analytic option price, Greeks, and implied volatility.
- Stochastic-alpha-beta-rho (SABR) model
- Hagan's BSM vol approximation.
- Choi & Wu's CEV vol approximation.
- Analytic integral for the normal SABR.
- Closed-form MC simulation for the normal SABR.
- Hyperbolic normal stochastic volatility (NSVh) model
- Analytic option pricing.
- Heston model
- FFT option pricing.
- Almost exact MC simulation by Glasserman & Kim and Choi & Kwok.
- Schobel-Zhu (OUSV) model
- FFT option pricing.
- Almost exact MC simulation by Choi
- Rough volatility models
- Rough Heston MC by Ma & Wu
About the Package
- Uses
numpyarrays as basic datatype so computations are naturally vectorized. - Purely Python without C/C++ extensisons.
- Implemented with Python class.
- Intended for academic use. By providing reference models, it saves researchers' time. See PyFENG for Papers in Related Projects below.
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
- Prof. Jaehyuk Choi (Peking University HSBC Business School). Email: pyfe@eml.cc
Related Projects
- Commercial versions (implemented and optimized in C/C++) for some models are available. Email the author at pyfe@eml.cc.
- PyFENG for Papers is a collection of Jupyter notebooks that reproduce the results of financial engineering research papers using PyFENG.
- FER: Financial Engineering in R developed by the same author.
Not all models in
PyFENGare implemented inFER.FERis a subset ofPyFENG.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyfeng-0.3.4.tar.gz.
File metadata
- Download URL: pyfeng-0.3.4.tar.gz
- Upload date:
- Size: 249.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
57925b0259a46dbc4afbb502710fbde48f1e624e7199be3d27fe42f42fb2eb7d
|
|
| MD5 |
9dd509c0476e9f0edda3abb69254ceb8
|
|
| BLAKE2b-256 |
a13bc600f3a61f014557571fd12fb7acdbfa79244d68fa60fb09020ca8ccb6f5
|
Provenance
The following attestation bundles were made for pyfeng-0.3.4.tar.gz:
Publisher:
publish.yml on PyFE/PyFENG
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfeng-0.3.4.tar.gz -
Subject digest:
57925b0259a46dbc4afbb502710fbde48f1e624e7199be3d27fe42f42fb2eb7d - Sigstore transparency entry: 1439138489
- Sigstore integration time:
-
Permalink:
PyFE/PyFENG@449618a38afae6d999366c26f1f315543d57234d -
Branch / Tag:
refs/tags/v0.3.4 - Owner: https://github.com/PyFE
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@449618a38afae6d999366c26f1f315543d57234d -
Trigger Event:
release
-
Statement type:
File details
Details for the file pyfeng-0.3.4-py3-none-any.whl.
File metadata
- Download URL: pyfeng-0.3.4-py3-none-any.whl
- Upload date:
- Size: 248.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
723f0f887738a65f17862b652fdd5cf9190faf325fdb1b534ee6f6367df43f1b
|
|
| MD5 |
e36b3c6e19bb4f57d84d823abcaff397
|
|
| BLAKE2b-256 |
8efafb65098c1de245ed2e55a0c091053fe034e515e200c248aee9d957d7ade9
|
Provenance
The following attestation bundles were made for pyfeng-0.3.4-py3-none-any.whl:
Publisher:
publish.yml on PyFE/PyFENG
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pyfeng-0.3.4-py3-none-any.whl -
Subject digest:
723f0f887738a65f17862b652fdd5cf9190faf325fdb1b534ee6f6367df43f1b - Sigstore transparency entry: 1439138498
- Sigstore integration time:
-
Permalink:
PyFE/PyFENG@449618a38afae6d999366c26f1f315543d57234d -
Branch / Tag:
refs/tags/v0.3.4 - Owner: https://github.com/PyFE
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@449618a38afae6d999366c26f1f315543d57234d -
Trigger Event:
release
-
Statement type: