Class: OptionLab::Models::LaplaceInputs

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/option_lab/models.rb

Overview

Laplace model inputs

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ LaplaceInputs

Returns a new instance of LaplaceInputs.



544
545
546
547
548
549
550
551
# File 'lib/option_lab/models.rb', line 544

def initialize(attributes = {})
  # Set defaults
  @model = 'laplace'

  super(attributes)

  validate!
end

Instance Attribute Details

#modelObject

Returns the value of attribute model.



542
543
544
# File 'lib/option_lab/models.rb', line 542

def model
  @model
end

#muObject

Returns the value of attribute mu.



542
543
544
# File 'lib/option_lab/models.rb', line 542

def mu
  @mu
end

#stock_priceObject

Returns the value of attribute stock_price.



542
543
544
# File 'lib/option_lab/models.rb', line 542

def stock_price
  @stock_price
end

#volatilityObject

Returns the value of attribute volatility.



542
543
544
# File 'lib/option_lab/models.rb', line 542

def volatility
  @volatility
end

#years_to_target_dateObject

Returns the value of attribute years_to_target_date.



542
543
544
# File 'lib/option_lab/models.rb', line 542

def years_to_target_date
  @years_to_target_date
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



557
558
559
560
561
562
563
564
565
# File 'lib/option_lab/models.rb', line 557

def ==(other)
  return false unless other.is_a?(LaplaceInputs)

  stock_price == other.stock_price &&
    volatility == other.volatility &&
    years_to_target_date == other.years_to_target_date &&
    mu == other.mu &&
    model == other.model
end

#hashObject



569
570
571
# File 'lib/option_lab/models.rb', line 569

def hash
  [stock_price, volatility, years_to_target_date, mu, model].hash
end

#validate!Object

Raises:

  • (ArgumentError)


553
554
555
# File 'lib/option_lab/models.rb', line 553

def validate!
  raise ArgumentError, "model must be 'laplace'" unless model == 'laplace'
end