def is_volume_rising(self, min_percentage: int): # we check raising against mean volume and against last tick volume - either of both. # print('is_volume_rising: volume_forecast={}, volume_meanPart_entry={}, min_percentage={}, p_volume={}'.format( # self.volume_forecast, self.volume_mean_part_entry, min_percentage, self.tick_previous.volume # )) if self.volume_mean_part_entry == 0: # we don't have volume information like for FOREX return True against_mean = MyMath.divide( self.volume_forecast, self.volume_mean_part_entry) > (100 + min_percentage) / 100 against_last = MyMath.divide( self.volume_forecast, self.tick_previous.volume) > (100 + min_percentage) / 100 return against_mean or against_last
def __init__(self, api: PatternBreakoutApi): self.sys_config = api.sys_config self.function_cont = api.function_cont self.constraints = api.constraints self.tick_previous = api.tick_previous self.tick_breakout = api.tick_breakout self.volume_mean_part_entry = api.volume_mean_for_breakout self.volume_forecast = api.volume_forecast self.breakout_date = self.tick_breakout.date self.volume_change_pct = MyMath.divide(self.tick_breakout.volume, self.tick_previous.volume, 2, 0) self.tolerance_pct = self.constraints.tolerance_pct self.bound_upper = MyMath.round_smart( self.function_cont.get_upper_value(self.tick_breakout.f_var)) self.bound_lower = MyMath.round_smart( self.function_cont.get_lower_value(self.tick_breakout.f_var)) self.pattern_breadth = MyMath.round_smart(self.bound_upper - self.bound_lower) self.tolerance_range = MyMath.round_smart(self.pattern_breadth * self.tolerance_pct) self.limit_upper = MyMath.round_smart(self.bound_upper + self.tolerance_range) self.limit_lower = MyMath.round_smart(self.bound_lower - self.tolerance_range) if api.forecast_breakout_direction == FD.NONE: self.breakout_direction = self.__get_breakout_direction__() else: self.breakout_direction = api.forecast_breakout_direction self.sign = 1 if self.breakout_direction == FD.ASC else -1 self.check_dict = {}
def __is_relation_heights_compliant__(self, height_end: float, height_start: float): if len(self.height_end_start_relation_bounds) == 0: # no relation defined return True if height_start == 0: return False end_start_relation = MyMath.divide(height_end, height_start) return self.height_end_start_relation_bounds[0] <= end_start_relation <= self.height_end_start_relation_bounds[1]
def get_details_for_annotations(self): if self.sys_config.period == PRD.INTRADAY: date_str = self.tick_breakout.time_str_for_f_var else: date_str = self.tick_breakout.date_str_for_f_var vol_change = (MyMath.divide(self.volume_forecast, self.volume_mean_part_entry, 2) - 1) * 100 return '{} ({}) - Volume change: {}%'.format( date_str, self.tick_breakout.position, round(vol_change, 0))
def __calculate_regression_values_for_component__( self, reg_comp: FibonacciDescendingRegressionComponent): index_comp_id = self.comp_id_list_reg.index(reg_comp.comp_id) if index_comp_id > 0: reg_comp_prev = self.comp_dic[self.comp_id_list_reg[index_comp_id - 1]] ret_comp_prev = self.comp_dic[self.comp_id_list_ret[index_comp_id - 1]] reg_comp.regression_value_against_last_regression = round( reg_comp_prev.min - reg_comp.min, 2) reg_comp.regression_value_against_last_retracement = round( ret_comp_prev.min - reg_comp.min, 2) # if reg_comp_prev.get_end_to_end_range() == 0: # ToDo - why is this happen ??? # print('if reg_comp_prev.get_end_to_end_range() == 0') reg_comp.regression_pct_against_last_regression = \ MyMath.divide(reg_comp.get_end_to_end_range(), reg_comp_prev.get_end_to_end_range(), 3)
def is_volume_rising(self, volume_compare, min_percentage: int): return MyMath.divide(self.volume, volume_compare) > (100 + min_percentage) / 100