Variable Spread Backtesting with .bar data and Zorro free

Posted By: trenki2

Variable Spread Backtesting with .bar data and Zorro free - 08/27/16 17:15

I was successfully able to do variable spread backtesting in the Zorro free version and I would like to share my approach here for anyone who might want to do the same.

I used my C# DukascopyTickDownloader code from my github repository at https://github.com/trenki2/DukascopyTickDownloader to download the free Dukascopy tick data and convert it to the format that Zorro needs.

The tick downloader can store the data in .t1 and also .bar data and additionally it creates a pseudo asset e.g. EUR/USDs which contains the spread data.

When backtesting one has to read the spread data from the corresponding pseudo asset, set the Spread variable and then do the actual trading.

Here is the code that worked for me:

Code:
while (loop("AUD/USD", "EUR/USD", "GBP/USD", "NZD/USD", "USD/CAD",  "USD/CHF", "USD/JPY"))
{
	string realAsset = Loop1;
	char spreadAsset[10];
	sprintf(spreadAsset, "%ss", realAsset);
	
	Detrend = NOPRICE;
	asset(spreadAsset);
	var spread = priceClose(0);
	
	Detrend = 0;
	asset(realAsset);
	Spread = spread;
	
	Trade();
}

Posted By: Calli

Re: Variable Spread Backtesting with .bar data and Zorro free - 08/28/16 08:30

Do you know this and Strat.Quant?
Posted By: trenki2

Re: Variable Spread Backtesting with .bar data and Zorro free - 08/28/16 10:04

I started development of my C# code before I knew about those posts.

Also the procedure in the first post that describes how to get the data into the Zorro format is rather involved. It talks about stratquant, cygwin, python and some other conversion scipts. According to the documentation the T1 data with variable spread can also only be used with Zorro S.

The C# code does all in one go without the need for additional tools and the generated .bar data with variable spread can also be used with Zorro Free. This is the improvement someone might be interested in.
Posted By: Calli

Re: Variable Spread Backtesting with .bar data and Zorro free - 08/28/16 11:42

Hmm?
1) StrategyQuant manages a lot more Symbols (Indeces, Futures, ..)
2) I manage with it about 400GB dld. Tickdata from Dukascopy on an external USB-drive
3) Zorro uses a rather strange format with most recent quotes at the beginning and the oldest at the end of the file, which to me is a bit questionable if you are dealing with files that has to be upadted - or do you want to to reload everything again and again?
4) Tickdata files are quite large, e.g. way toooo large to load them in Notepad++ or another editor at once and he uses python only to turn around the line sequence due to Zorro's time sequence formate. With normal Windows tools (like powershell) you only can either load everything at once (4GB) or (which will take a very long time from a usb-drive) read and save line by line??
5) I prefer using specialists for the tasks and not one thing that does everything. The specialists are better and provide more and the various tasks of several specialists are better to handle than one thing for all. E.g. compare the editors of mt4 or Zorro with Notepad++.
6) Why reinvent the wheel instead of focussing e.g. only on a better connection?
© 2024 lite-C Forums