Merge pull request #10758 from stash86/recursive-str
add is_number check to make sure we skip non-number columns
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import logging
|
import logging
|
||||||
|
import numbers
|
||||||
import shutil
|
import shutil
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
@@ -20,6 +21,10 @@ from freqtrade.resolvers import StrategyResolver
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def is_number(variable):
|
||||||
|
return isinstance(variable, numbers.Number) and not isinstance(variable, bool)
|
||||||
|
|
||||||
|
|
||||||
class RecursiveAnalysis(BaseAnalysis):
|
class RecursiveAnalysis(BaseAnalysis):
|
||||||
def __init__(self, config: dict[str, Any], strategy_obj: dict):
|
def __init__(self, config: dict[str, Any], strategy_obj: dict):
|
||||||
self._startup_candle = list(
|
self._startup_candle = list(
|
||||||
@@ -69,7 +74,12 @@ class RecursiveAnalysis(BaseAnalysis):
|
|||||||
values_diff_self = values_diff.loc["self"]
|
values_diff_self = values_diff.loc["self"]
|
||||||
values_diff_other = values_diff.loc["other"]
|
values_diff_other = values_diff.loc["other"]
|
||||||
|
|
||||||
if values_diff_self and values_diff_other:
|
if (
|
||||||
|
values_diff_self
|
||||||
|
and values_diff_other
|
||||||
|
and is_number(values_diff_self)
|
||||||
|
and is_number(values_diff_other)
|
||||||
|
):
|
||||||
diff = (values_diff_other - values_diff_self) / values_diff_self * 100
|
diff = (values_diff_other - values_diff_self) / values_diff_self * 100
|
||||||
str_diff = f"{diff:.3f}%"
|
str_diff = f"{diff:.3f}%"
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -33,6 +33,9 @@ class strategy_test_v3_recursive_issue(IStrategy):
|
|||||||
# Has both bias1 and bias2
|
# Has both bias1 and bias2
|
||||||
dataframe["rsi_lookahead"] = ta.RSI(dataframe, timeperiod=50).shift(-1)
|
dataframe["rsi_lookahead"] = ta.RSI(dataframe, timeperiod=50).shift(-1)
|
||||||
|
|
||||||
|
# String columns shouldn't cause issues
|
||||||
|
dataframe["test_string_column"] = f"a{len(dataframe)}"
|
||||||
|
|
||||||
return dataframe
|
return dataframe
|
||||||
|
|
||||||
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||||
|
|||||||
Reference in New Issue
Block a user