freqtrade/freqtrade

View on GitHub

Showing 514 of 516 total issues

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")

        # check and report signals
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 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.
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

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:
        self._datadir = datadir
Severity: Minor
Found in freqtrade/data/history/datahandlers/idatahandler.py - About 2 hrs to fix

    File exchange_utils.py has 277 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    """
    Exchange support utils
    """
    
    from datetime import datetime, timedelta, timezone
    Severity: Minor
    Found in freqtrade/exchange/exchange_utils.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

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

              def calculate_reward(self, action: int) -> float:  # noqa: C901
                  """
                  An example reward function. This is the one function that users will likely
                  wish to inject their own creativity into.
      
      
      Severity: Minor
      Found in freqtrade/freqai/RL/BaseReinforcementLearningModel.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_adjust_trade_entry_for_candle has a Cognitive Complexity of 19 (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 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_ohlcv_as_lists has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def _get_ohlcv_as_lists(self, processed: Dict[str, DataFrame]) -> Dict[str, Tuple]:
              """
              Helper function to convert a processed dataframes into lists for performance reasons.
      
              Used by backtest() - so keep this optimized for performance.
      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_loop has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def backtest_loop(
              self,
              row: Tuple,
              pair: str,
              current_time: datetime,
      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 _enter_trade has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

          def _enter_trade(
              self,
              pair: str,
              row: Tuple,
              direction: LongShort,
      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_candles_and_indicators has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring.
      Open

      def _analyze_candles_and_indicators(pair, trades: pd.DataFrame, signal_candles: pd.DataFrame):
          buyf = signal_candles
      
          if len(buyf) > 0:
              buyf = buyf.set_index("date", drop=False)
      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

      BaseEnvironment has 23 functions (exceeds 20 allowed). Consider refactoring.
      Open

      class BaseEnvironment(gym.Env):
          """
          Base class for environments. This class is agnostic to action count.
          Inherited classes customize this to include varying action counts/types,
          See RL/Base5ActionRLEnv.py and RL/Base4ActionRLEnv.py
      Severity: Minor
      Found in freqtrade/freqai/RL/BaseEnvironment.py - About 2 hrs to fix

        File RemotePairList.py has 268 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        """
        Remote PairList provider
        
        Provides pair list fetched from a remote source
        """
        Severity: Minor
        Found in freqtrade/plugins/pairlist/RemotePairList.py - About 2 hrs to fix

          Function purge_old_models has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def purge_old_models(self) -> None:
                  num_keep = self.freqai_info["purge_old_models"]
                  if not num_keep:
                      return
                  elif isinstance(num_keep, bool):
          Severity: Minor
          Found in freqtrade/freqai/data_drawer.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 step has a Cognitive Complexity of 18 (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/Base3ActionRLEnv.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_roi has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def _get_close_rate_for_roi(
                  self, row: Tuple, trade: LocalTrade, exit: ExitCheckTuple, trade_dur: int
              ) -> float:
                  is_short = trade.is_short or False
                  leverage = trade.leverage or 1.0
          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 _params_pretty_print has a Cognitive Complexity of 18 (exceeds 5 allowed). Consider refactoring.
          Open

              def _params_pretty_print(
                  params, space: str, header: str, non_optimized: Optional[Dict] = None
              ) -> None:
                  if space in params or (non_optimized and space in non_optimized):
                      space_params = HyperoptTools._space_params(params, space, 5)
          Severity: Minor
          Found in freqtrade/optimize/hyperopt_tools.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 strategy_resolver.py has 262 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          # pragma pylint: disable=attribute-defined-outside-init
          
          """
          This module load custom strategies
          """
          Severity: Minor
          Found in freqtrade/resolvers/strategy_resolver.py - About 2 hrs to fix

            File VolumePairList.py has 261 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            """
            Volume PairList provider
            
            Provides dynamic pair list based on trade volumes
            """
            Severity: Minor
            Found in freqtrade/plugins/pairlist/VolumePairList.py - About 2 hrs to fix

              Function filter_pairlist has a Cognitive Complexity of 17 (exceeds 5 allowed). Consider refactoring.
              Open

                  def filter_pairlist(self, pairlist: List[str], tickers: Dict) -> List[str]:
                      """
                      Filters and sorts pairlist and returns the whitelist again.
                      Called on each bot iteration - please use internal caching if necessary
                      :param pairlist: pairlist to filter or sort
              Severity: Minor
              Found in freqtrade/plugins/pairlist/MarketCapPairList.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