diff --git a/lib/options_library/option_calculator.rb b/lib/options_library/option_calculator.rb index 6c3c07e..b7f967f 100644 --- a/lib/options_library/option_calculator.rb +++ b/lib/options_library/option_calculator.rb @@ -2,7 +2,7 @@ # Since Feb 13, 2011 # Based on Black-Scholes forumla for pricing options -module Option +module OptionLib class Calculator class << self # used for finding implied vol based on a market (target) price @@ -49,6 +49,7 @@ def vega( underlying, strike, time, interest, sigma, dividend ) # computes the fair value of the call based on the knowns and assumed volatility (sigma) def price_call( underlying, strike, time, interest, sigma, dividend ) + return 0 if underlying== strike && time <= 0.00000 d1 = d_one( underlying, strike, time, interest, sigma, dividend ) discounted_underlying = exp(-1.0 * dividend * time) * underlying probability_weighted_value_of_being_exercised = discounted_underlying * norm_sdist( d1 ) @@ -62,6 +63,7 @@ def price_call( underlying, strike, time, interest, sigma, dividend ) # computes the fair value of the put based on the knowns and assumed volatility (sigma) def price_put( underlying, strike, time, interest, sigma, dividend ) + return 0 if underlying== strike && time <= 0.00000 d2 = d_two( underlying, strike, time, interest, sigma, dividend ) discounted_strike = strike * exp(-1.0 * interest * time) probabiltity_weighted_value_of_discounted_strike = discounted_strike * norm_sdist( -1.0 * d2 ) diff --git a/lib/options_library/option_call.rb b/lib/options_library/option_call.rb index c0bb4b4..309a9ff 100644 --- a/lib/options_library/option_call.rb +++ b/lib/options_library/option_call.rb @@ -2,7 +2,7 @@ # Since Feb 18, 2011 # Based on Black-Scholes forumla for pricing options -module Option +module OptionLib class Call < Model def initialize diff --git a/lib/options_library/option_model.rb b/lib/options_library/option_model.rb index 0b6ade1..4fa55cc 100644 --- a/lib/options_library/option_model.rb +++ b/lib/options_library/option_model.rb @@ -2,7 +2,7 @@ # Since Feb 18, 2011 # Based on Black-Scholes forumla for pricing options -module Option +module OptionLib class Model # The two known option types, Call and Put diff --git a/lib/options_library/option_put.rb b/lib/options_library/option_put.rb index bc3cba3..f620adc 100644 --- a/lib/options_library/option_put.rb +++ b/lib/options_library/option_put.rb @@ -2,7 +2,7 @@ # Since Feb 18, 2011 # Based on Black-Scholes forumla for pricing options -module Option +module OptionLib class Put < Model def initialize diff --git a/options_library.gemspec b/options_library.gemspec index c1a989e..de24d0f 100644 --- a/options_library.gemspec +++ b/options_library.gemspec @@ -2,7 +2,7 @@ Gem::Specification.new do |s| s.name = %q{options_library} - s.version = "1.0.3" + s.version = "1.0.32" s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version= s.authors = ["Dan Tylenda-Emmons"]