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
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
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
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"],
- Read upRead up
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
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"],
- Read upRead up
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
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
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"
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"
Function price_long_only_backtester
has 14 arguments (exceeds 4 allowed). Consider refactoring. Open
def price_long_only_backtester(
Function price_short_only_backtester
has 14 arguments (exceeds 4 allowed). Consider refactoring. Open
def price_short_only_backtester(
Function ohlc_short_only_backtester
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
def ohlc_short_only_backtester(
Function ohlc_long_only_backtester
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
def ohlc_long_only_backtester(
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:
- Read upRead up
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],
- Read upRead up
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,
- Read upRead up
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,
- Read upRead up
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.
- Read upRead up
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],
- Read upRead up
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"