interest_days 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a4ccc6e4b904bb4a1b308b1bc6020f44a54b4b427ce176c758fe691d848bc806
4
- data.tar.gz: 5153de34cd150fd8867ab9f8842334582e15c1f9c22ae63f722701148aa88eb2
3
+ metadata.gz: 97730e964a0b67a09476d0b44df33c0aecd8a81025f4e7892a375806938b1796
4
+ data.tar.gz: 5782b2a88733b57f74bb892a9c187807993ee07bd7f4445831284c281e54a808
5
5
  SHA512:
6
- metadata.gz: 7ee66d5bc9262d3a8059991c4b0e0374958fb7cc411b62f87453d59c1d1d5405f23f82cbb7edb7e2bc3ca47f4aee65c61cd9e758d743604f00c9f0f8c60b11ab
7
- data.tar.gz: dd5b07dbeebe22e3800ffc71ddfc882309ee9ce5c0073c1047825a3b5ef496c56fe5e40d98a73ee7a5f12584935519904372e63d91c13a070cac66c997cb8975
6
+ metadata.gz: 70e35e27e4b0716f331fd537359e102b44459eaca401e8591f6c7d978d82cf79f10192fb899cc305faa15c1ec31b51c2a1d4d1bccf7a881275d611f8069bdcb2
7
+ data.tar.gz: b76ea900e8087b538da8829c745b899bb861a93e7ee6441816bee1f4a11e4716a4f434d11ed7bf36d5a9b3df96fd5307714e0310ece92aaaec029d5b0f4d2ed5
data/CHANGELOG.md CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ ## [0.4.0] / 2022-03-22
3
+ ==================
4
+
5
+ * Update readme file.
6
+ * Bump version to 0.4.0.
7
+ * Add Isda Act Act strategy. #11
8
+
2
9
  ## [0.3.0] / 2022-02-03
3
10
  ==================
4
11
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- interest_days (0.3.0)
4
+ interest_days (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -72,4 +72,4 @@ DEPENDENCIES
72
72
  simplecov (~> 0.21.2)
73
73
 
74
74
  BUNDLED WITH
75
- 2.2.21
75
+ 2.2.33
data/README.md CHANGED
@@ -34,6 +34,7 @@ currently there a five supported conventions:
34
34
  - :isda_act_360
35
35
  - :isda_act_364
36
36
  - :isda_act_365
37
+ - :isda_act_act
37
38
  - :isda_30_e_360
38
39
  - :us_eom_30_360
39
40
  - :bond_basis_30_360
@@ -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
@@ -24,6 +24,7 @@ module InterestDays
24
24
  isda_act_360: InterestDays::Calculation::IsdaAct360,
25
25
  isda_act_364: InterestDays::Calculation::IsdaAct364,
26
26
  isda_act_365: InterestDays::Calculation::IsdaAct365,
27
+ isda_act_act: InterestDays::Calculation::IsdaActAct,
27
28
  isda_30_e_360: InterestDays::Calculation::Isda30e360,
28
29
  bond_basis_30_360: InterestDays::Calculation::Isda30e360,
29
30
  us_eom_30_360: InterestDays::Calculation::UsEom30360
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InterestDays
4
- VERSION = "0.3.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/interest_days.rb CHANGED
@@ -8,6 +8,7 @@ require "interest_days/calculation/us_eom_30_360"
8
8
  require "interest_days/calculation/isda_act_360"
9
9
  require "interest_days/calculation/isda_act_364"
10
10
  require "interest_days/calculation/isda_act_365"
11
+ require "interest_days/calculation/isda_act_act"
11
12
  require "interest_days/calculation/isda_30_e_360"
12
13
 
13
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.3.0
4
+ version: 0.4.0
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-02-03 00:00:00.000000000 Z
12
+ date: 2022-03-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -80,6 +80,7 @@ files:
80
80
  - lib/interest_days/calculation/isda_act_360.rb
81
81
  - lib/interest_days/calculation/isda_act_364.rb
82
82
  - lib/interest_days/calculation/isda_act_365.rb
83
+ - lib/interest_days/calculation/isda_act_act.rb
83
84
  - lib/interest_days/calculation/thirty_threesixty_base.rb
84
85
  - lib/interest_days/calculation/us_eom_30_360.rb
85
86
  - lib/interest_days/calculator.rb