interest_days 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97730e964a0b67a09476d0b44df33c0aecd8a81025f4e7892a375806938b1796
4
- data.tar.gz: 5782b2a88733b57f74bb892a9c187807993ee07bd7f4445831284c281e54a808
3
+ metadata.gz: 12518b1ae316f0c47b62233c4b7e48cf26653488c21028a02d0ec455013e4e41
4
+ data.tar.gz: 1eab20b63b6c8e62b95a952345743c90f84e079c54fc9620f5b2e33086dc5e83
5
5
  SHA512:
6
- metadata.gz: 70e35e27e4b0716f331fd537359e102b44459eaca401e8591f6c7d978d82cf79f10192fb899cc305faa15c1ec31b51c2a1d4d1bccf7a881275d611f8069bdcb2
7
- data.tar.gz: b76ea900e8087b538da8829c745b899bb861a93e7ee6441816bee1f4a11e4716a4f434d11ed7bf36d5a9b3df96fd5307714e0310ece92aaaec029d5b0f4d2ed5
6
+ metadata.gz: 100baf4853195b3d2fe8a81d3e71b773f038d9684c897d28e8ae715ad4bb199e3d411ecae6a55c931687a13fd0c00b92590eeb9dde36c37ba0ace8332d08ce08
7
+ data.tar.gz: 0db0edf6bb9fa4512f2e1c35c04e297e26f7124268d7fb82a6993f7a65a355e1d833e28cf268f5e24d81d972f7b89422306feb40520881369c91df3ac48cb479
@@ -13,7 +13,9 @@ jobs:
13
13
  ruby-version: '2.7.3'
14
14
  bundler-cache: true
15
15
  - name: Run the default task
16
- run: bundle exec rake
16
+ run: COVERAGE=true bundle exec rake
17
+ env:
18
+ token: ${{ secrets.CODECOV_TOKEN }}
17
19
  - name: Upload coverage to Codecov
18
20
  uses: codecov/codecov-action@v2
19
21
  with:
data/.gitignore CHANGED
@@ -10,3 +10,4 @@
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
12
  .history/*
13
+ .DS_Store
data/CHANGELOG.md CHANGED
@@ -1,18 +1,21 @@
1
1
 
2
+ ## [0.5.0] / 2022-11-07
3
+ ==================
4
+ * Add ICMA act/act strategy.
5
+
6
+ ## [0.4.1] / 2022-04-12
7
+ ==================
8
+
9
+ * Fix start_date_after_end_date method considering the case that start_date and end_date are equal.
10
+
2
11
  ## [0.4.0] / 2022-03-22
3
12
  ==================
4
13
 
5
14
  * Update readme file.
6
15
  * Bump version to 0.4.0.
7
- * Add Isda Act Act strategy. #11
16
+ * Add Isda act/act strategy. #11
8
17
 
9
18
  ## [0.3.0] / 2022-02-03
10
- ==================
11
-
12
- * Bump version to 0.3.0
13
- * Finish including isda act 364 (#11)
14
-
15
- ## [0.2.1] / 2022-02-03
16
19
  ==================
17
20
 
18
21
  * Bump version to 0.2.1
data/Gemfile CHANGED
@@ -8,8 +8,8 @@ gemspec
8
8
  gem "rake", "~> 13.0"
9
9
 
10
10
  group :test, :development do
11
- gem "codecov", "~> 0.6.0"
11
+ gem "codecov", "~> 0.6.0", require: false
12
12
  gem "rspec", "~> 3.0"
13
13
  gem "rubocop", "~> 1.7"
14
- gem "simplecov", "~> 0.21.2"
14
+ gem "simplecov", "~> 0.21.2", require: false
15
15
  end
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- interest_days (0.4.0)
4
+ interest_days (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -9,11 +9,16 @@ GEM
9
9
  ast (2.4.2)
10
10
  codecov (0.6.0)
11
11
  simplecov (>= 0.15, < 0.22)
12
+ coderay (1.1.3)
12
13
  diff-lcs (1.4.4)
13
14
  docile (1.4.0)
15
+ method_source (1.0.0)
14
16
  parallel (1.20.1)
15
17
  parser (3.0.2.0)
16
18
  ast (~> 2.4.1)
19
+ pry (0.13.1)
20
+ coderay (~> 1.1)
21
+ method_source (~> 1.0)
17
22
  rainbow (3.0.0)
18
23
  rake (13.0.6)
19
24
  regexp_parser (2.1.1)
@@ -64,6 +69,7 @@ PLATFORMS
64
69
  DEPENDENCIES
65
70
  codecov (~> 0.6.0)
66
71
  interest_days!
72
+ pry (~> 0.13.1)
67
73
  rake (~> 13.0)
68
74
  rspec (~> 3.0)
69
75
  rubocop (~> 1.7)
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # InterestDays
2
2
 
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.
3
+ This gem provides interest day factor calculation based on ISDA conventions e.g. Isda Act 360.
4
+ - Since version 0.2 interest_day gem supported 30/360 US EOM and 30/360 Bond Basis conventions.
5
5
  - Since version 0.3 the gem also supports Isda Act 364
6
6
 
7
7
  ## Installation
@@ -22,7 +22,7 @@ Or install it yourself as:
22
22
 
23
23
  ## Usage
24
24
 
25
- You can simple use the InterestDays::Calculator like:
25
+ You can simply use the InterestDays::Calculator like:
26
26
 
27
27
  ```ruby
28
28
  calculator = InterestDays::Calculator.new(start_date: start, end_date: end, strategy: :isda_act_360)
@@ -30,7 +30,7 @@ calculator = InterestDays::Calculator.new(start_date: start, end_date: end, stra
30
30
  calculator.interest_day_count_factor
31
31
  ```
32
32
 
33
- currently there a five supported conventions:
33
+ currently, there are five supported conventions:
34
34
  - :isda_act_360
35
35
  - :isda_act_364
36
36
  - :isda_act_365
@@ -38,6 +38,7 @@ currently there a five supported conventions:
38
38
  - :isda_30_e_360
39
39
  - :us_eom_30_360
40
40
  - :bond_basis_30_360
41
+ - :icma_act_act
41
42
 
42
43
  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
44
 
@@ -31,10 +31,12 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  # Uncomment to register a new dependency of your gem
33
33
  # spec.add_dependency "example-gem", "~> 1.0"
34
+ spec.add_development_dependency "pry", "~> 0.13.1"
34
35
  spec.add_development_dependency "rspec", "~> 3.2"
35
36
  spec.add_development_dependency "rubocop-rake"
36
37
  spec.add_development_dependency "rubocop-rspec"
37
38
 
38
39
  # For more information and examples about making a new gem, checkout our
39
40
  # guide at: https://bundler.io/guides/creating_gem.html
41
+ spec.metadata["rubygems_mfa_required"] = "true"
40
42
  end
@@ -27,7 +27,7 @@ module InterestDays
27
27
  private
28
28
 
29
29
  def start_date_after_end_date?
30
- start_date >= end_date
30
+ start_date > end_date
31
31
  end
32
32
 
33
33
  def days
@@ -0,0 +1,71 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InterestDays
4
+ module Calculation
5
+ # ISDA Act Act Convention calculation
6
+ class IcmaActAct < Base
7
+ DAYS_IN_YEAR = 365
8
+ DAYS_IN_LEAP_YEAR = 366
9
+
10
+ def day_count_factor
11
+ return days.fdiv(start_date_days_in_year) if start_date_and_end_date_in_same_year?
12
+
13
+ if years_in_between_factor > 1
14
+ return start_date_period_factor + years_in_between_factor + end_date_period_factor
15
+ end
16
+
17
+ days.fdiv(year_days_in_period)
18
+ end
19
+
20
+ private
21
+
22
+ def year_days_in_period
23
+ period_contains_leap_day? ? DAYS_IN_LEAP_YEAR : DAYS_IN_YEAR
24
+ end
25
+
26
+ def period_contains_leap_day?
27
+ !leap_day.nil? && leap_day.between?(start_date, end_date)
28
+ end
29
+
30
+ def leap_day
31
+ @leap_day ||= if start_date.leap?
32
+ Date.new(start_date.year, 2, 29)
33
+ elsif end_date.leap?
34
+ Date.new(end_date.year, 2, 29)
35
+ end
36
+ end
37
+
38
+ def start_date_period_factor
39
+ (start_date_days_in_year - start_date.yday).fdiv(start_date_days_in_year)
40
+ end
41
+
42
+ def end_date_period_factor
43
+ end_date.yday.fdiv(end_date_days_in_year)
44
+ end
45
+
46
+ def years_in_between_factor
47
+ (end_date.year - start_date.year) - 1
48
+ end
49
+
50
+ def start_date_period_with_leap_date?
51
+ start_date.leap? && start_date.month < 3
52
+ end
53
+
54
+ def end_date_period_with_leap_date?
55
+ end_date.leap? && end_date >= Date.new(end_date.year, 2, 29)
56
+ end
57
+
58
+ def start_date_and_end_date_in_same_year?
59
+ start_date.year.eql?(end_date.year)
60
+ end
61
+
62
+ def start_date_days_in_year
63
+ start_date_period_with_leap_date? ? DAYS_IN_LEAP_YEAR : DAYS_IN_YEAR
64
+ end
65
+
66
+ def end_date_days_in_year
67
+ end_date_period_with_leap_date? ? DAYS_IN_LEAP_YEAR : DAYS_IN_YEAR
68
+ end
69
+ end
70
+ end
71
+ end
@@ -8,8 +8,8 @@ module InterestDays
8
8
 
9
9
  # D2 day
10
10
  def end_date_days
11
- if ((@start_date.month == 2 && @start_date.date == days_in_month_for(@start_date)) &&
12
- (@end_date.month == 2 && @end_date.date == days_in_month_for(@end_date))) ||
11
+ if ((@start_date.month == 2 && @start_date.day == days_in_month_for(@start_date)) &&
12
+ (@end_date.month == 2 && @end_date.day == days_in_month_for(@end_date))) ||
13
13
  (@end_date.day == 31 && @start_date.day >= 30)
14
14
  RELEVANT_DAY_IN_MONTH
15
15
  else
@@ -19,7 +19,7 @@ module InterestDays
19
19
 
20
20
  # D1 day
21
21
  def start_date_days
22
- if (@start_date.month == 2 && @start_date.date == days_in_month_for(@start_date)) || @start_date.day == 31
22
+ if (@start_date.month == 2 && @start_date.day == days_in_month_for(@start_date)) || @start_date.day == 31
23
23
  RELEVANT_DAY_IN_MONTH
24
24
  else
25
25
  @start_date.day
@@ -27,7 +27,8 @@ module InterestDays
27
27
  isda_act_act: InterestDays::Calculation::IsdaActAct,
28
28
  isda_30_e_360: InterestDays::Calculation::Isda30e360,
29
29
  bond_basis_30_360: InterestDays::Calculation::Isda30e360,
30
- us_eom_30_360: InterestDays::Calculation::UsEom30360
30
+ us_eom_30_360: InterestDays::Calculation::UsEom30360,
31
+ icma_act_act: InterestDays::Calculation::IcmaActAct
31
32
  }
32
33
  end
33
34
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InterestDays
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
data/lib/interest_days.rb CHANGED
@@ -9,6 +9,7 @@ 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
11
  require "interest_days/calculation/isda_act_act"
12
+ require "interest_days/calculation/icma_act_act"
12
13
  require "interest_days/calculation/isda_30_e_360"
13
14
 
14
15
  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.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Mueller
@@ -9,8 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2022-03-29 00:00:00.000000000 Z
12
+ date: 2022-11-07 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: pry
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: 0.13.1
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: 0.13.1
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: rspec
16
30
  requirement: !ruby/object:Gem::Requirement
@@ -72,10 +86,10 @@ files:
72
86
  - Rakefile
73
87
  - bin/console
74
88
  - bin/setup
75
- - interest_days-0.2.0.gem
76
89
  - interest_days.gemspec
77
90
  - lib/interest_days.rb
78
91
  - lib/interest_days/calculation/base.rb
92
+ - lib/interest_days/calculation/icma_act_act.rb
79
93
  - lib/interest_days/calculation/isda_30_e_360.rb
80
94
  - lib/interest_days/calculation/isda_act_360.rb
81
95
  - lib/interest_days/calculation/isda_act_364.rb
@@ -92,6 +106,7 @@ metadata:
92
106
  homepage_uri: https://github.com/eugenmueller/interest_days
93
107
  source_code_uri: https://github.com/eugenmueller/interest_days
94
108
  changelog_uri: https://github.com/eugenmueller/interest_days/blob/v0.2.0/CHANGELOG.md
109
+ rubygems_mfa_required: 'true'
95
110
  post_install_message:
96
111
  rdoc_options: []
97
112
  require_paths:
@@ -107,7 +122,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
122
  - !ruby/object:Gem::Version
108
123
  version: '0'
109
124
  requirements: []
110
- rubygems_version: 3.1.6
125
+ rubygems_version: 3.3.17
111
126
  signing_key:
112
127
  specification_version: 4
113
128
  summary: Interest day calculation
Binary file