Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not getting the greeks other than IV #2

Closed
didieruzan opened this issue Feb 2, 2016 · 6 comments
Closed

Not getting the greeks other than IV #2

didieruzan opened this issue Feb 2, 2016 · 6 comments

Comments

@didieruzan
Copy link

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

@gnagel
Copy link
Owner

gnagel commented Feb 3, 2016

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

@didieruzan
Copy link
Author

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

@didieruzan
Copy link
Author

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

@gnagel
Copy link
Owner

gnagel commented Feb 22, 2016

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
  # }

@gnagel
Copy link
Owner

gnagel commented Feb 22, 2016

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.

@didieruzan
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants