freqtrade/freqtrade

View on GitHub

Showing 502 of 504 total issues

Function generic_visit has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def generic_visit(self, node):

        # space is not yet transferred from buy/sell to entry/exit and thereby has to be skipped.
        if isinstance(node, ast_comments.keyword):
            if node.arg == "space":
Severity: Minor
Found in freqtrade/strategy/strategyupdater.py - About 3 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 backtest_loop has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

    def backtest_loop(
            self, row: Tuple, pair: str, current_time: datetime, end_date: datetime,
            open_trade_count_start: int, trade_dir: Optional[LongShort],
            is_first: bool = True) -> int:
        """
Severity: Minor
Found in freqtrade/optimize/backtesting.py - About 3 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 price_to_precision has a Cognitive Complexity of 24 (exceeds 5 allowed). Consider refactoring.
Open

def price_to_precision(
    price: float,
    price_precision: Optional[float],
    precisionMode: Optional[int],
    *,
Severity: Minor
Found in freqtrade/exchange/exchange_utils.py - About 3 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

File wallets.py has 305 lines of code (exceeds 250 allowed). Consider refactoring.
Open

# pragma pylint: disable=W0603
""" Wallet """

import logging
from copy import deepcopy
Severity: Minor
Found in freqtrade/wallets.py - About 3 hrs to fix

    Function _get_adjust_trade_entry_for_candle has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

        def _get_adjust_trade_entry_for_candle(
                self, trade: LocalTrade, row: Tuple, current_time: datetime
        ) -> LocalTrade:
            current_rate: float = row[OPEN_IDX]
            current_profit = trade.calc_profit_ratio(current_rate)
    Severity: Minor
    Found in freqtrade/optimize/backtesting.py - About 3 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 _do_group_table_output has a Cognitive Complexity of 23 (exceeds 5 allowed). Consider refactoring.
    Open

    def _do_group_table_output(bigdf, glist, csv_path: Path, to_csv=False, ):
        for g in glist:
            # 0: summary wins/losses grouped by enter tag
            if g == "0":
                group_mask = ['enter_reason']
    Severity: Minor
    Found in freqtrade/data/entryexitanalysis.py - About 3 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

    File external_message_consumer.py has 300 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    ExternalMessageConsumer module
    
    Main purpose is to connect to external bot's message websocket to consume data
    from it
    Severity: Minor
    Found in freqtrade/rpc/external_message_consumer.py - About 3 hrs to fix

      File BaseEnvironment.py has 299 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import logging
      import random
      from abc import abstractmethod
      from enum import Enum
      from typing import List, Optional, Type, Union
      Severity: Minor
      Found in freqtrade/freqai/RL/BaseEnvironment.py - About 3 hrs to fix

        File api_v1.py has 296 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import logging
        from copy import deepcopy
        from typing import List, Optional
        
        from fastapi import APIRouter, Depends, Query
        Severity: Minor
        Found in freqtrade/rpc/api_server/api_v1.py - About 3 hrs to fix

          Function _rpc_balance has a Cognitive Complexity of 22 (exceeds 5 allowed). Consider refactoring.
          Open

              def _rpc_balance(self, stake_currency: str, fiat_display_currency: str) -> Dict:
                  """ Returns current account balance per crypto """
                  currencies: List[Dict] = []
                  total = 0.0
                  total_bot = 0.0
          Severity: Minor
          Found in freqtrade/rpc/rpc.py - About 3 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 is_tradesignal has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

              def is_tradesignal(self, action: int) -> bool:
                  """
                  Determine if the signal is a trade signal
                  e.g.: agent wants a Actions.Long_exit while it is in a Positions.short
                  """
          Severity: Minor
          Found in freqtrade/freqai/RL/Base5ActionRLEnv.py - About 2 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 print_results has a Cognitive Complexity of 21 (exceeds 5 allowed). Consider refactoring.
          Open

          def print_results(res_df: pd.DataFrame, analysis_groups: List[str], indicator_list: List[str],
                            csv_path: Path, rejected_signals=None, to_csv=False):
              if res_df.shape[0] > 0:
                  if analysis_groups:
                      _do_group_table_output(res_df, analysis_groups, to_csv=to_csv, csv_path=csv_path)
          Severity: Minor
          Found in freqtrade/data/entryexitanalysis.py - About 2 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 _get_close_rate_for_stoploss has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def _get_close_rate_for_stoploss(self, row: Tuple, trade: LocalTrade, exit: ExitCheckTuple,
                                               trade_dur: int) -> float:
                  # our stoploss was already lower than candle high,
                  # possibly due to a cancelled trade exit.
                  # exit at open price.
          Severity: Minor
          Found in freqtrade/optimize/backtesting.py - About 2 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 backtest has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def backtest(self, processed: Dict,
                           start_date: datetime, end_date: datetime) -> Dict[str, Any]:
                  """
                  Implement backtesting functionality
          
          
          Severity: Minor
          Found in freqtrade/optimize/backtesting.py - About 2 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 analyze_indicators has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def analyze_indicators(self):
          
                  pair_to_check = self.local_config['pairs'][0]
                  logger.info("Start checking for recursive bias")
          
          
          Severity: Minor
          Found in freqtrade/optimize/analysis/recursive.py - About 2 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 analyze_indicators has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

              def analyze_indicators(self, full_vars: VarHolder, cut_vars: VarHolder, current_pair: str):
                  # extract dataframes
                  cut_df: DataFrame = cut_vars.indicators[current_pair]
                  full_df: DataFrame = full_vars.indicators[current_pair]
          
          
          Severity: Minor
          Found in freqtrade/optimize/analysis/lookahead.py - About 2 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 find_existing_backtest_stats has a Cognitive Complexity of 20 (exceeds 5 allowed). Consider refactoring.
          Open

          def find_existing_backtest_stats(dirname: Union[Path, str], run_ids: Dict[str, str],
                                           min_backtest_date: Optional[datetime] = None) -> Dict[str, Any]:
              """
              Find existing backtest stats that match specified run IDs and load them.
              :param dirname: pathlib.Path object, or string pointing to the file.
          Severity: Minor
          Found in freqtrade/data/btanalysis.py - About 2 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

          File metrics.py has 278 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          import logging
          import math
          from datetime import datetime
          from typing import Dict, Tuple
          
          
          Severity: Minor
          Found in freqtrade/data/metrics.py - About 2 hrs to fix

            IDataHandler has 24 functions (exceeds 20 allowed). Consider refactoring.
            Open

            class IDataHandler(ABC):
            
                _OHLCV_REGEX = r'^([a-zA-Z_\d-]+)\-(\d+[a-zA-Z]{1,2})\-?([a-zA-Z_]*)?(?=\.)'
            
                def __init__(self, datadir: Path) -> None:
            Severity: Minor
            Found in freqtrade/data/history/datahandlers/idatahandler.py - About 2 hrs to fix

              Function gather_informative_pairs has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
              Open

                  def gather_informative_pairs(self) -> ListPairsWithTimeframes:
                      """
                      Internal method which gathers all informative pairs (user or automatically defined).
                      """
                      informative_pairs = self.informative_pairs()
              Severity: Minor
              Found in freqtrade/strategy/interface.py - About 2 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

              Severity
              Category
              Status
              Source
              Language