backtest_LOAD: Backtests the LOAD Online PS System

Description Usage Arguments Details Value

View source: R/backtest_strategy.R

Description

Runs the LOAD online PS System: For each stock regresses the prices in the last time_window many trading periods and thresholds the slope to classify the stock as with momentum or without momentum. It uses this classification to predict the price vector, then chooses the closest portfolio which is predicted to return at least wealth_factor_threshold over the next period

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
backtest_LOAD(
  price_relative_matrix,
  transaction_rate,
  decay_factor,
  regularization_factor,
  time_window,
  momentum_threshold,
  wealth_factor_threshold,
  price_matrix,
  price_mean_matrix
)

Arguments

price_relative_matrix

a matrix of price relatives, each row representing a trading period and each column an asset. A price relative is p_{t+1} / p_t, i.e. the ratio of trading price to next price. Prices change according to the price relatives after the trade, i.e. the price relatives for the trading period are not known at trading time

transaction_rate

The percentage of each transaction (buy and sell) spent on broker fees

decay_factor

α in the referenced paper, LOAD predicts that stocks regressing to the mean have approximate price MA_t = α p_t + (1-α)MA_{t-1}, MA_1 = p_1

regularization_factor

λ in the referenced paper, the regularization coeffecient for weight decay when regressing the prices in the recent time window. Must be non-negative

time_window

w in the referenced paper. The number of trading periods (including the most recent) to regress on (must be at least 2)

momentum_threshold

η in the referenced paper. If the regressed slope is greater than η we say the stock has momentum. This must be greater than 0.

wealth_factor_threshold

ε in the referenced paper. Once a price relative for the next trading period is predicted, this is the minimum return our traded portfolio should satisfy. This must be greater than 0.

price_matrix

(OPTIONAL) The prices during the trading periods (a matrix with one more row than price_relative_matrix). If not included, initial prices are assumed to be one.

price_mean_matrix

(OPTIONAL) The mean price MA_t is decay_factor * p_t + (1-decay_factor) * MA_{t-1}, a matrix the same size as prices. If not used, these are computed from the prices

Details

This method was developed in the following paper: https://www.sciencedirect.com/science/article/abs/pii/S0950705119303922#b19

Initial portfolio is uniform.

Value

a matrix with the same number of columns and one more row than price_relative_matrix, row i is the portfolio after a trade during period i, i.e. right before the ith price relatives change the prices.


benSepanski/pfselect documentation built on May 1, 2020, 1:57 p.m.