Python library for generating business dates for fast date operations and rich functionality.
Project description
A fast, efficient Python library for generating business dates inherited from float for fast date operations. Typical banking business methods are provided like business holidays adjustment, day count fractions. Beside dates generic business periods offer to create time periods like ‘10Y’, ‘3 Months’ or ‘2b’. Periods can easily added to business dates.
Example Usage
from datetime import date
from businessdate import BusinessDate, BusinessPeriod
>>> BusinessDate(20140101).add_days(10)
20140111
>>> BusinessPeriod('1Y').add_months(3)
1Y3M
>>> BusinessDate(20140101) + BusinessPeriod('1Y3M')
20150301
Install
The latest stable version can always be installed or updated via pip:
$ pip install businessdate
If the above fails, please try easy_install instead:
$ easy_install businessdate
Examples
# Simplest example possible
>>> from datetime import date
>>> from businessdate import BusinessDate, BusinessPeriod, BusinessRange, BusinessSchedule
>>> BusinessDate.from_date(date(2014, 1, 1)) == BusinessDate(20140101)
True
>>> BusinessDate(20140101) + '1y6m'
20150701
>>> BusinessDate(20140101).adjust_follow()
20140102
>>> BusinessPeriod('1Y')==BusinessPeriod(years=1)
True
>>> BusinessPeriod('1Y')
1Y
>>> BusinessPeriod('1Y').add_businessdays(3)
1Y3B
>>> BusinessPeriod('1Y') + '1y6m'
1Y6M
>>> sd = BusinessDate(20151231)
>>> ed = BusinessDate(20201231)
>>> BusinessRange(sd, ed, '1y', ed)
[20151231, 20161231, 20171231, 20181231, 20191231]
>>> BusinessSchedule(sd, ed, '1y', ed)
[20151231, 20161231, 20171231, 20181231, 20191231, 20201231]
>>> BusinessSchedule(sd, ed, '1y', ed).first_stub_long()
[20151231, 20171231, 20181231, 20191231, 20201231]
Development Version
The latest development version can be installed directly from GitHub:
$ pip install --upgrade git+https://github.com/pbrisk/businessdate.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
Built Distribution
Hashes for businessdate-0.3-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e29ae0c8b426185e21627ef447da0ce6effeabeafded35766ae6ffc2d7305140 |
|
MD5 | 043edcf13aa80859d2125694d81d52ef |
|
BLAKE2b-256 | 471a05e87165a8fa422619c2d8a317e135fefe0781264d311e6c99b78aa7163a |