Stratégie corrigée Calcul 20200101-20250514 4073$ 158.8$ mise moyenne profit

This commit is contained in:
Jérôme Delacotte
2025-05-19 19:31:49 +02:00
parent 2e1b874a29
commit 4a2f9126fc
2 changed files with 2920 additions and 7050 deletions

View File

@@ -25,6 +25,7 @@ import talib.abstract as talib
import freqtrade.vendor.qtpylib.indicators as qtpylib import freqtrade.vendor.qtpylib.indicators as qtpylib
import requests import requests
from datetime import timezone, timedelta from datetime import timezone, timedelta
from scipy.signal import savgol_filter
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -99,7 +100,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
}, },
"subplots": { "subplots": {
"Pct": { "Pct": {
"sma20_pct": { "sma20_deriv1": {
'color': "green" 'color': "green"
}, },
"down_pct": { "down_pct": {
@@ -123,11 +124,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
"color": "blue" "color": "blue"
} }
}, },
"Rsi_diff": { "Rsi_deriv": {
"rsi_diff_1h": { "rsi_deriv1_1h": {
"color": "red" "color": "red"
}, },
"rsi_diff_1d": { "rsi_deriv1_1d": {
"color": "blue" "color": "blue"
}, },
}, },
@@ -140,7 +141,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
} }
}, },
# "Diff": { # "Diff": {
# "sma10_diff": { # "sma10_deriv1": {
# "color": "#74effc" # "color": "#74effc"
# } # }
# }, # },
@@ -458,23 +459,26 @@ class Zeus_8_3_2_B_4_2(IStrategy):
count_of_buys = trade.nr_of_successful_entries count_of_buys = trade.nr_of_successful_entries
baisse = self.pairs[pair]['max_profit'] - current_profit
mx = self.pairs[pair]['max_profit'] / 5
if (last_candle['deriv1_1h'] < 0 and last_candle['deriv2_1h'] < 0) and ((baisse > mx) & (current_profit > expected_profit)):
return 'Drv_' + str(count_of_buys)
self.pairs[pair]['count_of_buys'] = count_of_buys self.pairs[pair]['count_of_buys'] = count_of_buys
self.pairs[pair]['current_profit'] = current_profit self.pairs[pair]['current_profit'] = current_profit
self.pairs[pair]['max_profit'] = max(self.pairs[pair]['max_profit'], current_profit) self.pairs[pair]['max_profit'] = max(self.pairs[pair]['max_profit'], current_profit)
if (last_candle['mid_smooth_deriv1'] >= 0): # if (last_candle['mid_smooth_deriv1'] >= 0):
return None # return None
if (last_candle['tendency'] in ('H++', 'H+')) and (last_candle['rsi'] < 80): # if (last_candle['tendency'] in ('H++', 'H+')) and (last_candle['rsi'] < 80):
return None # return None
#
baisse = self.pairs[pair]['max_profit'] - current_profit # if (baisse > mx) & (current_profit > expected_profit):
mx = self.pairs[pair]['max_profit'] / 5 # self.trades = list()
if (baisse > mx) & (current_profit > expected_profit): # return 'mx_' + str(count_of_buys)
self.trades = list() # if (last_candle['percent12'] <= -0.01) & (current_profit >= expected_profit):
return 'mx_' + str(count_of_buys) # self.trades = list()
if (last_candle['percent12'] <= -0.01) & (current_profit >= expected_profit): # return 'pft_' + str(count_of_buys)
self.trades = list()
return 'pft_' + str(count_of_buys)
self.pairs[pair]['max_touch'] = max(last_candle['haclose'], self.pairs[pair]['max_touch']) self.pairs[pair]['max_touch'] = max(last_candle['haclose'], self.pairs[pair]['max_touch'])
@@ -556,11 +560,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
if np.isnan(last_candle['rsi_1d']): if np.isnan(last_candle['rsi_1d']):
string = ' ' string = ' '
else: else:
string = (str(int(last_candle['rsi_1d']))) + " " + str(int(last_candle['rsi_diff_1d'])) string = (str(int(last_candle['rsi_1d']))) + " " + str(int(last_candle['rsi_deriv1_1d']))
trade_type = trade_type \ trade_type = trade_type \
+ " " + string \ + " " + string \
+ " " + str(int(last_candle['rsi_1h'])) \ + " " + str(int(last_candle['rsi_1h'])) \
+ " " + str(int(last_candle['rsi_diff_1h'])) + " " + str(int(last_candle['rsi_deriv1_1h']))
val144 = self.getProbaHausse144(last_candle) val144 = self.getProbaHausse144(last_candle)
val1h = self.getProbaHausse1h(last_candle) val1h = self.getProbaHausse1h(last_candle)
@@ -628,11 +632,11 @@ class Zeus_8_3_2_B_4_2(IStrategy):
dataframe['sma5'] = talib.SMA(dataframe, timeperiod=5) dataframe['sma5'] = talib.SMA(dataframe, timeperiod=5)
dataframe['sma10'] = talib.SMA(dataframe, timeperiod=10) dataframe['sma10'] = talib.SMA(dataframe, timeperiod=10)
dataframe['sma10_diff'] = 100 * dataframe['sma10'].diff() / dataframe['sma10'] self.calculeDerivees(dataframe, 'sma10')
dataframe['sma20'] = talib.SMA(dataframe, timeperiod=20) dataframe['sma20'] = talib.SMA(dataframe, timeperiod=20)
dataframe['sma20_pct'] = 100 * dataframe['sma20'].diff() / dataframe['sma20'] self.calculeDerivees(dataframe, 'sma20')
dataframe['sma144'] = talib.SMA(dataframe, timeperiod=144) dataframe['sma144'] = talib.SMA(dataframe, timeperiod=144)
dataframe['sma144_deriv1'] = 100 * dataframe['sma144'].diff() / dataframe['sma144'] self.calculeDerivees(dataframe, 'sma144')
dataframe["percent"] = (dataframe["close"] - dataframe["open"]) / dataframe["open"] dataframe["percent"] = (dataframe["close"] - dataframe["open"]) / dataframe["open"]
dataframe["percent3"] = (dataframe["close"] - dataframe["open"].shift(3)) / dataframe["open"].shift(3) dataframe["percent3"] = (dataframe["close"] - dataframe["open"].shift(3)) / dataframe["open"].shift(3)
@@ -644,8 +648,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# print(metadata['pair']) # print(metadata['pair'])
dataframe['rsi'] = talib.RSI(dataframe['close'], timeperiod=14) dataframe['rsi'] = talib.RSI(dataframe['close'], timeperiod=14)
dataframe['rsi_diff'] = dataframe['rsi'].diff() self.calculeDerivees(dataframe, 'rsi')
dataframe['rsi_diff_2'] = dataframe['rsi_diff'].diff()
# Bollinger Bands # Bollinger Bands
bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2) bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2)
@@ -686,18 +689,22 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# informative['volatility'] = talib.STDDEV(informative['close'], timeperiod=14) / informative['close'] # informative['volatility'] = talib.STDDEV(informative['close'], timeperiod=14) / informative['close']
# informative['atr'] = (talib.ATR(informative['high'], informative['low'], informative['close'], timeperiod=14)) / informative['close'] # informative['atr'] = (talib.ATR(informative['high'], informative['low'], informative['close'], timeperiod=14)) / informative['close']
informative['rsi'] = talib.RSI(informative['close']) #, timeperiod=7) informative['rsi'] = talib.RSI(informative['close']) #, timeperiod=7)
informative['rsi_diff'] = informative['rsi'].diff() self.calculeDerivees(informative, 'rsi')
informative['rsi_diff_2'] = informative['rsi_diff'].diff()
informative['max12'] = talib.MAX(informative['close'], timeperiod=12) informative['max12'] = talib.MAX(informative['close'], timeperiod=12)
informative['min12'] = talib.MIN(informative['close'], timeperiod=12) informative['min12'] = talib.MIN(informative['close'], timeperiod=12)
informative['sma5'] = talib.SMA(informative, timeperiod=5) informative['sma5'] = talib.SMA(informative, timeperiod=5)
informative['sma5_diff'] = 100 * informative['sma5'].diff() / informative['sma5'] self.calculeDerivees(informative, 'sma5')
informative['sma24'] = talib.SMA(informative, timeperiod=24) informative['sma24'] = talib.SMA(informative, timeperiod=24)
informative['sma24_deriv1'] = 100 * informative['sma24'].rolling(7).mean().diff() / informative['sma24'] self.calculeDerivees(informative, 'sma24')
self.calculateDownAndUp(informative, limit=0.0012) self.calculateDownAndUp(informative, limit=0.0012)
informative['close_smooth'] = self.conditional_smoothing(informative['mid'], threshold=0.0015)
informative['smooth'], informative['deriv1'], informative['deriv2'] = self.smooth_and_derivatives(informative['close_smooth'])
informative['deriv1'] = 100 * informative['deriv1'] / informative['mid']
informative['deriv2'] = 1000 * informative['deriv2'] / informative['mid']
dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1h", ffill=True) dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1h", ffill=True)
################### INFORMATIVE 1d ################### INFORMATIVE 1d
@@ -713,11 +720,10 @@ class Zeus_8_3_2_B_4_2(IStrategy):
informative['min3'] = talib.MIN(informative['close'], timeperiod=3) informative['min3'] = talib.MIN(informative['close'], timeperiod=3)
informative['rsi'] = talib.RSI(informative['close']) #, timeperiod=7) informative['rsi'] = talib.RSI(informative['close']) #, timeperiod=7)
informative['rsi_diff'] = informative['rsi'].diff() self.calculeDerivees(informative, 'rsi')
informative['rsi_diff_2'] = informative['rsi_diff'].diff()
informative['sma5'] = talib.SMA(informative, timeperiod=5) informative['sma5'] = talib.SMA(informative, timeperiod=5)
informative['sma5_diff'] = 100 * (informative['sma5'].rolling(5).mean().diff()) / informative['sma5'] self.calculeDerivees(informative, 'sma5')
dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1d", ffill=True) dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1d", ffill=True)
@@ -766,20 +772,32 @@ class Zeus_8_3_2_B_4_2(IStrategy):
dataframe["mid_smooth_deriv2_1h"] = horizon_h * dataframe["mid_smooth_deriv1_1h"].rolling(horizon_h).mean().diff() dataframe["mid_smooth_deriv2_1h"] = horizon_h * dataframe["mid_smooth_deriv1_1h"].rolling(horizon_h).mean().diff()
dataframe['sma5_1h'] = dataframe['sma5_1h'].rolling(window=horizon_h).mean() dataframe['sma5_1h'] = dataframe['sma5_1h'].rolling(window=horizon_h).mean()
dataframe['sma5_diff_1h'] = dataframe['sma5_diff_1h'].rolling(window=horizon_h).mean() dataframe['sma5_deriv1_1h'] = dataframe['sma5_deriv1_1h'].rolling(window=horizon_h).mean()
dataframe['sma24_1h'] = dataframe['sma24_1h'].rolling(window=horizon_h).mean() dataframe['sma24_1h'] = dataframe['sma24_1h'].rolling(window=horizon_h).mean()
dataframe['sma24_deriv1_1h'] = dataframe['sma24_deriv1_1h'].rolling(window=horizon_h).mean() dataframe['sma24_deriv1_1h'] = dataframe['sma24_deriv1_1h'].rolling(window=horizon_h).mean()
dataframe = self.calculateRegression(dataframe, column='mid_smooth_1h', window=horizon_h * 12, degree=4, future_offset=24) dataframe = self.calculateRegression(dataframe, column='mid_smooth_1h', window=horizon_h * 12, degree=4, future_offset=24)
# Suppose que df['close'] est ton prix de clôture
dataframe['close_smooth'] = self.conditional_smoothing(dataframe['mid'], threshold=0.0015)
dataframe['smooth'], dataframe['deriv1'], dataframe['deriv2'] = self.smooth_and_derivatives(dataframe['close_smooth'])
dataframe['deriv1'] = 100 * dataframe['deriv1'] / dataframe['mid']
dataframe['deriv2'] = 1000 * dataframe['deriv2'] / dataframe['mid']
# =============================== # ===============================
# Lissage des valeurs horaires # Lissage des valeurs Journalières
dataframe['mid_smooth_1d'] = dataframe['mid_smooth_1h'].rolling(window=horizon_d * 5).mean() dataframe['mid_smooth_1d'] = dataframe['mid_smooth_1d'].rolling(window=horizon_d * 5).mean()
dataframe["mid_smooth_deriv1_1d"] = dataframe["mid_smooth_1d"].rolling(horizon_d).mean().diff() / horizon_d dataframe["mid_smooth_deriv1_1d"] = dataframe["mid_smooth_1d"].rolling(horizon_d).mean().diff() / horizon_d
dataframe["mid_smooth_deriv2_1d"] = horizon_d * dataframe["mid_smooth_deriv1_1d"].rolling(horizon_d).mean().diff() dataframe["mid_smooth_deriv2_1d"] = horizon_d * dataframe["mid_smooth_deriv1_1d"].rolling(horizon_d).mean().diff()
dataframe['close_smooth_1d'] = self.conditional_smoothing(dataframe['mid_smooth_1d'], threshold=0.0015)
dataframe['smooth_1d'], dataframe['deriv1_1d'], dataframe['deriv2_1d'] = self.smooth_and_derivatives(dataframe['close_smooth_1d'])
dataframe['deriv1_1d'] = 10 * dataframe['deriv1_1d'] / dataframe['mid_smooth_1d']
dataframe['deriv2_1d'] = 100 * dataframe['deriv2_1d'] / dataframe['mid_smooth_1d']
dataframe['sma5_1d'] = dataframe['sma5_1d'].rolling(window=horizon_d * 5).mean() dataframe['sma5_1d'] = dataframe['sma5_1d'].rolling(window=horizon_d * 5).mean()
dataframe['sma5_diff_1d'] = dataframe['sma5_diff_1d'].rolling(window=horizon_d).mean() dataframe['sma5_deriv1_1d'] = dataframe['sma5_deriv1_1d'].rolling(window=horizon_d).mean()
# dataframe['sma24_1d'] = dataframe['sma24_1d'].rolling(window=horizon_d).mean() # dataframe['sma24_1d'] = dataframe['sma24_1d'].rolling(window=horizon_d).mean()
# dataframe['sma24_deriv1_1d'] = dataframe['sma24_deriv1_1d'].rolling(window=horizon_d).mean() # dataframe['sma24_deriv1_1d'] = dataframe['sma24_deriv1_1d'].rolling(window=horizon_d).mean()
# dataframe = self.calculateRegression(dataframe, column='mid_smooth_1d', window=24, degree=4, future_offset=12) # dataframe = self.calculateRegression(dataframe, column='mid_smooth_1d', window=24, degree=4, future_offset=12)
@@ -799,6 +817,10 @@ class Zeus_8_3_2_B_4_2(IStrategy):
return dataframe return dataframe
def calculeDerivees(self, dataframe, indic):
dataframe[f"{indic}_deriv1"] = 100 * dataframe[f"{indic}"].diff() / dataframe[f"{indic}"]
dataframe[f"{indic}_deriv2"] = 10 * dataframe[f"{indic}_deriv1"].diff()
def calculateDownAndUp(self, dataframe, limit=0.0001): def calculateDownAndUp(self, dataframe, limit=0.0001):
dataframe['down'] = dataframe['hapercent'] <= limit dataframe['down'] = dataframe['hapercent'] <= limit
dataframe['up'] = dataframe['hapercent'] >= limit dataframe['up'] = dataframe['hapercent'] >= limit
@@ -843,33 +865,37 @@ class Zeus_8_3_2_B_4_2(IStrategy):
buy_level = dataframe['average_line_50'] #dataframe['buy_level'] # self.get_buy_level(pair, dataframe) buy_level = dataframe['average_line_50'] #dataframe['buy_level'] # self.get_buy_level(pair, dataframe)
dataframe.loc[ # dataframe.loc[
( # (
(dataframe['max200_diff'] >= 0.01) # (dataframe['max200_diff'] >= 0.01)
& (dataframe['percent12'] < -0.002) # & (dataframe['percent12'] < -0.002)
& (dataframe['open'] < dataframe['average_line_288_099']) # & (dataframe['open'] < dataframe['average_line_288_099'])
& (dataframe['open'] < dataframe['average_line_50']) # & (dataframe['open'] < dataframe['average_line_50'])
& (dataframe['min12'].shift(2) == dataframe['min12']) # & (dataframe['min12'].shift(2) == dataframe['min12'])
& (dataframe['up_count'] > 0) # & (dataframe['up_count'] > 0)
& (dataframe["bb_width"] > 0.01) # & (dataframe["bb_width"] > 0.01)
), ['enter_long', 'enter_tag']] = (1, 'mx200') # ), ['enter_long', 'enter_tag']] = (1, 'mx200')
# dataframe.loc[
# (
# (dataframe['percent'] > 0)
# & (dataframe['mid_smooth_deriv1'] >= dataframe['mid_smooth_deriv1'].shift(1))
# ), ['enter_long', 'enter_tag']] = (1, 'down')
dataframe.loc[ dataframe.loc[
( (
(dataframe['mid_smooth_deriv1_1h'] >= -0.01) (dataframe['deriv1_1h'] >= 0)
& (dataframe['mid_smooth_deriv1_1h'] >= dataframe['mid_smooth_deriv1_1h'].shift(1)) & (dataframe['deriv1'] >= 0)
& (dataframe['mid_smooth_deriv2_1h'] >= dataframe['mid_smooth_deriv2_1h'].shift(1)) & (dataframe['deriv1'].shift(1) <= 0)
# & (dataframe['mid_smooth_deriv1'] >= dataframe['mid_smooth_deriv1'].shift(1)) & (dataframe['deriv1'] >= dataframe['deriv1'].shift(1))
# & (dataframe['mid_smooth_deriv1_24'] >= dataframe['mid_smooth_deriv1_24'].shift(1)) # avant pente positive ), ['enter_long', 'enter_tag']] = (1, 'smooth')
# & (dataframe['mid_smooth_deriv1_24'].shift(1) <= dataframe['mid_smooth_deriv1_24'].shift(2)) # accélération haussière
), ['enter_long', 'enter_tag']] = (1, 'down')
dataframe.loc[ # dataframe.loc[
( # (
(dataframe['low'] < dataframe['min200']) # (dataframe['low'] < dataframe['min200'])
& (dataframe['min50'] == dataframe['min50'].shift(3)) # & (dataframe['min50'] == dataframe['min50'].shift(3))
& (dataframe['tendency'] != "B-") # & (dataframe['tendency'] != "B-")
), ['enter_long', 'enter_tag']] = (1, 'low') # ), ['enter_long', 'enter_tag']] = (1, 'low')
dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.01, np.nan) dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.01, np.nan)
@@ -889,7 +915,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
indic_2 = 'sma144_deriv1' indic_2 = 'sma144_deriv1'
#indic_2 = 'percent_with_max_hour' #indic_2 = 'percent_with_max_hour'
# indic_1 = 'mid_smooth_deriv1_1h' # indic_1 = 'mid_smooth_deriv1_1h'
# indic_2 = 'sma5_diff_1d' # indic_2 = 'sma5_deriv1_1d'
self.calculateProbabilite2Index(df, futur_cols, indic_1, indic_2) self.calculateProbabilite2Index(df, futur_cols, indic_1, indic_2)
@@ -1018,17 +1044,17 @@ class Zeus_8_3_2_B_4_2(IStrategy):
pct_max = - pct pct_max = - pct
lim = - pct - (count_of_buys * 0.001) lim = - pct - (count_of_buys * 0.001)
# print(f"{trade.pair} current_profit={current_profit} count_of_buys={count_of_buys} pct_max={pct_max:.3f} lim={lim:.3f} rsi_diff_1f={last_candle['rsi_diff_1h']}") # print(f"{trade.pair} current_profit={current_profit} count_of_buys={count_of_buys} pct_max={pct_max:.3f} lim={lim:.3f} rsi_deriv1_1f={last_candle['rsi_deriv1_1h']}")
# val144 = self.getProbaHausse144(last_candle) # val144 = self.getProbaHausse144(last_candle)
# val1h = self.getProbaHausse1h(last_candle) # val1h = self.getProbaHausse1h(last_candle)
val = self.getProbaHausse144(last_candle) # val = self.getProbaHausse144(last_candle)
# if (days_since_open > count_of_buys) & (0 < count_of_buys <= max_buys) & (current_rate <= limit) & (last_candle['enter_long'] == 1): # if (days_since_open > count_of_buys) & (0 < count_of_buys <= max_buys) & (current_rate <= limit) & (last_candle['enter_long'] == 1):
limit_buy = 20 limit_buy = 20
if (count_of_buys < limit_buy) \ if (count_of_buys < limit_buy) \
and (last_candle['enter_long'] == 1) \ and (last_candle['enter_long'] == 1) \
and (pct_max < lim and val > self.buy_val_adjust.value and last_candle['mid_smooth_deriv1_1d'] > - 1): and (pct_max < lim): # and val > self.buy_val_adjust.value and last_candle['mid_smooth_deriv1_1d'] > - 1):
try: try:
max_amount = self.config.get('stake_amount', 100) * 2.5 max_amount = self.config.get('stake_amount', 100) * 2.5
@@ -1057,7 +1083,7 @@ class Zeus_8_3_2_B_4_2(IStrategy):
return None return None
# if (count_of_buys < limit_buy and pct_max > pct and current_profit > 0.004) \ # if (count_of_buys < limit_buy and pct_max > pct and current_profit > 0.004) \
# and (last_candle['rsi_diff_1h'] >= -5) \ # and (last_candle['rsi_deriv1_1h'] >= -5) \
# and (last_candle['tendency'] in ('P', 'H++', 'DH', 'H+')) \ # and (last_candle['tendency'] in ('P', 'H++', 'DH', 'H+')) \
# and (last_candle['mid_smooth_deriv1'] > 0.015): # and (last_candle['mid_smooth_deriv1'] > 0.015):
# try: # try:
@@ -1091,21 +1117,22 @@ class Zeus_8_3_2_B_4_2(IStrategy):
val = self.approx_val_from_bins( val = self.approx_val_from_bins(
matrice=self.smooth24_sma144_deriv1_matrice_df, matrice=self.smooth24_sma144_deriv1_matrice_df,
numeric_matrice=self.smooth24_sma144_deriv1_numeric_matrice, numeric_matrice=self.smooth24_sma144_deriv1_numeric_matrice,
row_label=value_1, row_label=value_2,
col_label=value_2) col_label=value_1)
return val return val
def getProbaHausse1h(self, last_candle): def getProbaHausse1h(self, last_candle):
value_1 = self.getValuesFromTable(self.mid_smooth_1h_bins, last_candle['mid_smooth_deriv1_1h']) value_1 = self.getValuesFromTable(self.mid_smooth_1h_bins, last_candle['mid_smooth_deriv1_1h'])
value_2 = self.getValuesFromTable(self.sma24_deriv1_1h_bins, last_candle['sma24_deriv1_1h']) value_2 = self.getValuesFromTable(self.sma24_deriv1_1h_bins, last_candle['sma24_deriv1_1h'])
val = self.approx_val_from_bins(matrice=self.smooth_smadiff_matrice_df, numeric_matrice=self.smooth_smadiff_numeric_matrice, row_label=value_2, val = self.approx_val_from_bins(matrice=self.smooth_smadiff_matrice_df, numeric_matrice=self.smooth_smadiff_numeric_matrice,
row_label=value_2,
col_label=value_1) col_label=value_1)
return val return val
def getProbaHausse1d(self, last_candle): def getProbaHausse1d(self, last_candle):
value_1 = self.getValuesFromTable(self.mid_smooth_1h_bins, last_candle['mid_smooth_deriv1_1d']) value_1 = self.getValuesFromTable(self.mid_smooth_1h_bins, last_candle['mid_smooth_deriv1_1d'])
value_2 = self.getValuesFromTable(self.sma24_deriv1_1h_bins, last_candle['sma5_diff_1d']) value_2 = self.getValuesFromTable(self.sma24_deriv1_1h_bins, last_candle['sma5_deriv1_1d'])
val = self.approx_val_from_bins(matrice=self.smooth_smadiff_matrice_df, numeric_matrice=self.smooth_smadiff_numeric_matrice, row_label=value_2, val = self.approx_val_from_bins(matrice=self.smooth_smadiff_matrice_df, numeric_matrice=self.smooth_smadiff_numeric_matrice, row_label=value_2,
col_label=value_1) col_label=value_1)
@@ -1363,3 +1390,27 @@ class Zeus_8_3_2_B_4_2(IStrategy):
# # "required_profit": 0.01 # # "required_profit": 0.01
# # } # # }
# ] # ]
def conditional_smoothing(self, series, threshold=0.002):
smoothed = [series.iloc[0]]
for val in series.iloc[1:]:
last = smoothed[-1]
if abs(val - last) / last >= threshold:
smoothed.append(val)
else:
smoothed.append(last)
return pd.Series(smoothed, index=series.index)
# Lissage + dérivées
def smooth_and_derivatives(self, series, window=25, polyorder=3):
y = series.values
smoothed = savgol_filter(y, window_length=window, polyorder=polyorder)
deriv1 = savgol_filter(y, window_length=window, polyorder=polyorder, deriv=1)
deriv2 = savgol_filter(y, window_length=window, polyorder=polyorder, deriv=2)
return (
pd.Series(smoothed, index=series.index),
pd.Series(deriv1, index=series.index),
pd.Series(deriv2, index=series.index),
)

File diff suppressed because it is too large Load Diff