derpy
Financial derivatives and portfolio analysis tools for python
Free software: MIT license
Documentation: https://derpy.readthedocs.io.
How to get up and running
to include the module in your project, you can simply use pip install derpy then in your python project
import derpy
print(derpy.__version__) # returns '0.0.1'
Example uses
Bonds
from derpy import bond as bd
px = 95.0428
face_val = 100.0
mat = 1.5
cpn_frq = 2
cpn_rate = 5.25
ytm = 5.5
print(' Price: {}'.format(bd.bond_price(face_val, mat, ytm, cpn_rate, cpn_frq)))
print(' Yield: {}'.format(bd.bond_ytm(px, face_val, mat, cpn_rate, cpn_frq)))
print(' ModDur: {}'.format(bd.bond_duration(px, face_val, mat, cpn_rate, cpn_frq)[0]))
print(' MacDur: {}'.format(bd.bond_duration(px, face_val, mat, cpn_rate, cpn_frq)[1]))
print('Convexity: {}'.format(bd.bond_convexity(px, face_val, mat, cpn_rate, cpn_frq)))
Options
from derpy.options import black_scholes_merton as bsm
# usage method 1: use function wrapper
input = ['call', 20, 21, 0.20, 0.1, 0.0002, 0]
call_price = bsm.option_pricing(bsm.euro_option, input)
call_gamma = bsm.option_pricing(bsm.gamma, input)
# usage method 2: call individual functions
put_price = bsm.euro_option('put', 20, 21, 0.2, 0.1, 0.0002) # div_yield is optional
put_gamma = bsm.gamma('put', 20, 21, 0.2, 0.1, 0.0002, 0.0001)
print(call_price) # return 0.16384395..
print(call_gamma) # return 0.23993880..
print(put_price) # return 1.16342..
print(put_gamma) # return 0.2399107..
Portfolio analysis
from derpy import portfolio as pt
securities = ['AAA', 'BBB']
positions = [[11, 10], [12, 10], [13, 10], [13, 11], [13, 12]]
prices = [[10, 10], [11, 10], [12, 10], [12, 10], [12, 10]]
dates = ['2018-07-01', '2018-08-01', '2018-09-01', '2018-10-01', '2018-11-01']
df_positions = pd.DataFrame(data=positions, columns=securities, index=dates)
df_prices = pd.DataFrame(data=prices, columns=securities, index=dates)
p = pt.Portfolio(names=securities, positions=df_positions, prices=df_prices)
print(p.sec_values())
print(p.sec_weights())
print(p.portfolio_value())
print(p.portfolio_returns())
History
0.1.0 (2018-09-19)
Released option pricing
Released portfolio analysis
Added testing for Options and Portfolios
Metadata
Release files for derpy 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| derpy-0.1.1.tar.gz | 15.8 kB | Without provenance | Details for derpy-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| derpy-0.1.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for derpy-0.1.1-py2.py3-none-any.whl |
Total release size: 29.2 kB
Release files / derpy-0.1.1.tar.gz
| Download URL | derpy-0.1.1.tar.gz |
|---|---|
| Size | 15.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
baacb62838cf7e1de41b1e289424373af8107b3f87ad101608b07dbedd47faf0
|
|
BLAKE2b-256 checksum How to use checksums |
880fba740f8495182413e5ec3ed81ed0c7ee8b7af38babfdfd6a19986d2022c6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.10.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5
|
Release files / derpy-0.1.1-py2.py3-none-any.whl
| Download URL | derpy-0.1.1-py2.py3-none-any.whl |
|---|---|
| Size | 13.4 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
a8bd325c49b2332247a9e0d345714eb44596bca4e7f3b8b847ae2f87be360658
|
|
BLAKE2b-256 checksum How to use checksums |
2d0fcc6bf47c238e8428729273de05f01e4bdc24fbe746660132f67ecf93e3a9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.10.0 pkginfo/1.4.2 requests/2.19.1 setuptools/40.4.1 requests-toolbelt/0.8.0 tqdm/4.26.0 CPython/3.6.5
|
Security for derpy 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.