Skip to main content

A Python library for financial yield curves.

Project description

Python library yieldcurves

GitHubWorkflow Read the Docs GitHub GitHub release PyPI Version PyPI - Python Version PyPI Downloads

A Python library for financial yield curves. Typical banking business methods are provided like interpolation, compounding, discounting and fx.

Example Usage

>>> from yieldcurves import YieldCurve
>>> from yieldcurves.interpolation import linear
>>> time_grid = [0, 2]
>>> rate_grid = [.03, .05]
>>> curve = linear(time_grid, rate_grid)
>>> yc = YieldCurve(curve)
>>> yc.zero(0, 1)
0.040000000000000036
>>> yc.df(0, 1)
0.9607894391523232

Or use datetime

>>> from yieldcurves import DateCurve
>>> from datetime import date
>>> start = date(2013, 1, 1)
>>> mid = date(2014, 1, 1)
>>> end = date(2015, 1, 1)
>>> dc = DateCurve.from_interpolation([start, end], [.03, .05], origin=start)
>>> dc.zero(start, mid)
0.03999999999999998
>>> dc.df(start, mid)
0.9608157444936446

The framework works fine with native datetime but we recommend businessdate package for more convenient functionality to roll out date schedules.

>>> from businessdate import BusinessDate, BusinessSchedule

So, build a date schedule.

>>> today = BusinessDate(20201031)
>>> schedule = BusinessSchedule(today, today + "8q", step="1q")
>>> schedule
[BusinessDate(20201031), BusinessDate(20210131), BusinessDate(20210430), BusinessDate(20210731), BusinessDate(20211031), BusinessDate(20220131), BusinessDate(20220430), BusinessDate(20220731), BusinessDate(20221031)]

Documentation

More documentation available at https://yieldcurves.readthedocs.io

Install

The latest stable version can always be installed or updated via pip:

$ pip install yieldcurves

Development Version

The latest development version can be installed directly from GitHub:

$ pip install --upgrade git+https://github.com/sonntagsgesicht/yieldcurves.git

Contributions

Issues and Pull Requests are always welcome.

License

Code and documentation are available according to the Apache Software License (see LICENSE).

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

yieldcurves-0.2.7.zip (42.8 kB view details)

Uploaded Source

File details

Details for the file yieldcurves-0.2.7.zip.

File metadata

  • Download URL: yieldcurves-0.2.7.zip
  • Upload date:
  • Size: 42.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.11

File hashes

Hashes for yieldcurves-0.2.7.zip
Algorithm Hash digest
SHA256 90f7d17603d44a4130f24e1bac771939251acd3acef03aa8a5e4a7caa7c04c1c
MD5 360068d3426f6eaac0a1d150e1bef5ff
BLAKE2b-256 3f233dd8a87630bf40737b266d84184f589a6dc290bee0caf8369cfadefd002e

See more details on using hashes here.

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