Class: ThePlaidApi::YieldRateType

Inherits:
Object
  • Object
show all
Defined in:
lib/the_plaid_api/models/yield_rate_type.rb

Overview

The type of rate which indicates how the predicted yield was calculated. It is one of: ‘coupon`: the annualized interest rate for securities with a one-year term or longer, such as treasury notes and bonds. `coupon_equivalent`: the calculated equivalent for the annualized interest rate factoring in the discount rate and time to maturity, for shorter term, non-interest-bearing securities such as treasury bills. `discount`: the rate at which the present value or cost is discounted from the future value upon maturity, also known as the face value. `yield`: the total predicted rate of return factoring in both the discount rate and the coupon rate, applicable to securities such as exchange-traded bonds which can both be interest-bearing as well as sold at a discount off its face value.

Constant Summary collapse

YIELD_RATE_TYPE =
[
  # TODO: Write general description for COUPON
  COUPON = 'coupon'.freeze,

  # TODO: Write general description for COUPON_EQUIVALENT
  COUPON_EQUIVALENT = 'coupon_equivalent'.freeze,

  # TODO: Write general description for DISCOUNT
  DISCOUNT = 'discount'.freeze,

  # TODO: Write general description for ENUM_YIELD
  ENUM_YIELD = 'yield'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = COUPON) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/the_plaid_api/models/yield_rate_type.rb', line 39

def self.from_value(value, default_value = COUPON)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'coupon' then COUPON
  when 'coupon_equivalent' then COUPON_EQUIVALENT
  when 'discount' then DISCOUNT
  when 'enum_yield' then ENUM_YIELD
  else
    default_value
  end
end

.validate(value) ⇒ Object



33
34
35
36
37
# File 'lib/the_plaid_api/models/yield_rate_type.rb', line 33

def self.validate(value)
  return false if value.nil?

  YIELD_RATE_TYPE.include?(value)
end