freqtrade/freqai/RL/BaseEnvironment.py
File BaseEnvironment.py
has 299 lines of code (exceeds 250 allowed). Consider refactoring. Open
Open
import logging
import random
from abc import abstractmethod
from enum import Enum
from typing import List, Optional, Type, Union
BaseEnvironment
has 23 functions (exceeds 20 allowed). Consider refactoring. Open
Open
class BaseEnvironment(gym.Env):
"""
Base class for environments. This class is agnostic to action count.
Inherited classes customize this to include varying action counts/types,
See RL/Base5ActionRLEnv.py and RL/Base4ActionRLEnv.py
Function __init__
has 13 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def __init__(self, df: DataFrame = DataFrame(), prices: DataFrame = DataFrame(),
Function reset_env
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
Open
def reset_env(self, df: DataFrame, prices: DataFrame, window_size: int,
Avoid too many return
statements within this function. Open
Open
return 0.
Function tensorboard_log
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
Open
def tensorboard_log(self, metric: str, value: Optional[Union[int, float]] = None,
inc: Optional[bool] = None, category: str = "custom"):
"""
Function builds the tensorboard_metrics dictionary
to be parsed by the TensorboardCallback. This
- 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"