hftbacktest.data.utils.binancehistmktdata module

convert(depth_filename, trades_filename, output_filename=None, buffer_size=100000000, feed_latency=0, base_latency=0, depth_has_header=None, trades_has_header=None)[source]

Converts Binance Historical Market Data files into a format compatible with HftBacktest. Since it doesn’t have a local timestamp, it lacks feed latency information, which can result in a significant discrepancy between live and backtest results. Collecting feed data yourself or obtaining the high quality of data from a data vendor is strongly recommended.

https://www.binance.com/en/landing/data

Parameters:
  • depth_filename (str) – Depth data filename

  • trades_filename (str) – Trades data filename

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

  • buffer_size (int) – Sets a preallocated row size for the buffer.

  • feed_latency (float) – Artificial feed latency value to be added to the exchange timestamp to create local timestamp.

  • base_latency (float) – The value to be added to the feed latency. See correct_local_timestamp().

  • method – The method to correct reversed exchange timestamp events. See validation.correct().

  • depth_has_header (bool | None) – True if the given file has a header, it will automatically detect it if set to None.

  • trades_has_header (bool | None) – True if the given file has a header, it will automatically detect it if set to None.

Returns:

Converted data compatible with HftBacktest.

Return type:

ndarray[Any, dtype[_ScalarType_co]]

convert_snapshot(snapshot_filename, output_filename=None, feed_latency=0, has_header=None, ss_buffer_size=1000000)[source]

Converts Binance Historical Market Data files into a format compatible with HftBacktest. Since it doesn’t have a local timestamp, it lacks feed latency information, which can result in a significant discrepancy between live and backtest results. Collecting feed data yourself or obtaining the high quality of data from a data vendor is strongly recommended.

https://www.binance.com/en/landing/data

Parameters:
  • snapshot_filename (str) – Snapshot filename

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

  • feed_latency (float) – Artificial feed latency value to be added to the exchange timestamp to create local timestamp.

  • has_header (bool | None) – True if the given file has a header, it will automatically detect it if set to None.

  • ss_buffer_size (int)

Returns:

Converted data compatible with HftBacktest.

Return type:

ndarray[Any, dtype[_ScalarType_co]]