Gamestudio Links
Zorro Links
Newest Posts
Blobsculptor tools and objects download here
by NeoDumont. 03/28/24 03:01
Issue with Multi-Core WFO Training
by aliswee. 03/24/24 20:20
Why Zorro supports up to 72 cores?
by Edgar_Herrera. 03/23/24 21:41
Zorro Trader GPT
by TipmyPip. 03/06/24 09:27
VSCode instead of SED
by 3run. 03/01/24 19:06
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (degenerate_762), 1,098 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
sakolin, rajesh7827, juergen_wue, NITRO_FOREVER, jack0roses
19043 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Generic Tick Data Support #481283
08/21/20 15:21
08/21/20 15:21
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Offline OP
Serious User
AndrewAMD  Offline OP
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
jcl,

The dataset functions allow us to store tick data with any arbitrary number of fields.

Likewise, I think it would be useful if any arbitrary tick data can be sourced in a variant of the tick() function.

Take, for example, a market depth trading application. I can live-record market depth ticks. I define my own tick, like so:

Code
typedef struct DEPTHTICK{
	DATE time; // [0]
	float fPrice; // [1] price data, positive for ask and negative for bid
	float fQty; // [2] quantity at price level's ask or bid
} DEPTHTICK;
So this struct has two fields and a timestamp.

Or maybe I wanted double precision for some reason, because the Asset price data is strange. And the price data can be negative, so let's add some flags. Then I'd do something like this:
Code
typedef struct DEPTHTICKv2{
	DATE time; // [0]
	var vPrice; // [1,2] price data
	float fQty; // [3] quantity at price level's ask or bid
	int flags; // [4]
} DEPTHTICKv2;
In this case, we have four fields and a timestamp. (Two are occupied by double precision.)

In a backtest, I would like to source this generic tick data.

On Init, I call a function that sources the dataset file. I tell the function how many fields there are (two). It returns a handle, int h.

As the backtest proceeds, Zorro invokes a user-supplied function generic_tick(int h, void* pTick), where h is the handle, and pTick is the pointer to my user-defined tick for the given timestamp.

Re: Generic Tick Data Support [Re: AndrewAMD] #481296
08/23/20 16:58
08/23/20 16:58
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Offline OP
Serious User
AndrewAMD  Offline OP
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
One minor correction to the above (I cannot edit my previous post):
Quote
Fields - Number of fields per record, including the date field.
https://manual.zorro-project.com/data.htm

So in the above examples, they should be three and five fields, respectively.

Re: Generic Tick Data Support [Re: AndrewAMD] #481302
08/24/20 13:22
08/24/20 13:22
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
Thanks, this seems to me a useful feature.

Re: Generic Tick Data Support [Re: AndrewAMD] #485762
04/20/22 11:04
04/20/22 11:04
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Offline OP
Serious User
AndrewAMD  Offline OP
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
I don't think this feature was ever added, was it? It really would be useful, especially in [Test] and [Train] modes.

I just want a callback that outputs ticks for all loaded datasets.

Re: Generic Tick Data Support [Re: AndrewAMD] #485765
04/20/22 14:00
04/20/22 14:00
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
I believe it's possible since a while, but not with a callback. You can read an arbitrary tick from a dataset with a code like this:

DEPTHTICKv2* MyTick = (DEPTHTICKv2*) dataStr(Handle,dataFind(Handle,wdate(),0)):

Re: Generic Tick Data Support [Re: AndrewAMD] #485767
04/20/22 14:16
04/20/22 14:16
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Offline OP
Serious User
AndrewAMD  Offline OP
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
OK, but I'd like a callback for the same reason that tick() was implemented.

Basically, ticks of arbitrary type can arrive at different frequencies than real ticks. In other words, this can happen, in this sequence:

tick()
tick()
tick()
generic_tick()
generic_tick()
generic_tick()
generic_tick()
tick()
tick()
tick()
generic_tick()
generic_tick()
generic_tick()
generic_tick()

The idea is to guarantee that all ticks will be caught in all circumstances.

Re: Generic Tick Data Support [Re: AndrewAMD] #485775
04/20/22 18:09
04/20/22 18:09
Joined: Jul 2000
Posts: 27,977
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,977
Frankfurt
If I understood it right, it can still be done with 2 lines in a tick function.

while(dataVar(H,N,0) <= wdate(0))
generic_tick(H,dataStr(H,N--,0));

N must be set to the earliest record number at start.

Re: Generic Tick Data Support [Re: AndrewAMD] #485776
04/20/22 18:32
04/20/22 18:32
Joined: Feb 2017
Posts: 1,718
Chicago
AndrewAMD Offline OP
Serious User
AndrewAMD  Offline OP
Serious User

Joined: Feb 2017
Posts: 1,718
Chicago
That should work just fine for my purposes. Thanks!


Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1