quantlab.utils.date_range.bar_label#

quantlab.utils.date_range.bar_label(value)[source]#

Return the label metrics.json and the report write for a bar.

A bar at midnight is written as an ISO date, any other bar as a full ISO timestamp, so daily labels stay dates while intraday labels keep their time of day; label_ns reads either back.

Parameters:
value

A bar: a numpy.datetime64, a pd.Timestamp or a string pd.Timestamp accepts.

Returns:
str

The label.

Examples

>>> bar_label(np.datetime64("2024-01-02T00:00"))
'2024-01-02'
>>> bar_label(pd.Timestamp("2024-01-02 15:30"))
'2024-01-02T15:30:00'