mlfinlab.online_data_structures.dollar_bars
Advances in Financial Machine Learning, Marcos Lopez de Prado Chapter 2: Financial Data Structures: Dollar Bars
Module for implementation of online dollar bars data structures. This module allows for sequential input of ticks to form dollar bars.
Module Contents
Classes
Class which implements dollar bars compression. |
- class DollarBarGenerator(threshold: 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 dollar 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.