quantlab.analysis.factor_report.most_common_spacing#
- quantlab.analysis.factor_report.most_common_spacing(timestamps)[source]#
Return the most common spacing between consecutive timestamps.
This is the rule
RawDataset.time_intervaluses: the mode rather than the minimum, so weekend and holiday gaps do not change the answer.- Parameters:
- timestampsxarray.DataArray, pandas.Index or numpy.ndarray
Sorted
datetime64timestamps; at least two.
- Returns:
- numpy.timedelta64
The most common spacing.
- Raises:
- ValueError
If fewer than two timestamps are given.
Examples
>>> most_common_spacing(pd.date_range("2024-01-01", periods=10, freq="B")) np.timedelta64(86400000000,'us')