How to get exact same tick time during BackTesting vs RealTime

Created at 28 Apr 2023, 20:21
ctid2514471's avatar

ctid2514471

Joined 23.01.2021

How to get exact same tick time during BackTesting vs RealTime
28 Apr 2023, 20:21


I am trying to write a bot based on ticks. (Let's call it a sniper bot...)

One thing I am checking during development is that I get exactly the same data during real processing vs back-testing.

While I can confirm that I get the same tick sequence of OHLC data, I cannot manage to replicate their exact timing during back-testing.
The timing is only off by a small amount, up to 100ms max maybe, but it varies randomly every tick.

I am using 'Server.TimeInUTC' (for both run types) when I get the tick event of type 'BarsTickEventArgs'.

Is this what I am supposed to do?

I also tried 'tick.Bars.LastBar.OpenTime' - Thinking that might be repeatable during back-testing (And since at the T1 level, and only the T1 level, OpenTime should be a unique, unchanging time for each tick I assume...), but that isn't the exact same value for both run types either.

It would seem reasonable that I should be able to get the exact same timestamp, to the millisecond, since it's being simulated anyway!, and since I am able to get a perfect replication of every other tick detail.

Am I missing something?
Or is this a bug?

As a clear view of what I am seeing, below shows the discrepancies.
Dark-yellow shows that the data mostly matches perfectly, tick for tick.

But Server.TimeInUTC does not align perfectly between batch and realtime, which seems unexpected as everything else is perfect.


@ctid2514471
Replies

PanagiotisChar
30 Apr 2023, 10:46

Hi there,

My guess is that this is due to latency which cannot be simulated in backtesting.

Aieden Technologies

Need help? Join us on Telegram

Need premium support? Trade with us

 


@PanagiotisChar