first
This commit is contained in:
0
.env/bin/user_data/strategies/.gitkeep
Normal file
0
.env/bin/user_data/strategies/.gitkeep
Normal file
0
.env/bin/user_data/strategies/__init__.py
Normal file
0
.env/bin/user_data/strategies/__init__.py
Normal file
216
.env/bin/user_data/strategies/data_eth_usdt_1m.py
Normal file
216
.env/bin/user_data/strategies/data_eth_usdt_1m.py
Normal file
@@ -0,0 +1,216 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class data_ETHUSDT_1m(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.24724,
|
||||
"30": 0.1,
|
||||
"46": 0.05,
|
||||
"151": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.1
|
||||
|
||||
# Trailing stoploss
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.02
|
||||
trailing_stop_positive_offset = 0.14
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = False
|
||||
ignore_roi_if_buy_signal = True
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'tema': {},
|
||||
'sar': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"MACD": {
|
||||
'macd': {'color': 'blue'},
|
||||
'macdsignal': {'color': 'orange'},
|
||||
},
|
||||
"RSI": {
|
||||
'rsi': {'color': 'red'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=14)
|
||||
dataframe['angle_short'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=10)
|
||||
dataframe['angle_mid'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=144)
|
||||
dataframe['angle_long'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=288)
|
||||
|
||||
dataframe['tsf_long'] = TSF(dataframe['close'], timeperiod=288)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=144)
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=10)
|
||||
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['correl_close_last_close'] = CORREL(dataframe['close'].shift(1), dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_tsf_long_close'] = CORREL(dataframe['tsf_long'], dataframe['close'], timeperiod=288)
|
||||
dataframe['correl_tsf_mid_close'] = CORREL(dataframe['tsf_mid'], dataframe['close'], timeperiod=144)
|
||||
dataframe['correl_tsf_short_close'] = CORREL(dataframe['tsf_short'], dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_angle_short_close'] = CORREL(dataframe['angle_short'], dataframe['close'], timeperiod=30)
|
||||
dataframe['correl_angle_mid_close'] = CORREL(dataframe['angle_mid'], dataframe['close'], timeperiod=144)
|
||||
dataframe['correl_angle_long_close'] = CORREL(dataframe['angle_long'], dataframe['close'], timeperiod=288)
|
||||
|
||||
dataframe['correl_hist_close'] = CORREL(dataframe['macdhist'], dataframe['close'], timeperiod=24)
|
||||
dataframe['correl_mfi_close'] = CORREL(dataframe['mfi'], dataframe['close'], timeperiod=14)
|
||||
|
||||
|
||||
|
||||
|
||||
dataframe['ema'] = EMA(dataframe['close'], timeperiod=8)
|
||||
dataframe['ma'] = MA(dataframe['close'], timeperiod=8, matype=0)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=20, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['lowerband'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > 14) &
|
||||
(0.5263534368259521 < dataframe['correl_h_l']) &
|
||||
(0.0728048430667152 < dataframe['correl_tsf_mid_close']) &
|
||||
(-0.02402596125126566 < dataframe['correl_angle_short_close']) &
|
||||
(0.2842166347875669 < dataframe['correl_angle_long_close']) &
|
||||
(-0.6552565064627378 < dataframe['correl_mfi_close']) &
|
||||
(-0.4853276710303872 < dataframe['correl_hist_close']) &
|
||||
(0.442188534531633 < dataframe['mfi']) &
|
||||
(0.6714488827895353 < dataframe['ema']) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['lowerband'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > 68) &
|
||||
(-0.6225944943311145 < dataframe['correl_h_l']) &
|
||||
(0.2602396802858502 < dataframe['correl_tsf_mid_close']) &
|
||||
(0.771988603840956 < dataframe['correl_angle_short_close']) &
|
||||
(0.33471662411500236 < dataframe['correl_angle_long_close']) &
|
||||
(-0.9562413964921457 < dataframe['correl_hist_close']) &
|
||||
(-0.43268559077377733 < dataframe['correl_mfi_close']) &
|
||||
(-0.25207265197064166 < dataframe['mfi']) &
|
||||
(-0.00739011415527302 < dataframe['ema']) &
|
||||
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
208
.env/bin/user_data/strategies/ethusdt2_safe_prod1.py
Normal file
208
.env/bin/user_data/strategies/ethusdt2_safe_prod1.py
Normal file
@@ -0,0 +1,208 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL, MAX, MIN, SAR, CCI, \
|
||||
HT_TRENDLINE, HT_DCPERIOD, HT_TRENDMODE, HT_SINE, RSI
|
||||
|
||||
from freqtrade.strategy import merge_informative_pair
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg2_ETHUSDT_1h_prod1(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.07371,
|
||||
"9817": 0.0461,
|
||||
"14487": 0.0254,
|
||||
"15960": 0
|
||||
}
|
||||
order_types = {
|
||||
'buy': 'market',
|
||||
'sell': 'market',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.23371
|
||||
|
||||
# Trailing stop:
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.11193
|
||||
trailing_stop_positive_offset = 0.20381
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'upperband': {'upperband': 'green'},
|
||||
'middleband': {'color': 'green'},
|
||||
'lowerband': {'color': 'green'},
|
||||
'tsf_mid': {'color': 'white'},
|
||||
'ema': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"corr": {
|
||||
'correl_h_l': {'color': 'black'},
|
||||
},
|
||||
"correl_tsf_mid_close": {
|
||||
'correl_tsf_mid_close': {'color': 'grey'},
|
||||
},
|
||||
"correl_angle_short_close": {
|
||||
'correl_angle_short_close': {'color': 'blue'},
|
||||
},
|
||||
"correl_angle_long_close": {
|
||||
'correl_angle_long_close': {'color': 'red'},
|
||||
},
|
||||
"correl_mfi_close": {
|
||||
'correl_mfi_close': {'color': 'black'},
|
||||
},
|
||||
"correl_hist_close": {
|
||||
'correl_tsf_mid_close': {'color': 'red'},
|
||||
},
|
||||
"mfi": {
|
||||
'mfi': {'color': 'yellow'},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/USDT", "1d")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
# dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12,
|
||||
# slowperiod=26, signalperiod=7)
|
||||
|
||||
# dataframe['cci'] = CCI(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=30)
|
||||
dataframe['ao'] = qtpylib.awesome_oscillator(dataframe, weighted=False, fast=5, slow=34)
|
||||
# dataframe['vwap'] = qtpylib.vwap(dataframe)
|
||||
# dataframe['vwap'] = qtpylib.rolling_vwap(dataframe)
|
||||
dataframe['rsi'] = RSI(dataframe['close'], timeperiod=14)
|
||||
# dataframe['tsf_long'] = TSF(dataframe['close'], timeperiod=200)
|
||||
# dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=7)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=50)
|
||||
|
||||
dataframe['angle_tsf_mid'] = LINEARREG_ANGLE(dataframe['tsf_mid'], timeperiod=10)
|
||||
# dataframe['angle'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=50)
|
||||
|
||||
# dataframe['tsf_max'] = MAX(dataframe['tsf_mid'], timeperiod=30)
|
||||
# dataframe['tsf_min'] = MIN(dataframe['tsf_mid'], timeperiod=30)
|
||||
# dataframe['sar'] = SAR(dataframe['high'], dataframe['low'])
|
||||
# dataframe['sine'], dataframe['leadsine'] = HT_SINE(dataframe['close'])
|
||||
# dataframe['trend'] = HT_TRENDLINE(dataframe['close'])
|
||||
# dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
# timeperiod=5)
|
||||
# dataframe['angle_trend_mid'] = LINEARREG_ANGLE(dataframe['trend'], timeperiod=10)
|
||||
|
||||
# dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
# timeperiod=30, nbdevup=2,
|
||||
# nbdevdn=2, matype=0)
|
||||
# if not self.dp:
|
||||
# # Don't do anything if DataProvider is not available.
|
||||
# return dataframe
|
||||
# # Get the informative pair
|
||||
# informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe='1d')
|
||||
# informative['trend'] = HT_TRENDLINE(informative['close'])
|
||||
# informative['period'] = HT_DCPERIOD(informative['close'])
|
||||
# informative['mode'] = HT_TRENDMODE(informative['close'])
|
||||
# # informative['sine'], informative['leadsine'] = HT_SINE(informative['close'])
|
||||
# informative['angle_trend'] = LINEARREG_ANGLE(informative['trend'], timeperiod=5)
|
||||
# # informative['sar'] = SAR(informative['high'], informative['low'])
|
||||
# dataframe = merge_informative_pair(dataframe, informative, self.timeframe, '1d', ffill=True)
|
||||
# return dataframe.set_index('date')['2021-01-01':].reset_index()
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['angle_tsf_mid'], -50)) &
|
||||
|
||||
# (dataframe['sine_1h'] < dataframe['leadsine_1h']) &
|
||||
# (dataframe['tsf_mid'] > dataframe['close']) &
|
||||
# (dataframe['ao'] > -5) &
|
||||
# (dataframe['rsi'] < 36) &
|
||||
(dataframe['rsi'] > 14) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['angle_tsf_mid'], 50)) &
|
||||
# (dataframe['sine_1h'] > dataframe['leadsine_1h']) &
|
||||
# (dataframe['sar_1d'] < dataframe['close']) &
|
||||
# (dataframe['tsf_mid'] < dataframe['close']) &
|
||||
(dataframe['rsi'] > 50) &
|
||||
(dataframe['ao'] < -10) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
214
.env/bin/user_data/strategies/ethusdt_high_risk.py
Normal file
214
.env/bin/user_data/strategies/ethusdt_high_risk.py
Normal file
@@ -0,0 +1,214 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL, MAX, MIN, SAR, CCI, \
|
||||
HT_TRENDLINE, HT_DCPERIOD, HT_TRENDMODE, HT_SINE, RSI, NATR, STOCH, STOCHF, STOCHRSI
|
||||
|
||||
from freqtrade.strategy import merge_informative_pair
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class ETHUSDT_1m_high_risk(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.22703036349783817,
|
||||
"30": 0.09085576426119433,
|
||||
"82": 0.029443202051755248,
|
||||
"164": 0
|
||||
}
|
||||
order_types = {
|
||||
'buy': 'market',
|
||||
'sell': 'market',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
# Stoploss:
|
||||
stoploss = -0.22515
|
||||
|
||||
# Trailing stop:
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.03428
|
||||
trailing_stop_positive_offset = 0.05094
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'upperband': {'upperband': 'green'},
|
||||
'middleband': {'color': 'green'},
|
||||
'lowerband': {'color': 'green'},
|
||||
'tsf_mid': {'color': 'white'},
|
||||
'ema': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"corr": {
|
||||
'correl_h_l': {'color': 'black'},
|
||||
},
|
||||
"correl_tsf_mid_close": {
|
||||
'correl_tsf_mid_close': {'color': 'grey'},
|
||||
},
|
||||
"correl_angle_short_close": {
|
||||
'correl_angle_short_close': {'color': 'blue'},
|
||||
},
|
||||
"correl_angle_long_close": {
|
||||
'correl_angle_long_close': {'color': 'red'},
|
||||
},
|
||||
"correl_mfi_close": {
|
||||
'correl_mfi_close': {'color': 'black'},
|
||||
},
|
||||
"correl_hist_close": {
|
||||
'correl_tsf_mid_close': {'color': 'red'},
|
||||
},
|
||||
"mfi": {
|
||||
'mfi': {'color': 'yellow'},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/BTC", "1h")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
dataframe['trend'] = HT_TRENDLINE(dataframe['close'])
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=12)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=48)
|
||||
|
||||
dataframe['vwap_short'] = qtpylib.rolling_vwap(dataframe, window=5)
|
||||
dataframe['vwap_mid'] = qtpylib.rolling_vwap(dataframe, window=90)
|
||||
dataframe['vwap_long'] = qtpylib.rolling_vwap(dataframe, window=1440)
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12,
|
||||
slowperiod=26, signalperiod=7)
|
||||
dataframe['ao_mid'] = qtpylib.awesome_oscillator(dataframe, weighted=False, fast=5, slow=36)
|
||||
dataframe['ao_short'] = qtpylib.awesome_oscillator(dataframe, weighted=False, fast=5, slow=15)
|
||||
|
||||
dataframe['cci'] = CCI(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=30)
|
||||
dataframe['rsi'] = RSI(dataframe['close'], timeperiod=14)
|
||||
dataframe['slowk'], dataframe['slowd'] = STOCH(dataframe['high'], dataframe['low'], dataframe['close'],
|
||||
fastk_period=5, slowk_period=3,
|
||||
slowk_matype=0, slowd_period=3,
|
||||
slowd_matype=0)
|
||||
dataframe['fastk'], dataframe['fastd'] = STOCHF(dataframe['high'], dataframe['low'], dataframe['close'],
|
||||
fastk_period=5, fastd_period=3, fastd_matype=0)
|
||||
dataframe['fastk'], dataframe['fastd'] = STOCHRSI(dataframe['close'], timeperiod=14, fastk_period=5,
|
||||
fastd_period=3, fastd_matype=0)
|
||||
|
||||
|
||||
dataframe['sar'] = SAR(dataframe['high'], dataframe['low'])
|
||||
|
||||
dataframe['min_high'] = MIN(dataframe['high'], timeperiod=5)
|
||||
dataframe['max_low'] = MAX(dataframe['low'], timeperiod=5)
|
||||
dataframe['max_low_min_high_ratio'] = dataframe['max_low'] - dataframe['min_high'].shift(15)
|
||||
dataframe['correl_h_l_30'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
|
||||
|
||||
dataframe['angle_tsf_short'] = LINEARREG_ANGLE(dataframe['tsf_short'], timeperiod=5)
|
||||
dataframe['angle_close'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=5)
|
||||
dataframe['sine'], dataframe['leadsine'] = HT_SINE(dataframe['close'])
|
||||
dataframe['mode'] = HT_TRENDMODE(dataframe['close'])
|
||||
dataframe['corel_mode'] = CORREL(dataframe['mode'], dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe = dataframe.reset_index().dropna()
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['sar'], dataframe['close'])) &
|
||||
(dataframe['angle_trend'] > 0) &
|
||||
(dataframe['angle_tsf_mid'] > 0) &
|
||||
(0.75227 < dataframe['correl_h_l_30']) &
|
||||
(0.4 < dataframe['correl_h_l_30']) &
|
||||
|
||||
# (dataframe['sine_1h'] < dataframe['leadsine_1h']) &
|
||||
# (dataframe['tsf_mid'] > dataframe['close']) &
|
||||
# (dataframe['angle'] > 0) &
|
||||
# (dataframe['rsi'] <50) &
|
||||
# (dataframe['natr'] > 1.1) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['sar'], dataframe['close'])) &
|
||||
|
||||
(dataframe['max_low'] - dataframe['min_high'].shift(15) < 0) &
|
||||
(dataframe['angle_trend'] < 2) &
|
||||
(dataframe['angle_tsf_mid'] < 2) &
|
||||
(dataframe['mode'] == 1) &
|
||||
# (dataframe['close'] < dataframe['vwap']) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
189
.env/bin/user_data/strategies/ltcusdt_1h.py
Normal file
189
.env/bin/user_data/strategies/ltcusdt_1h.py
Normal file
@@ -0,0 +1,189 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL, MAX, MIN, SAR, CCI, \
|
||||
HT_TRENDLINE, HT_DCPERIOD, HT_TRENDMODE, HT_SINE, RSI, NATR, HT_PHASOR
|
||||
|
||||
from freqtrade.strategy import merge_informative_pair
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class ltcusdt_1h(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.04371,
|
||||
"300": 0.0461,
|
||||
"14487": 0.0254,
|
||||
"15960": 0
|
||||
}
|
||||
order_types = {
|
||||
'buy': 'market',
|
||||
'sell': 'market',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.23
|
||||
|
||||
# Trailing stop:
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.11193
|
||||
trailing_stop_positive_offset = 0.20381
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'upperband': {'upperband': 'green'},
|
||||
'middleband': {'color': 'green'},
|
||||
'lowerband': {'color': 'green'},
|
||||
'tsf_mid': {'color': 'white'},
|
||||
'ema': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"corr": {
|
||||
'correl_h_l': {'color': 'black'},
|
||||
},
|
||||
"correl_tsf_mid_close": {
|
||||
'correl_tsf_mid_close': {'color': 'grey'},
|
||||
},
|
||||
"correl_angle_short_close": {
|
||||
'correl_angle_short_close': {'color': 'blue'},
|
||||
},
|
||||
"correl_angle_long_close": {
|
||||
'correl_angle_long_close': {'color': 'red'},
|
||||
},
|
||||
"correl_mfi_close": {
|
||||
'correl_mfi_close': {'color': 'black'},
|
||||
},
|
||||
"correl_hist_close": {
|
||||
'correl_tsf_mid_close': {'color': 'red'},
|
||||
},
|
||||
"mfi": {
|
||||
'mfi': {'color': 'yellow'},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/USDT", "1d")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12,
|
||||
slowperiod=26, signalperiod=7)
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=14)
|
||||
dataframe['ao'] = qtpylib.awesome_oscillator(dataframe, weighted=False, fast=5, slow=34)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=48)
|
||||
dataframe['sar'] = SAR(dataframe['high'], dataframe['low'])
|
||||
dataframe['natr'] = NATR(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=14)
|
||||
|
||||
dataframe['angle_tsf_mid'] = LINEARREG_ANGLE(dataframe['tsf_mid'], timeperiod=10)
|
||||
dataframe['sine'], dataframe['leadsine'] = HT_SINE(dataframe['close'])
|
||||
dataframe['sine'] = dataframe['sine'].multiply(10)
|
||||
dataframe['leadsine'] = dataframe['leadsine'].multiply(10)
|
||||
dataframe['trend'] = HT_TRENDLINE(dataframe['close'])
|
||||
dataframe['mode'] = HT_TRENDMODE(dataframe['close'])
|
||||
dataframe['inphase'], dataframe['quadrature'] = HT_PHASOR(dataframe['close'])
|
||||
|
||||
dataframe['angle_trend_mid'] = LINEARREG_ANGLE(dataframe['trend'], timeperiod=10)
|
||||
|
||||
dataframe['angle'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=12)
|
||||
dataframe['angle_macdsignal'] = LINEARREG_ANGLE(dataframe['macdsignal'], timeperiod=15)
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['leadsine'], dataframe['sine'])) &
|
||||
|
||||
# (dataframe['sine_1h'] < dataframe['leadsine_1h']) &
|
||||
# (dataframe['tsf_mid'] > dataframe['close']) &
|
||||
(dataframe['ao'] > -5) &
|
||||
(dataframe['angle_tsf_mid'] > -3) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['leadsine'], dataframe['sine'])) &
|
||||
# (dataframe['sine_1h'] > dataframe['leadsine_1h']) &
|
||||
# (dataframe['sar_1d'] < dataframe['close']) &
|
||||
# (dataframe['tsf_mid'] < dataframe['close']) &
|
||||
# (dataframe['natr'] > 2.5) &
|
||||
(dataframe['angle_tsf_mid'] < 5) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
301
.env/bin/user_data/strategies/macd_strg.py
Normal file
301
.env/bin/user_data/strategies/macd_strg.py
Normal file
@@ -0,0 +1,301 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, SAR, LINEARREG_ANGLE, TEMA, STOCHRSI, STOCH, STOCHF, RSI
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import talib.abstract as ta
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class macd_ethbtc_1m(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 1
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.04025819697656752,
|
||||
"7": 0.015188707936204564,
|
||||
"18": 0.005472487470606337,
|
||||
"41": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.33515742514178193
|
||||
|
||||
# Trailing stoploss
|
||||
trailing_stop = False
|
||||
trailing_stop_positive = 0.34089
|
||||
trailing_stop_positive_offset = 0.43254
|
||||
trailing_only_offset_is_reached = False
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = True
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'market',
|
||||
'sell': 'market',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'close': {},
|
||||
'sar': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"MACD": {
|
||||
'macd': {'color': 'blue'},
|
||||
'macdsignal': {'color': 'orange'},
|
||||
},
|
||||
"OU": {
|
||||
'ou': {'color': 'red'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/BTC", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
# MACD
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12,
|
||||
slowperiod=26, signalperiod=9)
|
||||
dataframe['macd_angle'] = LINEARREG_ANGLE(dataframe['macd'], timeperiod=3)
|
||||
dataframe['macdhist_angle'] = LINEARREG_ANGLE(dataframe['macd'], timeperiod=3)
|
||||
|
||||
|
||||
# Parabolic SAR
|
||||
dataframe['sar'] = SAR(dataframe['high'], dataframe['low'], acceleration=0, maximum=0)
|
||||
dataframe['sar_angle'] = LINEARREG_ANGLE(dataframe['sar'], timeperiod=3)
|
||||
|
||||
# Linear angle
|
||||
dataframe['angle'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=14)
|
||||
|
||||
dataframe['tema'] = TEMA(dataframe['close'], timeperiod=30)
|
||||
dataframe['sr_fastk'], dataframe['sr_fastd'] = STOCHRSI(dataframe['close'], timeperiod=14, fastk_period=5,
|
||||
fastd_period=3, fastd_matype=0)
|
||||
dataframe['sr_fastd_angle'] = LINEARREG_ANGLE(dataframe['sr_fastd'], timeperiod=4)
|
||||
|
||||
dataframe['slowk'], dataframe['slowd'] = STOCH(dataframe['high'], dataframe['low'], dataframe['close'],
|
||||
fastk_period=5, slowk_period=3, slowk_matype=0, slowd_period=3,
|
||||
slowd_matype=0)
|
||||
dataframe['slowd_angle'] = LINEARREG_ANGLE(dataframe['slowd'], timeperiod=3)
|
||||
dataframe['sf_fastk'], dataframe['sf_fastd'] = STOCHF(dataframe['high'], dataframe['low'], dataframe['close'], fastk_period=5, fastd_period=3, fastd_matype=0)
|
||||
dataframe['sf_fastd_angle'] = LINEARREG_ANGLE(dataframe['sf_fastd'], timeperiod=3)
|
||||
|
||||
dataframe['rsi'] = RSI(dataframe['close'], timeperiod=14)
|
||||
dataframe['rsi_angle'] = LINEARREG_ANGLE(dataframe['rsi'], timeperiod=5)
|
||||
|
||||
|
||||
# # first check if dataprovider is available
|
||||
# if self.dp:
|
||||
# if self.dp.runmode in ('live', 'dry_run'):
|
||||
# ob = self.dp.orderbook(metadata['pair'], 1)
|
||||
# dataframe['best_bid'] = ob['bids'][0][0]
|
||||
# dataframe['best_ask'] = ob['asks'][0][0]
|
||||
#
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['sar'])) &
|
||||
(0 > (dataframe['sar'] - dataframe['close'])) &
|
||||
(1 > (dataframe['sar'] - dataframe['sar'].shift(3))) &
|
||||
(1 > dataframe['macd']) &
|
||||
(1 > dataframe['macdhist']) &
|
||||
(0 < (dataframe['macdhist'] - dataframe['macdhist'].shift(3))) &
|
||||
(0 < dataframe['angle']) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['sar'], dataframe['close'])) &
|
||||
(dataframe['uo'] < 69) &
|
||||
(0 > (dataframe['sar'] - dataframe['close'])) &
|
||||
(1 > (dataframe['sar'] - dataframe['sar'].shift(3))) &
|
||||
(0 < dataframe['macd']) &
|
||||
(1 < dataframe['macdhist']) &
|
||||
(0 > (dataframe['macdhist'] - dataframe['macdhist'].shift(3))) &
|
||||
(0 > dataframe['angle']) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
|
||||
|
||||
"""
|
||||
buy1:
|
||||
trigger = macd cross above macdsignal
|
||||
guard = sar < close
|
||||
guard = 70 > ou > 50
|
||||
guard = lenear_angle > 0
|
||||
|
||||
buy2:
|
||||
trigger = sar < close
|
||||
guard = macd > macdsignal
|
||||
guard = 70 > ou > 50
|
||||
buy3:
|
||||
trigger = ou cross below 30 & close > max(close)
|
||||
|
||||
sell1:
|
||||
trigger = macd cross below macdsignal
|
||||
guard = sar > close
|
||||
guard = 50 > ou > 20
|
||||
sell2:
|
||||
trigger = sar > close
|
||||
guard = macd < macdsignal
|
||||
guard = 50 > ou > 20
|
||||
"""
|
||||
|
||||
"""
|
||||
+--------+---------+----------+------------------+--------------+------------------------------+----------------+-------------+
|
||||
| Best | Epoch | Trades | Win Draw Loss | Avg profit | Profit | Avg duration | Objective |
|
||||
|--------+---------+----------+------------------+--------------+------------------------------+----------------+-------------|
|
||||
| * Best | 3/500 | 1194 | 523 654 17 | -0.12% | -0.06906927 BTC (-138.00%) | 1,559.8 m | 2.71708 |
|
||||
| * Best | 6/500 | 100 | 20 0 80 | -0.07% | -0.00352831 BTC (-7.05%) | 11.5 m | 1.87067 |
|
||||
| Best | 37/500 | 12 | 6 0 6 | 0.49% | 0.00294367 BTC (5.88%) | 18.2 m | 1.86009 |
|
||||
| Best | 67/500 | 10 | 6 0 4 | 0.89% | 0.00443786 BTC (8.87%) | 19.5 m | 1.85245 |
|
||||
| Best | 91/500 | 73 | 21 5 47 | 0.00% | 0.00007645 BTC (0.15%) | 10.2 m | 1.85215 |
|
||||
| Best | 92/500 | 48 | 17 2 29 | 0.05% | 0.00116911 BTC (2.34%) | 10.4 m | 1.85189 |
|
||||
| Best | 94/500 | 12 | 6 0 6 | 0.69% | 0.00416071 BTC (8.31%) | 17.8 m | 1.85143 |
|
||||
| Best | 110/500 | 18 | 6 1 11 | 0.36% | 0.00327838 BTC (6.55%) | 14.3 m | 1.85113 |
|
||||
| Best | 257/500 | 48 | 16 0 32 | 0.06% | 0.00154456 BTC (3.09%) | 11.3 m | 1.8505 |
|
||||
| Best | 388/500 | 74 | 23 14 37 | 0.01% | 0.00045826 BTC (0.92%) | 8.2 m | 1.84665 |
|
||||
[Epoch 500 of 500 (100%)] || | [Time: 1:04:49, Elapsed Time: 1:04:49]
|
||||
2021-01-31 01:14:47,851 - freqtrade.optimize.hyperopt - INFO - 500 epochs saved to '/home/yakov/PycharmProjects/freqtrade/.env/bin/user_data/hyperopt_results/hyperopt_results_2021-01-31_00-07-23.pickle'.
|
||||
|
||||
Best result:
|
||||
|
||||
388/500: 74 trades. 23/14/37 Wins/Draws/Losses. Avg profit 0.01%. Median profit -0.02%. Total profit 0.00045826 BTC ( 0.92Σ%). Avg duration 8.2 min. Objective: 1.84665
|
||||
|
||||
|
||||
# Buy hyperspace params:
|
||||
buy_params = {
|
||||
'angle-enabled': False,
|
||||
'macd-enabled': False,
|
||||
'macd_value': 0.73579,
|
||||
'macdhist_shift': 0.87895,
|
||||
'macdhist_value': 0.29935,
|
||||
'sar-enabled': False,
|
||||
'sar_ratio': 0.43819,
|
||||
'sar_shift': 0.98992,
|
||||
'trigger': 'sell-macd_cross_signal'
|
||||
}
|
||||
|
||||
# Sell hyperspace params:
|
||||
sell_params = {
|
||||
'angle_h_s': 0.07105,
|
||||
'macd_value_s': 0.08408,
|
||||
'macdhist_shift_s': -0.72567,
|
||||
'macdhist_value_s': 0.77324,
|
||||
'sar_ratio_s': 0.58347,
|
||||
'sar_shift_s': 0.81212,
|
||||
'sell-angle-enabled': True,
|
||||
'sell-macd-enabled': False,
|
||||
'sell-sar-enabled': False,
|
||||
'sell-uo-enabled': True,
|
||||
'trigger': 'sell-macd_cross_signal',
|
||||
'uo_l_s': 14
|
||||
}
|
||||
|
||||
# ROI table:
|
||||
minimal_roi = {
|
||||
"0": 0.07193,
|
||||
"3": 0.0382,
|
||||
"5": 0.01183,
|
||||
"7": 0
|
||||
}
|
||||
|
||||
# Stoploss:
|
||||
stoploss = -0.25471
|
||||
|
||||
# Trailing stop:
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.04697
|
||||
trailing_stop_positive_offset = 0.05329
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
"""
|
||||
196
.env/bin/user_data/strategies/quick_btcusdt_1m.py
Normal file
196
.env/bin/user_data/strategies/quick_btcusdt_1m.py
Normal file
@@ -0,0 +1,196 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, SAR, LINEARREG_ANGLE, TEMA, STOCHRSI, STOCH, STOCHF, RSI
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import talib.abstract as ta
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class quick_btcusdt_1m(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 1
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.07186329732926479,
|
||||
"6": 0.03610260437996321,
|
||||
"14": 0.014117594921808408,
|
||||
"23": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.073946396013718
|
||||
|
||||
# Trailing stoploss
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.11645094244761
|
||||
trailing_stop_positive_offset = 0.20201226976340847
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = True
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'market',
|
||||
'sell': 'market',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'close': {},
|
||||
'sar': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"MACD": {
|
||||
'macd': {'color': 'blue'},
|
||||
'macdsignal': {'color': 'orange'},
|
||||
},
|
||||
"OU": {
|
||||
'ou': {'color': 'red'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("BTC/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
# MACD
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12,
|
||||
slowperiod=26, signalperiod=9)
|
||||
dataframe['macd_angle'] = LINEARREG_ANGLE(dataframe['macd'], timeperiod=3)
|
||||
dataframe['macdhist_angle'] = LINEARREG_ANGLE(dataframe['macd'], timeperiod=3)
|
||||
|
||||
# Linear angle
|
||||
dataframe['angle'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=14)
|
||||
|
||||
dataframe['tema'] = TEMA(dataframe['close'], timeperiod=30)
|
||||
dataframe['sr_fastk'], dataframe['sr_fastd'] = STOCHRSI(dataframe['close'], timeperiod=14, fastk_period=5,
|
||||
fastd_period=3, fastd_matype=0)
|
||||
dataframe['sr_fastd_angle'] = LINEARREG_ANGLE(dataframe['sr_fastd'], timeperiod=4)
|
||||
|
||||
dataframe['slowk'], dataframe['slowd'] = STOCH(dataframe['high'], dataframe['low'], dataframe['close'],
|
||||
fastk_period=5, slowk_period=3, slowk_matype=0, slowd_period=3,
|
||||
slowd_matype=0)
|
||||
dataframe['slowd_angle'] = LINEARREG_ANGLE(dataframe['slowd'], timeperiod=3)
|
||||
dataframe['sf_fastk'], dataframe['sf_fastd'] = STOCHF(dataframe['high'], dataframe['low'], dataframe['close'], fastk_period=5, fastd_period=3, fastd_matype=0)
|
||||
dataframe['sf_fastd_angle'] = LINEARREG_ANGLE(dataframe['sf_fastd'], timeperiod=3)
|
||||
|
||||
dataframe['rsi'] = RSI(dataframe['close'], timeperiod=14)
|
||||
dataframe['rsi_angle'] = LINEARREG_ANGLE(dataframe['rsi'], timeperiod=5)
|
||||
|
||||
|
||||
# # first check if dataprovider is available
|
||||
# if self.dp:
|
||||
# if self.dp.runmode in ('live', 'dry_run'):
|
||||
# ob = self.dp.orderbook(metadata['pair'], 1)
|
||||
# dataframe['best_bid'] = ob['bids'][0][0]
|
||||
# dataframe['best_ask'] = ob['asks'][0][0]
|
||||
#
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['macd'], dataframe['macdsignal'])) &
|
||||
(dataframe['sr_fastd_angle'] > -39) &
|
||||
(dataframe['sf_fastk'] > 33) &
|
||||
(dataframe['sf_fastd_angle'] > -80) &
|
||||
(dataframe['rsi_angle'] > 24) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
((dataframe['macdhist']) < 0.000241872676925719) &
|
||||
(dataframe['sr_fastd_angle'] > 71) &
|
||||
(dataframe['sf_fastd_angle'] < 21) &
|
||||
(dataframe['rsi_angle'] < 1) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
|
||||
197
.env/bin/user_data/strategies/quick_ethusdt_1m.py
Normal file
197
.env/bin/user_data/strategies/quick_ethusdt_1m.py
Normal file
@@ -0,0 +1,197 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, SAR, LINEARREG_ANGLE, TEMA, STOCHRSI, STOCH, STOCHF, RSI
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import talib.abstract as ta
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class quick_ethusdt_1m(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 1
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.07186329732926479,
|
||||
"6": 0.03610260437996321,
|
||||
"14": 0.014117594921808408,
|
||||
"23": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.073946396013718
|
||||
|
||||
# Trailing stoploss
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.11645094244761
|
||||
trailing_stop_positive_offset = 0.20201226976340847
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = True
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'market',
|
||||
'sell': 'market',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'close': {},
|
||||
'sar': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"MACD": {
|
||||
'macd': {'color': 'blue'},
|
||||
'macdsignal': {'color': 'orange'},
|
||||
},
|
||||
"OU": {
|
||||
'ou': {'color': 'red'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
# MACD
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12,
|
||||
slowperiod=26, signalperiod=9)
|
||||
dataframe['macd_angle'] = LINEARREG_ANGLE(dataframe['macd'], timeperiod=3)
|
||||
dataframe['macdhist_angle'] = LINEARREG_ANGLE(dataframe['macd'], timeperiod=3)
|
||||
|
||||
# Linear angle
|
||||
dataframe['angle'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=14)
|
||||
|
||||
dataframe['tema'] = TEMA(dataframe['close'], timeperiod=30)
|
||||
dataframe['sr_fastk'], dataframe['sr_fastd'] = STOCHRSI(dataframe['close'], timeperiod=14, fastk_period=5,
|
||||
fastd_period=3, fastd_matype=0)
|
||||
dataframe['sr_fastd_angle'] = LINEARREG_ANGLE(dataframe['sr_fastd'], timeperiod=4)
|
||||
|
||||
dataframe['slowk'], dataframe['slowd'] = STOCH(dataframe['high'], dataframe['low'], dataframe['close'],
|
||||
fastk_period=5, slowk_period=3, slowk_matype=0, slowd_period=3,
|
||||
slowd_matype=0)
|
||||
dataframe['slowd_angle'] = LINEARREG_ANGLE(dataframe['slowd'], timeperiod=3)
|
||||
dataframe['sf_fastk'], dataframe['sf_fastd'] = STOCHF(dataframe['high'], dataframe['low'], dataframe['close'], fastk_period=5, fastd_period=3, fastd_matype=0)
|
||||
dataframe['sf_fastd_angle'] = LINEARREG_ANGLE(dataframe['sf_fastd'], timeperiod=3)
|
||||
|
||||
dataframe['rsi'] = RSI(dataframe['close'], timeperiod=14)
|
||||
dataframe['rsi_angle'] = LINEARREG_ANGLE(dataframe['rsi'], timeperiod=5)
|
||||
|
||||
|
||||
# # first check if dataprovider is available
|
||||
# if self.dp:
|
||||
# if self.dp.runmode in ('live', 'dry_run'):
|
||||
# ob = self.dp.orderbook(metadata['pair'], 1)
|
||||
# dataframe['best_bid'] = ob['bids'][0][0]
|
||||
# dataframe['best_ask'] = ob['asks'][0][0]
|
||||
#
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['macd'], dataframe['macdsignal'])) &
|
||||
((dataframe['macd_angle']) > -0.007579827857282747) &
|
||||
(dataframe['tema'] < 0.124417394428206) &
|
||||
(dataframe['sr_fastd_angle'] > -39) &
|
||||
(dataframe['sf_fastk'] > 33) &
|
||||
(dataframe['rsi_angle'] > 24) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
((dataframe['macdhist']) < 0.000241872676925719) &
|
||||
(dataframe['sr_fastd_angle'] > 71) &
|
||||
(dataframe['sf_fastd_angle'] < 21) &
|
||||
(dataframe['rsi_angle'] < 1) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
|
||||
205
.env/bin/user_data/strategies/strg1_ada_usdt_1m.py
Normal file
205
.env/bin/user_data/strategies/strg1_ada_usdt_1m.py
Normal file
@@ -0,0 +1,205 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL, SAR
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg1_ADAUSDT_1m(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.16408611153968805,
|
||||
"18": 0.07786509535022122,
|
||||
"76": 0.01087364896379109,
|
||||
"193": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.14772112352872754
|
||||
|
||||
# Trailing stoploss
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.13192197532670782
|
||||
trailing_stop_positive_offset = 0.19046200322926082
|
||||
trailing_only_offset_is_reached = False
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = False
|
||||
ignore_roi_if_buy_signal = True
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'tema': {},
|
||||
'sar': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"MACD": {
|
||||
'macd': {'color': 'blue'},
|
||||
'macdsignal': {'color': 'orange'},
|
||||
},
|
||||
"RSI": {
|
||||
'rsi': {'color': 'red'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ADA/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=10,
|
||||
slowperiod=24, signalperiod=7)
|
||||
dataframe['sar'] = SAR(dataframe['high'], dataframe['low'])
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=14)
|
||||
dataframe['angle_short'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=10)
|
||||
dataframe['angle_mid'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=144)
|
||||
dataframe['angle_long'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=288)
|
||||
|
||||
dataframe['tsf_long'] = TSF(dataframe['close'], timeperiod=288)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=144)
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=10)
|
||||
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['correl_close_last_close'] = CORREL(dataframe['close'].shift(1), dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_tsf_long_close'] = CORREL(dataframe['tsf_long'], dataframe['close'], timeperiod=288)
|
||||
dataframe['correl_tsf_mid_close'] = CORREL(dataframe['tsf_mid'], dataframe['close'], timeperiod=144)
|
||||
dataframe['correl_tsf_short_close'] = CORREL(dataframe['tsf_short'], dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_angle_short_close'] = CORREL(dataframe['angle_short'], dataframe['close'], timeperiod=30)
|
||||
dataframe['correl_angle_mid_close'] = CORREL(dataframe['angle_mid'], dataframe['close'], timeperiod=144)
|
||||
dataframe['correl_angle_long_close'] = CORREL(dataframe['angle_long'], dataframe['close'], timeperiod=288)
|
||||
|
||||
dataframe['correl_hist_close'] = CORREL(dataframe['macdhist'], dataframe['close'], timeperiod=24)
|
||||
dataframe['correl_mfi_close'] = CORREL(dataframe['mfi'], dataframe['close'], timeperiod=14)
|
||||
|
||||
dataframe['ema'] = EMA(dataframe['close'], timeperiod=8)
|
||||
dataframe['ma'] = MA(dataframe['close'], timeperiod=8, matype=0)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=20, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['sar'], dataframe['close'])) &
|
||||
((dataframe['close'] - dataframe['tsf_mid']) > 0.6037118990957886) &
|
||||
((dataframe['close'] - dataframe['tsf_short']) > 0.280886393803766) &
|
||||
(0.7374370242135467 < dataframe['correl_h_l']) &
|
||||
(0.598218893737078 < dataframe['correl_tsf_short_close']) &
|
||||
(-0.5081118861877524 < dataframe['correl_mfi_close']) &
|
||||
(-0.00808699162233981 < (dataframe['ema'] - dataframe['middleband'])) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['sar'], dataframe['close'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) < 0.44785474790276225) &
|
||||
((dataframe['tsf_short'] - dataframe['close']) < 0.17576899126417125) &
|
||||
(0.030726048199457463 < dataframe['correl_h_l']) &
|
||||
(0.4328953914289484 < dataframe['correl_tsf_short_close']) &
|
||||
(0.09562688208375203 < dataframe['correl_mfi_close']) &
|
||||
(-0.00892438828151425 < (dataframe['ema'] - dataframe['middleband'])) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
199
.env/bin/user_data/strategies/strg1_btc_usdt_1m.py
Normal file
199
.env/bin/user_data/strategies/strg1_btc_usdt_1m.py
Normal file
@@ -0,0 +1,199 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg1_BTCUSDT_1m(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.24724,
|
||||
"14": 0.05512,
|
||||
"46": 0.01805,
|
||||
"151": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.02231
|
||||
|
||||
# Trailing stoploss
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.34089
|
||||
trailing_stop_positive_offset = 0.43254
|
||||
trailing_only_offset_is_reached = False
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = False
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'tema': {},
|
||||
'sar': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"MACD": {
|
||||
'macd': {'color': 'blue'},
|
||||
'macdsignal': {'color': 'orange'},
|
||||
},
|
||||
"RSI": {
|
||||
'rsi': {'color': 'red'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("BTC/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=10,
|
||||
slowperiod=24, signalperiod=7)
|
||||
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=14)
|
||||
dataframe['angle_short'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=10)
|
||||
dataframe['angle_mid'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=144)
|
||||
dataframe['angle_long'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=288)
|
||||
|
||||
dataframe['tsf_long'] = TSF(dataframe['close'], timeperiod=288)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=144)
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=10)
|
||||
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['correl_close_last_close'] = CORREL(dataframe['close'].shift(1), dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_tsf_long_close'] = CORREL(dataframe['tsf_long'], dataframe['close'], timeperiod=288)
|
||||
dataframe['correl_tsf_mid_close'] = CORREL(dataframe['tsf_mid'], dataframe['close'], timeperiod=144)
|
||||
dataframe['correl_tsf_short_close'] = CORREL(dataframe['tsf_short'], dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_angle_short_close'] = CORREL(dataframe['angle_short'], dataframe['close'], timeperiod=30)
|
||||
dataframe['correl_angle_mid_close'] = CORREL(dataframe['angle_mid'], dataframe['close'], timeperiod=144)
|
||||
dataframe['correl_angle_long_close'] = CORREL(dataframe['angle_long'], dataframe['close'], timeperiod=288)
|
||||
|
||||
dataframe['correl_hist_close'] = CORREL(dataframe['macdhist'], dataframe['close'], timeperiod=24)
|
||||
dataframe['correl_mfi_close'] = CORREL(dataframe['mfi'], dataframe['close'], timeperiod=14)
|
||||
|
||||
|
||||
|
||||
|
||||
dataframe['ema'] = EMA(dataframe['close'], timeperiod=8)
|
||||
dataframe['ma'] = MA(dataframe['close'], timeperiod=8, matype=0)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=20, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['middleband'])) &
|
||||
(dataframe['mfi'] < 16) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['macdsignal'], dataframe['macd'])) &
|
||||
(dataframe['correl_hist_close'] < 0.9) &
|
||||
(dataframe['mfi'] > 98) &
|
||||
(dataframe['middleband'] < 87) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
216
.env/bin/user_data/strategies/strg1_doge_usdt_1m.py
Normal file
216
.env/bin/user_data/strategies/strg1_doge_usdt_1m.py
Normal file
@@ -0,0 +1,216 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL, SAR
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg1_DOGEUSDT_1m(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.24724,
|
||||
"30": 0.1,
|
||||
"46": 0.05,
|
||||
"151": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.1
|
||||
|
||||
# Trailing stoploss
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.04
|
||||
trailing_stop_positive_offset = 0.14
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = False
|
||||
ignore_roi_if_buy_signal = True
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'tema': {},
|
||||
'sar': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"MACD": {
|
||||
'macd': {'color': 'blue'},
|
||||
'macdsignal': {'color': 'orange'},
|
||||
},
|
||||
"RSI": {
|
||||
'rsi': {'color': 'red'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("DOGE/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=10,
|
||||
slowperiod=24, signalperiod=7)
|
||||
dataframe['sar'] = SAR(dataframe['high'], dataframe['low'])
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=14)
|
||||
dataframe['angle_short'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=10)
|
||||
dataframe['angle_mid'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=144)
|
||||
dataframe['angle_long'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=288)
|
||||
|
||||
dataframe['tsf_long'] = TSF(dataframe['close'], timeperiod=288)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=144)
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=10)
|
||||
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['correl_close_last_close'] = CORREL(dataframe['close'].shift(1), dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_tsf_long_close'] = CORREL(dataframe['tsf_long'], dataframe['close'], timeperiod=288)
|
||||
dataframe['correl_tsf_mid_close'] = CORREL(dataframe['tsf_mid'], dataframe['close'], timeperiod=144)
|
||||
dataframe['correl_tsf_short_close'] = CORREL(dataframe['tsf_short'], dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_angle_short_close'] = CORREL(dataframe['angle_short'], dataframe['close'], timeperiod=30)
|
||||
dataframe['correl_angle_mid_close'] = CORREL(dataframe['angle_mid'], dataframe['close'], timeperiod=144)
|
||||
dataframe['correl_angle_long_close'] = CORREL(dataframe['angle_long'], dataframe['close'], timeperiod=288)
|
||||
|
||||
dataframe['correl_hist_close'] = CORREL(dataframe['macdhist'], dataframe['close'], timeperiod=24)
|
||||
dataframe['correl_mfi_close'] = CORREL(dataframe['mfi'], dataframe['close'], timeperiod=14)
|
||||
|
||||
|
||||
|
||||
|
||||
dataframe['ema'] = EMA(dataframe['close'], timeperiod=8)
|
||||
dataframe['ma'] = MA(dataframe['close'], timeperiod=8, matype=0)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=20, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['lowerband'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > 14) &
|
||||
(0.5263534368259521 < dataframe['correl_h_l']) &
|
||||
(0.0728048430667152 < dataframe['correl_tsf_mid_close']) &
|
||||
(-0.02402596125126566 < dataframe['correl_angle_short_close']) &
|
||||
(0.2842166347875669 < dataframe['correl_angle_long_close']) &
|
||||
(-0.6552565064627378 < dataframe['correl_mfi_close']) &
|
||||
(-0.4853276710303872 < dataframe['correl_hist_close']) &
|
||||
(0.442188534531633 < dataframe['mfi']) &
|
||||
(0.6714488827895353 < dataframe['ema']) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['lowerband'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > 68) &
|
||||
(-0.6225944943311145 < dataframe['correl_h_l']) &
|
||||
(0.2602396802858502 < dataframe['correl_tsf_mid_close']) &
|
||||
(0.771988603840956 < dataframe['correl_angle_short_close']) &
|
||||
(0.33471662411500236 < dataframe['correl_angle_long_close']) &
|
||||
(-0.9562413964921457 < dataframe['correl_hist_close']) &
|
||||
(-0.43268559077377733 < dataframe['correl_mfi_close']) &
|
||||
(-0.25207265197064166 < dataframe['mfi']) &
|
||||
(-0.00739011415527302 < dataframe['ema']) &
|
||||
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
233
.env/bin/user_data/strategies/strg1_eth_usdt_1m.py
Normal file
233
.env/bin/user_data/strategies/strg1_eth_usdt_1m.py
Normal file
@@ -0,0 +1,233 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg1_ETHUSDT_1m(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.24724,
|
||||
"30": 0.1,
|
||||
"46": 0.05,
|
||||
"151": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.2
|
||||
|
||||
# Trailing stoploss
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.19
|
||||
trailing_stop_positive_offset = 0.21
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = False
|
||||
ignore_roi_if_buy_signal = True
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'upperband': {'upperband': 'green'},
|
||||
'middleband': {'color': 'green'},
|
||||
'lowerband': {'color': 'green'},
|
||||
'tsf_mid': {'color': 'white'},
|
||||
'ema': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"corr": {
|
||||
'correl_h_l': {'color': 'black'},
|
||||
},
|
||||
"correl_tsf_mid_close": {
|
||||
'correl_tsf_mid_close': {'color': 'grey'},
|
||||
},
|
||||
"correl_angle_short_close": {
|
||||
'correl_angle_short_close': {'color': 'blue'},
|
||||
},
|
||||
"correl_angle_long_close": {
|
||||
'correl_angle_long_close': {'color': 'red'},
|
||||
},
|
||||
"correl_mfi_close": {
|
||||
'correl_mfi_close': {'color': 'black'},
|
||||
},
|
||||
"correl_hist_close": {
|
||||
'correl_tsf_mid_close': {'color': 'red'},
|
||||
},
|
||||
"mfi": {
|
||||
'mfi': {'color': 'yellow'},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=10,
|
||||
slowperiod=24, signalperiod=7)
|
||||
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=14)
|
||||
dataframe['angle_short'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=10)
|
||||
dataframe['angle_mid'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=144)
|
||||
dataframe['angle_long'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=288)
|
||||
|
||||
dataframe['tsf_long'] = TSF(dataframe['close'], timeperiod=288)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=144)
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=10)
|
||||
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['correl_close_last_close'] = CORREL(dataframe['close'].shift(1), dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_tsf_long_close'] = CORREL(dataframe['tsf_long'], dataframe['close'], timeperiod=288)
|
||||
dataframe['correl_tsf_mid_close'] = CORREL(dataframe['tsf_mid'], dataframe['close'], timeperiod=144)
|
||||
dataframe['correl_tsf_short_close'] = CORREL(dataframe['tsf_short'], dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_angle_short_close'] = CORREL(dataframe['angle_short'], dataframe['close'], timeperiod=30)
|
||||
dataframe['correl_angle_mid_close'] = CORREL(dataframe['angle_mid'], dataframe['close'], timeperiod=144)
|
||||
dataframe['correl_angle_long_close'] = CORREL(dataframe['angle_long'], dataframe['close'], timeperiod=288)
|
||||
|
||||
dataframe['correl_hist_close'] = CORREL(dataframe['macdhist'], dataframe['close'], timeperiod=24)
|
||||
dataframe['correl_mfi_close'] = CORREL(dataframe['mfi'], dataframe['close'], timeperiod=14)
|
||||
|
||||
|
||||
|
||||
|
||||
dataframe['ema'] = EMA(dataframe['close'], timeperiod=8)
|
||||
dataframe['ma'] = MA(dataframe['close'], timeperiod=8, matype=0)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=20, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['lowerband'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > 14) &
|
||||
(0.5263534368259521 < dataframe['correl_h_l']) &
|
||||
(0.0728048430667152 < dataframe['correl_tsf_mid_close']) &
|
||||
(-0.02402596125126566 < dataframe['correl_angle_short_close']) &
|
||||
(0.2842166347875669 < dataframe['correl_angle_long_close']) &
|
||||
(-0.6552565064627378 < dataframe['correl_mfi_close']) &
|
||||
(-0.4853276710303872 < dataframe['correl_hist_close']) &
|
||||
(0.442188534531633 < dataframe['mfi']) &
|
||||
(0.6714488827895353 < dataframe['ema']) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['lowerband'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > 68) &
|
||||
(-0.6225944943311145 < dataframe['correl_h_l']) &
|
||||
(0.2602396802858502 < dataframe['correl_tsf_mid_close']) &
|
||||
(0.771988603840956 < dataframe['correl_angle_short_close']) &
|
||||
(0.33471662411500236 < dataframe['correl_angle_long_close']) &
|
||||
(-0.9562413964921457 < dataframe['correl_hist_close']) &
|
||||
(-0.43268559077377733 < dataframe['correl_mfi_close']) &
|
||||
(-0.25207265197064166 < dataframe['mfi']) &
|
||||
(-0.00739011415527302 < dataframe['ema']) &
|
||||
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
216
.env/bin/user_data/strategies/strg1_eth_usdt_1m_prod.py
Normal file
216
.env/bin/user_data/strategies/strg1_eth_usdt_1m_prod.py
Normal file
@@ -0,0 +1,216 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg1_ETHUSDT_1m_prod(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.24724,
|
||||
"30": 0.1,
|
||||
"46": 0.05,
|
||||
"151": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.1
|
||||
|
||||
# Trailing stoploss
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.04
|
||||
trailing_stop_positive_offset = 0.14
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = False
|
||||
ignore_roi_if_buy_signal = True
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'tema': {},
|
||||
'sar': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"MACD": {
|
||||
'macd': {'color': 'blue'},
|
||||
'macdsignal': {'color': 'orange'},
|
||||
},
|
||||
"RSI": {
|
||||
'rsi': {'color': 'red'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=10,
|
||||
slowperiod=24, signalperiod=7)
|
||||
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=14)
|
||||
dataframe['angle_short'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=10)
|
||||
dataframe['angle_mid'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=144)
|
||||
dataframe['angle_long'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=288)
|
||||
|
||||
dataframe['tsf_long'] = TSF(dataframe['close'], timeperiod=288)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=144)
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=10)
|
||||
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['correl_close_last_close'] = CORREL(dataframe['close'].shift(1), dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_tsf_long_close'] = CORREL(dataframe['tsf_long'], dataframe['close'], timeperiod=288)
|
||||
dataframe['correl_tsf_mid_close'] = CORREL(dataframe['tsf_mid'], dataframe['close'], timeperiod=144)
|
||||
dataframe['correl_tsf_short_close'] = CORREL(dataframe['tsf_short'], dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_angle_short_close'] = CORREL(dataframe['angle_short'], dataframe['close'], timeperiod=30)
|
||||
dataframe['correl_angle_mid_close'] = CORREL(dataframe['angle_mid'], dataframe['close'], timeperiod=144)
|
||||
dataframe['correl_angle_long_close'] = CORREL(dataframe['angle_long'], dataframe['close'], timeperiod=288)
|
||||
|
||||
dataframe['correl_hist_close'] = CORREL(dataframe['macdhist'], dataframe['close'], timeperiod=24)
|
||||
dataframe['correl_mfi_close'] = CORREL(dataframe['mfi'], dataframe['close'], timeperiod=14)
|
||||
|
||||
|
||||
|
||||
|
||||
dataframe['ema'] = EMA(dataframe['close'], timeperiod=8)
|
||||
dataframe['ma'] = MA(dataframe['close'], timeperiod=8, matype=0)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=20, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['lowerband'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > 14) &
|
||||
(0.5263534368259521 < dataframe['correl_h_l']) &
|
||||
(0.0728048430667152 < dataframe['correl_tsf_mid_close']) &
|
||||
(-0.02402596125126566 < dataframe['correl_angle_short_close']) &
|
||||
(0.2842166347875669 < dataframe['correl_angle_long_close']) &
|
||||
(-0.6552565064627378 < dataframe['correl_mfi_close']) &
|
||||
(-0.4853276710303872 < dataframe['correl_hist_close']) &
|
||||
(0.442188534531633 < dataframe['mfi']) &
|
||||
(0.6714488827895353 < dataframe['ema']) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['lowerband'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > 68) &
|
||||
(-0.6225944943311145 < dataframe['correl_h_l']) &
|
||||
(0.2602396802858502 < dataframe['correl_tsf_mid_close']) &
|
||||
(0.771988603840956 < dataframe['correl_angle_short_close']) &
|
||||
(0.33471662411500236 < dataframe['correl_angle_long_close']) &
|
||||
(-0.9562413964921457 < dataframe['correl_hist_close']) &
|
||||
(-0.43268559077377733 < dataframe['correl_mfi_close']) &
|
||||
(-0.25207265197064166 < dataframe['mfi']) &
|
||||
(-0.00739011415527302 < dataframe['ema']) &
|
||||
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
189
.env/bin/user_data/strategies/strg2_ada_usdt_1m.py
Normal file
189
.env/bin/user_data/strategies/strg2_ada_usdt_1m.py
Normal file
@@ -0,0 +1,189 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL, SAR, HT_TRENDLINE, RSI, NATR
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg2_ADAUSDT_1m(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.0816,
|
||||
"30": 0.04762,
|
||||
"60": 0.01142,
|
||||
"150": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
# Stoploss:
|
||||
stoploss = -0.20102
|
||||
|
||||
# Trailing stop:
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.10581
|
||||
trailing_stop_positive_offset = 0.11224
|
||||
trailing_only_offset_is_reached = False
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = True
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'market',
|
||||
'sell': 'market',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'correl_h_l': {'color': 'black'},
|
||||
'upperband': {'color': 'green'},
|
||||
'middleband': {'color': 'green'},
|
||||
'lowerband': {'color': 'green'},
|
||||
},
|
||||
'subplots': {
|
||||
"MACD": {
|
||||
'macd': {'color': 'blue'},
|
||||
'macdsignal': {'color': 'orange'},
|
||||
},
|
||||
"mfi": {
|
||||
'mfi': {'color': 'red'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ADA/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=5)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=30)
|
||||
dataframe['ao'] = qtpylib.awesome_oscillator(dataframe, weighted=False, fast=5, slow=34)
|
||||
dataframe['rsi'] = RSI(dataframe['close'], timeperiod=14)
|
||||
|
||||
|
||||
dataframe['angle_tsf_mid'] = LINEARREG_ANGLE(dataframe['tsf_mid'], timeperiod=5)
|
||||
dataframe['angle_tsf_mid'] = LINEARREG_ANGLE(dataframe['tsf_short'], timeperiod=5)
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=10,
|
||||
slowperiod=24, signalperiod=7)
|
||||
dataframe['sar'] = SAR(dataframe['high'], dataframe['low'])
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=14)
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=30, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['sar'], dataframe['close'])) &
|
||||
(60 > dataframe['mfi']) &
|
||||
# (0.15 < dataframe['natr']) &
|
||||
(dataframe['angle_tsf_mid'] > 0) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['sar'], dataframe['close'])) &
|
||||
# (-0.00354 > dataframe['macdhist']) &
|
||||
(50.23156 > dataframe['mfi']) &
|
||||
(dataframe['angle_tsf_mid'] < 0) &
|
||||
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
189
.env/bin/user_data/strategies/strg2_ada_usdt_1m_prod.py
Normal file
189
.env/bin/user_data/strategies/strg2_ada_usdt_1m_prod.py
Normal file
@@ -0,0 +1,189 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL, SAR, HT_TRENDLINE, RSI, NATR
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg2_ADAUSDT_1m(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.0816,
|
||||
"30": 0.04762,
|
||||
"60": 0.01142,
|
||||
"150": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
# Stoploss:
|
||||
stoploss = -0.20102
|
||||
|
||||
# Trailing stop:
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.10581
|
||||
trailing_stop_positive_offset = 0.11224
|
||||
trailing_only_offset_is_reached = False
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = True
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'market',
|
||||
'sell': 'market',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'correl_h_l': {'color': 'black'},
|
||||
'upperband': {'color': 'green'},
|
||||
'middleband': {'color': 'green'},
|
||||
'lowerband': {'color': 'green'},
|
||||
},
|
||||
'subplots': {
|
||||
"MACD": {
|
||||
'macd': {'color': 'blue'},
|
||||
'macdsignal': {'color': 'orange'},
|
||||
},
|
||||
"mfi": {
|
||||
'mfi': {'color': 'red'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ADA/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=5)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=30)
|
||||
dataframe['ao'] = qtpylib.awesome_oscillator(dataframe, weighted=False, fast=5, slow=34)
|
||||
dataframe['rsi'] = RSI(dataframe['close'], timeperiod=14)
|
||||
|
||||
|
||||
dataframe['angle_tsf_mid'] = LINEARREG_ANGLE(dataframe['tsf_mid'], timeperiod=5)
|
||||
dataframe['angle_tsf_mid'] = LINEARREG_ANGLE(dataframe['tsf_short'], timeperiod=5)
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=10,
|
||||
slowperiod=24, signalperiod=7)
|
||||
dataframe['sar'] = SAR(dataframe['high'], dataframe['low'])
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=14)
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=30, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['sar'], dataframe['close'])) &
|
||||
(60 > dataframe['mfi']) &
|
||||
# (0.15 < dataframe['natr']) &
|
||||
(dataframe['angle_tsf_mid'] > 0) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['sar'], dataframe['close'])) &
|
||||
# (-0.00354 > dataframe['macdhist']) &
|
||||
(50.23156 > dataframe['mfi']) &
|
||||
(dataframe['angle_tsf_mid'] < 0) &
|
||||
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
178
.env/bin/user_data/strategies/strg2_ada_usdt_1m_sharpe.py
Normal file
178
.env/bin/user_data/strategies/strg2_ada_usdt_1m_sharpe.py
Normal file
@@ -0,0 +1,178 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL, SAR
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg2_ADAUSDT_1m_sharpe(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.17440164714028486,
|
||||
"38": 0.09394715625863974,
|
||||
"98": 0.027323845707844324,
|
||||
"170": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
# Stoploss:
|
||||
stoploss = -0.2399087254823858
|
||||
|
||||
# Trailing stop:
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.10717125716853501
|
||||
trailing_stop_positive_offset = 0.13807946709133387
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = False
|
||||
ignore_roi_if_buy_signal = True
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'correl_h_l': {'color': 'black'},
|
||||
'upperband': {'color': 'green'},
|
||||
'middleband': {'color': 'green'},
|
||||
'lowerband': {'color': 'green'},
|
||||
},
|
||||
'subplots': {
|
||||
"MACD": {
|
||||
'macd': {'color': 'blue'},
|
||||
'macdsignal': {'color': 'orange'},
|
||||
},
|
||||
"mfi": {
|
||||
'mfi': {'color': 'red'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ADA/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=10,
|
||||
slowperiod=24, signalperiod=7)
|
||||
dataframe['sar'] = SAR(dataframe['high'], dataframe['low'])
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=60)
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=60)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=35, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['middleband'])) &
|
||||
(0.6452515141186865 < dataframe['correl_h_l']) &
|
||||
(18 < dataframe['mfi']) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['close'], dataframe['middleband'])) &
|
||||
(0.1 < dataframe['correl_h_l']) &
|
||||
(17 > dataframe['mfi']) &
|
||||
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
231
.env/bin/user_data/strategies/strg2_eth_usdt_1m.py
Normal file
231
.env/bin/user_data/strategies/strg2_eth_usdt_1m.py
Normal file
@@ -0,0 +1,231 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg2_ETHUSDT_1m(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.14918562374415067,
|
||||
"34": 0.058385372968253246,
|
||||
"81": 0.02650295809826818,
|
||||
"164": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.22617753002701768
|
||||
|
||||
# Trailing stoploss
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.32322177120674106
|
||||
trailing_stop_positive_offset = 0.3600439363018107
|
||||
trailing_only_offset_is_reached = False
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = False
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'upperband': {'upperband': 'green'},
|
||||
'middleband': {'color': 'green'},
|
||||
'lowerband': {'color': 'green'},
|
||||
'tsf_mid': {'color': 'white'},
|
||||
'ema': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"corr": {
|
||||
'correl_h_l': {'color': 'black'},
|
||||
},
|
||||
"correl_tsf_mid_close": {
|
||||
'correl_tsf_mid_close': {'color': 'grey'},
|
||||
},
|
||||
"correl_angle_short_close": {
|
||||
'correl_angle_short_close': {'color': 'blue'},
|
||||
},
|
||||
"correl_angle_long_close": {
|
||||
'correl_angle_long_close': {'color': 'red'},
|
||||
},
|
||||
"correl_mfi_close": {
|
||||
'correl_mfi_close': {'color': 'black'},
|
||||
},
|
||||
"correl_hist_close": {
|
||||
'correl_tsf_mid_close': {'color': 'red'},
|
||||
},
|
||||
"mfi": {
|
||||
'mfi': {'color': 'yellow'},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12,
|
||||
slowperiod=26, signalperiod=7)
|
||||
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=30)
|
||||
dataframe['angle_short'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=30)
|
||||
dataframe['angle_mid'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=720)
|
||||
dataframe['angle_long'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=1440)
|
||||
|
||||
dataframe['tsf_long'] = TSF(dataframe['close'], timeperiod=1440)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=720)
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['correl_close_last_close'] = CORREL(dataframe['close'].shift(1), dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_tsf_long_close'] = CORREL(dataframe['tsf_long'], dataframe['close'], timeperiod=1440)
|
||||
dataframe['correl_tsf_mid_close'] = CORREL(dataframe['tsf_mid'], dataframe['close'], timeperiod=720)
|
||||
dataframe['correl_tsf_short_close'] = CORREL(dataframe['tsf_short'], dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_angle_short_close'] = CORREL(dataframe['angle_short'], dataframe['close'], timeperiod=30)
|
||||
dataframe['correl_angle_mid_close'] = CORREL(dataframe['angle_mid'], dataframe['close'], timeperiod=720)
|
||||
dataframe['correl_angle_long_close'] = CORREL(dataframe['angle_long'], dataframe['close'], timeperiod=1440)
|
||||
|
||||
dataframe['correl_hist_close'] = CORREL(dataframe['macdhist'], dataframe['close'], timeperiod=30)
|
||||
dataframe['correl_mfi_close'] = CORREL(dataframe['mfi'], dataframe['close'], timeperiod=30)
|
||||
|
||||
|
||||
|
||||
|
||||
dataframe['ema'] = EMA(dataframe['close'], timeperiod=15)
|
||||
dataframe['ma'] = MA(dataframe['close'], timeperiod=15, matype=0)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=30, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['middleband'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > 10) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > -23) &
|
||||
(dataframe['angle_mid'] > -31) &
|
||||
(0.6120614546605481 < dataframe['correl_angle_short_close']) &
|
||||
(0.4128274947005438 < dataframe['correl_angle_mid_close']) &
|
||||
(18 < dataframe['mfi']) &
|
||||
(-18 < (dataframe['ema'] - dataframe['middleband'])) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['close'], dataframe['middleband'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > 29) &
|
||||
((dataframe['tsf_short'] - dataframe['close']) > -94) &
|
||||
(dataframe['angle_mid'] > -10) &
|
||||
(0.2602396802858502 < dataframe['correl_tsf_mid_close']) &
|
||||
(-0.8240439026300765 < dataframe['correl_angle_short_close']) &
|
||||
(-0.9736515042784262 < dataframe['correl_angle_mid_close']) &
|
||||
(80 < dataframe['mfi']) &
|
||||
(26 < (dataframe['middleband'] - dataframe['ema'])) &
|
||||
(18 > dataframe['macdhist']) &
|
||||
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
212
.env/bin/user_data/strategies/strg2_eth_usdt_1m_360_30_15.py
Normal file
212
.env/bin/user_data/strategies/strg2_eth_usdt_1m_360_30_15.py
Normal file
@@ -0,0 +1,212 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import MACD, LINEARREG_ANGLE, TSF, MFI, BBANDS, CORREL
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg2_ETHUSDT_1m_360(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.14689,
|
||||
"23": 0.07987,
|
||||
"40": 0.03243,
|
||||
"136": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
# Stoploss:
|
||||
stoploss = -0.18934
|
||||
|
||||
# Trailing stop:
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.02891
|
||||
trailing_stop_positive_offset = 0.05001
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = False
|
||||
sell_profit_only = True
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'upperband': {'upperband': 'green'},
|
||||
'middleband': {'color': 'green'},
|
||||
'lowerband': {'color': 'green'},
|
||||
'tsf_mid': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"corr": {
|
||||
'correl_h_l': {'color': 'black'},
|
||||
},
|
||||
"correl_tsf_mid_close": {
|
||||
'correl_tsf_mid_close': {'color': 'grey'},
|
||||
},
|
||||
"correl_angle_short_close": {
|
||||
'correl_angle_short_close': {'color': 'blue'},
|
||||
},
|
||||
"correl_angle_long_close": {
|
||||
'correl_angle_long_close': {'color': 'red'},
|
||||
},
|
||||
"correl_mfi_close": {
|
||||
'correl_mfi_close': {'color': 'black'},
|
||||
},
|
||||
"correl_hist_close": {
|
||||
'correl_tsf_mid_close': {'color': 'red'},
|
||||
},
|
||||
"mfi": {
|
||||
'mfi': {'color': 'yellow'},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12,
|
||||
slowperiod=26, signalperiod=7)
|
||||
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=30)
|
||||
dataframe['angle_short'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=15)
|
||||
dataframe['angle_long'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=360)
|
||||
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=360)
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=15)
|
||||
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=15)
|
||||
dataframe['correl_close_last_close'] = CORREL(dataframe['close'].shift(1), dataframe['close'], timeperiod=15)
|
||||
|
||||
dataframe['correl_tsf_mid_close'] = CORREL(dataframe['tsf_mid'], dataframe['close'], timeperiod=15)
|
||||
dataframe['correl_tsf_short_close'] = CORREL(dataframe['tsf_short'], dataframe['close'], timeperiod=15)
|
||||
|
||||
dataframe['correl_angle_short_close'] = CORREL(dataframe['angle_short'], dataframe['close'], timeperiod=15)
|
||||
dataframe['correl_angle_long_close'] = CORREL(dataframe['angle_long'], dataframe['close'], timeperiod=15)
|
||||
|
||||
dataframe['correl_hist_close'] = CORREL(dataframe['macdhist'], dataframe['close'], timeperiod=15)
|
||||
dataframe['correl_mfi_close'] = CORREL(dataframe['mfi'], dataframe['close'], timeperiod=15)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=30, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['middleband'])) &
|
||||
(0.42804 < dataframe['correl_h_l']) &
|
||||
(dataframe['angle_short'] > -40) &
|
||||
(-0.23132 < dataframe['correl_angle_short_close']) &
|
||||
(0.5 < dataframe['macdhist']) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['close'], dataframe['upperband'])) &
|
||||
(36 < dataframe['angle_short']) &
|
||||
(0.72362 < dataframe['correl_angle_short_close']) &
|
||||
(0.40219 < dataframe['correl_h_l']) &
|
||||
(0 > dataframe['macdhist']) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
231
.env/bin/user_data/strategies/strg2_eth_usdt_1m_safe_prod.py
Normal file
231
.env/bin/user_data/strategies/strg2_eth_usdt_1m_safe_prod.py
Normal file
@@ -0,0 +1,231 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg2_ETHUSDT_1m_prod(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.14918562374415067,
|
||||
"34": 0.058385372968253246,
|
||||
"81": 0.02650295809826818,
|
||||
"164": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.22617753002701768
|
||||
|
||||
# Trailing stoploss
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.32322177120674106
|
||||
trailing_stop_positive_offset = 0.3600439363018107
|
||||
trailing_only_offset_is_reached = False
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = False
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'upperband': {'upperband': 'green'},
|
||||
'middleband': {'color': 'green'},
|
||||
'lowerband': {'color': 'green'},
|
||||
'tsf_mid': {'color': 'white'},
|
||||
'ema': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"corr": {
|
||||
'correl_h_l': {'color': 'black'},
|
||||
},
|
||||
"correl_tsf_mid_close": {
|
||||
'correl_tsf_mid_close': {'color': 'grey'},
|
||||
},
|
||||
"correl_angle_short_close": {
|
||||
'correl_angle_short_close': {'color': 'blue'},
|
||||
},
|
||||
"correl_angle_long_close": {
|
||||
'correl_angle_long_close': {'color': 'red'},
|
||||
},
|
||||
"correl_mfi_close": {
|
||||
'correl_mfi_close': {'color': 'black'},
|
||||
},
|
||||
"correl_hist_close": {
|
||||
'correl_tsf_mid_close': {'color': 'red'},
|
||||
},
|
||||
"mfi": {
|
||||
'mfi': {'color': 'yellow'},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12,
|
||||
slowperiod=26, signalperiod=7)
|
||||
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=30)
|
||||
dataframe['angle_short'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=30)
|
||||
dataframe['angle_mid'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=720)
|
||||
dataframe['angle_long'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=1440)
|
||||
|
||||
dataframe['tsf_long'] = TSF(dataframe['close'], timeperiod=1440)
|
||||
dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=720)
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['correl_close_last_close'] = CORREL(dataframe['close'].shift(1), dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_tsf_long_close'] = CORREL(dataframe['tsf_long'], dataframe['close'], timeperiod=1440)
|
||||
dataframe['correl_tsf_mid_close'] = CORREL(dataframe['tsf_mid'], dataframe['close'], timeperiod=720)
|
||||
dataframe['correl_tsf_short_close'] = CORREL(dataframe['tsf_short'], dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_angle_short_close'] = CORREL(dataframe['angle_short'], dataframe['close'], timeperiod=30)
|
||||
dataframe['correl_angle_mid_close'] = CORREL(dataframe['angle_mid'], dataframe['close'], timeperiod=720)
|
||||
dataframe['correl_angle_long_close'] = CORREL(dataframe['angle_long'], dataframe['close'], timeperiod=1440)
|
||||
|
||||
dataframe['correl_hist_close'] = CORREL(dataframe['macdhist'], dataframe['close'], timeperiod=30)
|
||||
dataframe['correl_mfi_close'] = CORREL(dataframe['mfi'], dataframe['close'], timeperiod=30)
|
||||
|
||||
|
||||
|
||||
|
||||
dataframe['ema'] = EMA(dataframe['close'], timeperiod=15)
|
||||
dataframe['ma'] = MA(dataframe['close'], timeperiod=15, matype=0)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=30, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['middleband'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > 10) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > -23) &
|
||||
(dataframe['angle_mid'] > -31) &
|
||||
(0.6120614546605481 < dataframe['correl_angle_short_close']) &
|
||||
(0.4128274947005438 < dataframe['correl_angle_mid_close']) &
|
||||
(18 < dataframe['mfi']) &
|
||||
(-18 < (dataframe['ema'] - dataframe['middleband'])) &
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['close'], dataframe['middleband'])) &
|
||||
((dataframe['tsf_mid'] - dataframe['close']) > 29) &
|
||||
((dataframe['tsf_short'] - dataframe['close']) > -94) &
|
||||
(dataframe['angle_mid'] > -10) &
|
||||
(0.2602396802858502 < dataframe['correl_tsf_mid_close']) &
|
||||
(-0.8240439026300765 < dataframe['correl_angle_short_close']) &
|
||||
(-0.9736515042784262 < dataframe['correl_angle_mid_close']) &
|
||||
(80 < dataframe['mfi']) &
|
||||
(26 < (dataframe['middleband'] - dataframe['ema'])) &
|
||||
(18 > dataframe['macdhist']) &
|
||||
|
||||
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
199
.env/bin/user_data/strategies/strg3_ada_usdt_1m.py
Normal file
199
.env/bin/user_data/strategies/strg3_ada_usdt_1m.py
Normal file
@@ -0,0 +1,199 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, BBANDS, CORREL, MAX, AROON, HT_PHASOR, HT_SINE, HT_DCPHASE, HT_TRENDMODE, \
|
||||
HT_TRENDLINE, CCI, AROONOSC, \
|
||||
RSI, MFI, LINEARREG_ANGLE, TSF
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg3_ADAUSDT_1m_test(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.2,
|
||||
"18": 0.07762,
|
||||
"65": 0.02142,
|
||||
"158": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
# Stoploss:
|
||||
stoploss = -0.17
|
||||
|
||||
# Trailing stop:
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.01
|
||||
trailing_stop_positive_offset = 0.05
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = False
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 130
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
},
|
||||
'subplots': {
|
||||
"sine": {
|
||||
'leadsine': {'color': 'green'},
|
||||
'ht_sine': {'color': 'orange'},
|
||||
},
|
||||
"aroon": {
|
||||
'aroon_down': {'color': 'brown'},
|
||||
'aroon_up': {'color': 'blue'},
|
||||
},
|
||||
"cci": {
|
||||
'cci': {'color': 'yellow'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ADA/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
dataframe['aroon_down'], dataframe['aroon_up'] = AROON(dataframe['high'], dataframe['low'], timeperiod=120)
|
||||
dataframe['aroonosc'] = AROONOSC(dataframe['high'], dataframe['low'], timeperiod=120)
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=30,
|
||||
slowperiod=60, signalperiod=15)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=30, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
dataframe['rsi'] = RSI(dataframe['close'], timeperiod=30)
|
||||
dataframe['ul'] = ULTOSC(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod1=5, timeperiod2=15,
|
||||
timeperiod3=30)
|
||||
# dataframe['slowk'], dataframe['slowd'] = STOCH(dataframe['high'], dataframe['low'], dataframe['close'],
|
||||
# fastk_period=15, slowk_period=7, slowk_matype=0, slowd_period=7,
|
||||
# slowd_matype=0)
|
||||
dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
timeperiod=30)
|
||||
dataframe['angle_short'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=30)
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=10)
|
||||
|
||||
dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['ht_phase'] = HT_DCPHASE(dataframe['close'])
|
||||
dataframe['ht_trendmode'] = HT_TRENDMODE(dataframe['close'])
|
||||
dataframe['ht_trendline'] = HT_TRENDLINE(dataframe['close'])
|
||||
dataframe['inphase'], dataframe['quadrature'] = HT_PHASOR(dataframe['close'])
|
||||
dataframe['ht_sine'], dataframe['leadsine'] = HT_SINE(dataframe['close'])
|
||||
dataframe['correl_sine_trend'] = CORREL(dataframe['leadsine'], dataframe['ht_trendmode'], timeperiod=10)
|
||||
dataframe['correl_ht_sine_trend'] = CORREL(dataframe['ht_sine'], dataframe['ht_trendmode'], timeperiod=10)
|
||||
dataframe['correl_ht_sine_close'] = CORREL(dataframe['ht_sine'], dataframe['close'], timeperiod=10)
|
||||
dataframe['cci'] = CCI(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=120)
|
||||
# dataframe['ht_phase_min'] = MIN(dataframe['ht_phase'], timeperiod=30)
|
||||
# dataframe['ht_phase_max'] = MAX(dataframe['ht_phase'], timeperiod=60)
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['leadsine'], dataframe['ht_sine'])) &
|
||||
(dataframe['cci'] < 0) &
|
||||
(dataframe['angle_short'] > 0) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['aroon_up'], 83)) &
|
||||
(dataframe['angle_short'] < 0) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
# Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
237
.env/bin/user_data/strategies/strg3_eth_usdt_1m.py
Normal file
237
.env/bin/user_data/strategies/strg3_eth_usdt_1m.py
Normal file
@@ -0,0 +1,237 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL, CCI, HT_DCPHASE, \
|
||||
HT_TRENDMODE, HT_TRENDLINE, MIN, MAX, HT_PHASOR, HT_SINE, LINEARREG, ATR, NATR, SAR
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg3_ETHUSDT_1m(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.22703036349783817,
|
||||
"30": 0.1085576426119433,
|
||||
"82": 0.029443202051755248,
|
||||
"164": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.1963679962572551
|
||||
|
||||
# Trailing stop:
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.2294395227514193
|
||||
trailing_stop_positive_offset = 0.3040424465654783
|
||||
trailing_only_offset_is_reached = False
|
||||
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = True
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'lr': {'color': 'green'},
|
||||
# 'angle_mid': {'color': 'blue'},
|
||||
'tsf_mid': {'color': 'orange'},
|
||||
},
|
||||
'subplots': {
|
||||
"correl_h_l": {
|
||||
'correl_h_l': {'color': 'black'}
|
||||
},
|
||||
"cci": {
|
||||
'cci': {'color': 'red'}
|
||||
},
|
||||
"natr": {
|
||||
'natr': {'color': 'red'}
|
||||
},
|
||||
"ht_phase": {
|
||||
'ht_phase': {'color': 'red'}
|
||||
},
|
||||
"ht_trendmode": {
|
||||
'ht_trendmode': {'color': 'red'}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
|
||||
# dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
# timeperiod=15)
|
||||
dataframe['cci_30'] = CCI(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=30)
|
||||
dataframe['cci_45'] = CCI(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=45)
|
||||
dataframe['trend_line'] = HT_TRENDLINE(dataframe['close'])
|
||||
|
||||
dataframe['angle_short'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=5)
|
||||
dataframe['angle_mid'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=10)
|
||||
dataframe['angle_long'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=30)
|
||||
dataframe['angle_trend_45'] = LINEARREG_ANGLE(dataframe['trend_line'], timeperiod=45)
|
||||
dataframe['angle_trend_30'] = LINEARREG_ANGLE(dataframe['trend_line'], timeperiod=30)
|
||||
# dataframe['atr'] = ATR(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=30)
|
||||
dataframe['natr'] = NATR(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=14)
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_h_l_30'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['correl_h_l_3'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=3)
|
||||
dataframe['correl_h_l_10'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=10)
|
||||
# dataframe['correl_close_last_close'] = CORREL(dataframe['close'].shift(1), dataframe['close'], timeperiod=30)
|
||||
#
|
||||
# dataframe['correl_tsf_long_close'] = CORREL(dataframe['tsf_long'], dataframe['close'], timeperiod=45)
|
||||
# dataframe['correl_tsf_mid_close'] = CORREL(dataframe['tsf_mid'], dataframe['close'], timeperiod=45)
|
||||
# dataframe['correl_tsf_short_close'] = CORREL(dataframe['tsf_short'], dataframe['close'], timeperiod=5)
|
||||
#
|
||||
# dataframe['correl_angle_short_close'] = CORREL(dataframe['angle_short'], dataframe['close'], timeperiod=45)
|
||||
# dataframe['correl_angle_mid_close'] = CORREL(dataframe['angle_mid'], dataframe['close'], timeperiod=45)
|
||||
# dataframe['correl_angle_long_close'] = CORREL(dataframe['angle_long'], dataframe['close'], timeperiod=45)
|
||||
#
|
||||
# dataframe['correl_mfi_close'] = CORREL(dataframe['mfi'], dataframe['close'], timeperiod=45)
|
||||
#
|
||||
# dataframe['ema'] = EMA(dataframe['close'], timeperiod=7)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=28, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
|
||||
# dataframe['correl_ht_sine_close'] = CORREL(dataframe['ht_sine'], dataframe['close'], timeperiod=30)
|
||||
dataframe['sar'] = SAR(dataframe['high'], dataframe['low'], acceleration=0.02, maximum=0.2)
|
||||
|
||||
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['sar'], dataframe['close'])) &
|
||||
(0 > dataframe['cci_30']) &
|
||||
(0.15 < dataframe['natr']) &
|
||||
(0 < (dataframe['trend_line'] - dataframe['close'])) &
|
||||
(0.75227 < dataframe['correl_h_l_30']) &
|
||||
# (dataframe['angle_long'] > 0) &
|
||||
# (0.44494 < dataframe['correl_angle_mid_close']) &
|
||||
# (-0.97597 < dataframe['correl_mfi_close']) & #
|
||||
# (57 > dataframe['mfi']) &
|
||||
# ((dataframe['close'] - dataframe['tsf_long']) > -3) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['sar'], dataframe['close'])) &
|
||||
(50 > dataframe['cci_30']) &
|
||||
# (100 < dataframe['cci_30']) &
|
||||
(0 < (dataframe['close'] - dataframe['trend_line'])) &
|
||||
(0.2 < dataframe['natr']) &
|
||||
(0.4 < dataframe['correl_h_l_30']) &
|
||||
|
||||
# (1 == dataframe['ht_trendmode']) &
|
||||
# ((dataframe['tsf_long'] - dataframe['close']) < -3) &
|
||||
# (dataframe['angle_mid'] < 50) &
|
||||
# (dataframe['angle_long'] < 0) &
|
||||
# (dataframe['angle_short'] > -9) &
|
||||
# (dataframe['correl_mfi_close'] > -0.4065) & #
|
||||
# (0.2552 < dataframe['correl_angle_long_close']) &
|
||||
# (0.46789 < dataframe['correl_angle_mid_close']) &
|
||||
# (57 < dataframe['mfi']) &
|
||||
# (0.00585 < (dataframe['quadrature'] - dataframe['inphase'])) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
@@ -0,0 +1,219 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL, CCI, HT_DCPHASE, \
|
||||
HT_TRENDMODE, HT_TRENDLINE, MIN, MAX, HT_PHASOR, HT_SINE, LINEARREG, ATR, NATR, SAR
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
"""
|
||||
|
||||
"""
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg3_ETHUSDT_1m_sellonlyprofit_prod(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.22703036349783817,
|
||||
"30": 0.09085576426119433,
|
||||
"82": 0.029443202051755248,
|
||||
"164": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.2263679962572551
|
||||
|
||||
# Trailing stop:
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.1294395227514193
|
||||
trailing_stop_positive_offset = 0.13040424465654783
|
||||
trailing_only_offset_is_reached = False
|
||||
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = True
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'lr': {'color': 'green'},
|
||||
# 'angle_mid': {'color': 'blue'},
|
||||
'tsf_mid': {'color': 'orange'},
|
||||
},
|
||||
'subplots': {
|
||||
"correl_h_l": {
|
||||
'correl_h_l': {'color': 'black'}
|
||||
},
|
||||
"cci": {
|
||||
'cci': {'color': 'red'}
|
||||
},
|
||||
"natr": {
|
||||
'natr': {'color': 'red'}
|
||||
},
|
||||
"ht_phase": {
|
||||
'ht_phase': {'color': 'red'}
|
||||
},
|
||||
"ht_trendmode": {
|
||||
'ht_trendmode': {'color': 'red'}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/USDT", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
|
||||
|
||||
# dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'],
|
||||
# timeperiod=15)
|
||||
dataframe['cci_30'] = CCI(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=30)
|
||||
dataframe['cci_45'] = CCI(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=45)
|
||||
dataframe['trend_line'] = HT_TRENDLINE(dataframe['close'])
|
||||
|
||||
dataframe['angle_short'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=5)
|
||||
dataframe['angle_mid'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=10)
|
||||
dataframe['angle_long'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=30)
|
||||
dataframe['angle_trend_45'] = LINEARREG_ANGLE(dataframe['trend_line'], timeperiod=45)
|
||||
dataframe['angle_trend_30'] = LINEARREG_ANGLE(dataframe['trend_line'], timeperiod=30)
|
||||
# dataframe['atr'] = ATR(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=30)
|
||||
dataframe['natr'] = NATR(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=14)
|
||||
dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=30)
|
||||
|
||||
dataframe['correl_h_l_30'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30)
|
||||
dataframe['correl_h_l_3'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=3)
|
||||
dataframe['correl_h_l_10'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=10)
|
||||
dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'],
|
||||
timeperiod=28, nbdevup=2,
|
||||
nbdevdn=2, matype=0)
|
||||
|
||||
dataframe['sar'] = SAR(dataframe['high'], dataframe['low'], acceleration=0.02, maximum=0.2)
|
||||
dataframe['angle_trend_fast'] = LINEARREG_ANGLE(dataframe['trend_line'], timeperiod=5)
|
||||
|
||||
|
||||
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['sar'], dataframe['close'])) &
|
||||
(50 > dataframe['cci_30']) &
|
||||
(0.15 < dataframe['natr']) &
|
||||
(dataframe['angle_trend_fast'] > 0) &
|
||||
(0.75227 < dataframe['correl_h_l_30']) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['sar'], dataframe['close'])) &
|
||||
(50 > dataframe['cci_30']) &
|
||||
(0.25 < dataframe['natr']) &
|
||||
(dataframe['angle_trend_fast'] < 0) &
|
||||
(0.4 < dataframe['correl_h_l_30']) &
|
||||
|
||||
# (1 == dataframe['ht_trendmode']) &
|
||||
# ((dataframe['tsf_long'] - dataframe['close']) < -3) &
|
||||
# (dataframe['angle_mid'] < 50) &
|
||||
# (dataframe['angle_long'] < 0) &
|
||||
# (dataframe['angle_short'] > -9) &
|
||||
# (dataframe['correl_mfi_close'] > -0.4065) & #
|
||||
# (0.2552 < dataframe['correl_angle_long_close']) &
|
||||
# (0.46789 < dataframe['correl_angle_mid_close']) &
|
||||
# (57 < dataframe['mfi']) &
|
||||
# (0.00585 < (dataframe['quadrature'] - dataframe['inphase'])) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
281
.env/bin/user_data/strategies/strtg2.py
Normal file
281
.env/bin/user_data/strategies/strtg2.py
Normal file
@@ -0,0 +1,281 @@
|
||||
# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement
|
||||
# isort: skip_file
|
||||
# --- Do not remove these libs ---
|
||||
import numpy as np # noqa
|
||||
import pandas as pd # noqa
|
||||
from pandas import DataFrame
|
||||
from talib._ta_lib import ULTOSC, MACD, SAR, LINEARREG_ANGLE
|
||||
|
||||
from freqtrade.strategy.interface import IStrategy
|
||||
|
||||
# --------------------------------
|
||||
# Add your lib to import here
|
||||
import talib.abstract as ta
|
||||
import freqtrade.vendor.qtpylib.indicators as qtpylib
|
||||
|
||||
|
||||
# This class is a sample. Feel free to customize it.
|
||||
class strg_ETHBTC_1m2(IStrategy):
|
||||
"""
|
||||
This is a sample strategy to inspire you.
|
||||
More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md
|
||||
|
||||
You can:
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
- Rename the class name (Do not forget to update class_name)
|
||||
- Add any methods you want to build your strategy
|
||||
- Add any lib you need to build your strategy
|
||||
|
||||
You must keep:
|
||||
- the lib in the section "Do not remove these libs"
|
||||
- the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend,
|
||||
populate_sell_trend, hyperopt_space, buy_strategy_generator
|
||||
"""
|
||||
# Strategy interface version - allow new iterations of the strategy interface.
|
||||
# Check the documentation or the Sample strategy to get the latest version.
|
||||
INTERFACE_VERSION = 2
|
||||
|
||||
# Minimal ROI designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "minimal_roi".
|
||||
minimal_roi = {
|
||||
"0": 0.04025819697656752,
|
||||
"7": 0.015188707936204564,
|
||||
"18": 0.005472487470606337,
|
||||
"41": 0
|
||||
}
|
||||
|
||||
# Optimal stoploss designed for the strategy.
|
||||
# This attribute will be overridden if the config file contains "stoploss".
|
||||
stoploss = -0.33515742514178193
|
||||
|
||||
# Trailing stoploss
|
||||
trailing_stop = False
|
||||
trailing_stop_positive = 0.34089
|
||||
trailing_stop_positive_offset = 0.43254
|
||||
trailing_only_offset_is_reached = False
|
||||
|
||||
# Optimal ticker interval for the strategy.
|
||||
timeframe = '1m'
|
||||
|
||||
# Run "populate_indicators()" only for new candle.
|
||||
process_only_new_candles = False
|
||||
|
||||
# These values can be overridden in the "ask_strategy" section in the config.
|
||||
use_sell_signal = True
|
||||
sell_profit_only = False
|
||||
ignore_roi_if_buy_signal = False
|
||||
|
||||
# Number of candles the strategy requires before producing valid signals
|
||||
startup_candle_count: int = 30
|
||||
|
||||
# Optional order type mapping.
|
||||
order_types = {
|
||||
'buy': 'limit',
|
||||
'sell': 'limit',
|
||||
'stoploss': 'market',
|
||||
'stoploss_on_exchange': False
|
||||
}
|
||||
|
||||
# Optional order time in force.
|
||||
order_time_in_force = {
|
||||
'buy': 'gtc',
|
||||
'sell': 'gtc'
|
||||
}
|
||||
|
||||
plot_config = {
|
||||
'main_plot': {
|
||||
'close': {},
|
||||
'sar': {'color': 'white'},
|
||||
},
|
||||
'subplots': {
|
||||
"MACD": {
|
||||
'macd': {'color': 'blue'},
|
||||
'macdsignal': {'color': 'orange'},
|
||||
},
|
||||
"OU": {
|
||||
'ou': {'color': 'red'},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
def informative_pairs(self):
|
||||
"""
|
||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||
These pair/interval combinations are non-tradeable, unless they are part
|
||||
of the whitelist as well.
|
||||
For more information, please consult the documentation
|
||||
:return: List of tuples in the format (pair, interval)
|
||||
Sample: return [("ETH/USDT", "5m"),
|
||||
("BTC/USDT", "15m"),
|
||||
]
|
||||
"""
|
||||
return [("ETH/BTC", "1m")]
|
||||
|
||||
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Adds several different TA indicators to the given DataFrame
|
||||
Performance Note: For the best performance be frugal on the number of indicators
|
||||
you are using. Let uncomment only the indicator you are using in your strategies
|
||||
or your hyperopt configuration, otherwise you will waste your memory and CPU usage.
|
||||
:param dataframe: Dataframe with data from the exchange
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: a Dataframe with all mandatory indicators for the strategies
|
||||
"""
|
||||
# # Ultimate Oscillator
|
||||
dataframe['uo'] = ULTOSC(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod1=7, timeperiod2=14, timeperiod3=28)
|
||||
|
||||
# MACD
|
||||
dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12, slowperiod=26, signalperiod=9)
|
||||
|
||||
# Parabolic SAR
|
||||
dataframe['sar'] = SAR(dataframe['high'], dataframe['low'], acceleration=0, maximum=0)
|
||||
|
||||
# Linear angle
|
||||
dataframe['angle'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=14)
|
||||
|
||||
# first check if dataprovider is available
|
||||
if self.dp:
|
||||
if self.dp.runmode in ('live', 'dry_run'):
|
||||
ob = self.dp.orderbook(metadata['pair'], 1)
|
||||
dataframe['best_bid'] = ob['bids'][0][0]
|
||||
dataframe['best_ask'] = ob['asks'][0][0]
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the buy signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_above(dataframe['close'], dataframe['sar'])) &
|
||||
(0 > (dataframe['sar'] - dataframe['close'])) &
|
||||
(1 > (dataframe['sar'] - dataframe['sar'].shift(3))) &
|
||||
(1 > dataframe['macd']) &
|
||||
(1 > dataframe['macdhist']) &
|
||||
(0 < (dataframe['macdhist'] - dataframe['macdhist'].shift(3))) &
|
||||
(0 < dataframe['angle']) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'buy'] = 1
|
||||
|
||||
return dataframe
|
||||
|
||||
def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
|
||||
"""
|
||||
Based on TA indicators, populates the sell signal for the given dataframe
|
||||
:param dataframe: DataFrame populated with indicators
|
||||
:param metadata: Additional information, like the currently traded pair
|
||||
:return: DataFrame with buy column
|
||||
"""
|
||||
dataframe.loc[
|
||||
(
|
||||
(qtpylib.crossed_below(dataframe['sar'], dataframe['close'])) &
|
||||
(dataframe['uo'] < 69) &
|
||||
(0 > (dataframe['sar'] - dataframe['close'])) &
|
||||
(1 > (dataframe['sar'] - dataframe['sar'].shift(3))) &
|
||||
(0 < dataframe['macd']) &
|
||||
(1 < dataframe['macdhist']) &
|
||||
(0 > (dataframe['macdhist'] - dataframe['macdhist'].shift(3))) &
|
||||
(0 > dataframe['angle']) &
|
||||
(dataframe['volume'] > 0) # Make sure Volume is not 0
|
||||
),
|
||||
'sell'] = 1
|
||||
return dataframe
|
||||
"""
|
||||
buy1:
|
||||
trigger = macd cross above macdsignal
|
||||
guard = sar < close
|
||||
guard = 70 > ou > 50
|
||||
guard = lenear_angle > 0
|
||||
|
||||
buy2:
|
||||
trigger = sar < close
|
||||
guard = macd > macdsignal
|
||||
guard = 70 > ou > 50
|
||||
buy3:
|
||||
trigger = ou cross below 30 & close > max(close)
|
||||
|
||||
sell1:
|
||||
trigger = macd cross below macdsignal
|
||||
guard = sar > close
|
||||
guard = 50 > ou > 20
|
||||
sell2:
|
||||
trigger = sar > close
|
||||
guard = macd < macdsignal
|
||||
guard = 50 > ou > 20
|
||||
"""
|
||||
|
||||
|
||||
"""
|
||||
+--------+---------+----------+------------------+--------------+------------------------------+----------------+-------------+
|
||||
| Best | Epoch | Trades | Win Draw Loss | Avg profit | Profit | Avg duration | Objective |
|
||||
|--------+---------+----------+------------------+--------------+------------------------------+----------------+-------------|
|
||||
| * Best | 3/500 | 1194 | 523 654 17 | -0.12% | -0.06906927 BTC (-138.00%) | 1,559.8 m | 2.71708 |
|
||||
| * Best | 6/500 | 100 | 20 0 80 | -0.07% | -0.00352831 BTC (-7.05%) | 11.5 m | 1.87067 |
|
||||
| Best | 37/500 | 12 | 6 0 6 | 0.49% | 0.00294367 BTC (5.88%) | 18.2 m | 1.86009 |
|
||||
| Best | 67/500 | 10 | 6 0 4 | 0.89% | 0.00443786 BTC (8.87%) | 19.5 m | 1.85245 |
|
||||
| Best | 91/500 | 73 | 21 5 47 | 0.00% | 0.00007645 BTC (0.15%) | 10.2 m | 1.85215 |
|
||||
| Best | 92/500 | 48 | 17 2 29 | 0.05% | 0.00116911 BTC (2.34%) | 10.4 m | 1.85189 |
|
||||
| Best | 94/500 | 12 | 6 0 6 | 0.69% | 0.00416071 BTC (8.31%) | 17.8 m | 1.85143 |
|
||||
| Best | 110/500 | 18 | 6 1 11 | 0.36% | 0.00327838 BTC (6.55%) | 14.3 m | 1.85113 |
|
||||
| Best | 257/500 | 48 | 16 0 32 | 0.06% | 0.00154456 BTC (3.09%) | 11.3 m | 1.8505 |
|
||||
| Best | 388/500 | 74 | 23 14 37 | 0.01% | 0.00045826 BTC (0.92%) | 8.2 m | 1.84665 |
|
||||
[Epoch 500 of 500 (100%)] || | [Time: 1:04:49, Elapsed Time: 1:04:49]
|
||||
2021-01-31 01:14:47,851 - freqtrade.optimize.hyperopt - INFO - 500 epochs saved to '/home/yakov/PycharmProjects/freqtrade/.env/bin/user_data/hyperopt_results/hyperopt_results_2021-01-31_00-07-23.pickle'.
|
||||
|
||||
Best result:
|
||||
|
||||
388/500: 74 trades. 23/14/37 Wins/Draws/Losses. Avg profit 0.01%. Median profit -0.02%. Total profit 0.00045826 BTC ( 0.92Σ%). Avg duration 8.2 min. Objective: 1.84665
|
||||
|
||||
|
||||
# Buy hyperspace params:
|
||||
buy_params = {
|
||||
'angle-enabled': False,
|
||||
'macd-enabled': False,
|
||||
'macd_value': 0.73579,
|
||||
'macdhist_shift': 0.87895,
|
||||
'macdhist_value': 0.29935,
|
||||
'sar-enabled': False,
|
||||
'sar_ratio': 0.43819,
|
||||
'sar_shift': 0.98992,
|
||||
'trigger': 'sell-macd_cross_signal'
|
||||
}
|
||||
|
||||
# Sell hyperspace params:
|
||||
sell_params = {
|
||||
'angle_h_s': 0.07105,
|
||||
'macd_value_s': 0.08408,
|
||||
'macdhist_shift_s': -0.72567,
|
||||
'macdhist_value_s': 0.77324,
|
||||
'sar_ratio_s': 0.58347,
|
||||
'sar_shift_s': 0.81212,
|
||||
'sell-angle-enabled': True,
|
||||
'sell-macd-enabled': False,
|
||||
'sell-sar-enabled': False,
|
||||
'sell-uo-enabled': True,
|
||||
'trigger': 'sell-macd_cross_signal',
|
||||
'uo_l_s': 14
|
||||
}
|
||||
|
||||
# ROI table:
|
||||
minimal_roi = {
|
||||
"0": 0.07193,
|
||||
"3": 0.0382,
|
||||
"5": 0.01183,
|
||||
"7": 0
|
||||
}
|
||||
|
||||
# Stoploss:
|
||||
stoploss = -0.25471
|
||||
|
||||
# Trailing stop:
|
||||
trailing_stop = True
|
||||
trailing_stop_positive = 0.04697
|
||||
trailing_stop_positive_offset = 0.05329
|
||||
trailing_only_offset_is_reached = True
|
||||
|
||||
"""
|
||||
Reference in New Issue
Block a user