Login Page - Create Account

Support Board


Date/Time: Tue, 14 Jan 2025 10:02:55 +0000



Post From: sc.FlattenAndCancelAllOrders during Replay mode

[2017-04-29 02:34:37]
User553714 - Posts: 184
Hi, Can you use sc.FlattenAndCancelAllOrders() during replay mode, it's hard to believe that you can't?
I have done a fair bit of testing on this and sc.FlattenAndCancelAllOrders() does not seem to function correctly during reply?
It works fine during an AutoTradeSystem backtesting but seems to produces strange behaviour when used in replay mode. What seems to be happening is that in Replay mode sc.FlattenandcancelAllOrders executes in "real time" even though the GlobalSimulation variable is set to true instead of executing at the current Replay Index. This means that the lastExitTrade Index always returns as the current Replay index so as the chart advances LastExitTradeIndex = Index (current replay Index).
See extract of log below which I think demonstrates what I am explaining, the current replay index/time is 2017-04-27 00:17 but Flatten executes at 2017-04-29 12:26:20.410 (system time)?
Order  2017-04-27 00:17:31.012  [Sim]CL-201706-NYMEX  
Order  2017-04-27 00:17:31.013  [Sim]CL-201706-NYMEX      
Order  2017-04-27 00:17:31.014  [Sim]CL-201706-NYMEX      
Order  2017-04-29 12:26:20.410  [Sim]CL-201706-NYMEX      
Order  2017-04-29 12:26:20.411  [Sim]CL-201706-NYMEX    
Order  2017-04-29 12:26:20.412  [Sim]CL-201706-NYMEX      
Fill  2017-04-29 12:26:20.413  [Sim]CL-201706-NYMEX
I hope I am not missing something simple but I can't seem to work this one out. Any help will be appreciated. Thanks.