Open apsteinmetz opened 7 years ago
It may actually be very easy to just leverage the PerformanceAnalytics
functions by getting tq_performance()
to accept a column name as an argument for Rf
. This should be fairly simple since the PerfAnalytics functions are already setup to accept the risk free rate.
Yes. I was surprised it didn't work to being with since tq_performance
just wraps the PerformanceAnalytics
function and passes through whatever you send it.
You may think this is overly complicating matters. If so, please disregard. I do like to retrieve a full set of asset returns including mutual funds, their benchmarks and the risk free rate as a set when using the PerformanceAnalytics package. Long format makes it easy to compare arbitrary sets of series in ggplot. Yet many performance functions require wide data to compare the asset, its benchmark and the risk-free rate.
I took a stab at making a helper function to convert long tidy to wide RaRb format by matching a list of assets and their benchmarks. You can optionally specify the symbol for the time-varying risk free rate.
I am using the
blp_bdh_tq
data set I created in this issue note