Qapi provides a light-weight library for quantitative analysis in finance. The package aims to optimize metrics for local data analysis, shiny web app or plumber-based microservice. Code is minimal with a limited packages dependency and basic input requirements. No missing values handling.
The package can be easily applied to matrix, data.frame, data.table, list, etc. with apply family of functions or custom helpers. It works with vectors and matrices.
Functions are implemented in pure R, for big data manipulation is advisable to use parallelization or C-based calculations.
Install the development version from GitHub:
# install.packages("remotes")
remotes::install_github("maxto/qapi")
library(qapi)
# rand time series
ts_mat <- rand_ts(m = 20,n = 3,as_ret = T,method="matrix")
ts_xts <- rand_ts(m = 20,n = 3,as_ret = T,method="xts")
ts_df <- rand_ts(m = 20,n = 3,as_ret = T,method="data.frame")
# single column or vector
sharpe_ratio(ts_mat[,1])
sharpe_ratio(ts_xts[,1])
sharpe_ratio(ts_df$s1)
# for multiple columns
apply(ts_mat,2,function(a)sharpe_ratio(a))
apply(ts_xts,2,function(a)sharpe_ratio(a))
apply(ts_df,2,function(a)sharpe_ratio(a))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.