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
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 businessdate-0.2.tar.gz.
File metadata
- Download URL: businessdate-0.2.tar.gz
- Upload date:
- Size: 19.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b3a9e449c2126ff1b22cb1b703cb5bfe79b8a5f61468e0ce6069eee13d8603c7
|
|
| MD5 |
e0eb5887390d41d1f41916faf08bf6a1
|
|
| BLAKE2b-256 |
9ee11d828264a067471e0da5bd19c1bbc7feb177c3c3843c6a77f77080eb3fdc
|
File details
Details for the file businessdate-0.2-py2-none-any.whl.
File metadata
- Download URL: businessdate-0.2-py2-none-any.whl
- Upload date:
- Size: 15.9 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
596a10ad179e83ccb5e5efa75e7d12f9b229de76ec74dc252c55b3bb4fac7d83
|
|
| MD5 |
ac798b845d497eb558f30c1a3de1a0f5
|
|
| BLAKE2b-256 |
1cb6f9fd10dd7e6bff448e7b7d46c968640bd8047196674e21b37a50b00a49ed
|