op_vol <- op |>
mutate(
biz_days = bizdays(
refdate, following(maturity_date, "Brazil/B3"), "Brazil/B3"
),
time_to_maturity = biz_days / 252,
rate = log(1 + r_252),
bsm_impvol = bsmimpvol(
close, type, close.underlying, strike, time_to_maturity, rate, 0
),
delta = bsmdelta(
type, close.underlying, strike, time_to_maturity, rate, 0, bsm_impvol
)
) |>
select(
refdate, symbol, volume, maturity_date,
type, close.underlying, strike, time_to_maturity, rate,
biz_days, close, high, low, bsm_impvol, delta
)