Class: OptionLab::Models::BlackScholesModelInputs
- Defined in:
- lib/option_lab/models.rb
Overview
Black-Scholes model inputs
Instance Attribute Summary collapse
-
#dividend_yield ⇒ Object
Returns the value of attribute dividend_yield.
-
#interest_rate ⇒ Object
Returns the value of attribute interest_rate.
-
#model ⇒ Object
Returns the value of attribute model.
-
#stock_price ⇒ Object
Returns the value of attribute stock_price.
-
#volatility ⇒ Object
Returns the value of attribute volatility.
-
#years_to_target_date ⇒ Object
Returns the value of attribute years_to_target_date.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(attributes = {}) ⇒ BlackScholesModelInputs
constructor
A new instance of BlackScholesModelInputs.
- #validate! ⇒ Object
Constructor Details
#initialize(attributes = {}) ⇒ BlackScholesModelInputs
Returns a new instance of BlackScholesModelInputs.
507 508 509 510 511 512 513 514 515 516 |
# File 'lib/option_lab/models.rb', line 507 def initialize(attributes = {}) # Set defaults @interest_rate = 0.0 @dividend_yield = 0.0 @model = 'black-scholes' super(attributes) validate! end |
Instance Attribute Details
#dividend_yield ⇒ Object
Returns the value of attribute dividend_yield.
500 501 502 |
# File 'lib/option_lab/models.rb', line 500 def dividend_yield @dividend_yield end |
#interest_rate ⇒ Object
Returns the value of attribute interest_rate.
500 501 502 |
# File 'lib/option_lab/models.rb', line 500 def interest_rate @interest_rate end |
#model ⇒ Object
Returns the value of attribute model.
500 501 502 |
# File 'lib/option_lab/models.rb', line 500 def model @model end |
#stock_price ⇒ Object
Returns the value of attribute stock_price.
500 501 502 |
# File 'lib/option_lab/models.rb', line 500 def stock_price @stock_price end |
#volatility ⇒ Object
Returns the value of attribute volatility.
500 501 502 |
# File 'lib/option_lab/models.rb', line 500 def volatility @volatility end |
#years_to_target_date ⇒ Object
Returns the value of attribute years_to_target_date.
500 501 502 |
# File 'lib/option_lab/models.rb', line 500 def years_to_target_date @years_to_target_date end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
522 523 524 525 526 527 528 529 530 531 |
# File 'lib/option_lab/models.rb', line 522 def ==(other) return false unless other.is_a?(BlackScholesModelInputs) stock_price == other.stock_price && volatility == other.volatility && years_to_target_date == other.years_to_target_date && interest_rate == other.interest_rate && dividend_yield == other.dividend_yield && model == other.model end |
#hash ⇒ Object
535 536 537 |
# File 'lib/option_lab/models.rb', line 535 def hash [stock_price, volatility, years_to_target_date, interest_rate, dividend_yield, model].hash end |
#validate! ⇒ Object
518 519 520 |
# File 'lib/option_lab/models.rb', line 518 def validate! raise ArgumentError, "model must be 'black-scholes' or 'normal'" unless ['black-scholes', 'normal'].include?(model) end |