freqtrade/freqtrade

View on GitHub

Showing 505 of 505 total issues

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

        def calculate_reward(self, action: int) -> float:
            """
            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/prediction_models/ReinforcementLearner.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 start_list_exchanges has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

def start_list_exchanges(args: Dict[str, Any]) -> None:
    """
    Print available exchanges
    :param args: Cli args from Arguments()
    :return: None
Severity: Minor
Found in freqtrade/commands/list_commands.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 _search_all_objects has a Cognitive Complexity of 16 (exceeds 5 allowed). Consider refactoring.
Open

    def _search_all_objects(
            cls, directory: Path, enum_failed: bool, recursive: bool = False,
            basedir: Optional[Path] = None) -> List[Dict[str, Any]]:
        """
        Searches a directory for valid objects
Severity: Minor
Found in freqtrade/resolvers/iresolver.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 entryexitanalysis.py has 252 lines of code (exceeds 250 allowed). Consider refactoring.
Open

import logging
from pathlib import Path
from typing import List

import joblib
Severity: Minor
Found in freqtrade/data/entryexitanalysis.py - About 2 hrs to fix

    File build_config_commands.py has 251 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    import logging
    import secrets
    from pathlib import Path
    from typing import Any, Dict, List
    
    
    Severity: Minor
    Found in freqtrade/commands/build_config_commands.py - About 2 hrs to fix

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

          def __init__(self, config: Config, *, exchange_config: Optional[ExchangeConfig] = None,
                       validate: bool = True, load_leverage_tiers: bool = False) -> None:
              """
              Initializes this module with the given config,
              it does basic validation whether the specified exchange and pairs are valid.
      Severity: Minor
      Found in freqtrade/exchange/exchange.py - About 1 hr to fix

        Function __exec_force_exit has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def __exec_force_exit(self, trade: Trade, ordertype: Optional[str],
                                  amount: Optional[float] = None) -> bool:
                # Check if there is there are open orders
                trade_entry_cancelation_registry = []
                for oo in trade.open_orders:
        Severity: Minor
        Found in freqtrade/rpc/rpc.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 generate_optimizer has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def generate_optimizer(self, raw_params: List[Any]) -> Dict[str, Any]:
                """
                Used Optimize function.
                Called once per epoch to optimize whatever is configured.
                Keep this function as optimized as possible!
        Severity: Minor
        Found in freqtrade/optimize/hyperopt.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 is_tradesignal has a Cognitive Complexity of 15 (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/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 setup_analyze_configuration has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def setup_analyze_configuration(args: Dict[str, Any], method: RunMode) -> Dict[str, Any]:
            """
            Prepare the configuration for the entry/exit reason analysis module
            :param args: Cli args from Arguments()
            :param method: Bot running mode
        Severity: Minor
        Found in freqtrade/commands/analyze_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 _load_cached_data_for_updating has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def _load_cached_data_for_updating(
            pair: str,
            timeframe: str,
            timerange: Optional[TimeRange],
            data_handler: IDataHandler,
        Severity: Minor
        Found in freqtrade/data/history/history_utils.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 get_trades_for_order has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

            def get_trades_for_order(self, order_id: str, pair: str, since: datetime,
                                     params: Optional[Dict] = None) -> List:
                trades = super().get_trades_for_order(order_id, pair, since, params)
        
                if self.trading_mode == TradingMode.FUTURES:
        Severity: Minor
        Found in freqtrade/exchange/gate.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 retrier_async has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
        Open

        def retrier_async(f):
            async def wrapper(*args, **kwargs):
                count = kwargs.pop('count', API_RETRY_COUNT)
                kucoin = args[0].name == "KuCoin"  # Check if the exchange is KuCoin.
                try:
        Severity: Minor
        Found in freqtrade/exchange/common.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 get_liquidation_price has 15 arguments (exceeds 4 allowed). Consider refactoring.
        Open

            def get_liquidation_price(
        Severity: Major
        Found in freqtrade/exchange/exchange.py - About 1 hr to fix

          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 _rpc_trade_statistics has 45 lines of code (exceeds 25 allowed). Consider refactoring.
            Open

                def _rpc_trade_statistics(
                        self, stake_currency: str, fiat_display_currency: str,
                        start_date: Optional[datetime] = None) -> Dict[str, Any]:
                    """ Returns cumulative profit statistics """
            
            
            Severity: Minor
            Found in freqtrade/rpc/rpc.py - About 1 hr to fix

              Function migrate_trades_and_orders_table has 45 lines of code (exceeds 25 allowed). Consider refactoring.
              Open

              def migrate_trades_and_orders_table(
                      decl_base, inspector, engine,
                      trade_back_name: str, cols: List,
                      order_back_name: str, cols_order: List):
                  base_currency = get_column_def(cols, 'base_currency', 'null')
              Severity: Minor
              Found in freqtrade/persistence/migrations.py - About 1 hr to fix

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

                    def __init__(self, config: Config, exchange: Optional[Exchange] = None) -> None:
                
                        LoggingMixin.show_output = False
                        self.config = config
                        self.results: BacktestResultType = get_BacktestResultType_default()
                Severity: Minor
                Found in freqtrade/optimize/backtesting.py - About 1 hr to fix

                  Function _send_msg has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def _send_msg(self, payload: dict) -> None:
                          """do the actual call to the webhook"""
                  
                          success = False
                          attempts = 0
                  Severity: Minor
                  Found in freqtrade/rpc/webhook.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_order_replace has a Cognitive Complexity of 14 (exceeds 5 allowed). Consider refactoring.
                  Open

                      def check_order_replace(self, trade: LocalTrade, order: Order, current_time,
                                              row: Tuple) -> bool:
                          """
                          Check if current analyzed entry order has to be replaced and do so.
                          If user requested cancellation and there are no filled orders in the trade will
                  Severity: Minor
                  Found in freqtrade/optimize/backtesting.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

                  Severity
                  Category
                  Status
                  Source
                  Language