freqtrade/freqtrade

View on GitHub
freqtrade/freqai/freqai_interface.py

Summary

Maintainability
F
3 days
Test Coverage

File freqai_interface.py has 829 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
import threading
import time
from abc import ABC, abstractmethod
from collections import deque
Severity: Major
Found in freqtrade/freqai/freqai_interface.py - About 1 day to fix

    Function start_backtesting has a Cognitive Complexity of 29 (exceeds 5 allowed). Consider refactoring.
    Open

        def start_backtesting(
            self, dataframe: DataFrame, metadata: dict, dk: FreqaiDataKitchen, strategy: IStrategy
        ) -> FreqaiDataKitchen:
            """
            The main broad execution for backtesting. For backtesting, each pair enters and then gets
    Severity: Minor
    Found in freqtrade/freqai/freqai_interface.py - About 4 hrs to fix

    Cognitive Complexity

    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

    A method's cognitive complexity is based on a few simple rules:

    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
    • Code is considered more complex for each "break in the linear flow of the code"
    • Code is considered more complex when "flow breaking structures are nested"

    Further reading

    Function __init__ has 46 lines of code (exceeds 25 allowed). Consider refactoring.
    Open

        def __init__(self, config: Config) -> None:
    
            self.config = config
            self.assert_config(self.config)
            self.freqai_info: Dict[str, Any] = config["freqai"]
    Severity: Minor
    Found in freqtrade/freqai/freqai_interface.py - About 1 hr to fix

      Function _start_scanning has a Cognitive Complexity of 10 (exceeds 5 allowed). Consider refactoring.
      Open

          def _start_scanning(self, strategy: IStrategy) -> None:
              """
              Function designed to constantly scan pairs for retraining on a separate thread (intracandle)
              to improve model youth. This function is agnostic to data preparation/collection/storage,
              it simply trains on what ever data is available in the self.dd.
      Severity: Minor
      Found in freqtrade/freqai/freqai_interface.py - About 1 hr to fix

      Cognitive Complexity

      Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

      A method's cognitive complexity is based on a few simple rules:

      • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
      • Code is considered more complex for each "break in the linear flow of the code"
      • Code is considered more complex when "flow breaking structures are nested"

      Further reading

      Function extract_data_and_train_model has 6 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def extract_data_and_train_model(
      Severity: Minor
      Found in freqtrade/freqai/freqai_interface.py - About 45 mins to fix

        Function start_live has 5 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def start_live(
        Severity: Minor
        Found in freqtrade/freqai/freqai_interface.py - About 35 mins to fix

          Function start_backtesting has 5 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def start_backtesting(
          Severity: Minor
          Found in freqtrade/freqai/freqai_interface.py - About 35 mins to fix

            Function set_initial_historic_predictions has 5 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def set_initial_historic_predictions(
            Severity: Minor
            Found in freqtrade/freqai/freqai_interface.py - About 35 mins to fix

              Function train has 5 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def train(self, unfiltered_df: DataFrame, pair: str,
              Severity: Minor
              Found in freqtrade/freqai/freqai_interface.py - About 35 mins to fix

                Function build_strategy_return_arrays has 5 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def build_strategy_return_arrays(
                Severity: Minor
                Found in freqtrade/freqai/freqai_interface.py - About 35 mins to fix

                  Function log_backtesting_progress has 5 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def log_backtesting_progress(self, tr_train: TimeRange, pair: str,
                  Severity: Minor
                  Found in freqtrade/freqai/freqai_interface.py - About 35 mins to fix

                    Function start has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
                    Open

                        def start(self, dataframe: DataFrame, metadata: dict, strategy: IStrategy) -> DataFrame:
                            """
                            Entry point to the FreqaiModel from a specific pair, it will train a new model if
                            necessary before making the prediction.
                    
                    
                    Severity: Minor
                    Found in freqtrade/freqai/freqai_interface.py - About 25 mins to fix

                    Cognitive Complexity

                    Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.

                    A method's cognitive complexity is based on a few simple rules:

                    • Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
                    • Code is considered more complex for each "break in the linear flow of the code"
                    • Code is considered more complex when "flow breaking structures are nested"

                    Further reading

                    There are no issues that match your filters.

                    Category
                    Status