use 1 hour bb

This commit is contained in:
jackyu66git
2025-07-22 01:44:59 +08:00
parent 6907ce7d8c
commit 83afedc0ec
2 changed files with 15 additions and 10 deletions
+14 -10
View File
@@ -22,7 +22,7 @@ logger = logging.getLogger(__name__)
# freqtrade plot-dataframe --strategy ChanLun_BTC_30 --datadir user_data/data/binance -c ./user_data/ChanLun_SOL_30.json --timerange=20250309-
# freqtrade trade -c ./user_data/Chan/config/ChanLun_BTC_30.json --strategy ChanLun_BTC_30 --strategy-path ./user_data/Chan/strategies
# freqtrade backtesting -c ./user_data/Chan/config/ChanLun_BTC_30.json --strategy ChanLun_BTC_30 --strategy-path ./user_data/Chan/strategies --timerange=20250510-20250520
# freqtrade backtesting -c ./user_data/Chan/config/ChanLun_BTC_30.json --strategy ChanLun_BTC_30 --strategy-path ./user_data/Chan/strategies --timerange=20250712-
# freqtrade download-data -c ./user_data/Chan/config/ChanLun_BTC_30.json -t 1m --pairs BTC/USDT:USDT --timerange=20250405-
# freqtrade hyperopt --hyperopt-loss SharpeHyperOptLossDaily --spaces roi stoploss --strategy ChanLun_BTC_30 --strategy-path ./user_data/Chan/strategies -c ./user_data/Chan/config/ChanLun_BTC_30.json -e 200 --timerange=20250201-20250401
@@ -62,6 +62,8 @@ class ChanLun_BTC_30(IStrategy):
"240": 0.025,
"360": 0
}
minimal_roi = {
}
can_short = True
lev = 1.0
stoploss = -0.2 # 设置为很大的负值,让custom_stoploss来控制
@@ -74,14 +76,14 @@ class ChanLun_BTC_30(IStrategy):
# 启用仓位调整功能以支持分批止盈
position_adjustment_enable = True
startup_candle_count = 780
startup_candle_count = 2880
time5 = 5
time15 = 15
time30 = 30
time60 = 60
time4h = 240
time30 = 3
time30 = 60
last_time = datetime.now()
chan = ChanLun()
chanpy = ChanPY()
@@ -117,9 +119,9 @@ class ChanLun_BTC_30(IStrategy):
#self.chan.plot_dual(dataframe_5, dataframe_30)
chanpy_state = self.chanpy.get_bsp_state(dataframe_5)
dataframe_5['chanpy_state'] = chanpy_state
state_list = self.chan.get_klc_state_list(dataframe_3)
dataframe_3['state'] = state_list
dataframe_3['fx'] = state_list
state_list = self.chan.get_klc_state_list(dataframe_60)
dataframe_60['state'] = state_list
dataframe_60['fx'] = state_list
#bi_list_1 = self.chan.get_bi_list(dataframe)
#bi_list_5 = self.chan.get_bi_list(dataframe_5)
#bi_list_15 = self.chan.get_bi_list(dataframe_15)
@@ -145,9 +147,11 @@ class ChanLun_BTC_30(IStrategy):
klc_list = self.chan.get_klc_list(dataframe)
bi_list = self.chan.cal_bi_list(klc_list)
seg_list = self.chan.get_seg_list(bi_list)
zs_list = self.chan.get_zs_list(bi_list, seg_list)
seg = seg_list[-1]
bi = bi_list[-1]
print(seg.start_time, seg.dir, bi.start_time, bi.dir)
zs = zs_list[-1]
print(zs.start_time, zs.zg, zs.zd, zs.dir)
def print_bi(self, bi_list):
if bi_list and len(bi_list) > 2:
bi1 = bi_list[-1]
@@ -160,8 +164,8 @@ class ChanLun_BTC_30(IStrategy):
macd = ta.MACD(df, fastperiod=fast, slowperiod=slow, signalperiod=period)
bb365 = ta.BBANDS(df, timeperiod=365, nbdevup=3.0, nbdevdn=3.0, matype=0)
bb120 = ta.BBANDS(df, timeperiod=120, nbdevup=3.0, nbdevdn=3.0, matype=0)
bb30 = ta.BBANDS(df, timeperiod=90, nbdevup=3.0, nbdevdn=3.0, matype=0)
bb302 = ta.BBANDS(df, timeperiod=90, nbdevup=2.0, nbdevdn=2.0, matype=0)
bb30 = ta.BBANDS(df, timeperiod=41, nbdevup=2.3, nbdevdn=2.3, matype=0)
bb302 = ta.BBANDS(df, timeperiod=41, nbdevup=2.0, nbdevdn=2.0, matype=0)
# 计算布林带中轨(移动平均线)
bb30_middle = ta.SMA(df, timeperiod=90)
@@ -226,7 +230,7 @@ class ChanLun_BTC_30(IStrategy):
new_exitprice = proposed_rate - 50
return new_exitprice
def adjust_trade_position(self, trade: Trade, current_time: datetime,
def adjust_trade_position1(self, trade: Trade, current_time: datetime,
current_rate: float, current_profit: float,
min_stake: Optional[float], max_stake: float,
current_entry_rate: float, current_exit_rate: float,