The olpsR package provides different On-line Portfolio Selection algorithms and functions to deal with the on-line portfolio selection problem where a portfolio is rebalanced in every period to achieve certain goals, e.g. maximizing terminal wealth. Datasets to test portfolio selection algorithms are also included.
For a background on On-line Portfolio Selection see for example [@LH14; http://arxiv.org/pdf/1212.2129.pdf].
NYSE, DJIA, SP500, TSE, DAX
To install the olpsR package run:
if (!require("devtools")) install.packages("devtools") devtools::install_github("ngloe/olpsR")
Once installed, the package can be loaded using:
library(olpsR)
To test portfolio selection algorithms some return data is loaded using the NYSE dataset. We select two assets, kinar and iroqu:
library(olpsR)
data(NYSE) x = cbind(kinar=NYSE$kinar, iroqu=NYSE$iroqu)
Algorithms can be computed by applying alg_ALG on the selected data where ALG is the desired algorithm. For example, to approximate the Universal Portfolio algorithm (UP) type:
UP = alg_UP(x); UP
Accessing UP then returns a short summary of the algorithm's output. To access the calculated portfolio wealth or the portfolio weights you can type:
UP$Wealth UP$Weights
The achieved portfolio wealth (performance) can be plotted by:
plot(UP)
To easily compare different algorithms pass them to the plot function:
BH_Market = alg_BH( x, weights=c(0.5, 0.5) ) BH_best = alg_BHbest(x) plot(BH_Market, BH_best, UP)
For more details and an overview of the implemented algorithms and functions please refer to the package help by typing:
help(package="olpsR")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.