gnagel/greeks

Not getting the greeks other than IV

Closed this issue · 6 comments

Hi,

I am using Math::Greeks::Calculator.new(...) to calculate the greeks, as in your example, but I am not getting any greeks in the result object (delta, gamma, etc...), I am only getting IV.
Could you explain how to retrieve the rest of the greeks.

Thank you in advance,
Didier

Hi @didieruzan !
Thanks for letting me know. Please include a sample the code/data you are testing with so I can test it locally too.

Glenn

Hi @gnagel
Sure, here are some input data for options: AAU1160318P00005000
stock_price: 0.5377
stock_dividend_rate: 0.0
federal_reserve_interest_rate: 0.01
option_expires_in_days: 1
option_strike: 5.0
option_type: :put
option_price: 6.3000

Thanks!
Didier

Hi @gnagel, I just realised I didn't supply you a sample code as you requested, so here it is:
calc_result = Math::Greeks::Calculator.new(
:stock_price => 0.5747,
:stock_dividend_rate => 0.0,
:federal_reserve_interest_rate => 0.01,
:option_expires_in_days => 20,
:option_strike => 5.0,
:option_type => :put,
:option_price => 6.2100
)

You'll notice that calc_result does not include delta, gamma, vega, rho nor theta, even though it should according to documentation.

Thank you in advance.
Didier

Hi @didieruzan
I did some research into this one. You are missing two parameters: :option_volume & :option_open_interest. Once you supply those parameters the calcualtions work correctly:

  opts = {:stock_price=>4.04, :stock_dividend_rate=>0.0, :option_type=>nil, :option_price=>0.17, :option_strike=>3.5, :option_expires_in_days=>50.0, :federal_reserve_interest_rate=>0.03, :option_volume=>100.0, :option_open_interest=>0.0, :option_type => :put}
  calc_result = Math::Greeks::Calculator.new(opts)
  puts calc_result.to_hash
  # { 
  #   :federal_reserve_interest_rate=>0.03, 
  #   :stock_dividend_rate=>0.0, 
  #   :stock_price=>4.04, 
  #   :option_expires_in_days=>50.0, 
  #   :option_type=>:put, 
  #   :option_strike=>3.5, 
  #   :option_price=>0.17, 
  #   :option_volume=>100.0, 
  #   :option_open_interest=>0.0, 
  #   :premium_value=>0.0, 
  #   :time_value=>0.17, 
  #   :annualized_premium_value=>33.94, 
  #   :annualized_time_value=>33.94, 
  #   :iv=>68.02, 
  #   :delta=>-5.81, 
  #   :gamma=>-5.05, 
  #   :vega=>1.9, 
  #   :rho=>-0.95, 
  #   :theta=>-1.86, 
  #   :delta_vs_theta=>3.13, 
  #   :break_even=>26.33
  # }

I'll add some debugging helpers to the module to make it clearer when an error occurs, as well as push up the V2 of this library with a cleaner syntax & more tests.

Thank you!

Didier Uzan
Mobile: +972 54 779 3384
Pivot.rocks

On Mon, Feb 22, 2016 at 6:33 PM G Nagel notifications@github.com wrote:

Closed #2 #2.


Reply to this email directly or view it on GitHub
#2 (comment).

Didier Uzan

+972 54 779 3384
Pivot.rocks