def get_function_container_by_api(api: PatternFunctionContainerFactoryApi): pattern_type = api.pattern_type sys_config = api.sys_config df = api.pattern_range.get_related_part_from_data_frame(api.df_min_max) f_upper = api.get_f_upper() f_lower = api.get_f_lower() f_cont = PatternFunctionContainerFactory.get_function_container( sys_config, pattern_type, df, f_lower, f_upper) if FT.is_pattern_type_any_head_shoulder(api.pattern_type): f_cont.set_tick_for_helper( api.pattern_range.hsf.tick_shoulder_left) elif FT.is_pattern_type_any_fibonacci(api.pattern_type): f_cont.max_positions_after_tick_for_helper = api.pattern_range.fib_form.max_positions_after_tick_for_helper return f_cont
def __check_for_loop_break__(pattern: Pattern, counter: int, number_of_positions: int, tick: WaveTick) -> bool: if pattern.breakout is not None: return True if counter > number_of_positions: # maximal number for the whole pattern (from start) return True if pattern.function_cont.is_tick_breakout_on_wrong_side(tick): return True if counter > pattern.breakout_required_after_ticks: return True if tick.f_var > pattern.function_cont.f_var_cross_f_upper_f_lower > 0: if not FT.is_pattern_type_any_fibonacci(pattern.pattern_type): return True # if not function_cont.is_regression_value_in_pattern_for_f_var(tick.f_var - 6): # # check the last value !!! in some IMPORTANT cases is the breakout just on that day... # return True if not pattern.function_cont.is_tick_inside_pattern_range(tick): return True return False