Algorithm for Detrend=SHUFFLE

Posted By: kujo

Algorithm for Detrend=SHUFFLE - 04/18/18 23:19

JCL,

1. Could you please share the code or algorithm used in Detrend=SHUFFLE? I'd like to know how Zorro generates shuffled price curves.

2. If I use Detrend=SHUFFLE, do percentage returns have the same mean and standard deviation as original percentage returns?

3. Is it correct to use shuffled prices with Detrend=SHUFFLE for Monte Carlo reality check? I'm concerned that this mode keeps overall trend and price range. Does it mean that simulated prices are correlated in a similar manner as the original prices? I thought that it's important to remove existing correlations in prices for the MonteCarlo analysis.

Thank you!
Posted By: jcl

Re: Algorithm for Detrend=SHUFFLE - 04/19/18 11:43

Detrend=SHUFFLE uses the Fisher-Yates algorithm. Which method a reality check uses depends on the reality check.
Posted By: kujo

Re: Algorithm for Detrend=SHUFFLE - 04/19/18 13:24

As I understand, Fisher-Yates algorithm shuffles data without replacement. I generated a couple of shuffled price curves with priceClose() and compared with original curve. I sorted and compared percentage returns (p0/p1-1) and price difference (p0-p1). They are different. I wonder what is shuffled then? I assumed the returns should be the same but shuffled? Mean of returns is different as well.

I want to run the Monte Carlo analysis: generate simulated price curves and run my algo on them to reject the null hypothesis. As I understand, Zorro provides 2 options out-of-the-box: Detrend=SHUFFLE (according to the updated manual it's randomize(SHUFFLE,...) ) and randomize(BOOTSTRAP). The difference is that the first one is shuffling without replacement (used for montecarlo in the Black Book example), the second one is shuffling with replacement (used for Whit Reality Check). Which method can be used for above-mentioned montecarlo analysis? Which one is preferable? What's the difference?



© 2024 lite-C Forums