aatj887/call-implied-price-distribution-framework
1
1from openbb import obb # In charge of the collection of SOFR data we will use to calculate risk free.2import pandas as pd # Used to interact with the data as dataframes 3import numpy as np4from datetime import date, timedelta5 6def load_sofr_history(start:str, end:str):7 """8 Obtains the SOFR data from FRED on the defined start and end dates.9 start and end must be in format YYYY-MM-DD.10 """11 df = obb.economy.fred_series("SOFR", start_date=start, end_date=end).to_dataframe()12 s = df/10013 s = s['SOFR']14 return s15 16def risk_free_value():17 """18 Returns the most recent risk-free rate (SOFR) as a decimal.19 """20 sofr_history = load_sofr_history((date.today()-timedelta(days=7)).strftime("%Y-%m-%d"), date.today().strftime("%Y-%m-%d"))21 r = sofr_history.tail(1).iloc[0]22 return r23 24 25 26 27 28 29 