freqtrade/freqtrade

View on GitHub
freqtrade/strategy/interface.py

Summary

Maintainability
F
1 wk
Test Coverage

File interface.py has 1182 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
IStrategy interface
This module defines the interface to apply for strategies
"""
import logging
Severity: Major
Found in freqtrade/strategy/interface.py - About 3 days to fix

    IStrategy has 50 functions (exceeds 20 allowed). Consider refactoring.
    Open

    class IStrategy(ABC, HyperStrategyMixin):
        """
        Interface for freqtrade strategies
        Defines the mandatory structure must follow any custom strategies
    
    
    Severity: Minor
    Found in freqtrade/strategy/interface.py - About 7 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 __init__ has a Cognitive Complexity of 13 (exceeds 5 allowed). Consider refactoring.
      Open

          def __init__(self, config: Config) -> None:
              self.config = config
              # Dict to determine if analysis is necessary
              self._last_candle_seen_per_pair: Dict[str, datetime] = {}
              super().__init__(config)
      Severity: Minor
      Found in freqtrade/strategy/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 _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(self, trade: Trade, current_time: datetime,
        Severity: Major
        Found in freqtrade/strategy/interface.py - About 1 hr to fix

          Function custom_stake_amount has 11 arguments (exceeds 4 allowed). Consider refactoring.
          Open

              def custom_stake_amount(self, pair: str, current_time: datetime, current_rate: float,
          Severity: Major
          Found in freqtrade/strategy/interface.py - About 1 hr to fix

            Function confirm_trade_entry has 10 arguments (exceeds 4 allowed). Consider refactoring.
            Open

                def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float,
            Severity: Major
            Found in freqtrade/strategy/interface.py - About 1 hr to fix

              Function adjust_entry_price has 10 arguments (exceeds 4 allowed). Consider refactoring.
              Open

                  def adjust_entry_price(self, trade: Trade, order: Optional[Order], pair: str,
              Severity: Major
              Found in freqtrade/strategy/interface.py - About 1 hr to fix

                Function should_exit has 10 arguments (exceeds 4 allowed). Consider refactoring.
                Open

                    def should_exit(self, trade: Trade, rate: float, current_time: datetime, *,
                Severity: Major
                Found in freqtrade/strategy/interface.py - About 1 hr to fix

                  Function confirm_trade_exit has 10 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                      def confirm_trade_exit(self, pair: str, trade: Trade, order_type: str, amount: float,
                  Severity: Major
                  Found in freqtrade/strategy/interface.py - About 1 hr to fix

                    Function leverage has 9 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                        def leverage(self, pair: str, current_time: datetime, current_rate: float,
                    Severity: Major
                    Found in freqtrade/strategy/interface.py - About 1 hr to fix

                      Function ft_stoploss_adjust has 9 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                          def ft_stoploss_adjust(self, current_rate: float, trade: Trade,
                      Severity: Major
                      Found in freqtrade/strategy/interface.py - About 1 hr to fix

                        Function custom_exit_price has 8 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                            def custom_exit_price(self, pair: str, trade: Trade,
                        Severity: Major
                        Found in freqtrade/strategy/interface.py - About 1 hr to fix

                          Function custom_stoploss has 8 arguments (exceeds 4 allowed). Consider refactoring.
                          Open

                              def custom_stoploss(self, pair: str, trade: Trade, current_time: datetime, current_rate: float,
                          Severity: Major
                          Found in freqtrade/strategy/interface.py - About 1 hr to fix

                            Function custom_entry_price has 8 arguments (exceeds 4 allowed). Consider refactoring.
                            Open

                                def custom_entry_price(self, pair: str, trade: Optional[Trade],
                            Severity: Major
                            Found in freqtrade/strategy/interface.py - About 1 hr to fix

                              Function ft_stoploss_reached has 8 arguments (exceeds 4 allowed). Consider refactoring.
                              Open

                                  def ft_stoploss_reached(self, current_rate: float, trade: Trade,
                              Severity: Major
                              Found in freqtrade/strategy/interface.py - About 1 hr to fix

                                Function assert_df has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
                                Open

                                    def assert_df(self, dataframe: DataFrame, df_len: int, df_close: float, df_date: datetime):
                                        """
                                        Ensure dataframe (length, last candle) was not modified, and has all elements we need.
                                        """
                                        message_template = "Dataframe returned from strategy has mismatching {}."
                                Severity: Minor
                                Found in freqtrade/strategy/interface.py - About 55 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

                                Function custom_exit has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                Open

                                    def custom_exit(self, pair: str, trade: Trade, current_time: datetime, current_rate: float,
                                Severity: Major
                                Found in freqtrade/strategy/interface.py - About 50 mins to fix

                                  Function custom_sell has 7 arguments (exceeds 4 allowed). Consider refactoring.
                                  Open

                                      def custom_sell(self, pair: str, trade: Trade, current_time: datetime, current_rate: float,
                                  Severity: Major
                                  Found in freqtrade/strategy/interface.py - About 50 mins to fix

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

                                        def check_entry_timeout(self, pair: str, trade: Trade, order: Order,
                                    Severity: Minor
                                    Found in freqtrade/strategy/interface.py - About 45 mins to fix

                                      Function get_entry_signal has a Cognitive Complexity of 8 (exceeds 5 allowed). Consider refactoring.
                                      Open

                                          def get_entry_signal(
                                              self,
                                              pair: str,
                                              timeframe: str,
                                              dataframe: DataFrame,
                                      Severity: Minor
                                      Found in freqtrade/strategy/interface.py - About 45 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

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

                                          def check_sell_timeout(self, pair: str, trade: Trade, order: Order,
                                      Severity: Minor
                                      Found in freqtrade/strategy/interface.py - About 45 mins to fix

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

                                            def check_exit_timeout(self, pair: str, trade: Trade, order: Order,
                                        Severity: Minor
                                        Found in freqtrade/strategy/interface.py - About 45 mins to fix

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

                                              def check_buy_timeout(self, pair: str, trade: Trade, order: Order,
                                          Severity: Minor
                                          Found in freqtrade/strategy/interface.py - About 45 mins to fix

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

                                                def order_filled(self, pair: str, trade: Trade, order: Order,
                                            Severity: Minor
                                            Found in freqtrade/strategy/interface.py - About 45 mins to fix

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

                                                  def populate_any_indicators(self, pair: str, df: DataFrame, tf: str,
                                              Severity: Minor
                                              Found in freqtrade/strategy/interface.py - About 45 mins to fix

                                                Avoid deeply nested control flow statements.
                                                Open

                                                                        if len(reason_cust) > CUSTOM_TAG_MAX_LENGTH:
                                                                            logger.warning(f'Custom exit reason returned from '
                                                                                           f'custom_exit is too long and was trimmed'
                                                                                           f'to {CUSTOM_TAG_MAX_LENGTH} characters.')
                                                                            custom_reason = reason_cust[:CUSTOM_TAG_MAX_LENGTH]
                                                Severity: Major
                                                Found in freqtrade/strategy/interface.py - About 45 mins to fix

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

                                                      def ignore_expired_candle(
                                                  Severity: Minor
                                                  Found in freqtrade/strategy/interface.py - About 35 mins to fix

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

                                                        def is_pair_locked(self, pair: str, *, candle_date: Optional[datetime] = None,
                                                    Severity: Minor
                                                    Found in freqtrade/strategy/interface.py - About 35 mins to fix

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

                                                          def lock_pair(self, pair: str, until: datetime,
                                                      Severity: Minor
                                                      Found in freqtrade/strategy/interface.py - About 35 mins to fix

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

                                                            def feature_engineering_expand_all(self, dataframe: DataFrame, period: int,
                                                        Severity: Minor
                                                        Found in freqtrade/strategy/interface.py - About 35 mins to fix

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

                                                              def assert_df(self, dataframe: DataFrame, df_len: int, df_close: float, df_date: datetime):
                                                          Severity: Minor
                                                          Found in freqtrade/strategy/interface.py - About 35 mins to fix

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

                                                                def get_exit_signal(
                                                            Severity: Minor
                                                            Found in freqtrade/strategy/interface.py - About 35 mins to fix

                                                              Function _adjust_trade_position_internal has a Cognitive Complexity of 7 (exceeds 5 allowed). Consider refactoring.
                                                              Open

                                                                  def _adjust_trade_position_internal(
                                                                          self, trade: Trade, current_time: datetime,
                                                                          current_rate: float, current_profit: float,
                                                                          min_stake: Optional[float], max_stake: float,
                                                                          current_entry_rate: float, current_exit_rate: float,
                                                              Severity: Minor
                                                              Found in freqtrade/strategy/interface.py - About 35 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

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

                                                                  def __informative_pairs_freqai(self) -> ListPairsWithTimeframes:
                                                                      """
                                                                      Create informative-pairs needed for FreqAI
                                                                      """
                                                                      if self.config.get('freqai', {}).get('enabled', False):
                                                              Severity: Minor
                                                              Found in freqtrade/strategy/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