Skip to content

Commit dd8f4fe

Browse files
authored
Skip ib automater restart if already restarted (#205)
1 parent ba7ccbb commit dd8f4fe

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

QuantConnect.InteractiveBrokersBrokerage/InteractiveBrokersBrokerage.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5277,6 +5277,22 @@ private void OnIbAutomaterExited(object sender, ExitedEventArgs e)
52775277
{
52785278
try
52795279
{
5280+
// We won't trigger a restart if the automater was already started in the meantime
5281+
// or if there was an error starting it. If it's recoverable, it will be restarted
5282+
// by the user action somewhere else
5283+
if (_ibAutomater.IsRunning())
5284+
{
5285+
Log.Trace("InteractiveBrokersBrokerage.OnIbAutomaterExited(): IBAutomater is already running, skipping restart.");
5286+
return;
5287+
}
5288+
5289+
var lastResult = _ibAutomater.GetLastStartResult();
5290+
if (lastResult.HasError)
5291+
{
5292+
Log.Trace("InteractiveBrokersBrokerage.OnIbAutomaterExited(): last IBAutomater start had error, skipping restart.");
5293+
return;
5294+
}
5295+
52805296
Log.Trace("InteractiveBrokersBrokerage.OnIbAutomaterExited(): restarting...");
52815297

52825298
var result = _ibAutomater.Start(false);

0 commit comments

Comments
 (0)