mlfinlab.online_data_structures.runs_bars
Advances in Financial Machine Learning, Marcos Lopez de Prado Chapter 2: Financial Data Structures: Runs Bars
Module for implementation of online runs bars data structures. This module allows for sequential input of ticks to form runs bars.
Module Contents
Classes
Class which implements runs bars compression. |
- class RunsBarGenerator(runs_type: str, expected_imbalance_window: int, exp_num_ticks_init: int, tick_fields_mapping: dict = None, aggressor_side_mapping: dict = None, exchange: str = None, contract: str = None)
-
Bases:
mlfinlab.online_data_structures.base_bars.BarGenerator
Class which implements runs bars compression.
- __metaclass__
- process_tick(tick: dict | list) bool
-
Process one tick or a list of ticks. :return: (bool) Flag indicating that a new bar was formed.
- set_threshold(threshold: float)
-
Set new threshold for bar calculations. :param threshold: (float) threshold to set.
- apply_tick_rule(price: float) Tuple[int, float]
-
Applies the tick rule as defined on page 29 of Advances in Financial Machine Learning. :param price: (float) Price at time t. :return: (Tuple[int, float]) The signed tick and tick difference.