Skip to main content

derpy

https://img.shields.io/pypi/v/derpy.svg https://img.shields.io/travis/rjdscott/derpy.svg Documentation Status

Financial derivatives and portfolio analysis tools for python

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

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)

Source distribution for derpy 0.1.1
File Size Uploaded
derpy-0.1.1.tar.gz 15.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for derpy 0.1.1
File Interpreter ABI Platform
derpy-0.1.1-py2.py3-none-any.whl Python 2, Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page