策略代码之前搞错了,用的是未去除看底牌代码的版本,现已恢复
This commit is contained in:
parent
7c227d942f
commit
30840cfd5a
@ -1,3 +1,39 @@
|
||||
{
|
||||
"strategy_name": "FreqaiPrimer",
|
||||
"params": {
|
||||
"max_open_trades": {
|
||||
"max_open_trades": 4
|
||||
},
|
||||
"buy": {
|
||||
"buy_rsi": 45.2500884290867
|
||||
},
|
||||
"sell": {
|
||||
"sell_rsi": 75.2500884290867
|
||||
},
|
||||
"protection": {},
|
||||
"roi": {
|
||||
"0": 0.20400000000000001,
|
||||
"18": 0.07100000000000001,
|
||||
"47": 0.03,
|
||||
"102": 0
|
||||
},
|
||||
"stoploss": {
|
||||
"stoploss": -0.07
|
||||
},
|
||||
"trailing": {
|
||||
"trailing_stop": true,
|
||||
"trailing_stop_positive": 0.237,
|
||||
"trailing_stop_positive_offset": 0.267,
|
||||
"trailing_only_offset_is_reached": false
|
||||
}
|
||||
},
|
||||
"ft_stratparam_v": 1,
|
||||
"export_time": "2025-05-17 11:42:41.193338+00:00"
|
||||
}ubuntu@giana:~/freqtrade/freqtrade/templates$ cd ../../
|
||||
ubuntu@giana:~/freqtrade$ cd config_examples/
|
||||
ubuntu@giana:~/freqtrade/config_examples$ md5sum freqaiprimer.json
|
||||
0c76d7f7d56cd6ff551e803ade3f4dcc freqaiprimer.json
|
||||
ubuntu@giana:~/freqtrade/config_examples$ cat freqaiprimer.json
|
||||
{
|
||||
"$schema": "https://schema.freqtrade.io/schema.json",
|
||||
"trading_mode": "spot",
|
||||
@ -35,8 +71,8 @@
|
||||
},
|
||||
"pair_whitelist": [
|
||||
"BTC/USDT",
|
||||
"TON/USDT",
|
||||
"ETH/USDT",
|
||||
"TON/USDT",
|
||||
"OKB/USDT",
|
||||
"DOT/USDT",
|
||||
"SOL/USDT"
|
||||
|
||||
@ -5,28 +5,28 @@
|
||||
"max_open_trades": 4
|
||||
},
|
||||
"buy": {
|
||||
"buy_rsi": 47.038290547713025
|
||||
"buy_rsi": 50.0
|
||||
},
|
||||
"sell": {
|
||||
"sell_rsi": 77.03829054771305
|
||||
"sell_rsi": 87.0823069705334
|
||||
},
|
||||
"protection": {},
|
||||
"roi": {
|
||||
"0": 0.093,
|
||||
"20": 0.05,
|
||||
"27": 0.008,
|
||||
"51": 0
|
||||
"0": 0.184,
|
||||
"24": 0.068,
|
||||
"48": 0.025,
|
||||
"57": 0
|
||||
},
|
||||
"stoploss": {
|
||||
"stoploss": -0.033
|
||||
"stoploss": -0.021
|
||||
},
|
||||
"trailing": {
|
||||
"trailing_stop": true,
|
||||
"trailing_stop_positive": 0.183,
|
||||
"trailing_stop_positive_offset": 0.255,
|
||||
"trailing_stop_positive": 0.076,
|
||||
"trailing_stop_positive_offset": 0.082,
|
||||
"trailing_only_offset_is_reached": true
|
||||
}
|
||||
},
|
||||
"ft_stratparam_v": 1,
|
||||
"export_time": "2025-05-18 10:08:45.257900+00:00"
|
||||
}
|
||||
"export_time": "2025-05-20 05:24:26.645871+00:00"
|
||||
}
|
||||
@ -124,8 +124,9 @@ class FreqaiPrimer(IStrategy):
|
||||
dataframe["%-volatility"] = dataframe["%-volatility"].ffill()
|
||||
dataframe["%-volatility"] = dataframe["%-volatility"].fillna(0)
|
||||
|
||||
# 移除 shift(-label_period),改为使用当前及过去的数据
|
||||
dataframe["&-buy_rsi"] = ta.RSI(dataframe, timeperiod=14)
|
||||
dataframe["&-buy_rsi"] = dataframe["&-buy_rsi"].shift(-label_period).ffill().bfill()
|
||||
dataframe["&-buy_rsi"] = dataframe["&-buy_rsi"].rolling(window=label_period).mean().ffill().bfill()
|
||||
|
||||
for col in ["&-buy_rsi", "%-volatility"]:
|
||||
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], 0)
|
||||
@ -154,8 +155,9 @@ class FreqaiPrimer(IStrategy):
|
||||
dataframe["tema"] = ta.TEMA(dataframe, timeperiod=9)
|
||||
|
||||
label_period = self.freqai_info["feature_parameters"]["label_period_candles"]
|
||||
# 使用滚动窗口而非未来函数来生成 up_or_down 列
|
||||
dataframe["up_or_down"] = np.where(
|
||||
dataframe["close"].shift(-label_period) > dataframe["close"], 1, 0
|
||||
dataframe["close"].rolling(window=label_period).mean() > dataframe["close"], 1, 0
|
||||
)
|
||||
|
||||
if "&-buy_rsi" in dataframe.columns:
|
||||
@ -168,7 +170,7 @@ class FreqaiPrimer(IStrategy):
|
||||
|
||||
dataframe["&-sell_rsi"] = dataframe["&-buy_rsi"] + 30
|
||||
dataframe["&-stoploss"] = self.stoploss - (dataframe["%-volatility"] * 5).clip(-0.05, 0.05)
|
||||
dataframe["&-roi_0"] = (dataframe["close"].shift(-label_period) / dataframe["close"] - 1).clip(0, 0.2)
|
||||
dataframe["&-roi_0"] = (dataframe["close"].rolling(window=label_period).mean() / dataframe["close"] - 1).clip(0, 0.2)
|
||||
|
||||
for col in ["&-buy_rsi", "&-sell_rsi", "&-stoploss", "&-roi_0"]:
|
||||
dataframe[col] = dataframe[col].replace([np.inf, -np.inf], 0)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user