From caa10a8a20264b259bdbed7bb9d082fcc7a7e90c Mon Sep 17 00:00:00 2001 From: northern-64bit <75195383+northern-64bit@users.noreply.github.com> Date: Thu, 22 Dec 2022 14:43:31 +0100 Subject: [PATCH] Fix the greeks calculations of the chain command (#3812) * Fix greeks * Improve readability Co-authored-by: James Maslek --- openbb_terminal/stocks/options/yfinance_model.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/openbb_terminal/stocks/options/yfinance_model.py b/openbb_terminal/stocks/options/yfinance_model.py index 05337cc9e24..3b87fb3f9f4 100644 --- a/openbb_terminal/stocks/options/yfinance_model.py +++ b/openbb_terminal/stocks/options/yfinance_model.py @@ -130,11 +130,12 @@ def get_option_chain_expiry( dt = ( datetime.strptime(expiry, "%Y-%m-%d") + timedelta(hours=16) - datetime.now() ).total_seconds() / (60 * 60 * 24) + rf = get_rf() # Note the way the Option class is defined, put has a -1 input and call has a +1 input for df, option_type in zip(df_list, option_factor): df["Delta"] = df.apply( lambda x: Option( - last_price, x.strike, 0.03, 0, dt, x.impliedVolatility, option_type + last_price, x.strike, rf, 0, dt, x.impliedVolatility, option_type ).Delta(), axis=1, ) @@ -142,13 +143,13 @@ def get_option_chain_expiry( warnings.simplefilter("ignore") df["Gamma"] = df.apply( lambda x: Option( - last_price, x.strike, 0.03, 0, dt, x.impliedVolatility, option_type + last_price, x.strike, rf, 0, dt, x.impliedVolatility, option_type ).Gamma(), axis=1, ) df["Theta"] = df.apply( lambda x: Option( - last_price, x.strike, 0.03, 0, dt, x.impliedVolatility, option_type + last_price, x.strike, rf, 0, dt, x.impliedVolatility, option_type ).Theta(), axis=1, ) @@ -542,7 +543,6 @@ def get_greeks( dif = (expire_dt - datetime.now() + timedelta(hours=16)).total_seconds() / ( 60 * 60 * 24 ) - print(dif) strikes = [] for _, row in chain.iterrows(): vol = row["impliedVolatility"]