Пример #1
0
    def __init__(self, metric: str, num_prev_bars: int,
                 expected_imbalance_window: int, exp_num_ticks_init: int,
                 exp_num_ticks_constraints: List, batch_size: int,
                 analyse_thresholds: bool):
        """
        Constructor

        :param metric: (str) type of imbalance bar to create. Example: "dollar_imbalance"
        :param num_prev_bars: (int) Window size for E[T]s (number of previous bars to use for expected number of ticks estimation)
        :param expected_imbalance_window: (int) EMA window used to estimate expected imbalance
        :param exp_num_ticks_init: (int) Initial number of expected ticks
        :param exp_num_ticks_constraints (list) Minimum and maximum possible number of expected ticks. Used to control bars sampling convergence
        :param batch_size: (int) Number of rows to read in from the csv, per batch
        :param analyse_thresholds: (bool) flag to return thresholds values (theta, exp_num_ticks, exp_imbalance) in a
                                          form of Pandas DataFrame
        """
        BaseImbalanceBars.__init__(self, metric, batch_size,
                                   expected_imbalance_window,
                                   exp_num_ticks_init, analyse_thresholds)

        # EMA Imbalance specific  hyper parameters
        self.num_prev_bars = num_prev_bars
        if exp_num_ticks_constraints is None:
            self.min_exp_num_ticks = 0
            self.max_exp_num_ticks = np.inf
        else:
            self.min_exp_num_ticks = exp_num_ticks_constraints[0]
            self.max_exp_num_ticks = exp_num_ticks_constraints[1]
Пример #2
0
    def __init__(self, metric: str, expected_imbalance_window: int,
                 exp_num_ticks_init: int, batch_size: int,
                 analyse_thresholds: bool):
        """
        Constructor

        :param metric: (str) type of imbalance bar to create. Example: "dollar_imbalance"
        :param expected_imbalance_window: (int) EMA window used to estimate expected imbalance
        :param exp_num_ticks_init: (int) Initial number of expected ticks
        :param batch_size: (int) Number of rows to read in from the csv, per batch
        :param analyse_thresholds: (bool) Flag to save  and return thresholds used to sample imbalance bars
        """
        BaseImbalanceBars.__init__(self, metric, batch_size,
                                   expected_imbalance_window,
                                   exp_num_ticks_init, analyse_thresholds)
Пример #3
0
    def __init__(self, file_path_or_df: Tuple[str, pd.DataFrame], metric: str,
                 expected_imbalance_window: int, exp_num_ticks_init: int,
                 batch_size: int, analyse_thresholds: bool):
        """
        Constructor

        :param file_path_or_df: (str or pd.DataFrame) Path to the csv file or Pandas Data Frame containing raw tick data in the format[date_time, price, volume]
        :param metric: (str) type of imbalance bar to create. Example: "dollar_imbalance"
        :param expected_imbalance_window: (int) EMA window used to estimate expected imbalance
        :param exp_num_ticks_init: (int) Initial number of expected ticks
        :param batch_size: (int) Number of rows to read in from the csv, per batch
        :param analyse_thresholds: (bool) Flag to save  and return thresholds used to sample imbalance bars
        """
        BaseImbalanceBars.__init__(self, file_path_or_df, metric, batch_size,
                                   expected_imbalance_window,
                                   exp_num_ticks_init, analyse_thresholds)