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
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
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()
- 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 __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)
- 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 _adjust_trade_position_internal
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
def _adjust_trade_position_internal(
Function adjust_trade_position
has 12 arguments (exceeds 4 allowed). Consider refactoring. Open
def adjust_trade_position(self, trade: Trade, current_time: datetime,
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,
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,
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,
Function should_exit
has 10 arguments (exceeds 4 allowed). Consider refactoring. Open
def should_exit(self, trade: Trade, rate: float, current_time: datetime, *,
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,
Function leverage
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def leverage(self, pair: str, current_time: datetime, current_rate: float,
Function ft_stoploss_adjust
has 9 arguments (exceeds 4 allowed). Consider refactoring. Open
def ft_stoploss_adjust(self, current_rate: float, trade: Trade,
Function custom_exit_price
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def custom_exit_price(self, pair: str, trade: Trade,
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,
Function custom_entry_price
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def custom_entry_price(self, pair: str, trade: Optional[Trade],
Function ft_stoploss_reached
has 8 arguments (exceeds 4 allowed). Consider refactoring. Open
def ft_stoploss_reached(self, current_rate: float, trade: Trade,
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 {}."
- 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 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,
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,
Function check_entry_timeout
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_entry_timeout(self, pair: str, trade: Trade, order: Order,
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,
- 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 check_sell_timeout
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_sell_timeout(self, pair: str, trade: Trade, order: Order,
Function check_exit_timeout
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_exit_timeout(self, pair: str, trade: Trade, order: Order,
Function check_buy_timeout
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def check_buy_timeout(self, pair: str, trade: Trade, order: Order,
Function order_filled
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def order_filled(self, pair: str, trade: Trade, order: Order,
Function populate_any_indicators
has 6 arguments (exceeds 4 allowed). Consider refactoring. Open
def populate_any_indicators(self, pair: str, df: DataFrame, tf: str,
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]
Function ignore_expired_candle
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def ignore_expired_candle(
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,
Function lock_pair
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def lock_pair(self, pair: str, until: datetime,
Function feature_engineering_expand_all
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def feature_engineering_expand_all(self, dataframe: DataFrame, period: int,
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):
Function get_exit_signal
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
def get_exit_signal(
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,
- 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 __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):
- 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"