Processing Tick data for zorro strategy

Posted By: adityam

Processing Tick data for zorro strategy - 10/31/18 11:30

Hello,
I have written a strategy using 1-minute OHLC data (date,time,open,high,low,close,volume). However, I am unable to code the same strategy on a tick-by-tick data (date,time,tradedPrice,volume). I am trying to play with barPeriod values e.g. 1./60 but the program is asking for the t1 file instead of a t6 file. The document says that lesser than 1 minute is processed by t1 file however also mentions using barPeroid < 1 for lower intervals. afaik t1 is used for ask/bid spread analysis. Is there a place I can refer for this to understand fully how to work with tick data?
Thanks
Posted By: jcl

Re: Processing Tick data for zorro strategy - 11/01/18 13:02

Yes, for a 1-second bar periods you'll need history in .t1 format. .t6 files contain candles and are not suited for small bar periods.
Posted By: adityam

Re: Processing Tick data for zorro strategy - 11/05/18 09:40

Thanks for input. Is there a sample in zorro scripts that can help getting a t1 from a csv file (format: date-yyyymmdd, time-hh:mm:ss, price, vol) e.g. (20180917,15:29:59,11396.05,375)? There was an available script to help convert a csv to t6 however i couldn't find one for t1. Any help with this is appreciated.

Thanks
Posted By: jcl

Re: Processing Tick data for zorro strategy - 11/05/18 15:43

The script is different for any CSV, but here's a more complex example for bitcoin prices:

Code:
void main()
{
  string Format = "+0,,,%t,f,f,s";
  int Records = dataParse(1,Format,"History\BTCEUR.csv");
  printf("n%d records read",Records);
// now convert it to t1 and change sign for sell quotes
  for(i=0; i<Records; i++) {
    T1* t1 = dataAppendRow(2,2);
    t1->time = dataVar(1,i,0);
    t1->fVal = dataVar(1,i,1);
    string sell = dataStr(1,i,3);
    if(sell[0] == 't') t1->fVal = -t1->fVal;
// display progress bar and check [Stop] button
    if(!progress(100*i/Records,0)) break;
  }
  if(Records) dataSave(2,"History\BTCEUR.t1");
}

Posted By: adityam

Re: Processing Tick data for zorro strategy - 11/06/18 08:11

Just to be sure if T1 format is the right format for this usecase.
typedef struct T1
{
DATE time; // time stamp, GMT
float fVal; // positive for ask, negative for bid
} T1; // single-stream tick, .t1 file content

T1 format has these 2 values i.e time and fVal where fVal is ask or bid price, however the format that i have in csv has (date, time, tradedPrice, volume) and T1 format doesn't seem to handle it. How would T1 handle this format then?
Posted By: jcl

Re: Processing Tick data for zorro strategy - 11/06/18 09:08

T1 does not contain volume. If you want volume, you must indeed use a .t6 file. You can then ignore the warning message that .t1 is recommended.
Posted By: adityam

Re: Processing Tick data for zorro strategy - 11/12/18 06:40

Thanks for this information.
I still cannot process the data that i have with the t6 file. The problem i have is as below.
Input csv file is of format (date, time, tradedPrice, volume) e.g. 20180917,15:30:00,11395.1,300
however when i use csvToHistory.c script with following string format
string Format = "%Y%m%d,%H:%M:%S,f4,f6";
I get error Error 062: No 7 records in C:UsersAdministratorZorroHistoryNIFTY_I_TICK_2018.t6
Can't open C:UsersAdministratorZorroHistoryNIFTY_I_TICK_2018.t6

T6 file needs all 7 entries date, time, open, high, low, close, volume etc.
And if i use following format string:
string Format = "+%Y%m%d,%H:%M:%S,f3,f1,f2,f4,f6,f5";
Assuming the open (f3) and high (f1) would contain price and volume respectively and trying to use priceOpen() and priceHigh() to print the price and vol values results zero for both.
How do i then use csvToHistory script to process the csv file of above format and use it in my script?

Thanks
Posted By: jcl

Re: Processing Tick data for zorro strategy - 11/14/18 12:56

Look into the resulting t6 file with the History script or the ZHistoryEditor. Then you see which fields are wrong, and can fix the format string accordingly.
Posted By: adityam

Re: Processing Tick data for zorro strategy - 11/15/18 03:40

Thanks Jcl,
As mentioned in previous comment, the t6 file look ok to me. It has proper time and open, high fields populated and rest are zero. However when i try to get these values from script using priceOpen() it doesnt return the values displayed in t6 files but zero.

Output of t6 file from history script is as below:

Date Open High Low Close Val Vol
18-09-17 09:15 11481 3450.0 0.0 0.0 0.0 0

In my script i use:
var Open = priceOpen();
var High = priceHigh();
to get these values but it returns zero instead of 11481 and 3450.0

Anything else that i can try to figure out the issue?
Posted By: jcl

Re: Processing Tick data for zorro strategy - 11/15/18 09:57

That's not a valid OHLC file. The Open can not be higher than the High, nor can Low and Close be zero.
Posted By: adityam

Re: Processing Tick data for zorro strategy - 11/15/18 20:15

So do you mean to say that the following format cannot be handled via a t6 format?
Date,time,price,vol
20180917,15:29:59,11396.05,375
Because whichever format is used the t6 would need OHLC values which the above file doesn't have?
If yes then how can this be handled?
Posted By: Petra

Re: Processing Tick data for zorro strategy - 11/15/18 22:08

You must store the price in OHLC and the volume in Vol.
Posted By: AVL

Re: Processing Tick data for zorro strategy - 10/30/20 18:42

Originally Posted by jcl
T1 does not contain volume. If you want volume, you must indeed use a .t6 file. You can then ignore the warning message that .t1 is recommended.

Is there a reason why developers decided not to include Volume (Ask/Bid Size) in .t1 format? Isn't it illogical to exclude it from format made for high-precision backtesting? In this case, backtester is not checking whether an order was filled, so it's not a high precision backtesting. Even Multicharts is considering Volume in tick-by-tick backtesting.
Posted By: AVL

Re: Processing Tick data for zorro strategy - 10/30/20 19:06

I've created a thread regarding the issues with tick data: https://opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=481785&#Post481785
© 2024 lite-C Forums