Synthetic Stock Data: how to "correctly" simulate

Discussions about the testing and simulation of mechanical trading systems using historical data and other methods. Trading Blox Customers should post Trading Blox specific questions in the Customer Support forum.
Post Reply
AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2071
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Synthetic Stock Data: how to "correctly" simulate

Post by AFJ Garner »

Synthetic Stock Data: how to "correctly" simulate volatility
Now take a look at a chart of the volatility of daily returns for the same rolling periods on a synthetic data series created using GBM and (in the GBM calculations) a fixed, static figure for volatility. Take a look also at the chart of the closing prices from which the volatility was calculated. Neither the volatility chart nor the stock price chart look much like those derived from real prices. Too static, not enough jumps and changes as volatility flows with market conditions.

See below:
randomClosefixedstddev
fixedstddev

The next two charts show volatility and closing prices for another synthetic data series, this time using randomly altered figures for target volatility. Note how both bear a much greater similarity to the volatility charts for real price series shown in the above posts, reflecting day to day “normalityâ€
Attachments
randomClosefixed std dev.PNG
randomClosefixed std dev.PNG (26.62 KiB) Viewed 5971 times
fixed StdDev.PNG
fixed StdDev.PNG (112.27 KiB) Viewed 5972 times
randomClose.PNG
randomClose.PNG (36.23 KiB) Viewed 5971 times
randomStdDev.PNG
randomStdDev.PNG (80.06 KiB) Viewed 5971 times
gui.PNG
gui.PNG (14.59 KiB) Viewed 5972 times
mojojojo
Roundtable Knight
Roundtable Knight
Posts: 131
Joined: Mon Oct 31, 2005 2:07 pm

Re: Synthetic Stock Data: how to "correctly" simul

Post by mojojojo »

AFJ Garner wrote: Note how both bear a much greater similarity to the volatility charts for real price series shown in the above posts
I'm not sure of the above posts that your referring too.

With that said, your solution does a much better job at capturing the volatility clustering that actually occurs in the market, compared to the static method.

Very nice.
AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2071
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Post by AFJ Garner »

Sorry for the confusion (the result of clumsy copy and pasting). The "other" post can be seen here: http://tradersplace.net/forum/thread/15 ... s-markets/

It gives some charts of rolling period volatility on various real data series.
AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2071
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Post by AFJ Garner »

Below you will find a screenshot of the latest version of my random data generator. At some stage I will explain the GUI in greater detail - but it is probably pretty obvious. I have randomised pretty well every element except for “driftâ€
Attachments
generator11Jul13.PNG
generator11Jul13.PNG (20.96 KiB) Viewed 5889 times
ASCII File No 4.PNG
ASCII File No 4.PNG (33.32 KiB) Viewed 5889 times
4.xls
(1.86 MiB) Downloaded 429 times
1000Tests.xls
(141.5 KiB) Downloaded 385 times
stopsareforwimps
Roundtable Knight
Roundtable Knight
Posts: 199
Joined: Sun Oct 10, 2010 1:47 am
Location: Melbourne Australia

Post by stopsareforwimps »

[quote="AFJ Garner"]Below you will find a screenshot of the latest version of my random data generator.

...

What does that mean in practical terms? It means that with an assumption of zero drift, you can expect the price series to be mean reverting in the long term.

...

The trends are of course meaningless and unpredictable: but that does NOT mean they are “unfollowableâ€
AFJ Garner
Roundtable Knight
Roundtable Knight
Posts: 2071
Joined: Fri Apr 25, 2003 3:33 pm
Location: London
Contact:

Post by AFJ Garner »

stopsareforwimps wrote:
Anthony as I understand it random fluctuations (eg coin flips) do not mean revert. The expected average *absolute* deviation from zero is proportional to the square root of the time. This, even though the expected value at any time is 0.

Actually they do revert in that you can show that the value passes through zero an infinite number of times eventually. But in between the diverge further and further away.

From memory Einstein showed this in the context of Brownian motion.

On the second point I cannot fathom how trends that are unpredictable and meaningless can be followed (profitably). Can you give us some hints as to how this can be?

Tim
Tim

I believe I am right in saying that the distribution of outcomes in a coin flip is uniform whereas with geometric Brownian motion it is normal? I am using the latter but of course both "mean revert" in the sense I used the term. They cross and recross the starting point. Again, both distributions are symmetrical.

If you take a big enough collection of data series calculated in such a way, the mean reversion and symmetrical distribution become more immediately apparent and obvious: on a buy and hold basis they will sum up to a return of zero (however long an individual series may take to revert to its starting point).

Since trend following is about "following" and not prediction, it seems to me that the lack of predictability does not matter. The apparent "trends" in random data are meaningless in that they are not caused by any agency other than computer code and random chance: in real markets you may be able to ascribe a "meaning" to the trend: scarcity of oil in an environment of rising Crude price for instance. But an algorithm does not care what causes a "trend" (meaningless or otherwise): it can still follow it while it lasts.

Using pure geometric Brownian motion to create many thousands of price series, I find that any sort of trend following is a zero sum game before costs. However it is interesting to note that the win loss ratio is remarkably similar to that that typically applies on profitable trading of real markets: around 30% of trades are profitable. Although of course you can play around with different systems and get the win loss ratio far higher if you so choose. So, it IS possible to follow "trends" in random data created by GBM. The difference is that such trends are not strong, frequent or long enough for the 30% winners to outweigh the 70% of losers in terms of profitability.

But, is data any less "random" if we introduce random drift? I think probably not. If positive or negative drift lasts for long enough in a single direction at any one time suddenly, BINGO, it becomes possible to trade profitably using a trend following algorithm on random data. Drift elongates and strengthens trends.

Why does any of this matter to real trading and the real world? Well, the huge benefit for me has been to appreciate very much more clearly what market conditions are necessary for TF to work. Will it make me any more profitable? No but it has made me a great deal more comfortable with what I am doing.

If there are frequent and strong enough real world trends I will profit; if not I won't.

The creation of random, synthetic data is a very useful playground.
Post Reply