Class: OptionLab::Models::PricingResult

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

Overview

Option pricing result with prices and Greeks

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

This class inherits a constructor from OptionLab::Models::BaseModel

Instance Attribute Details

#deltaObject

Returns the value of attribute delta.



746
747
748
# File 'lib/option_lab/models.rb', line 746

def delta
  @delta
end

#gammaObject

Returns the value of attribute gamma.



746
747
748
# File 'lib/option_lab/models.rb', line 746

def gamma
  @gamma
end

#modelObject

Returns the value of attribute model.



746
747
748
# File 'lib/option_lab/models.rb', line 746

def model
  @model
end

#parametersObject

Returns the value of attribute parameters.



746
747
748
# File 'lib/option_lab/models.rb', line 746

def parameters
  @parameters
end

#priceObject

Returns the value of attribute price.



746
747
748
# File 'lib/option_lab/models.rb', line 746

def price
  @price
end

#rhoObject

Returns the value of attribute rho.



746
747
748
# File 'lib/option_lab/models.rb', line 746

def rho
  @rho
end

#thetaObject

Returns the value of attribute theta.



746
747
748
# File 'lib/option_lab/models.rb', line 746

def theta
  @theta
end

#vegaObject

Returns the value of attribute vega.



746
747
748
# File 'lib/option_lab/models.rb', line 746

def vega
  @vega
end

Instance Method Details

#to_hObject



766
767
768
769
770
771
772
773
774
775
776
777
# File 'lib/option_lab/models.rb', line 766

def to_h
  {
    price: price,
    delta: delta,
    gamma: gamma,
    theta: theta,
    vega: vega,
    rho: rho,
    model: model,
    parameters: parameters,
  }
end

#to_sObject



755
756
757
758
759
760
761
762
763
764
# File 'lib/option_lab/models.rb', line 755

def to_s
  result = "Option Price: #{price.round(4)}\n"
  result += "Delta: #{delta.round(4)}\n" if delta
  result += "Gamma: #{gamma.round(4)}\n" if gamma
  result += "Theta: #{theta.round(4)}\n" if theta
  result += "Vega: #{vega.round(4)}\n" if vega
  result += "Rho: #{rho.round(4)}\n" if rho
  result += "Model: #{model}\n" if model
  result
end