Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions py_vollib_vectorized/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ def price_dataframe(df, *, flag_col=None, underlying_price_col=None, strike_col=
raise ValueError("Model must be one of: `black`, `black_scholes`, `black_scholes_merton`")

if inplace:
df["Price"] = price
df["Price"] = price.to_numpy() if not isinstance(price, np.ndarray) else price
else:
output_df["Price"] = price
output_df["Price"] = price.to_numpy() if not isinstance(price, np.ndarray) else price

if _iv_calc:
if model == "black":
Expand All @@ -164,16 +164,16 @@ def price_dataframe(df, *, flag_col=None, underlying_price_col=None, strike_col=
raise ValueError("Model must be one of: `black`, `black_scholes`, `black_scholes_merton`")

if inplace:
df["IV"] = sigma
df["IV"] = sigma.to_numpy() if not isinstance(sigma, np.ndarray) else sigma
else:
output_df["IV"] = sigma
output_df["IV"] = sigma.to_numpy() if not isinstance(sigma, np.ndarray) else sigma

if _greek_calc:
greeks = get_all_greeks(flag, S, K, t, r, sigma, q, model=model, return_as="dataframe")

for col in greeks:
if inplace:
df[col] = greeks[col]
df[col] = greeks[col].to_numpy()
else:
output_df[col] = greeks[col]

Expand Down
10 changes: 5 additions & 5 deletions py_vollib_vectorized/greeks.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def delta(flag, S, K, t, r, sigma, q=None, *, model="black_scholes", return_as="

if model == "black":
b = 0
delta = numerical_delta_black(flag, S, K, t, r, sigma, b)
delta = numerical_delta_black(flag, S, K, t, r, sigma)
elif model == "black_scholes":
b = r
delta = numerical_delta_black_scholes(flag, S, K, t, r, sigma, b)
Expand Down Expand Up @@ -106,7 +106,7 @@ def theta(flag, S, K, t, r, sigma, q=None, *, model="black_scholes", return_as=

if model == "black":
b = 0
theta = numerical_theta_black(flag, S, K, t, r, sigma, b)
theta = numerical_theta_black(flag, S, K, t, r, sigma)

elif model == "black_scholes":
b = r
Expand Down Expand Up @@ -167,7 +167,7 @@ def vega(flag, S, K, t, r, sigma, q=None, *, model="black_scholes", return_as="d

if model == "black":
b = 0
vega = numerical_vega_black(flag, S, K, t, r, sigma, b)
vega = numerical_vega_black(flag, S, K, t, r, sigma)

elif model == "black_scholes":
b = r
Expand Down Expand Up @@ -229,7 +229,7 @@ def rho(flag, S, K, t, r, sigma, q=None, *, model="black_scholes", return_as="da

if model == "black":
b = 0
rho = numerical_rho_black(flag, S, K, t, r, sigma, b)
rho = numerical_rho_black(flag, S, K, t, r, sigma)

elif model == "black_scholes":
b = r
Expand Down Expand Up @@ -291,7 +291,7 @@ def gamma(flag, S, K, t, r, sigma, q=None, *, model="black_scholes", return_as=
if model == "black":
b = 0
# black scholes, it calls the black_scholes function and not the black function.
gamma = numerical_gamma_black(flag, S, K, t, r, sigma, b)
gamma = numerical_gamma_black(flag, S, K, t, r, sigma)
elif model == "black_scholes":
b = r
gamma = numerical_gamma_black_scholes(flag, S, K, t, r, sigma, b)
Expand Down