interest_days 0.2.1 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +23 -0
- data/Gemfile +1 -4
- data/Gemfile.lock +2 -2
- data/README.md +6 -1
- data/lib/interest_days/calculation/base.rb +13 -0
- data/lib/interest_days/calculation/isda_act_364.rb +1 -1
- data/lib/interest_days/calculation/isda_act_act.rb +45 -0
- data/lib/interest_days/calculator.rb +2 -0
- data/lib/interest_days/version.rb +1 -1
- data/lib/interest_days.rb +2 -0
- metadata +3 -3
- data/interest_days-0.2.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 953488e1e6675656aa813e1755e726a45ba0d7541bfd0368008bd70fd7642cd5
|
4
|
+
data.tar.gz: 2275c9d7678db7a25bacfcac4de27e33b4f1119d8dc4fa8ae9aef7c73f70f790
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6639f9a66b367755cd8e8126dce225d246dd106e32286fc4152392da20bbc86cf39ecd1350c19c80af971373fd58e8f44659637d8babf83003f37d4c3b5828fc
|
7
|
+
data.tar.gz: 250f46d051b56af3674187d9043c0cd3958b6778826aa66139db6f23508b2f10eab830442fc76eba5d039f7a712d7625dc62568141fc847e7739259c2e530b93
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,27 @@
|
|
1
1
|
|
2
|
+
## [0.4.1] / 2022-04-12
|
3
|
+
==================
|
4
|
+
|
5
|
+
* Fix start_date_after_end_date method considering the case that start_date and end_date are equal.
|
6
|
+
|
7
|
+
## [0.4.0] / 2022-03-22
|
8
|
+
==================
|
9
|
+
|
10
|
+
* Update readme file.
|
11
|
+
* Bump version to 0.4.0.
|
12
|
+
* Add Isda Act Act strategy. #11
|
13
|
+
|
14
|
+
## [0.3.0] / 2022-02-03
|
15
|
+
==================
|
16
|
+
|
17
|
+
* Bump version to 0.2.1
|
18
|
+
* Change the gemspec metadata.
|
19
|
+
* Setup siplecov.
|
20
|
+
* Add spec for act 364 strategy.
|
21
|
+
* Add act 364 calculation strategy.
|
22
|
+
* Tests isda 30 e 360 (#5)
|
23
|
+
* Add codecov integration.
|
24
|
+
|
2
25
|
## [0.2.0] / 2021-10-08
|
3
26
|
==================
|
4
27
|
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# InterestDays
|
2
2
|
|
3
3
|
This gem provide interest day factor calculation based on ISDA conventions e.g. Isda Act 360.
|
4
|
-
Since version 0.2 interest_day gem support 30/360 US EOM and 30/360 Bond Basis conventions.
|
4
|
+
- Since version 0.2 interest_day gem support 30/360 US EOM and 30/360 Bond Basis conventions.
|
5
|
+
- Since version 0.3 the gem also supports Isda Act 364
|
5
6
|
|
6
7
|
## Installation
|
7
8
|
|
@@ -31,11 +32,15 @@ calculator.interest_day_count_factor
|
|
31
32
|
|
32
33
|
currently there a five supported conventions:
|
33
34
|
- :isda_act_360
|
35
|
+
- :isda_act_364
|
34
36
|
- :isda_act_365
|
37
|
+
- :isda_act_act
|
35
38
|
- :isda_30_e_360
|
36
39
|
- :us_eom_30_360
|
37
40
|
- :bond_basis_30_360
|
38
41
|
|
42
|
+
As often, [Wikipedia](https://en.wikipedia.org/wiki/Day_count_convention) is the best resource, so check it out to get more insights into these conventions.
|
43
|
+
|
39
44
|
## Development
|
40
45
|
|
41
46
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
module InterestDays
|
4
4
|
module Calculation
|
5
|
+
# StartDateBeforeEndDateError class
|
6
|
+
class StartDateBeforeEndDateError < StandardError
|
7
|
+
def initialize(msg = "End date have to be after start date!")
|
8
|
+
super(msg)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
5
12
|
# Base calculation class
|
6
13
|
class Base
|
7
14
|
attr_reader :start_date, :end_date
|
@@ -9,6 +16,8 @@ module InterestDays
|
|
9
16
|
def initialize(start_date:, end_date:)
|
10
17
|
@start_date = start_date
|
11
18
|
@end_date = end_date
|
19
|
+
|
20
|
+
raise StartDateBeforeEndDateError if start_date_after_end_date?
|
12
21
|
end
|
13
22
|
|
14
23
|
def day_count_factor
|
@@ -17,6 +26,10 @@ module InterestDays
|
|
17
26
|
|
18
27
|
private
|
19
28
|
|
29
|
+
def start_date_after_end_date?
|
30
|
+
start_date > end_date
|
31
|
+
end
|
32
|
+
|
20
33
|
def days
|
21
34
|
@end_date - @start_date
|
22
35
|
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module InterestDays
|
4
|
+
module Calculation
|
5
|
+
# ISDA Act Act Convention calculation
|
6
|
+
class IsdaActAct < Base
|
7
|
+
RELEVANT_DAYS_IN_YEAR = 365
|
8
|
+
RELEVANT_DAYS_IN_LEAP_YEAR = 366
|
9
|
+
|
10
|
+
def day_count_factor
|
11
|
+
return days.fdiv(stard_date_days_in_year) if start_date_and_end_date_in_same_year?
|
12
|
+
|
13
|
+
end_date_days.fdiv(end_date_days_in_year) +
|
14
|
+
start_date_days.fdiv(stard_date_days_in_year) +
|
15
|
+
full_years_between_start_and_end_date
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def full_years_between_start_and_end_date
|
21
|
+
(end_date.year - start_date.year) - 1
|
22
|
+
end
|
23
|
+
|
24
|
+
def start_date_and_end_date_in_same_year?
|
25
|
+
start_date.year.eql?(end_date.year)
|
26
|
+
end
|
27
|
+
|
28
|
+
def stard_date_days_in_year
|
29
|
+
start_date.leap? ? RELEVANT_DAYS_IN_LEAP_YEAR : RELEVANT_DAYS_IN_YEAR
|
30
|
+
end
|
31
|
+
|
32
|
+
def end_date_days_in_year
|
33
|
+
end_date.leap? ? RELEVANT_DAYS_IN_LEAP_YEAR : RELEVANT_DAYS_IN_YEAR
|
34
|
+
end
|
35
|
+
|
36
|
+
def start_date_days
|
37
|
+
stard_date_days_in_year - start_date.yday
|
38
|
+
end
|
39
|
+
|
40
|
+
def end_date_days
|
41
|
+
end_date.yday
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -22,7 +22,9 @@ module InterestDays
|
|
22
22
|
def strategies
|
23
23
|
@strategies ||= {
|
24
24
|
isda_act_360: InterestDays::Calculation::IsdaAct360,
|
25
|
+
isda_act_364: InterestDays::Calculation::IsdaAct364,
|
25
26
|
isda_act_365: InterestDays::Calculation::IsdaAct365,
|
27
|
+
isda_act_act: InterestDays::Calculation::IsdaActAct,
|
26
28
|
isda_30_e_360: InterestDays::Calculation::Isda30e360,
|
27
29
|
bond_basis_30_360: InterestDays::Calculation::Isda30e360,
|
28
30
|
us_eom_30_360: InterestDays::Calculation::UsEom30360
|
data/lib/interest_days.rb
CHANGED
@@ -6,7 +6,9 @@ require "interest_days/calculation/base"
|
|
6
6
|
require "interest_days/calculation/thirty_threesixty_base"
|
7
7
|
require "interest_days/calculation/us_eom_30_360"
|
8
8
|
require "interest_days/calculation/isda_act_360"
|
9
|
+
require "interest_days/calculation/isda_act_364"
|
9
10
|
require "interest_days/calculation/isda_act_365"
|
11
|
+
require "interest_days/calculation/isda_act_act"
|
10
12
|
require "interest_days/calculation/isda_30_e_360"
|
11
13
|
|
12
14
|
module InterestDays
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: interest_days
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugen Mueller
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2022-
|
12
|
+
date: 2022-04-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -72,7 +72,6 @@ files:
|
|
72
72
|
- Rakefile
|
73
73
|
- bin/console
|
74
74
|
- bin/setup
|
75
|
-
- interest_days-0.2.0.gem
|
76
75
|
- interest_days.gemspec
|
77
76
|
- lib/interest_days.rb
|
78
77
|
- lib/interest_days/calculation/base.rb
|
@@ -80,6 +79,7 @@ files:
|
|
80
79
|
- lib/interest_days/calculation/isda_act_360.rb
|
81
80
|
- lib/interest_days/calculation/isda_act_364.rb
|
82
81
|
- lib/interest_days/calculation/isda_act_365.rb
|
82
|
+
- lib/interest_days/calculation/isda_act_act.rb
|
83
83
|
- lib/interest_days/calculation/thirty_threesixty_base.rb
|
84
84
|
- lib/interest_days/calculation/us_eom_30_360.rb
|
85
85
|
- lib/interest_days/calculator.rb
|
data/interest_days-0.2.0.gem
DELETED
Binary file
|