Skip to content

Commit

Permalink
docs: clarify the docstring about snapshot timestamp adjustment.
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaz001 committed Aug 12, 2024
1 parent 41286ee commit 0659f1e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions py-hftbacktest/hftbacktest/data/utils/databento.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ def convert(
r"""
Converts a DataBento L3 Market-By-Order data file into a format compatible with HftBacktest.
DataBento's historical data includes a Start-of-Day (SOD) snapshot for CME data. In the snapshot, the exchange
timestamp represents the original time when the order was submitted, and the data is sorted in chronological order.
This ensures that orders are built with the correct price-time priority. However, since these timestamps are in the
past (before the clear message), the exchange timestamp is artificially set to the local timestamp to indicate the
snapshot. This adjustment maintains the chronological order of exchange timestamps during multi-day backtesting.
Args:
input_file: DataBento's DBN file. e.g. *.mbo.dbn.zst
symbol: Specify the symbol to process in the given file. If the file contains multiple symbols, the symbol
Expand Down Expand Up @@ -93,12 +99,7 @@ def convert(
else:
raise ValueError(side)

# DataBento's historical data includes a Start-of-Day (SOD) snapshot for CME data. In this snapshot, the
# exchange timestamp represents the original time when the order was submitted, and the data is sorted in
# chronological order. This ensures that orders are built with the correct price-time priority.
# However, since these timestamps are in the past, the exchange timestamp is artificially set to the local
# timestamp to indicate the snapshot.
# This adjustment maintains the chronological order of exchange timestamps during multi-day backtesting.
# Adjusts the timestamps for the snapshot.
if DEPTH_CLEAR_EVENT == DEPTH_CLEAR_EVENT:
snapshot_ts = local_ts
if local_ts != snapshot_ts:
Expand Down

0 comments on commit 0659f1e

Please sign in to comment.