[Unit] Description=ibkr-quant daily run: today's bars, then MOC orders on rebalance sessions After=ibgateway.service # make gateway restarts a Gateway that has lost IBKR or its historical data # farm. Retries cover today's bar arriving late (delayed data) and Gateway # restarts; make submit refuses to double-submit while orders are open and # succeeds once IBKR holds every order an earlier run sent. # Every 10 minutes from 09:50 ET until the 15:45 end of the order window: on # 2026-10-12 six retries 5 minutes apart gave up after 35 minutes while the # data farm was down. The start limit is a backstop; ExecCondition ends the day. StartLimitIntervalSec=21600 StartLimitBurst=34 [Service] Type=oneshot WorkingDirectory=%h/projects/ibkr-quant Environment=PATH=%h/.local/bin:/usr/local/bin:/usr/bin:/bin # Past 15:45 ET make submit cannot send orders; a failed condition skips the # start without counting as a failure, so it is not restarted. ExecCondition=/bin/sh -c 'test "$(TZ=America/New_York date +%%H%%M)" -lt 1545' ExecStartPre=/usr/bin/make gateway GATEWAY_ARGS=--history ExecStart=/usr/bin/make bars submit Restart=on-failure RestartSec=600