策略使用了 利润高的配置, 符合损失函数 评估标准的配置被注释
Some checks failed
Binance Leverage tiers update / auto-update (push) Has been cancelled
Some checks failed
Binance Leverage tiers update / auto-update (push) Has been cancelled
This commit is contained in:
parent
b41320a809
commit
928bc012d8
@ -67,7 +67,7 @@
|
|||||||
"freqaimodel": "CatboostClassifier",
|
"freqaimodel": "CatboostClassifier",
|
||||||
"purge_old_models": 2,
|
"purge_old_models": 2,
|
||||||
"train_period_days": 15,
|
"train_period_days": 15,
|
||||||
"identifier": "test77",
|
"identifier": "test82",
|
||||||
"train_period_days": 30,
|
"train_period_days": 30,
|
||||||
"backtest_period_days": 10,
|
"backtest_period_days": 10,
|
||||||
"live_retrain_hours": 0,
|
"live_retrain_hours": 0,
|
||||||
|
|||||||
@ -69,4 +69,18 @@ services:
|
|||||||
--config /freqtrade/config_examples/config_freqai.okx.json
|
--config /freqtrade/config_examples/config_freqai.okx.json
|
||||||
--strategy-path /freqtrade/templates
|
--strategy-path /freqtrade/templates
|
||||||
--strategy FreqaiExampleStrategy
|
--strategy FreqaiExampleStrategy
|
||||||
--timerange 20240905-20250420
|
--timerange 20250101-20250420
|
||||||
|
--fee 0.001
|
||||||
|
|
||||||
|
# command: >
|
||||||
|
# hyperopt
|
||||||
|
# --logfile /freqtrade/user_data/logs/freqtrade.log
|
||||||
|
# --freqaimodel LightGBMRegressor
|
||||||
|
# --config /freqtrade/config_examples/config_freqai.okx.json
|
||||||
|
# --strategy-path /freqtrade/templates
|
||||||
|
# --strategy FreqaiExampleStrategy
|
||||||
|
# --timerange 20250301-20250420
|
||||||
|
# --hyperopt-loss SharpeHyperOptLoss
|
||||||
|
# --spaces buy sell roi stoploss trailing
|
||||||
|
# --fee 0.001
|
||||||
|
# -e 200
|
||||||
|
|||||||
@ -1,32 +1,32 @@
|
|||||||
{
|
{
|
||||||
"strategy_name": "FreqaiExampleStrategy",
|
"strategy_name": "FreqaiExampleStrategy",
|
||||||
"params": {
|
"params": {
|
||||||
"trailing": {
|
|
||||||
"trailing_stop": true,
|
|
||||||
"trailing_stop_positive": 0.01,
|
|
||||||
"trailing_stop_positive_offset": 0.02,
|
|
||||||
"trailing_only_offset_is_reached": false
|
|
||||||
},
|
|
||||||
"max_open_trades": {
|
"max_open_trades": {
|
||||||
"max_open_trades": 4
|
"max_open_trades": 4
|
||||||
},
|
},
|
||||||
"buy": {
|
"buy": {
|
||||||
"buy_rsi": 39.92672300850069
|
"buy_rsi": 49
|
||||||
},
|
},
|
||||||
"sell": {
|
"sell": {
|
||||||
"sell_rsi": 69.92672300850067
|
"sell_rsi": 64
|
||||||
},
|
},
|
||||||
"protection": {},
|
"protection": {},
|
||||||
"roi": {
|
"roi": {
|
||||||
"0": 0.132,
|
"0": 0.07600000000000001,
|
||||||
"8": 0.047,
|
"7": 0.034,
|
||||||
"14": 0.007,
|
"13": 0.007,
|
||||||
"60": 0
|
"60": 0
|
||||||
},
|
},
|
||||||
"stoploss": {
|
"stoploss": {
|
||||||
"stoploss": -0.322
|
"stoploss": -0.087
|
||||||
|
},
|
||||||
|
"trailing": {
|
||||||
|
"trailing_stop": true,
|
||||||
|
"trailing_stop_positive": 0.333,
|
||||||
|
"trailing_stop_positive_offset": 0.341,
|
||||||
|
"trailing_only_offset_is_reached": true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"ft_stratparam_v": 1,
|
"ft_stratparam_v": 1,
|
||||||
"export_time": "2025-04-23 12:30:05.550433+00:00"
|
"export_time": "2025-04-23 15:53:46.477203+00:00"
|
||||||
}
|
}
|
||||||
@ -10,7 +10,14 @@ from freqtrade.strategy import IStrategy, IntParameter, DecimalParameter
|
|||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class FreqaiExampleStrategy(IStrategy):
|
class FreqaiExampleStrategy(IStrategy):
|
||||||
minimal_roi = {}
|
## minimal_roi 设置为{} 利润稍高, 回头再说,
|
||||||
|
minimal_roi = {
|
||||||
|
"0": 0.076,
|
||||||
|
"7": 0.034,
|
||||||
|
"13": 0.007,
|
||||||
|
"60": 0
|
||||||
|
}
|
||||||
|
|
||||||
stoploss = 0.0
|
stoploss = 0.0
|
||||||
trailing_stop = True
|
trailing_stop = True
|
||||||
process_only_new_candles = True
|
process_only_new_candles = True
|
||||||
@ -19,12 +26,41 @@ class FreqaiExampleStrategy(IStrategy):
|
|||||||
can_short = False
|
can_short = False
|
||||||
|
|
||||||
# Hyperopt 参数
|
# Hyperopt 参数
|
||||||
buy_rsi = IntParameter(low=10, high=50, default=27, space="buy", optimize=False, load=True)
|
buy_rsi = IntParameter(low=10, high=50, default=27, space="buy", optimize=True, load=True)
|
||||||
sell_rsi = IntParameter(low=50, high=90, default=59, space="sell", optimize=False, load=True)
|
sell_rsi = IntParameter(low=50, high=90, default=59, space="sell", optimize=True, load=True)
|
||||||
roi_0 = DecimalParameter(low=0.01, high=0.2, default=0.038, space="roi", optimize=True, load=True)
|
roi_0 = DecimalParameter(low=0.01, high=0.2, default=0.038, space="roi", optimize=True, load=True)
|
||||||
roi_15 = DecimalParameter(low=0.005, high=0.1, default=0.027, space="roi", optimize=True, load=True)
|
roi_15 = DecimalParameter(low=0.005, high=0.1, default=0.027, space="roi", optimize=True, load=True)
|
||||||
roi_30 = DecimalParameter(low=0.001, high=0.05, default=0.009, space="roi", optimize=True, load=True)
|
roi_30 = DecimalParameter(low=0.001, high=0.05, default=0.009, space="roi", optimize=True, load=True)
|
||||||
stoploss_param = DecimalParameter(low=-0.25, high=-0.05, default=-0.1, space="stoploss", optimize=True, load=True)
|
stoploss_param = DecimalParameter(low=-0.25, high=-0.05, default=-0.1, space="stoploss", optimize=True, load=True)
|
||||||
|
trailing_stop_positive_offset = DecimalParameter(low=0.01, high=0.5, default=0.02, space="trailing", optimize=True, load=True)
|
||||||
|
|
||||||
|
# 以下配置 利润低, 但是 更符合 损失函数的评估
|
||||||
|
# minimal_roi = {
|
||||||
|
# "0": 0.076,
|
||||||
|
# "7": 0.034,
|
||||||
|
# "13": 0.007,
|
||||||
|
# "60": 0
|
||||||
|
# }
|
||||||
|
# stoploss = -0.087
|
||||||
|
# trailing_stop = True
|
||||||
|
# trailing_stop_positive = 0.333
|
||||||
|
# trailing_stop_positive_offset = 0.341
|
||||||
|
# trailing_only_offset_is_reached = True
|
||||||
|
# process_only_new_candles = True
|
||||||
|
# use_exit_signal = True
|
||||||
|
# startup_candle_count: int = 40
|
||||||
|
# can_short = False
|
||||||
|
# max_open_trades = 4
|
||||||
|
#
|
||||||
|
# # Hyperopt 参数
|
||||||
|
# buy_rsi = IntParameter(low=10, high=50, default=49, space="buy", optimize=True, load=True)
|
||||||
|
# sell_rsi = IntParameter(low=50, high=90, default=64, space="sell", optimize=True, load=True)
|
||||||
|
# roi_0 = DecimalParameter(low=0.01, high=0.2, default=0.076, space="roi", optimize=True, load=True)
|
||||||
|
# roi_15 = DecimalParameter(low=0.005, high=0.1, default=0.034, space="roi", optimize=True, load=True)
|
||||||
|
# roi_30 = DecimalParameter(low=0.001, high=0.05, default=0.007, space="roi", optimize=True, load=True)
|
||||||
|
# stoploss_param = DecimalParameter(low=-0.25, high=-0.05, default=-0.087, space="stoploss", optimize=True, load=True)
|
||||||
|
# trailing_stop_positive_offset = DecimalParameter(low=0.01, high=0.5, default=0.341, space="trailing", optimize=True, load=True)
|
||||||
|
|
||||||
|
|
||||||
# 保护机制
|
# 保护机制
|
||||||
protections = [
|
protections = [
|
||||||
@ -184,7 +220,7 @@ class FreqaiExampleStrategy(IStrategy):
|
|||||||
# 动态追踪止盈
|
# 动态追踪止盈
|
||||||
dataframe["trailing_stop_positive"] = (dataframe["roi_0_pred"] * 0.5).clip(0.01, 0.3)
|
dataframe["trailing_stop_positive"] = (dataframe["roi_0_pred"] * 0.5).clip(0.01, 0.3)
|
||||||
dataframe["trailing_stop_positive_offset"] = (dataframe["roi_0_pred"] * 0.75).clip(0.02, 0.4)
|
dataframe["trailing_stop_positive_offset"] = (dataframe["roi_0_pred"] * 0.75).clip(0.02, 0.4)
|
||||||
|
|
||||||
# 设置动态参数
|
# 设置动态参数
|
||||||
self.stoploss = float(dataframe["stoploss_pred"].iloc[-1])
|
self.stoploss = float(dataframe["stoploss_pred"].iloc[-1])
|
||||||
self.buy_rsi.value = float(dataframe["buy_rsi_pred"].iloc[-1])
|
self.buy_rsi.value = float(dataframe["buy_rsi_pred"].iloc[-1])
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user