Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Time

Overview

Time related data in roboquant uses the Python datetime object with the timezone set to UTC.

For example event.time is always in timezone UTC, even if the event originates from an exchange in a different timezone. This makes it fast and robust when comparing dates.

Timeframe

A timeframe represents a period in time with a certain start- and end-time. Like other time variables in roboquant, these are Python datetime objects using the UTC timezone.

The start-time of a timeframe is always inclusive, but the end-time can be either inclusive or exclusive.

[2020-01-01 00:00:00 ― 2024-01-01 00:00:00]
[2021-01-01 00:12:00 ― 2021-10-01 00:13:00>

You can split timeframes as well as sample from a timeframe, useful in certain types of back test.

Timeline

Timeline implements a list of datetime objects. Like the other time variables, the individual entries are Python datetime objects using the UTC timezone.

Timeline entries should be added in ascending order. This makes it suitable to act as the index of a TimeSeries.

2
2024-01-01 00:00:00+00:00

Typically you don’t create timelines manually, but rather they are returned as the result of a method call.

TimeSeries

TimeSeries implements a multi-variate timeseries. It extends Pandas DataFrame with the index always being a timeline and the columns are always float values.

Output
IBM Stock prices
                                  IBM
2020-01-02 05:00:00+00:00   98.017044
2020-01-03 05:00:00+00:00   97.235359
2020-01-06 05:00:00+00:00   97.061638
2020-01-07 05:00:00+00:00   97.126778
2020-01-08 05:00:00+00:00   97.937431
...                               ...
2026-09-24 04:00:00+00:00  227.059998
2026-09-25 04:00:00+00:00  225.509995
2026-09-28 04:00:00+00:00  220.669998
2026-09-29 04:00:00+00:00  219.990005
2026-09-30 04:00:00+00:00  219.929993

[1695 rows x 1 columns]
Asset correlations:
           INTC      TSLA      MSFT       IBM       JPM
INTC  1.000000  0.144592 -0.033631  0.058141  0.255665
TSLA  0.144592  1.000000  0.714278  0.701025  0.746224
MSFT -0.033631  0.714278  1.000000  0.880512  0.879392
IBM   0.058141  0.701025  0.880512  1.000000  0.942873
JPM   0.255665  0.746224  0.879392  0.942873  1.000000
Equity
                             pnl/equity
2020-01-02 05:00:00+00:00  1.000000e+06
2020-01-03 05:00:00+00:00  1.000000e+06
2020-01-06 05:00:00+00:00  1.000000e+06
2020-01-07 05:00:00+00:00  1.000000e+06
2020-01-08 05:00:00+00:00  1.000000e+06
...                                 ...
2026-09-24 04:00:00+00:00  2.319510e+06
2026-09-25 04:00:00+00:00  2.359148e+06
2026-09-28 04:00:00+00:00  2.318860e+06
2026-09-29 04:00:00+00:00  2.292761e+06
2026-09-30 04:00:00+00:00  2.286357e+06

[1695 rows x 1 columns]