Skip to content

Commit

Permalink
Merge pull request #22 from kmedian/dev
Browse files Browse the repository at this point in the history
Prepare next release
  • Loading branch information
ulf1 committed Nov 13, 2021
2 parents 0969623 + ba4b1e2 commit 0f2cacf
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/syntax-and-unit-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:

strategy:
matrix:
python-version: ['3.6', '3.7', '3.8', '3.x']
python-version: ['3.6', '3.7', '3.8', '3.9','3.10']

name: Python ${{ matrix.python-version }} Tests

Expand Down
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.4.7 / 2021-11-13

* Bugfixes for Act AFB and ISDA by @emiliobasualdo

# 0.4.6 / 2020-04-23

* Test multiple python versions
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Functions
### Install a virtual environment

```
python3.6 -m venv .venv
python3.7 -m venv .venv
source .venv/bin/activate
pip3 install --upgrade pip
pip3 install -r requirements.txt
Expand Down
15 changes: 14 additions & 1 deletion test/test_act_afb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ class Test_ActAfb(unittest.TestCase):

def test1(self):
x = act_afb(2018, 12, 15, 2019, 3, 1)
self.assertEquals(round(x, 8), 0.20547945)
self.assertEquals(round(x, 15), 0.208219178082192)
self.assertEquals(round(x, 8), 0.20821918)

def test2(self):
x = act_afb(2018, 12, 31, 2019, 1, 1)
self.assertEquals(round(x, 8), round(1. / 365., 8))

def test3(self):
x = act_afb(1994, 6, 30, 1997, 6, 30)
self.assertEquals(round(x, 8), 3.0)

def test4(self):
x = act_afb(1994, 2, 10, 1994, 6, 30)
self.assertEquals(round(x, 8), round(140. / 365., 8))


# run
Expand Down
15 changes: 14 additions & 1 deletion test/test_act_isda.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,20 @@ class Test_ActIsda(unittest.TestCase):

def test1(self):
x = act_isda(2018, 12, 15, 2019, 3, 1)
self.assertEquals(round(x, 8), 0.20547945)
# self.assertEquals(round(x, 15), 0.208219178082192)
self.assertEquals(round(x, 8), round(0.208219178082118, 8))

def test2(self):
x = act_isda(2018, 12, 31, 2019, 1, 1)
self.assertEquals(round(x, 8), round(1. / 365., 8))

def test3(self):
x = act_isda(1994, 6, 30, 1997, 6, 30)
self.assertEquals(round(x, 8), 3.0)

def test4(self):
x = act_isda(1994, 2, 10, 1994, 6, 30)
self.assertEquals(round(x, 8), round(140. / 365., 8))


# run
Expand Down
20 changes: 10 additions & 10 deletions test/test_yearfrac.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ def test1(self):
d1 = datetime(2018, 12, 15)
d2 = datetime(2019, 3, 1)
x = yearfrac(d1, d2, 'act')
self.assertEquals(round(x, 8), 0.20547945)
self.assertEquals(round(x, 15), 0.208219178082192)

def test2(self):
d1 = datetime(2018, 12, 15)
d2 = datetime(2019, 3, 1)
x = yearfrac(d1, d2, 'act_isda')
self.assertEquals(round(x, 8), 0.20547945)
self.assertEquals(round(x, 8), round(0.208219178082118, 8))

def test3(self):
d1 = datetime(2018, 12, 15)
Expand All @@ -36,26 +36,26 @@ def test_vector_vector(self):
v2 = [datetime(2019, 3, 1), datetime(2019, 3, 1)]
x = yearfrac(v1, v2, 'act')
self.assertEquals(
[round(x[0], 8), round(x[1], 8)],
[0.20547945, 0.20547945]
[round(x[0], 15), round(x[1], 15)],
[0.208219178082192, 0.208219178082192]
)

def test_vector_scalar(self):
v = [datetime(2018, 12, 15), datetime(2018, 12, 15)]
s = datetime(2019, 3, 1)
x = yearfrac(v, s, 'act')
self.assertEquals(
[round(x[0], 8), round(x[1], 8)],
[0.20547945, 0.20547945]
[round(x[0], 15), round(x[1], 15)],
[0.208219178082192, 0.208219178082192]
)

def test_scalar_vector(self):
s = datetime(2018, 12, 15)
v = [datetime(2019, 3, 1), datetime(2019, 3, 1)]
x = yearfrac(s, v, 'act')
self.assertEquals(
[round(x[0], 8), round(x[1], 8)],
[0.20547945, 0.20547945]
[round(x[0], 15), round(x[1], 15)],
[0.208219178082192, 0.208219178082192]
)

def test_nparray_vector(self):
Expand All @@ -65,8 +65,8 @@ def test_nparray_vector(self):
v2 = [datetime(2019, 3, 1), datetime(2019, 3, 1)]
x = yearfrac(v1, v2, 'act')
self.assertEquals(
[round(x[0], 8), round(x[1], 8)],
[0.20547945, 0.20547945]
[round(x[0], 15), round(x[1], 15)],
[0.208219178082192, 0.208219178082192]
)


Expand Down
2 changes: 1 addition & 1 deletion yearfrac/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.4.6'
__version__ = '0.4.7'

from .isaleapyear import isaleapyear
from .julianday import date_to_jd, jd_to_date
Expand Down
2 changes: 1 addition & 1 deletion yearfrac/act_afb.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def act_afb(y1: int, m1: int, d1: int,
return diff_days / denom

elif y1 < y2:
diffa = date_to_jd(y1, 12, 31) - date_to_jd(y1, m1, d1)
diffa = date_to_jd(y1, 12, 31) - date_to_jd(y1, m1, d1) + 1
denoma = 366e0 if isaleapyear(y1) and (m1 < 3) else 365e0

diffb = date_to_jd(y2, m2, d2) - date_to_jd(y2, 1, 1)
Expand Down
2 changes: 1 addition & 1 deletion yearfrac/act_isda.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def act_isda(y1: int, m1: int, d1: int,
return diff_days / denom

elif y1 < y2:
diffa = date_to_jd(y1, 12, 31) - date_to_jd(y1, m1, d1)
diffa = date_to_jd(y1, 12, 31) - date_to_jd(y1, m1, d1) + 1
denoma = 366e0 if isaleapyear(y1) else 365e0

diffb = date_to_jd(y2, m2, d2) - date_to_jd(y2, 1, 1)
Expand Down

0 comments on commit 0f2cacf

Please sign in to comment.