interest_days 0.2.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: fd70242df3cc611422eab114a361fa95159a2b38f80c1f36588f65bd42696eae
4
- data.tar.gz: 1110b831429ac7ec6e544ac7122d020ee2cf0a3e2b815ce028dea04db218b34f
3
+ metadata.gz: 97730e964a0b67a09476d0b44df33c0aecd8a81025f4e7892a375806938b1796
4
+ data.tar.gz: 5782b2a88733b57f74bb892a9c187807993ee07bd7f4445831284c281e54a808
5
5
  SHA512:
6
- metadata.gz: b6f267d1f27967ab0e522b6b4e0854ffb4d4b56986ae848adbc535b826282380a20cbe9bde47dae5baa743ea9da4de0e5341d135cb161a53540d3e28325ae35a
7
- data.tar.gz: 801180a7509c5e751d7a1d91ebfedb335d69c0f7d4d19ad3c05d7cba8c7c7d1d07ba0f4aacee1a87e9ae287b30d4e3f4317eac5a3d9267b2dce7dcbbcc5842f5
6
+ metadata.gz: 70e35e27e4b0716f331fd537359e102b44459eaca401e8591f6c7d978d82cf79f10192fb899cc305faa15c1ec31b51c2a1d4d1bccf7a881275d611f8069bdcb2
7
+ data.tar.gz: b76ea900e8087b538da8829c745b899bb861a93e7ee6441816bee1f4a11e4716a4f434d11ed7bf36d5a9b3df96fd5307714e0310ece92aaaec029d5b0f4d2ed5
@@ -14,3 +14,7 @@ jobs:
14
14
  bundler-cache: true
15
15
  - name: Run the default task
16
16
  run: bundle exec rake
17
+ - name: Upload coverage to Codecov
18
+ uses: codecov/codecov-action@v2
19
+ with:
20
+ token: ${{ secrets.CODECOV_TOKEN }}
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ .history/*
data/CHANGELOG.md CHANGED
@@ -1,4 +1,36 @@
1
- ## [Unreleased]
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
+
9
+ ## [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
+ ==================
17
+
18
+ * Bump version to 0.2.1
19
+ * Change the gemspec metadata.
20
+ * Setup siplecov.
21
+ * Add spec for act 364 strategy.
22
+ * Add act 364 calculation strategy.
23
+ * Tests isda 30 e 360 (#5)
24
+ * Add codecov integration.
25
+
26
+ ## [0.2.0] / 2021-10-08
27
+ ==================
28
+
29
+ * Feature/#2 30 360 bond basis (#4)
30
+ * Merge pull request #1 from eugenmueller/FIX/readme_typo
31
+ * FIX: indention in README
32
+ * FIX: fix readme typo
33
+ * add .history dir to gitignore
2
34
 
3
35
  ## [0.1.0] - 2021-10-03
4
36
 
data/Gemfile CHANGED
@@ -7,6 +7,9 @@ gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
9
 
10
- gem "rspec", "~> 3.0"
11
-
12
- gem "rubocop", "~> 1.7"
10
+ group :test, :development do
11
+ gem "codecov", "~> 0.6.0"
12
+ gem "rspec", "~> 3.0"
13
+ gem "rubocop", "~> 1.7"
14
+ gem "simplecov", "~> 0.21.2"
15
+ end
data/Gemfile.lock CHANGED
@@ -1,13 +1,16 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- interest_days (0.2.0)
4
+ interest_days (0.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
9
  ast (2.4.2)
10
+ codecov (0.6.0)
11
+ simplecov (>= 0.15, < 0.22)
10
12
  diff-lcs (1.4.4)
13
+ docile (1.4.0)
11
14
  parallel (1.20.1)
12
15
  parser (3.0.2.0)
13
16
  ast (~> 2.4.1)
@@ -45,19 +48,28 @@ GEM
45
48
  rubocop (~> 1.0)
46
49
  rubocop-ast (>= 1.1.0)
47
50
  ruby-progressbar (1.11.0)
51
+ simplecov (0.21.2)
52
+ docile (~> 1.1)
53
+ simplecov-html (~> 0.11)
54
+ simplecov_json_formatter (~> 0.1)
55
+ simplecov-html (0.12.3)
56
+ simplecov_json_formatter (0.1.3)
48
57
  unicode-display_width (2.0.0)
49
58
 
50
59
  PLATFORMS
60
+ x86_64-darwin-19
51
61
  x86_64-darwin-20
52
62
  x86_64-linux
53
63
 
54
64
  DEPENDENCIES
65
+ codecov (~> 0.6.0)
55
66
  interest_days!
56
67
  rake (~> 13.0)
57
68
  rspec (~> 3.0)
58
69
  rubocop (~> 1.7)
59
70
  rubocop-rake
60
71
  rubocop-rspec
72
+ simplecov (~> 0.21.2)
61
73
 
62
74
  BUNDLED WITH
63
- 2.2.21
75
+ 2.2.33
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
 
@@ -23,19 +24,22 @@ Or install it yourself as:
23
24
 
24
25
  You can simple use the InterestDays::Calculator like:
25
26
 
26
- ```ruby
27
- calculator = InterestDays::Calculator.new(start_date: start, end_date: end, strategy: :isda_act_360)
28
-
29
- calculator.interest_day_count_factor
30
- ```
27
+ ```ruby
28
+ calculator = InterestDays::Calculator.new(start_date: start, end_date: end, strategy: :isda_act_360)
29
+
30
+ calculator.interest_day_count_factor
31
+ ```
31
32
 
32
- currently there a three supported conventions:
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.
39
43
 
40
44
  ## Development
41
45
 
@@ -45,7 +49,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
45
49
 
46
50
  ## Contributing
47
51
 
48
- Bug reports and pull requests are welcome on GitHub at https://github.com/eugenmueller/interest_days.
52
+ Bug reports and pull requests are welcome on GitHub at https://github.com/eugenmueller/interest_days. ;)
49
53
 
50
54
  ## License
51
55
 
Binary file
@@ -5,7 +5,7 @@ require_relative "lib/interest_days/version"
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "interest_days"
7
7
  spec.version = InterestDays::VERSION
8
- spec.authors = ["Eugen Mueller"]
8
+ spec.authors = ["Eugen Mueller", "Kevin Liebholz"]
9
9
  spec.email = ["eugen.mllr@gmail.com"]
10
10
 
11
11
  spec.summary = "Interest day calculation"
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.metadata["homepage_uri"] = spec.homepage
20
20
  spec.metadata["source_code_uri"] = "https://github.com/eugenmueller/interest_days"
21
- spec.metadata["changelog_uri"] = "https://github.com/eugenmueller/interest_days/CHANGELOG.md"
21
+ spec.metadata["changelog_uri"] = "https://github.com/eugenmueller/interest_days/blob/v0.2.0/CHANGELOG.md"
22
22
 
23
23
  # Specify which files should be added to the gem when it is released.
24
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -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,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module InterestDays
4
+ module Calculation
5
+ # ISDA 30 E 365 Convention calculation
6
+ class IsdaAct364 < Base
7
+ RELEVANT_DAYS_IN_YEAR = 364
8
+
9
+ def day_count_factor
10
+ days.fdiv(RELEVANT_DAYS_IN_YEAR)
11
+ end
12
+ end
13
+ end
14
+ 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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module InterestDays
4
- VERSION = "0.2.0"
4
+ VERSION = "0.4.0"
5
5
  end
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,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interest_days
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Mueller
8
+ - Kevin Liebholz
8
9
  autorequire:
9
10
  bindir: exe
10
11
  cert_chain: []
11
- date: 2021-10-08 00:00:00.000000000 Z
12
+ date: 2022-03-29 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: rspec
@@ -71,12 +72,15 @@ files:
71
72
  - Rakefile
72
73
  - bin/console
73
74
  - bin/setup
75
+ - interest_days-0.2.0.gem
74
76
  - interest_days.gemspec
75
77
  - lib/interest_days.rb
76
78
  - lib/interest_days/calculation/base.rb
77
79
  - lib/interest_days/calculation/isda_30_e_360.rb
78
80
  - lib/interest_days/calculation/isda_act_360.rb
81
+ - lib/interest_days/calculation/isda_act_364.rb
79
82
  - lib/interest_days/calculation/isda_act_365.rb
83
+ - lib/interest_days/calculation/isda_act_act.rb
80
84
  - lib/interest_days/calculation/thirty_threesixty_base.rb
81
85
  - lib/interest_days/calculation/us_eom_30_360.rb
82
86
  - lib/interest_days/calculator.rb
@@ -87,7 +91,7 @@ licenses:
87
91
  metadata:
88
92
  homepage_uri: https://github.com/eugenmueller/interest_days
89
93
  source_code_uri: https://github.com/eugenmueller/interest_days
90
- changelog_uri: https://github.com/eugenmueller/interest_days/CHANGELOG.md
94
+ changelog_uri: https://github.com/eugenmueller/interest_days/blob/v0.2.0/CHANGELOG.md
91
95
  post_install_message:
92
96
  rdoc_options: []
93
97
  require_paths: