Giter Site home page Giter Site logo

businessdate's Introduction

Python library businessdate

Codeship

Read the Docs

GitHub

GitHub release

PyPI Version

PyPI - Python Version

PyPI Downloads

PyPI Downloads

A fast, efficient Python library for generating business dates for simple and fast date operations.

>>> from businessdate import BusinessDate

>>> BusinessDate(2017,12,31) + '2 weeks'
BusinessDate(20180114)

>>> BusinessDate(20171231) + '2w'  # same but shorter
BusinessDate(20180114)

>>> BusinessDate(20180114).to_date()
datetime.date(2018, 1, 14)

Typical banking business features are provided like holiday adjustments to move dates away from weekend days or holidays. As well as functionality to get year fractions depending on day count conventions as the lengths of interest payment periods.

Beside dates business periods can be created for time intervals like 10Y, 3 Months or 2b. Those periods can easily be added to or subtracted from business dates.

Moreover range style schedule generator are provided to systematic build a list of dates. Such are used to set up a payment schedule of loan and financial derivatives.

Example Usage

>>> from datetime import date
>>> from businessdate import BusinessDate, BusinessPeriod


>>> BusinessDate(year=2014, month=1, day=11)
BusinessDate(20140111)

>>> BusinessDate(date(2014,1,11))
BusinessDate(20140111)

>>> BusinessDate(20140111)
BusinessDate(20140111)

>>> BusinessDate('20140111')
BusinessDate(20140111)

>>> BusinessDate('2015-12-31')
BusinessDate(20151231)

>>> BusinessDate('31.12.2015')
BusinessDate(20151231)

>>> BusinessDate('12/31/2015')
BusinessDate(20151231)

>>> BusinessDate(42369)
BusinessDate(20151231)

>>> BusinessDate(20140101) + BusinessPeriod('1Y3M')
BusinessDate(20150401)

>>> BusinessDate(20140101) + '1Y3M'
BusinessDate(20150401)

>>> BusinessDate(20170101) - '1Y1D'
BusinessDate(20151231)

>>> BusinessDate() == BusinessDate(date.today())
True

>>> BusinessDate('1Y3M20140101')
BusinessDate(20150401)

For more examples see the documentation.

Install

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

$ pip install businessdate

Development Version

The latest development version can be installed directly from GitHub:

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

or downloaded from https://github.com/sonntagsgesicht/businessdate.

ToDo

  1. decide which base class or inheritance for BusisnessDate is better:
    1. BaseDateFloat (float inheritance)
    2. BaseDateDatetimeDate (datetime.date inheritance)

2. store businessdays adjustment convention and holidays as private property of BusinessDate. The information should not get lost under BusinessPeriod operation. Decide which date determines convention and holidays of a BusinessRange.

Contributions

Issues and Pull Requests are always welcome.

License

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

businessdate's People

Contributors

sonntagsgesicht avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

businessdate's Issues

cannot import name 'BusinessDate' from 'businessdate'

Hello . I wanted to have a look at your library and pip installed businessdate.
Trying to follow your first example I am running into the following issue (from idle Python 3.7.2 on Windows 7) -

Python 3.7.2 (tags/v3.7.2:9a3ffc0492, Dec 23 2018, 22:20:52) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license()" for more information.

from businessdate import BusinessDate, BusinessPeriod
Traceback (most recent call last):
File "<pyshell#0>", line 1, in
from businessdate import BusinessDate, BusinessPeriod
File "C:\Python37\lib\site-packages\businessdate_init_.py", line 18, in
from businessdate import BusinessDate, BusinessPeriod, BusinessSchedule, BusinessRange,
ImportError: cannot import name 'BusinessDate' from 'businessdate' (C:\Python37\lib\site-packages\businessdate_init_.py)

All the Best ***

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.