Learn R Programming

QuantTools (version 0.5.2)

back_test: Generic back test function

Description

Generic back test function

Usage

back_test(enter, exit, price, stop_loss = -1000, side = 1L)

Arguments

enter
bool vector of length n of enter signals
exit
bool vector of length n of exit signals
price
numeric vector of length n of prices
stop_loss
relative stop loss, must be negative
side
direction of enter order, -1:short, 1:long

Value

trades data.table with columns price_enter,price_exit,mtm_min,mtm_max,id_enter,id_exit,pnl_trade,side

Details

Back test by enter and exit signals with stop loss on price history. Execution is immediate. Useful for testing on daily data.