Delayed Strategy execution due to Streaming heartbeat?
Author: mkbryan
Creation Date: 7/11/2016 4:38 PM
profile picture

mkbryan

#1
Gents,
There seems to be an occasional significant delay while streaming. First, I'll describe the symptom and then provide the background. Hopefully you can provide some information that offers an explanation and potential workarounds/fixes.

The symptom is visible in the attached picture showing the range of times for the heartbeat from 0 to 630ms on the blue line.The upper and lower bands of one standard deviation from the linear regression line are the red and green lines. Most of the data is within one standard deviation, which is 60ms. The outliers are multiple orders of magnitude times one standard deviation, which is about 300-600ms. The result of the delay is a delayed start of the strategy, which results in a delayed trade decision (alert).

Here's the background. The strategy timestamps the UTC time to a log file. These timestamps are used as the data for the delay analysis. The strategy runs every minute (although similar delays are seen at higher datascales). The delays used to be longer (multiple seconds) and are now less because of the changes to the Windows 10 system including deferring scheduled tasks such as auto-updaters and disk defragmentation while the market is open, and raising the WealthLab Pro priority to Highest. The system clock is synchronized at user logon. The computer running WealthLab Pro 6.9.15 is the only computer on the Internet. Profiling data from both the Visual Studio 15 debug profiler and the Windows 10 Performance Monitor show nothing (yet - the offending data may not be profiled).

At this point, I'm guessing that the streaming heartbeat comes from network and network transmission delay is the root of the problem. Your insight would help diagnose the delay.

Many thanks in advance.

~Marc
profile picture

Eugene

#2
Marc,

Is the occasional half a second delay really a problem that big? Especially considering that it's an outlier which happens once in 350 runs i.e. once per session - if I interpreted your chart correctly and we're talking 1-minute bars here.

Do you know your strategy's bottlenecks e.g. off the top of my hat: not using an SSD, slow performing external data requests (SQL, file...), streaming hi-res video on your LAN etc?

Have you tried disabling mostly all Performance Visualizers for your particular Streaming strategy? (Reopen the Strategy window for change to apply.)

QUOTE:
I'm guessing that the streaming heartbeat comes from network

I rather think that Streaming Strategies are driven by the system timer on your PC that depends on the PC clock.
profile picture

mkbryan

#3
Hi Eugene,

In the delay data posted in the graph (1m data scale), there were 6 samples outside of 1 standard deviation from 200 to 630ms. The strategy executes 1800+ bars in less than 200ms. With this perspective, a 200+ ms delay before the strategy starts is significant because it's 50% of the effective strategy execution time.

The PC clock seems to work just fine based on the Performance Monitor timers. So, I'm trying to understand exactly what triggers the heartbeat and subsequent streaming strategy execution. If there's something that can improve the trigger response, I'll take action.

Thanks for any additional insight.

~Marc
profile picture

mkbryan

#4
Gents,

Having not seen a response (pardon me if you're looking into it), here's a clarifying question.

How does WealthLab Pro know the live (current trading session) native market time? It seems WealthLab must be provided the native market timestamp by the streaming provider so WLP can build/aggregate a new streaming bar and append it to the existing streaming bars (and static data) such that the timestamps are "on the same clock".

Does WLP get the native market time once when streaming is turned on and then use the local computer timer for each subsequent heartbeat or does WLP get the native market time at the end of each heartbeat period? Perhaps there is another method?

TIA.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).