BaptisteZloch/Quant-Invest-Lab

View on GitHub

Showing 42 of 42 total issues

File reports.py has 916 lines of code (exceeds 250 allowed). Consider refactoring.
Open

from scipy.stats import skew, kurtosis
from typing import Optional, Union, Literal
import pandas as pd
import numpy as np
from math import pi
Severity: Major
Found in quant_invest_lab/reports.py - About 2 days to fix

    File backtest.py has 742 lines of code (exceeds 250 allowed). Consider refactoring.
    Open

    from datetime import datetime
    from typing import Callable, Literal, Optional, Union, Tuple
    import pandas as pd
    import numpy as np
    from tqdm import tqdm
    Severity: Major
    Found in quant_invest_lab/backtest.py - About 1 day to fix

      File indicators.py has 597 lines of code (exceeds 250 allowed). Consider refactoring.
      Open

      import pandas as pd
      import numpy as np
      import numpy.typing as npt
      from typing import Literal, Callable, Optional
      from scipy import stats, signal
      Severity: Major
      Found in quant_invest_lab/indicators.py - About 1 day to fix

        Function __ohlc_backtest_one_position_type has a Cognitive Complexity of 43 (exceeds 5 allowed). Consider refactoring.
        Open

        def __ohlc_backtest_one_position_type(
            ohlcv_df: pd.DataFrame,
            entry_function: Callable[[pd.Series, pd.Series], bool],
            exit_function: Callable[[pd.Series, pd.Series, int], bool],
            position_type: Literal["long", "short"],
        Severity: Minor
        Found in quant_invest_lab/backtest.py - About 6 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 440 lines of code (exceeds 250 allowed). Consider refactoring.
        Open

        import numpy as np
        import numpy.typing as npt
        from functools import lru_cache
        import pandas as pd
        import scipy.stats as stat
        Severity: Minor
        Found in quant_invest_lab/metrics.py - About 6 hrs to fix

          Function __price_backtest_one_position_type has a Cognitive Complexity of 42 (exceeds 5 allowed). Consider refactoring.
          Open

          def __price_backtest_one_position_type(
              price_df: pd.DataFrame,
              entry_function: Callable[[pd.Series, pd.Series], bool],
              exit_function: Callable[[pd.Series, pd.Series, int], bool],
              position_type: Literal["long", "short"],
          Severity: Minor
          Found in quant_invest_lab/backtest.py - About 6 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 portfolio.py has 381 lines of code (exceeds 250 allowed). Consider refactoring.
          Open

          from typing import Iterable, Literal, Optional
          import pandas as pd
          import numpy as np
          import numpy.typing as npt
          import numpy.linalg as linalg
          Severity: Minor
          Found in quant_invest_lab/portfolio.py - About 5 hrs to fix

            File data_provider.py has 363 lines of code (exceeds 250 allowed). Consider refactoring.
            Open

            from datetime import datetime
            from functools import lru_cache
            from typing import Optional, Callable, Literal
            import os
            import pandas as pd
            Severity: Minor
            Found in quant_invest_lab/data_provider.py - About 4 hrs to fix

              Consider simplifying this complex logical expression.
              Open

                      if position_opened is False and entry_function(row, previous_row) is True:
                          position_opened = True
                          current_trade["entry_date"] = index
                          current_trade["entry_price"] = row.Close
                          current_trade["entry_reason"] = "Entry position triggered"
              Severity: Critical
              Found in quant_invest_lab/backtest.py - About 3 hrs to fix

                Consider simplifying this complex logical expression.
                Open

                        if position_opened is False and entry_function(row, previous_row) is True:
                            position_opened = True
                            current_trade["entry_date"] = index
                            current_trade["entry_price"] = row["Price"]
                            current_trade["entry_reason"] = "Entry position triggered"
                Severity: Critical
                Found in quant_invest_lab/backtest.py - About 3 hrs to fix

                  Function price_long_only_backtester has 14 arguments (exceeds 4 allowed). Consider refactoring.
                  Open

                  def price_long_only_backtester(
                  Severity: Major
                  Found in quant_invest_lab/backtest.py - About 1 hr to fix

                    Function price_short_only_backtester has 14 arguments (exceeds 4 allowed). Consider refactoring.
                    Open

                    def price_short_only_backtester(
                    Severity: Major
                    Found in quant_invest_lab/backtest.py - About 1 hr to fix

                      Function ohlc_short_only_backtester has 13 arguments (exceeds 4 allowed). Consider refactoring.
                      Open

                      def ohlc_short_only_backtester(
                      Severity: Major
                      Found in quant_invest_lab/backtest.py - About 1 hr to fix

                        Function ohlc_long_only_backtester has 13 arguments (exceeds 4 allowed). Consider refactoring.
                        Open

                        def ohlc_long_only_backtester(
                        Severity: Major
                        Found in quant_invest_lab/backtest.py - About 1 hr to fix

                          Function download_history has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                                  def download_history(
                                      self, symbol: str, since: str, timeframe: Timeframe, jobs: int = -1
                                  ) -> pd.DataFrame:
                                      """Download a set of historical data and save it.
                                      Args:
                          Severity: Minor
                          Found in quant_invest_lab/data_provider.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 price_long_only_backtester has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def price_long_only_backtester(
                              df: pd.DataFrame,
                              price_column: str,
                              long_entry_function: Callable[[pd.Series, pd.Series], bool],
                              long_exit_function: Callable[[pd.Series, pd.Series, int], bool],
                          Severity: Minor
                          Found in quant_invest_lab/backtest.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 ohlc_long_only_backtester has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def ohlc_long_only_backtester(
                              df: pd.DataFrame,
                              long_entry_function: Callable[[pd.Series, pd.Series], bool],
                              long_exit_function: Callable[[pd.Series, pd.Series, int], bool],
                              timeframe: Timeframe,
                          Severity: Minor
                          Found in quant_invest_lab/backtest.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 ohlc_short_only_backtester has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def ohlc_short_only_backtester(
                              df: pd.DataFrame,
                              short_entry_function: Callable[[pd.Series, pd.Series], bool],
                              short_exit_function: Callable[[pd.Series, pd.Series, int], bool],
                              timeframe: Timeframe,
                          Severity: Minor
                          Found in quant_invest_lab/backtest.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 detect_fractal_support_resistance has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def detect_fractal_support_resistance(high: pd.Series, low: pd.Series) -> list[float]:
                              """Detects the supports and resistances according to the fractal method.
                          
                              Args:
                                  high (pd.Series): The high series from the OHLCV Data.
                          Severity: Minor
                          Found in quant_invest_lab/indicators.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 price_short_only_backtester has a Cognitive Complexity of 12 (exceeds 5 allowed). Consider refactoring.
                          Open

                          def price_short_only_backtester(
                              df: pd.DataFrame,
                              price_column: str,
                              short_entry_function: Callable[[pd.Series, pd.Series], bool],
                              short_exit_function: Callable[[pd.Series, pd.Series, int], bool],
                          Severity: Minor
                          Found in quant_invest_lab/backtest.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