IbcAlpha / IBC

Automation of Interactive Brokers TWS. You can download the latest release here: https://github.com/ibcalpha/ibc/releases/latest
GNU General Public License v3.0
974 stars 174 forks source link

Windows task scheduler - Stop task if it runs longer than 1435 minutes #232

Closed mpolavieja closed 5 months ago

mpolavieja commented 8 months ago

Hello, I am using the task template provided within the IBC files, and I am wondering what is the reason to have the following condition enabled on the trigger:

I have tested it and I found this leads to IBC closing and therefore TWS closing disorderly before the autologoff. Since 1435 minutes is 23 hours and 55 minutes, just under 24 hours, this irremediably happens right before TWS autologoff time.

I think it is better to disable this option and let the TWS autologoff feature run so it closes down tidily, and have the start time of the task set to launch IBC a couple of minutes after TWS's autologoff. Is this correct or am I missing something? Is there a reason for this condition to be enabled to 1435 minutes?

Thanks.

rlktradewright commented 8 months ago

Yes, you are right, and in fact I no longer use this setting myself, but I have forgotten to update the sample task template in the repository. I'll do that shortly.

In the meantime, here's the export of my actual scheduled task that I use for my live TWS, just in case it's helpful:

<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
  <RegistrationInfo>
    <Date>2014-03-01T18:45:15.7467279</Date>
    <Author>TW\d41a3npql2</Author>
    <URI>\Trading\Start TWS Live</URI>
  </RegistrationInfo>
  <Triggers>
    <CalendarTrigger>
      <Repetition>
        <Interval>PT10M</Interval>
        <Duration>PT23H55M</Duration>
        <StopAtDurationEnd>false</StopAtDurationEnd>
      </Repetition>
      <StartBoundary>2014-03-01T22:15:00</StartBoundary>
      <Enabled>true</Enabled>
      <ScheduleByWeek>
        <DaysOfWeek>
          <Sunday />
          <Monday />
          <Tuesday />
          <Wednesday />
          <Thursday />
        </DaysOfWeek>
        <WeeksInterval>1</WeeksInterval>
      </ScheduleByWeek>
    </CalendarTrigger>
  </Triggers>
  <Principals>
    <Principal id="Author">
      <UserId>S-1-5-21-4137257962-3514354744-3491261515-1127</UserId>
      <LogonType>InteractiveToken</LogonType>
      <RunLevel>LeastPrivilege</RunLevel>
    </Principal>
  </Principals>
  <Settings>
    <MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
    <DisallowStartIfOnBatteries>true</DisallowStartIfOnBatteries>
    <StopIfGoingOnBatteries>true</StopIfGoingOnBatteries>
    <AllowHardTerminate>true</AllowHardTerminate>
    <StartWhenAvailable>false</StartWhenAvailable>
    <RunOnlyIfNetworkAvailable>false</RunOnlyIfNetworkAvailable>
    <IdleSettings>
      <StopOnIdleEnd>true</StopOnIdleEnd>
      <RestartOnIdle>false</RestartOnIdle>
    </IdleSettings>
    <AllowStartOnDemand>true</AllowStartOnDemand>
    <Enabled>true</Enabled>
    <Hidden>false</Hidden>
    <RunOnlyIfIdle>false</RunOnlyIfIdle>
    <DisallowStartOnRemoteAppSession>false</DisallowStartOnRemoteAppSession>
    <UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
    <WakeToRun>false</WakeToRun>
    <ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
    <Priority>7</Priority>
  </Settings>
  <Actions Context="Author">
    <Exec>
      <Command>C:\IBC-Live\StartTWS.bat</Command>
      <Arguments>/INLINE</Arguments>
    </Exec>
  </Actions>
</Task>
mpolavieja commented 8 months ago

Thank you very much. I see that in your new task you have also cleared the option "Stop the task if it runs longer than 25 hours" in the settings tab. That makes sense to me as well.