trading_returns: Calculate the average trading returns based on predicted...

Description Usage Arguments Value

Description

A two column matrix is provided containing a prediction in column 1 (yhat), and the actual trading returns in column 2 (y). The function first identifies valid long and short trades by examining yhat, and flagging the trade as a long trade if yhat >= long_thres, or as a short trade if yhat <= short_thres. Vectors with yhat values in the band between the two thresholds are ignored (deemed not worth trading).

Usage

1
trading_returns(mat, long_thres = 0, short_thres = 0)

Arguments

mat

The two column matrix to calculate the trading returns. The first column is the prediction (yhat), while the second column is the target (y).

long_thres

The threshold above which the yhat column is flagged as a trade to go long (buying the security).

short_thres

The threshold below which the yhat colum is flagged as a trading to go short (shorting the security).

Value

Returns the average trading return over all flagged trades in the matrix. For short trades, a negative value of y corresponds to a positive return for this calculation.


jeanmarcgp/mlStocks documentation built on May 19, 2019, 12:38 a.m.