freqtrade/freqtrade

View on GitHub
freqtrade/persistence/trade_model.py

Summary

Maintainability
F
5 days
Test Coverage

File trade_model.py has 1642 lines of code (exceeds 250 allowed). Consider refactoring.
Open

"""
This module contains the class to persist trades into SQLite
"""
import logging
from collections import defaultdict
Severity: Major
Found in freqtrade/persistence/trade_model.py - About 4 days to fix

    Function to_json has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
    Open

        def to_json(self, entry_side: str, minified: bool = False) -> Dict[str, Any]:
            """
            :param minified: If True, only return a subset of the data is returned.
                             Only used for backtesting.
            """
    Severity: Minor
    Found in freqtrade/persistence/trade_model.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_from_ccxt_object has 6 arguments (exceeds 4 allowed). Consider refactoring.
    Open

        def parse_from_ccxt_object(
    Severity: Minor
    Found in freqtrade/persistence/trade_model.py - About 45 mins to fix

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

          def update_from_ccxt_object(self, order):
              """
              Update Order from ccxt response
              Only updates if fields are available from ccxt -
              """
      Severity: Minor
      Found in freqtrade/persistence/trade_model.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 update_fee has 5 arguments (exceeds 4 allowed). Consider refactoring.
      Open

          def update_fee(self, fee_cost: float, fee_currency: Optional[str], fee_rate: Optional[float],
      Severity: Minor
      Found in freqtrade/persistence/trade_model.py - About 35 mins to fix

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

            def adjust_stop_loss(self, current_price: float, stoploss: Optional[float],
        Severity: Minor
        Found in freqtrade/persistence/trade_model.py - About 35 mins to fix

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

              def get_trades_proxy(*, pair: Optional[str] = None, is_open: Optional[bool] = None,
          Severity: Minor
          Found in freqtrade/persistence/trade_model.py - About 35 mins to fix

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

                def get_trades_proxy(*, pair: Optional[str] = None, is_open: Optional[bool] = None,
            Severity: Minor
            Found in freqtrade/persistence/trade_model.py - About 35 mins to fix

              There are no issues that match your filters.

              Category
              Status