Description Usage Arguments Value
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).
1 | trading_returns(mat, long_thres = 0, short_thres = 0)
|
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). |
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.