1
$\begingroup$

I want to backtest a strategy using K-fold cross validation. Assume I have a period of 300 days in my backtest. I divide it into 30 folds of 10 days each.

On day 1 of a fold, I enter a trade, and exit after 6 days. On day 7 I enter another trade. But when we hit day 10, the final day in the fold, the trade is still open.

What is the best way to handle this? Should I just close the trade at the end of day 10, and record the pnl at that point? Or just ignore the trade altogether since it was unfinished (ie, still open).

$\endgroup$

1 Answer 1

1
$\begingroup$

Ideally, you should close the trade and book the pnl and do the analysis with respect to that. But the problem here is you are making the decision based on two trades. You can tackle this problem using the following way

  1. Determine the average duration of your trade say d days
  2. The number of days in the fold should be at least able to accommodate 10 trades. This size of the fold should be 10 * d
  3. There should be atleast 4 folds for you to confidently cross validate your strategy. Thus the number of data points required are 10 * d * 4. That is 40 times the average duration of the trade.

The numbers given are only for representation purpose but the general rule of thumb is there should be more number of trades per fold to effectively validate your trading strategy. Otherwise there is a high possibility that by sheer luck 2 trades happen to be profitable.

And as the number of trades increases, early closing of trade shouldn't be a problem.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.