Take the 2-minute tour ×
Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

I want to generate synthetic forex data for the purpose of backtesting my trading algorithms. I have some rough ideas in mind on how to do this:

Start with a curve representing a trend, then randomly generate points around the curve according to a Gaussian or some other distribution. Then take the generated points and somehow generate the bar data (open, high, low, close) around those points; alternatively, add a time factor, and then randomly determine when a tick occurs and collect the data into bars afterward.

My question is: is this far off from the established methods for synthetic data generation? I suppose that raises the more basic question: are there any established methods for synthetic data generation? I can't seem to find any writing on this subject, be it a blog post or a research paper.

So in addition to a request for external resources on synthetic data generation, I'd like to know what sorts of distributions best model the relationships between open, high, low, close, or how to generate the appropriate intervals between ticks, the spread between ask and bid prices, etc.

share|improve this question
1  
You could use a stochastic process with a drift and volatility term. Perhaps an interest rate model such as Vasicek that has mean reversion, ES-VJ++ which is Vasicek with jumps, Hull-White, Black-Derman-Toy, etc. etc. The problem of course is that your trading algorithms (should) quickly identify the Guassian (or otherwise) assumptions from the model and beat the "market". Why not try sim trading with a broker that will give you live data? I have not seen writings on synthetic trading data. –  strimp099 Aug 15 '11 at 1:46
    
Beating a fake market is a problem, hence my interest in existing research. You're right, I should and do test on live data from a broker as well. The problem is that live data takes time, and I can't control it. In addition to live testing, I want to have a suite of unit tests to run my strategy against, to serve as a sanity check that even in the ideal cases my strategy makes profit. Ideally, I would check a large number of cases with varying parameters. I can't guarantee that all such movements show up in live data, and historical data is unclean in addition to having the same problem. –  JeremyKun Aug 15 '11 at 4:30
    
So yes, maybe I want the data to be so simplistic that any reasonable strategy should beat it, but even so I want to model a real market as closely as possible... –  JeremyKun Aug 15 '11 at 4:31
add comment

3 Answers

You could start with some representative data (i.e. historical data for the period of interest) and then use bootstrapping to estimate the true distribution of that data. From there, you can use that distribution to generate representative data.

share|improve this answer
    
So what if I can't easily find the particular trend I want to model in historical data? –  JeremyKun Aug 17 '11 at 22:05
    
If you can't find any examples, then how do you know your trend is a realistic scenario? –  Greg Aug 17 '11 at 22:26
    
That's not the point. Just because a scenario hasn't happened before doesn't mean it can't happen in the future. Wouldn't you want your strategy to work in such cases too? –  JeremyKun Aug 20 '11 at 23:20
    
Indeed, but then you get into the realm of just making up data. How do you know that your scenario is possible? You can certainly invent a scenario, but it's going to miss "realistic" nuance and you don't really know where it lies in the true probability distribution, other than being pretty far down one tail (if nothing similar has happened before in historical data) –  Greg Aug 21 '11 at 3:14
    
Right. That's the point of my question. How can I generate synthetic streams of data that are realistic to a reasonable degree, but have potentially never happened with exactly a particular set of parameters before? What if I want to plan for a European financial crisis? I can't very well look into history for that, but it's happening now. –  JeremyKun Aug 21 '11 at 15:31
add comment

For starters, I am not even sure why you need to ask this question. There is literally years of free tick data available for FX, just check out quant.SE's data wiki.

Having said that, a Gaussian is a very poor fit to high-frequency data, particularly FX. Your strategy for simulating data depends on the idea behind the simulation. If you wish to actually estimate any parameters or test methods on this data, and you will be accepting or rejecting ideas based on the results of the simulation, I urge you to stop right there and reconsider.

If, instead, you wish to model the volatility of the process and test the ability of your system to deal with changes to the parameters of the data generating process, you should consult chapter 5 and particularly page 122 of An Introduction to High Frequency Finance. They write:

The distributions of returns are increasingly fat-tailed as data frequency increases (smaller interval sizes) and are hence distinctly unstable...

Scaling laws describe mean absolute returns and mean squared returns as functions of their time intervals...

There is evidence of seasonal heteroskedasticity in the form of distinct daily and weekly clusters of volatility...

Some papers claim FX returns to be close to Paretian stable ones, for instance (McFarland et al., 1982; Westerfield, 1997); some to Student distributions that are not stable (Rogalski and Vinso, 1978; Boothe and Glassman, 1987); some reject any single distribution... Most researchers now agree that a better description of the data generating process is in the form of a conditional heteroskedastic model rather than being from an unconditional distribution.

Finally, if you wish to construct OHLC data, your best bet is to model the data generating process as above along with a tick frequency process (also discussed in the above reference) and construct OHLC bars from simulated tick data.

share|improve this answer
    
I certainly don't mean to offend anyone by wanting synthetic data in addition to historical data. I just want to be able to isolate trends with specific volatility parameters, and hence give me a wider range of data to work with. Of course, the synthetic data would have a smaller weight on my overall decision about a strategy; but if I make some small change that has inadvertent side effects on some cases that don't happen to show up in my historical data, it would be better to know about it. I'm sure that if real data were as easy as a Gaussian, this forum wouldn't exist. –  JeremyKun Aug 16 '11 at 1:44
    
And of course, thanks so much for your specific reference! I'll check it out and maybe add another comment with what I find. –  JeremyKun Aug 16 '11 at 1:47
    
So, I guess that raises the question: what "conditional" process controls the heteroskedasticity? Are there any known models that seem to work similarly to a particular subset of real-world data? –  JeremyKun Aug 16 '11 at 2:02
    
@bean no one is offended. I just think that for FX simulating data is usually not worth the effort. But, if you want to go ahead anyway, I suggest you match the level of sophistication of your simulation to the sophistication of your trading algorithm. –  Tal Fishman Aug 16 '11 at 10:11
    
Say I'm not interested in simulating HFT. Assuming we look at weekly trends, perhaps the data fits some kind of known distribution/process in an easier way? Or at least the relationships of OHLC pieces is more tractable? –  JeremyKun Aug 17 '11 at 22:05
show 1 more comment

The method for generating synthetic data described here might be useful to you. Also I believe the meboot R package can be used for synthetic time series generation.

share|improve this answer
    
This is interesting, but it doesn't look like the author of the blog post provides a method to change the market parameters. He just takes real tick data and modifies it slightly... And for those reading here's a link to the paper about meboot. I'll have to look more closely to see what that's about. jstatsoft.org/v29/i05/paper –  JeremyKun Aug 16 '11 at 1:55
    
I agree that there are some limitations and I have posted my adapted version here –  babelproofreader Aug 16 '11 at 14:56
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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