with v3
This commit is contained in:
parent
02a5cc410f
commit
9490a8e12e
@ -263,18 +263,29 @@ class FreqaiExampleStrategy(IStrategy):
|
||||
"buy_rsi_pred": 30, # Default RSI buy threshold
|
||||
"sell_rsi_pred": 70, # Default RSI sell threshold
|
||||
"stoploss_pred": -0.1, # Default stoploss
|
||||
"roi_0_pred": 0.038 # Default ROI
|
||||
"roi_0_pred": 0.038, # Default ROI
|
||||
"do_predict": 0 # Default prediction flag
|
||||
}
|
||||
|
||||
# Initialize columns before any calculations
|
||||
for col, default_value in pred_columns.items():
|
||||
if col not in dataframe.columns:
|
||||
logger.warning(f"Column {col} missing, initializing with default value {default_value}")
|
||||
dataframe[col] = default_value
|
||||
else:
|
||||
# Ensure column exists and has proper type
|
||||
if dataframe[col].dtype not in [np.float64, np.int64]:
|
||||
logger.warning(f"Column {col} has incorrect dtype {dataframe[col].dtype}, converting to float")
|
||||
dataframe[col] = dataframe[col].astype(float)
|
||||
|
||||
# Ensure no NaN values
|
||||
if dataframe[col].isna().any():
|
||||
logger.warning(f"Column {col} contains NaN values, filling with default value {default_value}")
|
||||
dataframe[col] = dataframe[col].fillna(default_value)
|
||||
|
||||
# Now perform calculations that depend on these columns
|
||||
dataframe["sell_rsi_pred"] = dataframe["buy_rsi_pred"] + 20
|
||||
dataframe["sell_rsi_pred"] = dataframe["sell_rsi_pred"].fillna(dataframe["sell_rsi_pred"].median())
|
||||
|
||||
# 检查并处理 NaN 值
|
||||
for col in pred_columns + ["&-sell_rsi", "&-stoploss", "&-roi_0"]:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user