interest_days 0.4.1 → 0.5.1

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: 953488e1e6675656aa813e1755e726a45ba0d7541bfd0368008bd70fd7642cd5
4
- data.tar.gz: 2275c9d7678db7a25bacfcac4de27e33b4f1119d8dc4fa8ae9aef7c73f70f790
3
+ metadata.gz: ebecc4f50f64001035dbc934d9c34db95d4d9839ca1ed2beead12a1812648d97
4
+ data.tar.gz: bfc358121e3074f372fac9c28a7fd5885ab8f735c9c1164f65e387df9857a07b
5
5
  SHA512:
6
- metadata.gz: 6639f9a66b367755cd8e8126dce225d246dd106e32286fc4152392da20bbc86cf39ecd1350c19c80af971373fd58e8f44659637d8babf83003f37d4c3b5828fc
7
- data.tar.gz: 250f46d051b56af3674187d9043c0cd3958b6778826aa66139db6f23508b2f10eab830442fc76eba5d039f7a712d7625dc62568141fc847e7739259c2e530b93
6
+ metadata.gz: 5c30a8d1ad8dd5cb5c0ac71c8ec51cae52f3eb14a45beaf488f4fd2f5617ac18356328ec2e93f0492bbf0c7079349067bd5ca0d8c7460b072f9b410726b510f2
7
+ data.tar.gz: 2ba3ebc474f4dcf71e165bc5270933be011cd72f33ec5ae4d15a46a0bb9ac4c86dbd9dea1da22b18b91b3d859cad2e684cacd6078f6ea2f69c1a58af6d18d953
metadata CHANGED
@@ -1,16 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: interest_days
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eugen Mueller
8
8
  - Kevin Liebholz
9
+ - Cassy Dodd
9
10
  autorequire:
10
11
  bindir: exe
11
12
  cert_chain: []
12
- date: 2022-04-12 00:00:00.000000000 Z
13
+ date: 2022-11-11 00:00:00.000000000 Z
13
14
  dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: pry
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: 0.13.1
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: 0.13.1
14
29
  - !ruby/object:Gem::Dependency
15
30
  name: rspec
16
31
  requirement: !ruby/object:Gem::Requirement
@@ -59,31 +74,7 @@ email:
59
74
  executables: []
60
75
  extensions: []
61
76
  extra_rdoc_files: []
62
- files:
63
- - ".github/workflows/main.yml"
64
- - ".gitignore"
65
- - ".rspec"
66
- - ".rubocop.yml"
67
- - CHANGELOG.md
68
- - Gemfile
69
- - Gemfile.lock
70
- - LICENSE.txt
71
- - README.md
72
- - Rakefile
73
- - bin/console
74
- - bin/setup
75
- - interest_days.gemspec
76
- - lib/interest_days.rb
77
- - lib/interest_days/calculation/base.rb
78
- - lib/interest_days/calculation/isda_30_e_360.rb
79
- - lib/interest_days/calculation/isda_act_360.rb
80
- - lib/interest_days/calculation/isda_act_364.rb
81
- - lib/interest_days/calculation/isda_act_365.rb
82
- - lib/interest_days/calculation/isda_act_act.rb
83
- - lib/interest_days/calculation/thirty_threesixty_base.rb
84
- - lib/interest_days/calculation/us_eom_30_360.rb
85
- - lib/interest_days/calculator.rb
86
- - lib/interest_days/version.rb
77
+ files: []
87
78
  homepage: https://github.com/eugenmueller/interest_days
88
79
  licenses:
89
80
  - MIT
@@ -91,6 +82,7 @@ metadata:
91
82
  homepage_uri: https://github.com/eugenmueller/interest_days
92
83
  source_code_uri: https://github.com/eugenmueller/interest_days
93
84
  changelog_uri: https://github.com/eugenmueller/interest_days/blob/v0.2.0/CHANGELOG.md
85
+ rubygems_mfa_required: 'true'
94
86
  post_install_message:
95
87
  rdoc_options: []
96
88
  require_paths:
@@ -106,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
98
  - !ruby/object:Gem::Version
107
99
  version: '0'
108
100
  requirements: []
109
- rubygems_version: 3.1.6
101
+ rubygems_version: 3.3.17
110
102
  signing_key:
111
103
  specification_version: 4
112
104
  summary: Interest day calculation
@@ -1,20 +0,0 @@
1
- name: Interest days CI
2
-
3
- on: [push,pull_request]
4
-
5
- jobs:
6
- build:
7
- runs-on: ubuntu-latest
8
- steps:
9
- - uses: actions/checkout@v2
10
- - name: Set up Ruby
11
- uses: ruby/setup-ruby@v1
12
- with:
13
- ruby-version: '2.7.3'
14
- bundler-cache: true
15
- - name: Run the default task
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 DELETED
@@ -1,12 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
12
- .history/*
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
data/.rubocop.yml DELETED
@@ -1,20 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 2.7
3
- NewCops: enable
4
-
5
- Style/StringLiterals:
6
- Enabled: true
7
- EnforcedStyle: double_quotes
8
-
9
- Style/StringLiteralsInInterpolation:
10
- Enabled: true
11
- EnforcedStyle: double_quotes
12
-
13
- Layout/LineLength:
14
- Max: 120
15
-
16
- Naming/VariableNumber:
17
- EnforcedStyle: snake_case
18
-
19
- Metrics/BlockLength:
20
- Max: 50
data/CHANGELOG.md DELETED
@@ -1,36 +0,0 @@
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
-
25
- ## [0.2.0] / 2021-10-08
26
- ==================
27
-
28
- * Feature/#2 30 360 bond basis (#4)
29
- * Merge pull request #1 from eugenmueller/FIX/readme_typo
30
- * FIX: indention in README
31
- * FIX: fix readme typo
32
- * add .history dir to gitignore
33
-
34
- ## [0.1.0] - 2021-10-03
35
-
36
- - Initial release
data/Gemfile DELETED
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- source "https://rubygems.org"
4
-
5
- # Specify your gem's dependencies in interest_days.gemspec
6
- gemspec
7
-
8
- gem "rake", "~> 13.0"
9
-
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 DELETED
@@ -1,75 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- interest_days (0.4.1)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- ast (2.4.2)
10
- codecov (0.6.0)
11
- simplecov (>= 0.15, < 0.22)
12
- diff-lcs (1.4.4)
13
- docile (1.4.0)
14
- parallel (1.20.1)
15
- parser (3.0.2.0)
16
- ast (~> 2.4.1)
17
- rainbow (3.0.0)
18
- rake (13.0.6)
19
- regexp_parser (2.1.1)
20
- rexml (3.2.5)
21
- rspec (3.10.0)
22
- rspec-core (~> 3.10.0)
23
- rspec-expectations (~> 3.10.0)
24
- rspec-mocks (~> 3.10.0)
25
- rspec-core (3.10.1)
26
- rspec-support (~> 3.10.0)
27
- rspec-expectations (3.10.1)
28
- diff-lcs (>= 1.2.0, < 2.0)
29
- rspec-support (~> 3.10.0)
30
- rspec-mocks (3.10.2)
31
- diff-lcs (>= 1.2.0, < 2.0)
32
- rspec-support (~> 3.10.0)
33
- rspec-support (3.10.2)
34
- rubocop (1.18.3)
35
- parallel (~> 1.10)
36
- parser (>= 3.0.0.0)
37
- rainbow (>= 2.2.2, < 4.0)
38
- regexp_parser (>= 1.8, < 3.0)
39
- rexml
40
- rubocop-ast (>= 1.7.0, < 2.0)
41
- ruby-progressbar (~> 1.7)
42
- unicode-display_width (>= 1.4.0, < 3.0)
43
- rubocop-ast (1.7.0)
44
- parser (>= 3.0.1.1)
45
- rubocop-rake (0.6.0)
46
- rubocop (~> 1.0)
47
- rubocop-rspec (2.4.0)
48
- rubocop (~> 1.0)
49
- rubocop-ast (>= 1.1.0)
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)
57
- unicode-display_width (2.0.0)
58
-
59
- PLATFORMS
60
- x86_64-darwin-19
61
- x86_64-darwin-20
62
- x86_64-linux
63
-
64
- DEPENDENCIES
65
- codecov (~> 0.6.0)
66
- interest_days!
67
- rake (~> 13.0)
68
- rspec (~> 3.0)
69
- rubocop (~> 1.7)
70
- rubocop-rake
71
- rubocop-rspec
72
- simplecov (~> 0.21.2)
73
-
74
- BUNDLED WITH
75
- 2.2.33
data/LICENSE.txt DELETED
@@ -1,21 +0,0 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2021 Eugen Mueller
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
data/README.md DELETED
@@ -1,56 +0,0 @@
1
- # InterestDays
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.
5
- - Since version 0.3 the gem also supports Isda Act 364
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'interest_days'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle install
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install interest_days
22
-
23
- ## Usage
24
-
25
- You can simple use the InterestDays::Calculator like:
26
-
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
- ```
32
-
33
- currently there a five supported conventions:
34
- - :isda_act_360
35
- - :isda_act_364
36
- - :isda_act_365
37
- - :isda_act_act
38
- - :isda_30_e_360
39
- - :us_eom_30_360
40
- - :bond_basis_30_360
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
-
44
- ## Development
45
-
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.
47
-
48
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
49
-
50
- ## Contributing
51
-
52
- Bug reports and pull requests are welcome on GitHub at https://github.com/eugenmueller/interest_days. ;)
53
-
54
- ## License
55
-
56
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile DELETED
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rspec/core/rake_task"
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- require "rubocop/rake_task"
9
-
10
- RuboCop::RakeTask.new
11
-
12
- task default: %i[spec rubocop]
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "bundler/setup"
5
- require "interest_days"
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- # require "pry"
12
- # Pry.start
13
-
14
- require "irb"
15
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,40 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/interest_days/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "interest_days"
7
- spec.version = InterestDays::VERSION
8
- spec.authors = ["Eugen Mueller", "Kevin Liebholz"]
9
- spec.email = ["eugen.mllr@gmail.com"]
10
-
11
- spec.summary = "Interest day calculation"
12
- spec.description = "Interest days gem calculate interest days depends on desired method."
13
- spec.homepage = "https://github.com/eugenmueller/interest_days"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.7.0"
16
-
17
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'https://mygemserver.com'"
18
-
19
- spec.metadata["homepage_uri"] = spec.homepage
20
- spec.metadata["source_code_uri"] = "https://github.com/eugenmueller/interest_days"
21
- spec.metadata["changelog_uri"] = "https://github.com/eugenmueller/interest_days/blob/v0.2.0/CHANGELOG.md"
22
-
23
- # Specify which files should be added to the gem when it is released.
24
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
- spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
27
- end
28
- spec.bindir = "exe"
29
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
31
-
32
- # Uncomment to register a new dependency of your gem
33
- # spec.add_dependency "example-gem", "~> 1.0"
34
- spec.add_development_dependency "rspec", "~> 3.2"
35
- spec.add_development_dependency "rubocop-rake"
36
- spec.add_development_dependency "rubocop-rspec"
37
-
38
- # For more information and examples about making a new gem, checkout our
39
- # guide at: https://bundler.io/guides/creating_gem.html
40
- end
@@ -1,38 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module InterestDays
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
-
12
- # Base calculation class
13
- class Base
14
- attr_reader :start_date, :end_date
15
-
16
- def initialize(start_date:, end_date:)
17
- @start_date = start_date
18
- @end_date = end_date
19
-
20
- raise StartDateBeforeEndDateError if start_date_after_end_date?
21
- end
22
-
23
- def day_count_factor
24
- raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}"
25
- end
26
-
27
- private
28
-
29
- def start_date_after_end_date?
30
- start_date > end_date
31
- end
32
-
33
- def days
34
- @end_date - @start_date
35
- end
36
- end
37
- end
38
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module InterestDays
4
- module Calculation
5
- # ISDA 30 E 360 Convention calculation
6
- class Isda30e360 < ThirtyThreesixtyBase
7
- private
8
-
9
- def end_date_days
10
- [@end_date.day, RELEVANT_DAY_IN_MONTH].min
11
- end
12
-
13
- def start_date_days
14
- [@start_date.day, RELEVANT_DAY_IN_MONTH].min
15
- end
16
- end
17
- end
18
- end
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module InterestDays
4
- module Calculation
5
- # ISDA Act 360 Convention calculation
6
- class IsdaAct360 < Base
7
- RELEVANT_DAYS_IN_YEAR = 360
8
-
9
- def day_count_factor
10
- days.fdiv(RELEVANT_DAYS_IN_YEAR)
11
- end
12
- end
13
- end
14
- end
@@ -1,14 +0,0 @@
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
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module InterestDays
4
- module Calculation
5
- # ISDA 30 E 365 Convention calculation
6
- class IsdaAct365 < Base
7
- RELEVANT_DAYS_IN_YEAR = 365
8
-
9
- def day_count_factor
10
- days.fdiv(RELEVANT_DAYS_IN_YEAR)
11
- end
12
- end
13
- end
14
- end
@@ -1,45 +0,0 @@
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
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module InterestDays
4
- module Calculation
5
- # ISDA 30 E 360 Convention calculation
6
- class ThirtyThreesixtyBase < Base
7
- RELEVANT_DAYS_IN_YEAR = 360
8
- RELEVANT_DAY_IN_MONTH = 30
9
-
10
- def day_count_factor
11
- (year_interval_in_days + month_interval_in_days + day_interval).fdiv(RELEVANT_DAYS_IN_YEAR)
12
- end
13
-
14
- private
15
-
16
- def year_interval_in_days
17
- RELEVANT_DAYS_IN_YEAR * (@end_date.year - @start_date.year)
18
- end
19
-
20
- def month_interval_in_days
21
- RELEVANT_DAY_IN_MONTH * (@end_date.month - @start_date.month)
22
- end
23
-
24
- def day_interval
25
- end_date_days - start_date_days
26
- # [@end_date.day, 30].min - [@start_date.day, 30].min
27
- end
28
-
29
- def end_date_days
30
- raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}"
31
- end
32
-
33
- def start_date_days
34
- raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}"
35
- end
36
-
37
- def days_in_month_for(date)
38
- Date.new(date.year, date.month, -1).day
39
- end
40
- end
41
- end
42
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module InterestDays
4
- module Calculation
5
- # ISDA 30 E 360 Convention calculation
6
- class UsEom30360 < ThirtyThreesixtyBase
7
- private
8
-
9
- # D2 day
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))) ||
13
- (@end_date.day == 31 && @start_date.day >= 30)
14
- RELEVANT_DAY_IN_MONTH
15
- else
16
- @end_date.day
17
- end
18
- end
19
-
20
- # D1 day
21
- def start_date_days
22
- if (@start_date.month == 2 && @start_date.date == days_in_month_for(@start_date)) || @start_date.day == 31
23
- RELEVANT_DAY_IN_MONTH
24
- else
25
- @start_date.day
26
- end
27
- end
28
- end
29
- end
30
- end
@@ -1,34 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module InterestDays
4
- # Main calculator class
5
- class Calculator
6
- attr_accessor :strategy, :start_date, :end_date
7
-
8
- def initialize(start_date:, end_date:, strategy:)
9
- @start_date = start_date
10
- @end_date = end_date
11
- @strategy = strategies[strategy.to_sym]
12
- end
13
-
14
- def interest_day_count_factor
15
- raise StandardError, "Strategy is not set" if @strategy.nil?
16
-
17
- @strategy.new(start_date: @start_date, end_date: @end_date).day_count_factor
18
- end
19
-
20
- private
21
-
22
- def strategies
23
- @strategies ||= {
24
- isda_act_360: InterestDays::Calculation::IsdaAct360,
25
- isda_act_364: InterestDays::Calculation::IsdaAct364,
26
- isda_act_365: InterestDays::Calculation::IsdaAct365,
27
- isda_act_act: InterestDays::Calculation::IsdaActAct,
28
- isda_30_e_360: InterestDays::Calculation::Isda30e360,
29
- bond_basis_30_360: InterestDays::Calculation::Isda30e360,
30
- us_eom_30_360: InterestDays::Calculation::UsEom30360
31
- }
32
- end
33
- end
34
- end
@@ -1,5 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module InterestDays
4
- VERSION = "0.4.1"
5
- end
data/lib/interest_days.rb DELETED
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "interest_days/version"
4
- require "interest_days/calculator"
5
- require "interest_days/calculation/base"
6
- require "interest_days/calculation/thirty_threesixty_base"
7
- require "interest_days/calculation/us_eom_30_360"
8
- require "interest_days/calculation/isda_act_360"
9
- require "interest_days/calculation/isda_act_364"
10
- require "interest_days/calculation/isda_act_365"
11
- require "interest_days/calculation/isda_act_act"
12
- require "interest_days/calculation/isda_30_e_360"
13
-
14
- module InterestDays
15
- class Error < StandardError; end
16
- # Your code goes here...
17
- end