コード例 #1
0
def get_control_data_for_process_name(data, process_name):
    data_control = dataControlProcess(data)
    diag_process_config = diagProcessConfig(data)

    control_data = data_control.get_dict_of_control_processes()
    control_data_for_process = control_data[process_name]

    all_config = diag_process_config.get_config_dict(process_name)

    time_to_run = diag_process_config.is_it_time_to_run(process_name)
    previous_finished = diag_process_config.has_previous_process_finished_in_last_day(
        process_name)
    time_to_stop = diag_process_config.is_it_time_to_stop(process_name)
    right_machine = diag_process_config.is_this_correct_machine(process_name)

    data_for_process = dataForProcess(
        name=process_name,
        running=control_data_for_process.currently_running,
        start=control_data_for_process.last_start_time.strftime(
            short_date_string),
        end=control_data_for_process.last_end_time.strftime(short_date_string),
        status=control_data_for_process.status,
        finished_in_last_day=control_data_for_process.
        has_process_finished_in_last_day(),
        start_time=all_config["start_time"],
        end_time=all_config["end_time"],
        required_machine=all_config["machine_name"],
        previous_required=all_config["previous_process"],
        right_machine=right_machine,
        time_to_run=time_to_run,
        time_to_stop=time_to_stop,
        previous_finished=previous_finished,
    )

    return data_for_process
コード例 #2
0
def view_strategy_config(data):
    diag_config = diagProcessConfig(data)
    strategy_name = get_valid_strategy_name_from_user(data=data)
    result_dict = diag_config.get_strategy_dict_for_strategy(strategy_name)
    for key, value in result_dict.items():
        print("%s: %s" % (str(key), str(value)))
    print("\nAbove should be modified in private_config.yaml files")
コード例 #3
0
def view_process_config(data):
    diag_config = diagProcessConfig(data)
    process_name = get_process_name(data)
    result_dict = diag_config.get_config_dict(process_name)
    for key, value in result_dict.items():
        print("%s: %s" % (str(key), str(value)))
    print("\nAbove should be modified in private_config.yaml files")
コード例 #4
0
ファイル: broker.py プロジェクト: ineedmore/pysystemtrade
    def less_than_one_hour_of_trading_leg_for_contract(
            self, contract: futuresContract):

        diag_controls = diagProcessConfig()
        hours_left_before_process_finishes = diag_controls.how_long_in_hours_before_trading_process_finishes(
        )

        if hours_left_before_process_finishes < 1:
            ## irespective of instrument traded
            return True

        result = self.data.broker_futures_contract.less_than_one_hour_of_trading_leg_for_contract(
            contract)

        return result
コード例 #5
0
def _get_list_of_timer_functions(data,
                                 process_name,
                                 list_of_timer_names_and_functions,
                                 use_strategy_config=False):
    list_of_timer_functions = []
    diag_process = diagProcessConfig(data)

    for entry in list_of_timer_names_and_functions:
        if use_strategy_config:
            strategy_name, object, function_object = entry
            method_name = strategy_name
            run_on_completion_only = False
        else:
            method_name, object = entry
            function_object = getattr(object, method_name)
            run_on_completion_only = diag_process.run_on_completion_only(
                process_name, method_name)

        log = object.data.log
        frequency_minutes = diag_process.frequency_for_process_and_method(
            process_name, method_name, use_strategy_config=use_strategy_config)
        max_executions = diag_process.max_executions_for_process_and_method(
            process_name, method_name, use_strategy_config=use_strategy_config)
        timer_class = timerClassWithFunction(
            method_name,
            function_object,
            data,
            process_name=process_name,
            frequency_minutes=frequency_minutes,
            max_executions=max_executions,
            run_on_completion_only=run_on_completion_only,
            log=log,
        )
        list_of_timer_functions.append(timer_class)

    list_of_timer_functions = listOfTimerFunctions(list_of_timer_functions)
    return list_of_timer_functions
コード例 #6
0
def get_methods_dict(data):
    diag_process_config = diagProcessConfig(data)
    all_methods_dict = diag_process_config.get_process_configuration_for_item_name(
        "methods")

    return all_methods_dict
コード例 #7
0
def get_process_with_strategies(data):
    diag_process_config = diagProcessConfig(data)
    process_with_strategies = (
        diag_process_config.get_list_of_processes_run_over_strategies())
    return process_with_strategies
コード例 #8
0
def get_strategy_class_object_config(process_name, data, strategy_name):
    diag_config = diagProcessConfig(data)
    config_this_process = diag_config.get_strategy_dict_for_process(
        process_name, strategy_name
    )
    return config_this_process