Learn R Programming

Contemporary Portfolio Optimization with R

© 2013-2018 Ronald Hochreiter / ron@hochreiter.net

This package aims at implementing something along the lines of a tidy portfolio optimization framework, simplifying the whole process from data to decision as good as possible.

More about Finance with R can be found at http://finance-r.com/

Main Motivation

The main motivation is to create a R package that simplifies the process of portfolio optimization as much as possible. Furthermore providing an approach to portfolio optimization which is completely agnostic to risk measures and optimization methods. Finally the approach should naturally fit into the contemporary R piping concept using packages like magrittr.

Usage

Instant gratification

# Load the package
library(portfolio.optimization)

# Use any scenario data, e.g. the one provided with the package
data(sp100w17av30s)

# Do a portfolio optimization in one line
weights(optimal.portfolio(scenario.set))

Piping using magrittr

Furthermore, everything should be pipeable and such is the design of the package, i.e.

# The above initial portfolio optimization can be piped as follows 
scenario.set %>% 
  optimal.portfolio %>% 
  weights

# Of course, this is interesting if you change lots of parameters and keeps your
# portfolio models readable and well-shaped for communication
scenario.set %>% 
  portfolio.model %>% 
  objective("expected.shortfall") %>% 
  alpha(0.1) %>% 
  upper.bound(0.2) %>%
  optimal.portfolio %>% 
  weights

Further examples

There are some tutorials built into the package, which you may e.g. open with the following commands:

file.edit(po.tutorial("101"))
file.edit(po.tutorial("compare"))

Copy Link

Version

Install

install.packages('portfolio.optimization')

Monthly Downloads

186

Version

1.0-0

License

MIT + file LICENSE

Maintainer

Ronald Hochreiter

Last Published

August 24th, 2018

Functions in portfolio.optimization (1.0-0)

optimal.portfolio.markowitz

Portfolio Optimization minimizing Standard Deviation
optimal.portfolio.mad.long.short

Portfolio Optimization minimizing MAD (Active Extension)
portfolio.model

Create a portfolio.model instance (or fix an existing one)
lower.bound

Set lower bounds on assets
momentum

Set momentum parameters for a portfolio.model
sp100w17av30s

S&P 100 weekly stock returns 2017 of 30 stocks with the highest average trading volume over the whole year
portfolio.optimization-package

Contemporary Portfolio Optimization
aux_risk.alias

Convert risk alias names to internal names
aux_portfolio.default

Set portfolio.model default values
linear.constraint.eq

Create or update a vector-based linear equality constraint set
po.tutorial

Open a specific portfolio.optimization package tutorial
active.extension

Enable active extension portfolios
aux_simulate.scenarios

Simulate a multivariate-normal scenario.set
optimal.portfolio.expected.shortfall.long.short

Portfolio Optimization minimizing Conditional Value at Risk (CVaR) with active extensions
optimal.portfolio

Meta-function to optimize portfolios given a portfolio.model instance
objective

Set new objective of a portfolio.model
alpha

Set new alpha of a portfolio.model
portfolio.weights

Return the portfolio weights of a portfolio.model
optimal.portfolio.expected.shortfall

Portfolio Optimization minimizing Conditional Value at Risk (CVaR)
upper.bound

Set upper bounds on assets
print.portfolio.model

Overload print() for portfolio.model
optimal.portfolio.reward

Compute maximum/minimum return portfolio given the constraints
portfolio.loss

Return the loss distribution of the portfolio.model
sp100w17av

S&P 100 average trading volume over the whole year 2017
optimal.portfolio.momentum

Momentum portfolio including momentum for active extensions
sp100w17

S&P 100 weekly stock returns 2017
optimal.portfolio.mad

Portfolio Optimization minimizing MAD
optimal.portfolio.1overN

1 over N portfolio
linear.constraint.iq

Create or update a vector-based linear inequality constraint set
long.only

Disable active extension portfolios