istox 0.1.94 → 0.1.95

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: 43804b33ac5a8aec861ed14882a2e2bb0fbbf0090dc50303f4cdb601024c1b46
4
- data.tar.gz: a8912b96ea64951023d686bdcc7429912c754156bbed14d2144d59d23c837619
3
+ metadata.gz: eadc2878c739807c16ebc1252a460f1881a910d3626bf4c754e9de24793b7842
4
+ data.tar.gz: c81a31aa33e6e50d283a25036a84098aaef446926af5a5ef0cdb3f9a13857883
5
5
  SHA512:
6
- metadata.gz: 34e841dedc2d4d778277c7cf2f4636542a5724a823312bd26f7f625f074965f62b7d33ce0ed4dba068adf063aa858fd009dd04968e9d79604d6ad97d5a4d3c83
7
- data.tar.gz: 99476cf586495b78e5de3d52590f40aa3ae1d823e901a96643b8ee2d098b4e5e9e955640a6ba220ad875907df2a59119e8c1938c42fb1fe4612b00c1fe8426fe
6
+ metadata.gz: a26a64b83c378f9431fb81421794413328ff701b94e4911c644cf9d4b1b2f4e04875af350538a2405745b010e1192aedca3622d6729571683a6405873411e804
7
+ data.tar.gz: c9a789fc9076c32b3e25e362543e255cd7f85ea471d138638894c615ab887a4e2aaa503d8c426a8a93feeae421f6e4aa02d955d6f7066d2cbb7ad04ad2536330
@@ -18,16 +18,16 @@ module Istox
18
18
  raise "Invalid maturity_date #{maturity_date}" if (maturity_date.nil? || maturity_date.methods.include?("strftime"))
19
19
  raise "Invalid years #{years}" if (years.nil? || !is_number?(years))
20
20
  raise "Invalid coupon_frequency #{days_of_year}" if (coupon_frequency.nil? || !is_number?(coupon))
21
- raise "Invalid coupon_payment_dates #{coupon_payment_dates}" if (coupon_payment_dates.nil? || coupon_payment_dates.count == 0 || coupon_payment_dates.any? { |date| date > maturity_date })
21
+ raise "Invalid coupon_payment_dates #{coupon_payment_dates}" if (coupon_payment_dates.nil? || coupon_payment_dates.count == 0 || coupon_payment_dates.any? { |date| date > maturity_date.to_date })
22
22
  raise "Invalid days_of_year #{days_of_year}" if (days_of_year != 365 && days_of_year != 360)
23
23
 
24
24
  @coupon = coupon.to_d
25
- @maturity_date = maturity_date
25
+ @maturity_date = maturity_date.to_date
26
26
  @years = years
27
27
  @coupon_frequency = coupon_frequency.to_d
28
28
  @days_of_year = days_of_year.to_d
29
29
  @face_value = face_value
30
- @coupon_payment_dates = coupon_payment_dates.sort
30
+ @coupon_payment_dates = coupon_payment_dates.map(&:to_date).sort
31
31
  @start_date = (@maturity_date-(years*12).to_i.months)
32
32
  end
33
33
 
@@ -120,6 +120,7 @@ module Istox
120
120
  # end
121
121
 
122
122
  def price_for_irr(irr, date, ex_coupon_date: nil, fees: 0)
123
+ date = date.to_date
123
124
  raise "Date is after maturity_date!" if date > @maturity_date
124
125
  if date <= @start_date
125
126
  date = @start_date
@@ -187,7 +188,7 @@ module Istox
187
188
  end
188
189
 
189
190
  def first_coupon(date, ex_coupon_date)
190
- if @coupon_payment_dates.include?(date) || (!ex_coupon_date.nil? && date > ex_coupon_date)
191
+ if @coupon_payment_dates.include?(date) || (!ex_coupon_date.nil? && date > ex_coupon_date.to_date)
191
192
  # if today is on coupon payment date, we won't include the coupon
192
193
  # as by default it's passing ex_coupon_date in our calculation
193
194
  # after ex coupon date, buyer won't receive next coupon
data/lib/istox/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Istox
2
- VERSION = '0.1.94'.freeze
2
+ VERSION = '0.1.95'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: istox
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.94
4
+ version: 0.1.95
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siong Leng
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-10-25 00:00:00.000000000 Z
11
+ date: 2019-11-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny