freqtrade/freqtrade

View on GitHub

Showing 516 of 518 total issues

Function strategy_safe_wrapper has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def strategy_safe_wrapper(f: F, message: str = "", default_retval=None, supress_error=False) -> F:
    """
    Wrapper around user-provided methods and functions.
    Caches all exceptions and returns either the default_retval (if it's not None) or raises
    a StrategyError exception, which then needs to be handled by the calling method.
Severity: Minor
Found in freqtrade/strategy/strategy_wrapper.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 text_table_add_metrics has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

def text_table_add_metrics(strat_results: Dict) -> str:
    if len(strat_results["trades"]) > 0:
        best_trade = max(strat_results["trades"], key=lambda x: x["profit_ratio"])
        worst_trade = min(strat_results["trades"], key=lambda x: x["profit_ratio"])

Severity: Minor
Found in freqtrade/optimize/optimize_reports/bt_output.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 step has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def step(self, action: int):
        """
        Logic for a single step (incrementing one candle in time)
        by the agent
        :param: action: int = the action type that the agent plans
Severity: Minor
Found in freqtrade/freqai/RL/Base5ActionRLEnv.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 _resolve_pairs_list has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
Open

    def _resolve_pairs_list(self, config: Config) -> None:
        """
        Helper for download script.
        Takes first found:
        * -p (pairs argument)
Severity: Minor
Found in freqtrade/configuration/configuration.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 _adjust_trade_position_internal has 12 arguments (exceeds 4 allowed). Consider refactoring.
Open

    def _adjust_trade_position_internal(
Severity: Major
Found in freqtrade/strategy/interface.py - About 1 hr to fix

    Function adjust_trade_position has 12 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def adjust_trade_position(
    Severity: Major
    Found in freqtrade/strategy/interface.py - About 1 hr to fix

      Function _download_pair_history has 12 arguments (exceeds 4 allowed). Consider refactoring.
      Open

      def _download_pair_history(
      Severity: Major
      Found in freqtrade/data/history/history_utils.py - About 1 hr to fix

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

            def __init__(self, config: Config) -> None:
                """
                Init all variables and objects the bot needs to work
                :param config: configuration dict, you can use Configuration.get_config()
                to get the config dict.
        Severity: Minor
        Found in freqtrade/freqtradebot.py - About 1 hr to fix

          Function _ft_load_params has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def _ft_load_params(self, params: Dict, space: str, hyperopt: bool = False) -> None:
                  """
                  Set optimizable parameter values.
                  :param params: Dictionary with new parameter values.
                  """
          Severity: Minor
          Found in freqtrade/strategy/hyper.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 global_stop has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def global_stop(
                  self, now: Optional[datetime] = None, side: LongShort = "long"
              ) -> Optional[PairLock]:
                  if not now:
                      now = datetime.now(timezone.utc)
          Severity: Minor
          Found in freqtrade/plugins/protectionmanager.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 visit_ClassDef has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def visit_ClassDef(self, node):
                  # check if the class is derived from IStrategy
                  if any(
                      isinstance(base, ast_comments.Name) and base.id == "IStrategy" for base in node.bases
                  ):
          Severity: Minor
          Found in freqtrade/strategy/strategyupdater.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 load_data has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def load_data(self, coin: str, dk: FreqaiDataKitchen) -> Any:  # noqa: C901
                  """
                  loads all data required to make a prediction on a sub-train time range
                  :returns:
                  :model: User trained model which can be inferenced for new predictions
          Severity: Minor
          Found in freqtrade/freqai/data_drawer.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 step has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def step(self, action: int):
                  """
                  Logic for a single step (incrementing one candle in time)
                  by the agent
                  :param: action: int = the action type that the agent plans
          Severity: Minor
          Found in freqtrade/freqai/RL/Base4ActionRLEnv.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 text_table_recursive_analysis_instances has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def text_table_recursive_analysis_instances(recursive_instances: List[RecursiveAnalysis]):
                  startups = recursive_instances[0]._startup_candle
                  headers = ["indicators"]
                  for candle in startups:
                      headers.append(candle)
          Severity: Minor
          Found in freqtrade/optimize/analysis/recursive_helpers.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 _check_empty_df has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def _check_empty_df(
                  self,
                  pairdf: DataFrame,
                  pair: str,
                  timeframe: str,
          Severity: Minor
          Found in freqtrade/data/history/datahandlers/idatahandler.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 _print_objs_tabular has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def _print_objs_tabular(objs: List, print_colorized: bool) -> None:
              if print_colorized:
                  colorama_init(autoreset=True)
                  red = Fore.RED
                  yellow = Fore.YELLOW
          Severity: Minor
          Found in freqtrade/commands/list_commands.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 set_custom_data has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def set_custom_data(trade_id: int, key: str, value: Any) -> None:
                  value_type = type(value).__name__
          
                  if value_type not in CustomDataWrapper.unserialized_types:
                      try:
          Severity: Minor
          Found in freqtrade/persistence/custom_data.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 load_backtest_data has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

          def load_backtest_data(filename: Union[Path, str], strategy: Optional[str] = None) -> pd.DataFrame:
              """
              Load backtest data file.
              :param filename: pathlib.Path object, or string pointing to a file or directory
              :param strategy: Strategy to load - mainly relevant for multi-strategy backtests
          Severity: Minor
          Found in freqtrade/data/btanalysis.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 _parse_args has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
          Open

              def _parse_args(self) -> argparse.Namespace:
                  """
                  Parses given arguments and returns an argparse Namespace instance.
                  """
                  parsed_arg = self.parser.parse_args(self.args)
          Severity: Minor
          Found in freqtrade/commands/arguments.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 custom_stake_amount has 11 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def custom_stake_amount(
          Severity: Major
          Found in freqtrade/strategy/interface.py - About 1 hr to fix
            Severity
            Category
            Status
            Source
            Language