Hi,
I have a script that runs on a 1 minute basis and appends to a log file during it's execution. In the log file I log the time. I have noticed that there are times where the script seems to skip a minute. Meaning instead of executing every minute it executes in 2 minutes. I can see this when looking at the log file. I have also watched the action column in the Strategy Window and found that during normal behavior it says:
Entering Montior Thread
Execute: SPY Trade-Ideas Strategy
Update Complete(2): SPY (0 Symbols left)
Leaving Streaming Filter Monitor Thread
But when it skips a minute it says this:
Entering Montior Thread
Update Complete(2): SPY (0 symbols left)
Leaving Streaming Filter Monitor Thread
Is there a way to make sure that my script gets executed every minute?
Thanks,
-Frank
Size:
Color:
The log file is for debugging and although I'd expect you'd see the Execute message each time, we're not privy to the code that creates that message. Believe or not, there could be a bug in the debug/instrumentation code too!
That said, a strategy won't execute if there isn't an update for the symbol. That's unlikely for SPY, so the only way that I can think of to approach this is for
your strategy to log when it runs, and then review the log to find missing runs. Here's a method that you can add to your strategy and an example of how to call it.
CODE:
Please log in to see this code.
Finally, if you're executing a strategy for just 1 symbol, I'd highly recommend using a Streaming Strategy Window to avoid the several seconds of delay that you get when using the S. Monitor.
Size:
Color:
Cone,
Thanks for the code. I have put it into my strategy and have the output:
CODE:
Please log in to see this code.
Please not that bar transition from 290 to 0 happens over a one minute span. However, the 291 to 0 happens over a two minute span. Not sure if this is helpful or not.
On a separate note how do I go about creating a Streaming Strategy Window? I see that it is mentioned three times in the User's Guide but no instructions as how to create one. Any help that you can give me in creating one would be greatly appreciated.
Thanks,
-Frank
Size:
Color:
QUOTE:
On a separate note how do I go about creating a Streaming Strategy Window?
It just takes clicking the Stream button.
Size:
Color:
Okay, then I'd definitely use a Streaming window until we figure out what's going on.
Side note:
It's only necessary to call that routine once per Execute() ... take the call out of the bar loop. ;)
Size:
Color:
Cone,
I thought the same thing but the (int bar) parameter in the function proto-type made me think you wanted it in the bar for loop.
CODE:
Please log in to see this code.
-Frank
Size:
Color:
Just use the example method call to pass the last bar in the chart: LogRun(Bars.Count - 1);
I'm going to run this today. If there's anything interesting about your setup, let me know. I'm just going to run it on SPY 1-Minute bars in the S. Monitor.
Size:
Color:
Cone,
The only thing that might be interesting about my strategy is that I don't actually ever trade on SPY I switch to another symbol and call BuyAtLimit and ShortAtLimit using SetContext(<symbol>, true) first and then RestoreContext().
Other than that I can't think of anything. If you need my code let me know. It gets the the entry and exit information from Trade-Ideas through a TCP connection. This is happening pretty consistently on my side. If there is something that I can do to assist in your debugging please let me know. If you need to, you can modify your DLL's to dump log data to a file, send the DLL to me and I will use it on my side and send you the log files.
-Frank
Size:
Color:
I wasn't really thinking about the strategy itself since that wouldn't affect if Execute() is called. Rather, if a DataSet is assigned to the Strategy, which symbols, etc.
Although I missed a few hours in the middle of the day (forgot that the laptop was running this test and I closed it), all the runs for the remainder of the day were accounted for.
In your experience, how frequently does this happen?
What is the symbol that you're trading?
Size:
Color:
Cone,
When I was running the strategy in the Strategy Monitor I could see in the logs that a minute was skipped at least 5 or 6 times in a hour time frame. The symbol that I had clicked on to run the strategy with was SPY.
Let me know if there is anything else that I can do in helping you debug this issue.
-Frank
Size:
Color:
Assuming that SPY is updated every bar (as I'm seeing), the only explanation that I can think of is that the strategy is taking more than 50 seconds or so to execute. Requesting a secondary symbol will definitely add delay, but only a few seconds.
What's the secondary symbol that you're trading?
Size:
Color:
Cone,
My strategy gets the order information from an external stock advisory called Trade-Ideas. I didn't capture the trades that were taken two days ago, but I can give you the symbols that were take on December 12, 2016.
ADI AEM AU BCO BRSS FIVE GG HPE LOCO LULU MSM SGMS SPY TRI VEEV YRD
I haven't used the Strategy Monitor since I switched to a Streaming Strategy Window configuration which seems to work great. If you would like I can switch back to the Strategy Monitor now and see if I'm still getting the issue today.
-Frank
Size:
Color:
As long as you don't use the secondary symbol data to trade, I'd definitely stick with the S.S. (Streaming Strategy) Window. Even if for pairs strategies, I'd stay with a SSW; but keeping in mind
the solution described here (click).
As for troubleshooting, I'm wanting to see if the issue has something to do with trading the secondary symbol. Do the missing events correlate in some way (like on the bar prior) to a trading Alert? Or any other correlation?
The thing I'm noticing about nearly all those symbols is that they have "zero-volume intervals", which means their DataSeries will be missing a bar for those intervals. I'm not sure how that would affect a strategy running on SPY in the S. Monitor, but it's something to start with.
Size:
Color:
Cone,
I have switched back to the Strategy Monitor and I am watching my logs and the log code that you provided above. I haven't seen any skipping yet but will let you know if I do.
-Frank
Size:
Color:
Cone,
I ran my code from 1:00 PM EST till 4:00 PM EST and never say a minute skip. Not sure what was going on the other day but I can't reproduce the minute skipping. I will try to keep looking at this on the next market open.
-Frank
Size:
Color:
Roger. I didn't detect any skips either.
Size:
Color: