我一直在网上查找,但找不到我的问题的具体示例/答案。我使用Quantmod和PerformanceAnalytics库来计算使用CAPM函数的投资组合的alpha和beta。但我不想假设Rf = 0.我想得到实际/历史无风险利率。
我可以从FRED获得5年期国库券持续到期率(DGS5)或5年期国库券持续到期率(GS5)(不太确定它们之间是否存在差异),但我如何从中得到Rf值?这只是平均值吗?感谢。
或者我完全离开了:(。感谢您的任何见解。
答案 0 :(得分:4)
通常使用90天或30天的国库券作为无风险利率,可以这样下载(这里我使用的是90天账单):
library(quant mod)
getSymbols('DGS3MO',src = 'FRED’)
> tail(DGS3MO)
DGS3MO
2016-10-18 0.34
2016-10-19 0.35
2016-10-20 0.35
2016-10-21 0.34
2016-10-24 0.33
2016-10-25 0.34
答案 1 :(得分:-1)
hvollmeier 的回答很好,但它并没有完全提供无风险利率。但是,您可以在此 Python 工作流程中使用诸如“DGS3MO”之类的数据,这些数据可以轻松转换为 R:
Computing Risk Free Rates and Excess Returns from Zero-Coupon-Bonds
当然,它是在 Python 中...在那里你可以找到以下函数和理论的完整解释:
def ZCB_YTM_Implied_r_f(YTM, Maturity, D):
"""
This Python function returns the Zero-Coupn Bond (ZCB) Yield To Maturity (YTM) Implied Risk Free Interest Rate, thus its name 'ZCB_YTM_Implied_r_f'
YTM (Datastream pandas dataframe): The Yield To Maturity of the Zero-Coupon Bond in question.
It requiers the DSWS library from Refinitiv.
E.g.: YTM = ds.get_data(tickers = 'TRUS1MT', fields = "X", start = '1950-01-01', freq = 'D')/100
Maturity (float): The number of years until the bond matures.
This can be lower than 1, e.g.: One-Month Zero-Coupon Treasury Bill would have a 'Maturity' value of 1/12.
E.g.: Maturity = 1/12
D (int): The number of time periods (e.g.: days) until the bond matures
N.B.: The 1-, 2-, and 3-month rates are equivalent to 30-, 60-, and 90-day dates respectively, as reported on the Board's Commercial Paper Web page.
E.g.: D = 30
"""
# Rename the columns of 'YTM' correctly:
instrument_name = YTM.columns[0][0]
arrays = [[instrument_name],['YTM']]
tuples = list(zip(*arrays))
YTM.columns = pandas.MultiIndex.from_tuples(tuples, names=['Instrument', 'Field'])
# Calculate the r_f
r_f = ((YTM + 1)**(1/D))-1
# Rename the columns of r_f correctly:
instrument_name = YTM.columns[0][0]
arrays = [[instrument_name],['YTM_Implied_r_f']]
tuples = list(zip(*arrays))
r_f.columns = pandas.MultiIndex.from_tuples(tuples, names=['Instrument', 'Field'])
# return a list including r_f 0th and YTM 1st.
return(r_f, YTM)