FrictradeLearning
This commit is contained in:
@@ -73,7 +73,7 @@ RESET = "\033[0m"
|
|||||||
|
|
||||||
|
|
||||||
class FrictradeLearning(IStrategy):
|
class FrictradeLearning(IStrategy):
|
||||||
startup_candle_count = 200
|
startup_candle_count = 360
|
||||||
train_model = None
|
train_model = None
|
||||||
model_indicators = []
|
model_indicators = []
|
||||||
DEFAULT_PARAMS = {
|
DEFAULT_PARAMS = {
|
||||||
@@ -634,6 +634,8 @@ class FrictradeLearning(IStrategy):
|
|||||||
|
|
||||||
informative['rsi'] = talib.RSI(informative['mid'], timeperiod=14)
|
informative['rsi'] = talib.RSI(informative['mid'], timeperiod=14)
|
||||||
self.calculeDerivees(informative, 'rsi', ema_period=12)
|
self.calculeDerivees(informative, 'rsi', ema_period=12)
|
||||||
|
self.calculateScores(informative, 6)
|
||||||
|
|
||||||
# informative = self.rsi_trend_probability(informative)
|
# informative = self.rsi_trend_probability(informative)
|
||||||
|
|
||||||
# probas = self.calculModelInformative(informative)
|
# probas = self.calculModelInformative(informative)
|
||||||
@@ -889,13 +891,7 @@ class FrictradeLearning(IStrategy):
|
|||||||
self.calculeDerivees(dataframe, 'sma5', ema_period=3)
|
self.calculeDerivees(dataframe, 'sma5', ema_period=3)
|
||||||
|
|
||||||
horizon = 180
|
horizon = 180
|
||||||
dataframe['price_change'] = (dataframe['close'] - dataframe['close'].shift(horizon)) / dataframe['close'].shift(horizon)
|
self.calculateScores(dataframe, horizon)
|
||||||
# dataframe['rsi_delta'] = dataframe['rsi'] - dataframe['rsi'].shift(horizon)
|
|
||||||
|
|
||||||
dataframe['price_score'] = (dataframe['price_change'] / 0.05).clip(0, 2)
|
|
||||||
# dataframe['rsi_score'] = (dataframe['rsi_delta'] / 15).clip(0, 2)
|
|
||||||
|
|
||||||
dataframe['heat_score'] = talib.MAX(dataframe['price_score'], timeperiod=horizon) #+ dataframe['rsi_score']
|
|
||||||
|
|
||||||
# val = 90000
|
# val = 90000
|
||||||
# steps = 12
|
# steps = 12
|
||||||
@@ -957,6 +953,7 @@ class FrictradeLearning(IStrategy):
|
|||||||
|
|
||||||
if self.pairs[pair]['count_of_buys']:
|
if self.pairs[pair]['count_of_buys']:
|
||||||
dca_threshold = self.pairs[pair]['dca_thresholds'][min(self.pairs[pair]['count_of_buys'] - 1, len(self.pairs[pair]['dca_thresholds']) - 1)]
|
dca_threshold = self.pairs[pair]['dca_thresholds'][min(self.pairs[pair]['count_of_buys'] - 1, len(self.pairs[pair]['dca_thresholds']) - 1)]
|
||||||
|
dataframe[f"next_dca"] = val * (1 - dca_threshold)
|
||||||
print(f"count_of_buys={self.pairs[pair]['count_of_buys']} dca_threshold={dca_threshold} {self.pairs[pair]['dca_thresholds']}")
|
print(f"count_of_buys={self.pairs[pair]['count_of_buys']} dca_threshold={dca_threshold} {self.pairs[pair]['dca_thresholds']}")
|
||||||
|
|
||||||
print(f"val={val} dca={self.pairs[pair]['dca_thresholds']} ath={self.pairs[pair]['last_ath']} first_price={self.pairs[pair]['first_price']}")
|
print(f"val={val} dca={self.pairs[pair]['dca_thresholds']} ath={self.pairs[pair]['last_ath']} first_price={self.pairs[pair]['first_price']}")
|
||||||
@@ -984,7 +981,7 @@ class FrictradeLearning(IStrategy):
|
|||||||
loss_amount += total_stake * dca_previous
|
loss_amount += total_stake * dca_previous
|
||||||
offset = self.dynamic_trailing_offset(pair, total_stake, price=val, ath=ath, count_of_buys=count)
|
offset = self.dynamic_trailing_offset(pair, total_stake, price=val, ath=ath, count_of_buys=count)
|
||||||
|
|
||||||
if count == self.pairs[pair]['count_of_buys'] - self.pairs[pair]['has_gain']:
|
if count == self.pairs[pair]['count_of_buys'] - self.pairs[pair]['has_gain'] - 1:
|
||||||
print(f"next_buy={round(val * (1 - pct),1)} count={count} pct={round(pct, 4)}")
|
print(f"next_buy={round(val * (1 - pct),1)} count={count} pct={round(pct, 4)}")
|
||||||
dataframe[f"next_buy"] = val * (1 - pct)
|
dataframe[f"next_buy"] = val * (1 - pct)
|
||||||
count += 1
|
count += 1
|
||||||
@@ -996,6 +993,13 @@ class FrictradeLearning(IStrategy):
|
|||||||
|
|
||||||
return dataframe
|
return dataframe
|
||||||
|
|
||||||
|
def calculateScores(self, dataframe, horizon):
|
||||||
|
dataframe['price_change'] = (dataframe['close'] - dataframe['close'].shift(horizon)) / dataframe['close'].shift(horizon)
|
||||||
|
# dataframe['rsi_delta'] = dataframe['rsi'] - dataframe['rsi'].shift(horizon)
|
||||||
|
dataframe['price_score'] = (dataframe['price_change'] / 0.05).clip(0, 2)
|
||||||
|
# dataframe['rsi_score'] = (dataframe['rsi_delta'] / 15).clip(0, 2)
|
||||||
|
dataframe['heat_score'] = talib.MAX(dataframe['price_score'], timeperiod=horizon) # + dataframe['rsi_score']
|
||||||
|
|
||||||
def getOpenTrades(self):
|
def getOpenTrades(self):
|
||||||
# if len(self.trades) == 0:
|
# if len(self.trades) == 0:
|
||||||
self.trades = Trade.get_open_trades()
|
self.trades = Trade.get_open_trades()
|
||||||
@@ -1059,7 +1063,7 @@ class FrictradeLearning(IStrategy):
|
|||||||
# & (dataframe['min180'].shift(3) == dataframe['min180'])
|
# & (dataframe['min180'].shift(3) == dataframe['min180'])
|
||||||
, ['enter_long', 'enter_tag']
|
, ['enter_long', 'enter_tag']
|
||||||
] = (1, f"future")
|
] = (1, f"future")
|
||||||
dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.003, np.nan)
|
dataframe['test'] = np.where(dataframe['enter_long'] == 1, dataframe['close'] * 1.01, np.nan)
|
||||||
|
|
||||||
return dataframe
|
return dataframe
|
||||||
|
|
||||||
@@ -2334,6 +2338,9 @@ class FrictradeLearning(IStrategy):
|
|||||||
and not c.startswith('sma12_deriv1_1h')
|
and not c.startswith('sma12_deriv1_1h')
|
||||||
and not c.startswith('sma12_1h')
|
and not c.startswith('sma12_1h')
|
||||||
and not c.startswith('confidence_index')
|
and not c.startswith('confidence_index')
|
||||||
|
and not c.startswith('price_change')
|
||||||
|
and not c.startswith('price_score')
|
||||||
|
and not c.startswith('heat_score')
|
||||||
]
|
]
|
||||||
# Étape 3 : remplacer inf et NaN par 0
|
# Étape 3 : remplacer inf et NaN par 0
|
||||||
dataframe[usable_cols] = dataframe[usable_cols].replace([np.inf, -np.inf], 0).fillna(0)
|
dataframe[usable_cols] = dataframe[usable_cols].replace([np.inf, -np.inf], 0).fillna(0)
|
||||||
|
|||||||
Reference in New Issue
Block a user