hftbacktest.data.utils.migration2 module

convert(input_file, output_filename=None, ts_mul=1000)[source]

Converts HftBacktest v1 data file into HftBacktest v2 data.

Since v1 data uses -1 in timestamps to indicate the invalidity of the event on that processor side, there will be a loss of timestamp information. Furthermore, it cannot check its validity due to this. Validity should be confirmed during the v1 generation.

Parameters:
  • input_file (str) – Input filename for HftBacktest v1 data.

  • output_filename (str | None) – If provided, the converted data will be saved to the specified filename in npz format.

  • ts_mul (float) – The value is multiplied by the v1 format timestamp to adjust the timestamp unit. Typically, v1 uses microseconds, while v2 uses nanoseconds, so the default value is 1000.

Returns:

Converted data compatible with HftBacktest.

Return type:

ndarray[Any, dtype[_ScalarType_co]]