pq_performance {pedquant} | R Documentation |
calculating performance metrics
Description
pq_performance
calculates performance metrics based on returns of market price or portfolio. The performance analysis functions are calling from PerformanceAnalytics
package, which includes many widely used performance metrics.
Usage
pq_performance(dt, Ra, Rb = NULL, perf_fun, ...)
Arguments
dt |
a list/dataframe of time series datasets. |
Ra |
the column name of asset returns. |
Rb |
the column name of baseline returns, defaults to NULL. |
perf_fun |
performance function from |
... |
additional parameters, the arguments used in |
Examples
## Not run:
library(pedquant)
library(data.table)
# load data
data(dt_banks)
data(dt_ssec)
# calculate returns
datret1 = pq_return(dt_banks, 'close', freq = 'monthly', rcol_name = 'Ra')
datret2 = pq_return(dt_ssec, 'close', freq = 'monthly', rcol_name = 'Rb')
# merge returns of assets and baseline
datRaRb = merge(
rbindlist(datret1)[, .(date, symbol, Ra)],
rbindlist(datret2)[, .(date, Rb)],
by = 'date', all.x = TRUE
)
# claculate table.CAPM metrics
perf_capm = pq_performance(datRaRb, Ra = 'Ra', Rb = 'Rb', perf_fun = 'table.CAPM')
rbindlist(perf_capm, idcol = 'symbol')
## End(Not run)
[Package pedquant version 0.2.4 Index]