-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
79 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) Thomas Feldmann | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# days360 | ||
|
||
[![Tests](https://github.com/tfeldmann/days360/actions/workflows/tests.yml/badge.svg)](https://github.com/tfeldmann/days360/actions/workflows/tests.yml) | ||
<a href="https://pypi.org/project/days360/"> | ||
<img src="https://img.shields.io/pypi/v/days360" title="PyPI Version"> | ||
</a> | ||
|
||
Calculates the days between two dates based on the 360-day year. | ||
|
||
- Implementation of Excel's (or Number's) `DAYS360` / `TAGE360` formula in python. | ||
- Both EU and US methods of calculation are supported, with optional Excel bug compatibility. | ||
|
||
## Installation | ||
|
||
``` | ||
pip install days360 | ||
``` | ||
|
||
## Usage | ||
|
||
```python | ||
from datetime import date | ||
from days360 import days360 | ||
|
||
date_a = date(2022, 10, 2) | ||
date_b = date(2023, 11, 30) | ||
|
||
# supported methods: "US" (default), "US_NASD", "EU" | ||
days = days360(date_a, date_b, method="US") | ||
print(days) # prints 418 | ||
``` | ||
|
||
## Planned | ||
|
||
- ISDA, PSA and SIA methods | ||
- https://www.isda.org/2008/12/22/30-360-day-count-conventions/) | ||
- https://web.archive.org/web/20160425044113/http://www.nyift.com/lesson/day-count-convention-bonds/ | ||
- https://github.com/miradulo/isda_daycounters | ||
|
||
## Notes and credits | ||
|
||
- Implementations are based on https://en.wikipedia.org/wiki/360-day_calendar. | ||
- This library started as a port of this ruby gem: https://github.com/tamaloa/days360/tree/master |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters