NexusFi: Find Your Edge


Home Menu

 





How to measure data feed latencies between continents?


Discussion in Traders Hideout

Updated
      Top Posters
    1. looks_one Koepisch with 22 posts (5 thanks)
    2. looks_two Big Mike with 18 posts (6 thanks)
    3. looks_3 artemiso with 11 posts (1 thanks)
    4. looks_4 gomi with 7 posts (21 thanks)
      Best Posters
    1. looks_one gomi with 3 thanks per post
    2. looks_two Fat Tails with 3 thanks per post
    3. looks_3 Big Mike with 0.3 thanks per post
    4. looks_4 Koepisch with 0.2 thanks per post
    1. trending_up 28,255 views
    2. thumb_up 48 thanks given
    3. group 8 followers
    1. forum 66 posts
    2. attach_file 15 attachments




 
Search this Thread

How to measure data feed latencies between continents?

  #51 (permalink)
 
sam028's Avatar
 sam028 
Site Moderator
 
Posts: 3,765 since Jun 2009
Thanks Given: 3,825
Thanks Received: 4,629


artemiso View Post
I'm not a very good programmer, so I apologize if the code is incomprehensible.

I'll bow out of this thread and let you focus on the clock synchronization issues.


I have a more readable version and less obsfuscated version, and had fun in reading the original one .

[off]For higher level of obfuscation, see https://www.ioccc.org/2013/mills/mills.c and all IOCCC 2013 winning entries.[/off]

Success requires no deodorant! (Sun Tzu)
Follow me on Twitter Reply With Quote
Thanked by:

Can you help answer these questions
from other members on NexusFi?
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
Increase in trading performance by 75%
The Elite Circle
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Just another trading journal: PA, Wyckoff & Trends
34 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
18 thanks
GFIs1 1 DAX trade per day journal
16 thanks
Vinny E-Mini & Algobox Review TRADE ROOM
13 thanks
  #52 (permalink)
 artemiso 
New York, NY
 
Experience: Beginner
Platform: Vanguard 401k
Broker: Yahoo Finance
Trading: Mutual funds
Posts: 1,152 since Jul 2012
Thanks Given: 784
Thanks Received: 2,685


sam028 View Post

I have a more readable version and less obsfuscated version, and had fun in reading the original one .

[off]For higher level of obfuscation, see https://www.ioccc.org/2013/mills/mills.c and all IOCCC 2013 winning entries.[/off]

I figured it wouldn't take long to find someone who can decipher the code here.

Reply With Quote
  #53 (permalink)
 gomi 
Paris
Market Wizard
 
Experience: None
Platform: NinjaTrader
Posts: 1,270 since Oct 2009
Thanks Given: 282
Thanks Received: 4,505


Just a few off topic points on clock management in Windows with (or without) NTP.

I made a lot of tests with NTP and my conclusion is that
* I requires symmetrical latency ( not available on ADSL because of the A)
* I required low latency jitter (not the case at on a DSL network, if you make an NTP query and your PC is busy downloading, you'll be off by tens or hundreds of milliseconds)

Because of its huge time constants it also requires a stable clock speed ie constant temperature (not the case in a PC, because of room temperature or PC load)

I tried lots of builds, selected specific NTP low stratum servers, but the NTP feedback loop never stabilized because of the PC and network non ideal configurations.


So I bought a cheapo GPS card and plugged it in my PC through the serial port (to get the GPS very precise pulse called PPS)

To manage my clock built a C program that uses a very simple algo : if PC ahead of time the put clock in "slow" mode, else put PC in "fast" mode

Before Windows 8 you had to use peformance counters to build a precise clock estimate, now with Windows 8 you can call GetSystemTimePreciseAsFileTime which will give you nanosec precision time. It makes all the clock stuff coding much more easier.....

Of course it's much more simpler to use a NTP daemon with the GPS clock , but I got fed with NTP so built my own...

Here's the result, you see you can have much lower than ms precision with a very basic gps board (with PPS)


I you choose to go with the hardware way, it's better to use a legacy serial port, which has a direct IRQ access to the CPU, than going through the full serial over usb stack.

Reply With Quote
  #54 (permalink)
 gomi 
Paris
Market Wizard
 
Experience: None
Platform: NinjaTrader
Posts: 1,270 since Oct 2009
Thanks Given: 282
Thanks Received: 4,505

You can also watch OS latency and check for rogue drivers using latencymon

Reply With Quote
  #55 (permalink)
 Koepisch 
@ Germany
 
Experience: Beginner
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: FDAX
Posts: 569 since Nov 2011
Thanks Given: 440
Thanks Received: 518


gomi View Post
Just a few off topic points on clock management in Windows with (or without) NTP.

I made a lot of tests with NTP and my conclusion is that
* I requires symmetrical latency ( not available on ADSL because of the A)
* I required low latency jitter (not the case at on a DSL network, if you make an NTP query and your PC is busy downloading, you'll be off by tens or hundreds of milliseconds)

Because of its huge time constants it also requires a stable clock speed ie constant temperature (not the case in a PC, because of room temperature or PC load)

I tried lots of builds, selected specific NTP low stratum servers, but the NTP feedback loop never stabilized because of the PC and network non ideal configurations.


So I bought a cheapo GPS card and plugged it in my PC through the serial port (to get the GPS very precise pulse called PPS)

To manage my clock built a C program that uses a very simple algo : if PC ahead of time the put clock in "slow" mode, else put PC in "fast" mode

Before Windows 8 you had to use peformance counters to build a precise clock estimate, now with Windows 8 you can call GetSystemTimePreciseAsFileTime which will give you nanosec precision time. It makes all the clock stuff coding much more easier.....

Of course it's much more simpler to use a NTP daemon with the GPS clock , but I got fed with NTP so built my own...

Here's the result, you see you can have much lower than ms precision with a very basic gps board (with PPS)
Attachment 137497

I you choose to go with the hardware way, it's better to use a legacy serial port, which has a direct IRQ access to the CPU, than going through the full serial over usb stack.

Thanks GOMI, thats exact my current way to solve this issue. In the meantime i've received all things to build my own stratum 1 GPS based time source (with PPS of course). To overcome windows time granularity issues i access the time in a direct way. Network path to my local device is very symmetric.

Started this thread Reply With Quote
Thanked by:
  #56 (permalink)
 gomi 
Paris
Market Wizard
 
Experience: None
Platform: NinjaTrader
Posts: 1,270 since Oct 2009
Thanks Given: 282
Thanks Received: 4,505

If your clock is correctly set up, you can use GomTimeMeasureV2 to watch time distribution on tick arrivals


3 tick modes : Last, BidAsk, All (Hotkey Space Bar)
This allows to check if the time distrubution is constant depending on tick types.

2 visualisation modes : Basic and Convolution
The problem is that NT has 1 second resolution, so to find real latency, we use a sliding convolution window of 1 second, and we try to see which starting time of the window captures the maximum ticks. This will give the latency.

If network latency is constant, the convolution should be triangular.

In basic mode, the point which is the most to the left is the minimum measured network lag (based on data feed timestamp)

You can move the chart around by using Ctrl+click and move.


Here's an example


We can see that :
shortest lag on dax is 200 ms
shortest lag on ES is 170 ms

mean network las is 270 ms.

Bid/Ask ticks have greater lag than Price ticks, so you may need to throw all the delta stuff away ;-)

Attached Files
Elite Membership required to download: GomTimeMeasureV2.1.zip
Reply With Quote
  #57 (permalink)
 Koepisch 
@ Germany
 
Experience: Beginner
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: FDAX
Posts: 569 since Nov 2011
Thanks Given: 440
Thanks Received: 518


gomi View Post
If your clock is correctly set up, you can use GomTimeMeasureV2 to watch time distribution on tick arrivals


3 tick modes : Last, BidAsk, All (Hotkey Space Bar)
This allows to check if the time distrubution is constant depending on tick types.

2 visualisation modes : Basic and Convolution
The problem is that NT has 1 second resolution, so to find real latency, we use a sliding convolution window of 1 second, and we try to see which starting time of the window captures the maximum ticks. This will give the latency.

If network latency is constant, the convolution should be triangular.

In basic mode, the point which is the most to the left is the minimum measured network lag (based on data feed timestamp)

You can move the chart around by using Ctrl+click and move.


Here's an example
Attachment 137533

We can see that :
shortest lag on dax is 200 ms
shortest lag on ES is 170 ms

mean network las is 270 ms.

Bid/Ask ticks have greater lag than Price ticks, so you may need to throw all the delta stuff away ;-)

Thanks a lot @gomi for your contributions. I have to re-read your post a few times and look into the NT code. Till now i haven't had an idea to utilize NT for that issue due to lack of exchange time stamps. If i got an access to rithmic API (pending since several day's) i want to compare my time to the R|API exchange time stamps. So it would be a big improvement if i could utilize a second datafeed to make the measurements.

Started this thread Reply With Quote
  #58 (permalink)
 
Silvester17's Avatar
 Silvester17 
Columbus, OH
Market Wizard
 
Experience: None
Platform: NT 8, TOS
Trading: ES
Posts: 3,603 since Aug 2009
Thanks Given: 5,139
Thanks Received: 11,527


gomi View Post
If your clock is correctly set up, you can use GomTimeMeasureV2 to watch time distribution on tick arrivals


3 tick modes : Last, BidAsk, All (Hotkey Space Bar)
This allows to check if the time distrubution is constant depending on tick types.

2 visualisation modes : Basic and Convolution
The problem is that NT has 1 second resolution, so to find real latency, we use a sliding convolution window of 1 second, and we try to see which starting time of the window captures the maximum ticks. This will give the latency.

If network latency is constant, the convolution should be triangular.

In basic mode, the point which is the most to the left is the minimum measured network lag (based on data feed timestamp)

You can move the chart around by using Ctrl+click and move.


Here's an example
Attachment 137533

We can see that :
shortest lag on dax is 200 ms
shortest lag on ES is 170 ms

mean network las is 270 ms.

Bid/Ask ticks have greater lag than Price ticks, so you may need to throw all the delta stuff away ;-)

@gomi never fails to come up with something new. just amazing

here's an example from the other side of the atlantic:



and thank you for this brilliant tool!!

Reply With Quote
Thanked by:
  #59 (permalink)
 Koepisch 
@ Germany
 
Experience: Beginner
Platform: NinjaTrader
Broker: Mirus Futures/Zen-Fire
Trading: FDAX
Posts: 569 since Nov 2011
Thanks Given: 440
Thanks Received: 518

@gomi: I haven't grasb it yet. You said "we use a sliding convolution window of 1 second, and we try to see which starting time of the window captures the maximum ticks" - is that related to the assumption that the most ticks are at the very beginning of a new second?

Started this thread Reply With Quote
  #60 (permalink)
 gomi 
Paris
Market Wizard
 
Experience: None
Platform: NinjaTrader
Posts: 1,270 since Oct 2009
Thanks Given: 282
Thanks Received: 4,505


Suppose you have a constant latency of 150 ms.
Then the measured latency should be equally distributed between 0.150 s (ticks happening at mm:ss.000, timestamped mm:ss ), and 1.150 s (ticks happening at mm:ss.99999999999, also timestamped mm:ss).

The idea is you take the histogram of all latencies, and you cumulate it using a sliding window of 1 second length.
So you calculate how much ticks you have between
0 and 1
0.10 and 1.10
0.20 and 1.20
etc....

The window that catches the maximum of ticks will be the one that represents the latency.
Here's a chart, the blue reactangle is where the measured tick latencies are.

Reply With Quote
Thanked by:




Last Updated on February 17, 2014


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts