Scheduling

An example crontab for scheduling data collection and paper trading is provided in quantrocket.countdown.crontab.sh.

Code highlights

The following line executes the custom script each morning at 8 AM to initiate real-time data collection for the combo:

0 8 * * mon-fri quantrocket satellite exec 'codeload.calspread.collect_combo.collect_combo' --params 'universe:cl-fut' 'contract_months:[1,2]' 'tick_db:cl-combo-tick' 'until:16:30:00 America/New_York'

The trading strategy runs every minute from 9 AM to 3:59 PM, with orders simply logged to flightlog:

* 9-15 * * mon-fri quantrocket moonshot trade 'calspread-native-cl' | quantrocket flightlog log -n 'quantrocket.moonshot'

Install the crontab

This section assumes that you're not already using your countdown service for any scheduled tasks and that you haven't yet set its timezone. If you're already using countdown, you can edit your existing crontab, or add a new countdown service for New York tasks. See the usage guide for help.

All the commands on the provided crontab are intended to be run in New York time. By default, the countdown timezone is UTC:

In [1]:
from quantrocket.countdown import get_timezone, set_timezone
get_timezone()
Out[1]:
{'timezone': 'UTC'}

So first, set the countdown timezone to New York time:

In [2]:
set_timezone("America/New_York")
Out[2]:
{'status': 'successfully set timezone to America/New_York'}

Install the crontab by moving it to the /codeload directory. (First open a flightlog terminal so you can see if it loads successfully.)

In [3]:
# move file over unless it already exists
![ -e /codeload/quantrocket.countdown.crontab* ] && echo 'oops, the file already exists!' || mv quantrocket.countdown.crontab.sh /codeload/

You should see a success message in flightlog:

quantrocket.countdown: INFO Successfully loaded quantrocket.countdown.crontab.sh