Merge remote-tracking branch 'origin/Multiple_paires' into Multiple_paires
This commit is contained in:
@@ -17,13 +17,13 @@
|
||||
"max_open_trades": 20
|
||||
},
|
||||
"sell": {
|
||||
"b30_indicateur": "sma24",
|
||||
"baisse": 0.2,
|
||||
"sell_force_sell": -0.121,
|
||||
"b30_indicateur": "sma36",
|
||||
"baisse": 0.3,
|
||||
"sell_force_sell": -0.03,
|
||||
"sell_indicator": "sma36"
|
||||
},
|
||||
"protection": {
|
||||
"drop_from_last_entry": 0.0,
|
||||
"drop_from_last_entry": -0.01,
|
||||
"mises_bull": 4
|
||||
}
|
||||
},
|
||||
|
||||
62
Empty5m.py
62
Empty5m.py
@@ -19,6 +19,8 @@ from freqtrade.strategy import (BooleanParameter, CategoricalParameter, DecimalP
|
||||
import ta
|
||||
import talib.abstract as talib
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
from ta.trend import SMAIndicator, EMAIndicator, MACD, ADXIndicator
|
||||
from ta.momentum import RSIIndicator, StochasticOscillator
|
||||
|
||||
from functools import reduce
|
||||
from random import shuffle
|
||||
@@ -103,6 +105,7 @@ class Empty5m(IStrategy):
|
||||
position_adjustment_enable = True
|
||||
use_custom_stoploss = True
|
||||
|
||||
can_short = True
|
||||
#max_open_trades = 3
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
@@ -559,14 +562,14 @@ class Empty5m(IStrategy):
|
||||
self.pairs[pair]['force_sell'] = True
|
||||
return 'smaBF'
|
||||
else:
|
||||
if current_profit < self.sell_force_sell.value \
|
||||
if current_profit < self.sell_force_sell.value and self.wallets.get_available_stake_amount() < 50 \
|
||||
and last_candle[f"close"] <= last_candle[self.sell_indicator.value]:
|
||||
self.pairs[pair]['force_sell'] = True
|
||||
return 'sma'
|
||||
|
||||
if current_profit > 0.00 and \
|
||||
if current_profit > 0.01 and \
|
||||
(baisse > self.baisse.value and last_candle[f"close"] <= last_candle[self.b30_indicateur.value]) \
|
||||
and last_candle['hapercent'] <0 :
|
||||
and last_candle['hapercent'] < 0:
|
||||
self.pairs[pair]['force_sell'] = True
|
||||
return 'B30'
|
||||
|
||||
@@ -694,12 +697,14 @@ class Empty5m(IStrategy):
|
||||
dataframe["volume_mean"] = dataframe["volume"].rolling(20).mean()
|
||||
dataframe["volume_ratio"] = dataframe["volume"] / dataframe["volume_mean"]
|
||||
|
||||
dataframe["market_state"] = 0
|
||||
# dataframe["market_state"] = 0
|
||||
#
|
||||
# dataframe.loc[dataframe["percent"] < -0.005, "market_state"] = -1
|
||||
# dataframe.loc[(dataframe["percent3"] < -0.015) & (dataframe["volume_ratio"] > 2), "market_state"] = -2
|
||||
# dataframe.loc[(dataframe["percent"] > 0.003) & (dataframe["volume_ratio"] > 1.5), "market_state"] = 1
|
||||
# dataframe["velocity"] = dataframe["percent"] - dataframe["percent3"]
|
||||
|
||||
dataframe.loc[dataframe["percent"] < -0.005, "market_state"] = -1
|
||||
dataframe.loc[(dataframe["percent3"] < -0.015) & (dataframe["volume_ratio"] > 2), "market_state"] = -2
|
||||
dataframe.loc[(dataframe["percent"] > 0.003) & (dataframe["volume_ratio"] > 1.5), "market_state"] = 1
|
||||
dataframe["velocity"] = dataframe["percent"] - dataframe["percent3"]
|
||||
dataframe = self.calculateMarketState(dataframe, metadata)
|
||||
|
||||
# ######################################################################################################
|
||||
################### INFORMATIVE 1h
|
||||
@@ -746,6 +751,7 @@ class Empty5m(IStrategy):
|
||||
informative['stop_buying'] = latched
|
||||
informative = self.calculateDownAndUp(informative, limit=0.0001)
|
||||
|
||||
informative = self.calculateMarketState(informative, metadata)
|
||||
dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1h", ffill=True)
|
||||
# ######################################################################################################
|
||||
|
||||
@@ -789,6 +795,7 @@ class Empty5m(IStrategy):
|
||||
else:
|
||||
latched[i] = latched[i - 1]
|
||||
informative['stop_buying'] = latched
|
||||
informative = self.calculateMarketState(informative, metadata)
|
||||
|
||||
dataframe = merge_informative_pair(dataframe, informative, self.timeframe, "1d", ffill=True)
|
||||
# ######################################################################################################
|
||||
@@ -981,17 +988,23 @@ class Empty5m(IStrategy):
|
||||
conditions = list()
|
||||
# conditions.append(dataframe['mid_regression'].shift(2) > dataframe['mid_regression'].shift(1))
|
||||
# conditions.append(dataframe['mid_regression'].shift(1) < dataframe['mid_regression'])
|
||||
conditions.append(dataframe['close'] <= dataframe['min12_1h'])
|
||||
conditions.append(dataframe['min60'] == dataframe['min60'].shift(5))
|
||||
conditions.append(dataframe['close'] <= dataframe['min3_1h'])
|
||||
# conditions.append(dataframe['min60'] == dataframe['min60'].shift(5))
|
||||
conditions.append(dataframe['has_cross_min_6'] == 1)
|
||||
conditions.append(dataframe['down_count'] <= 5)
|
||||
conditions.append(dataframe['down_count'] <= 5)
|
||||
# conditions.append(dataframe['down_count'] <= 5)
|
||||
# conditions.append(dataframe['sma12_deriv1'] >= 0)
|
||||
dataframe.loc[
|
||||
reduce(lambda x, y: x & y, conditions),
|
||||
['enter_long', 'enter_tag']
|
||||
] = (1, 'Mid')
|
||||
|
||||
dataframe.loc[
|
||||
(
|
||||
(dataframe['rsi'] > 70) # surachat
|
||||
),
|
||||
'enter_short'
|
||||
] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
@@ -1413,4 +1426,27 @@ class Empty5m(IStrategy):
|
||||
if i - shift_value > 1: # Vérifier que le shift ne dépasse pas l'index
|
||||
down_pct_values[i] = 100 * (dataframe['close'].iloc[i] - dataframe['close'].iloc[i - shift_value]) / \
|
||||
dataframe['close'].iloc[i - shift_value]
|
||||
return down_pct_values
|
||||
return down_pct_values
|
||||
|
||||
def calculateMarketState(self, dataframe, metadata):
|
||||
|
||||
dataframe['ema50'] = EMAIndicator(dataframe['close'], window=50).ema_indicator()
|
||||
dataframe['ema200'] = EMAIndicator(dataframe['close'], window=200).ema_indicator()
|
||||
# RSI
|
||||
dataframe['rsi'] = RSIIndicator(dataframe['close'], window=14).rsi()
|
||||
dataframe["market_state"] = 0
|
||||
|
||||
cond_bull = (
|
||||
(dataframe["rsi"] > 55) &
|
||||
(dataframe["ema50"] > dataframe["ema200"])
|
||||
)
|
||||
|
||||
cond_bear = (
|
||||
(dataframe["rsi"] < 45) &
|
||||
(dataframe["ema50"] < dataframe["ema200"])
|
||||
)
|
||||
|
||||
dataframe.loc[cond_bull, "market_state"] = 1
|
||||
dataframe.loc[cond_bear, "market_state"] = -1
|
||||
|
||||
return dataframe
|
||||
@@ -1267,7 +1267,7 @@ class FrictradeLearning(IStrategy):
|
||||
# hours_since_first_price = (current_time - trade.open_date_utc).seconds / 3600.0
|
||||
# days_since_first_price = (current_time - trade.open_date_utc).days
|
||||
hours = (current_time - trade.date_last_filled_utc).total_seconds() / 3600.0
|
||||
# minutes = (current_time - trade.date_last_filled_utc).total_seconds() / 60.0
|
||||
minutes = (current_time - trade.date_last_filled_utc).total_seconds() / 60.0
|
||||
|
||||
count_of_buys = trade.nr_of_successful_entries
|
||||
# current_time_utc = current_time.astimezone(timezone.utc)
|
||||
@@ -1331,8 +1331,8 @@ class FrictradeLearning(IStrategy):
|
||||
increase = - decline
|
||||
|
||||
# FIN ########################## ALGO ATH
|
||||
force = hours > 12 #self.hours_force.value and last_candle[self.indic_1h_force_buy.value] > 0
|
||||
condition = last_candle['percent'] > 0 \
|
||||
force = False #self.hours_force.value and last_candle[self.indic_1h_force_buy.value] > 0
|
||||
condition = minutes > 5 and last_candle['percent'] > 0 \
|
||||
and ((count_of_buys <= 4 and last_candle['sma24_deriv1'] > 0) or (count_of_buys > 4 and last_candle['sma60_deriv1'] > 0))\
|
||||
and last_candle['close'] < self.pairs[pair]['first_price']
|
||||
|
||||
|
||||
Reference in New Issue
Block a user