Label concurrency

q.label.concurrency counts the label intervals active at each observation. Event lifetimes include both their start and end observations, matching the endpoint convention used by triple-barrier labels.

Concurrent labels share future returns and are therefore not independent observations.

import pandas as pd

import qrt as q

observations = pd.date_range("2026-01-01", periods=7, name="datetime")
end_times = pd.Series(
    observations[[3, 5, 6]],
    index=observations[[0, 1, 4]].rename("event_time"),
    name="touch_time",
)
active = q.label.concurrency(observations, end_times)
pd.DataFrame({"concurrency": active})
concurrency
datetime
2026-01-01 1
2026-01-02 2
2026-01-03 2
2026-01-04 2
2026-01-05 2
2026-01-06 2
2026-01-07 1

The first event is active from positions 0 through 3, the second from 1 through 5, and the third from 4 through 6. Counts outside all event lifetimes are zero.

Back to top