QuantRocket logo


Realtime Data Collection

For paper trading we will collect native combo data each day for the calendar spread that interests us.

Create real-time database

First, we create a tick db for collecting bid and ask prices. We associate it with the 'cl-fut' universe (because this argument is required) but in reality we will specify a particular combo each time we collect data. Importantly, we specify primary_exchange=True to indicate that we want to collect native combo data. (See the usage guide for more on combos.)

Then, we create an aggregate database of 1-minute bars from the tick database. As data is collected into the tick database, it will automatically be aggregated into 1-minute bars in the aggregate database.

Collect real-time data

Each day, we want to collect native combo market data for the calendar spread of month 1 and 2 (in this example). The exact contracts which make up this combo will change over time, specifically, on each new rollover date.

We create a custom script to carry out our data collection strategy. The custom code is provided in a function called collect_combo in the file collect_combo.py. The function performs the following steps:

Running the custom code

The custom code can be run by importing the function in Python or at the command line using the satellite service. The advantage of using the satellite service is that we can schedule the command to run daily from our countdown service crontab (see the scheduling notebook). The command is shown below. It can be executed manually for testing purposes by executing the following cell:

Next Up

Part 5: Moonshot Native Spread Strategy