├── .gitattributes ├── .gitignore ├── README.md ├── misc └── wherelambo.jpg └── strategies ├── README.md ├── archived ├── BinHV27.py ├── BinHV45.py ├── Cluc4.py ├── Cluc4werk.py ├── Cluc5werk.py ├── Cluc6werk.py ├── Cluc7werk.py ├── ClucCrypROI.py ├── ClucCrypSlow.py ├── ClucFiatROI.py ├── ClucFiatSlow.py ├── ClucHAnix.py ├── ClucHAwerk.py ├── Cluckie.py ├── Enchilada.py ├── Fakebuy.py ├── FisherHull.py ├── Guacamole.py ├── Hacklemore.py ├── Hacklemore2.py ├── Hacklemore3.py ├── HacklemoreX.py ├── Hacklemost.py ├── Ichis.py ├── Infinite_ROI.py ├── KAMACCIRSI.py ├── KamaRsi2.py ├── Kamaflage.py ├── Lateralus.py ├── Pmax.py ├── Renko.py ├── RenkoYolo.py ├── Schism-0318.py ├── Schism-Badstreak.py ├── Schism-Badstreak2.py ├── Schism-v1.3.py ├── Schism-v1.4.py ├── Schism-v1.5.py ├── Schism-v1.6.py ├── Schism-v1.py ├── Schism-v2.py ├── Schism.py ├── Schism2MM.py ├── Schism6.py ├── SchismLess-v2.py ├── SchismLess.py ├── Slowbro.py ├── Solipsis-Con-v1.py ├── Solipsis-Con.py ├── Solipsis-tradedbexp.py ├── Solipsis-v1.py ├── Solipsis-v2.4.py ├── Solipsis-v2.5.py ├── Solipsis-v2.6.py ├── Solipsis-v2.py ├── Solipsis-v3-fuck.py ├── Solipsis-v3.py ├── SolipsisMM.py ├── Solipsis_v3.py ├── Solipsis_v4.py ├── Stinkfist.py ├── StochRSITEMA.py ├── SuperHV27.py ├── Supertrend.py ├── Supertrend_ORIG.py ├── XtraThicc.py ├── YOLO.py ├── consensus_strat.py ├── gettinMoist.py └── hyperopts │ ├── BinHV45HyperOpt.py │ ├── Cluc4werkHyperopt.py │ ├── Cluc5werkHyperopt.py │ ├── Cluc6werkHyperopt.py │ ├── Cluc7werkHyperopt.py │ ├── ClucCrypROIHyperopt.py │ ├── ClucCrypSlowHyperopt.py │ ├── ClucFiatROIHyperopt.py │ ├── ClucFiatSlowHyperopt.py │ ├── ClucHAnixHyperopt.py │ ├── ClucHAwerkHyperopt.py │ ├── CluckieHyp.py │ ├── FisherHullHyp.py │ ├── GuacamoleHyp.py │ ├── HackieHyp.py │ ├── HacklemoreOpt.py │ ├── HacklemostOpt.py │ ├── KAMACCIRSI_Hyperopt.py │ ├── KamaRsi2Hyp.py │ ├── KamaflageHyp.py │ ├── LateralusHyp.py │ ├── PmaxHyper.py │ ├── RenkoHyp.py │ ├── Schism2HypMM.py │ ├── SchismHyp-Badstreak.py │ ├── SchismHyp-Badstreak2.py │ ├── SchismHyp-v1.3.py │ ├── SchismHyp-v1.4.py │ ├── SchismHyp-v1.5.py │ ├── SchismHyp-v1.6.py │ ├── SchismHyp-v2.py │ ├── SchismHyp.py │ ├── SchismLessHyp.py │ ├── SolipsisHyp-Con-v1.py │ ├── SolipsisHyp-Con.py │ ├── SolipsisHyp-v1.py │ ├── SolipsisHyp-v2.4.py │ ├── SolipsisHyp-v2.5.py │ ├── SolipsisHyp-v2.6.py │ ├── SolipsisHyp-v2.py │ ├── SolipsisHyp-v3.py │ ├── SolipsisHyp_v3.py │ ├── SolipsisMMHyp.py │ ├── StinkfistHyp.py │ ├── StochRSITEMAHyperopt.py │ ├── SuperHV27Hyp.py │ ├── SupertrendHyp.py │ ├── YOLOHyp.py │ ├── avgprofit_hyperopt_loss.py │ └── winrate_hyperopt_loss.py └── solipsis ├── README.md ├── Solipsis.py ├── Solipsis_v5.py └── custom_indicators.py /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Freqtrade Excludes 2 | 3 | # Private configs 4 | config/ 5 | config-*.json 6 | config-trade*.json 7 | config-dry*.json 8 | config-backtest*.json 9 | 10 | # Data 11 | data/ 12 | 13 | # Live or Private Strategies 14 | live/ 15 | private/ 16 | 17 | # Strategies that are not mine 18 | other/ 19 | sample/ 20 | private/ 21 | 22 | ######################################## 23 | # General Python .gitignore below 24 | 25 | # Byte-compiled / optimized / DLL files 26 | __pycache__/ 27 | *.py[cod] 28 | *$py.class 29 | 30 | # C extensions 31 | *.so 32 | 33 | # Distribution / packaging 34 | .Python 35 | build/ 36 | develop-eggs/ 37 | dist/ 38 | downloads/ 39 | eggs/ 40 | .eggs/ 41 | lib/ 42 | lib64/ 43 | parts/ 44 | sdist/ 45 | var/ 46 | wheels/ 47 | pip-wheel-metadata/ 48 | share/python-wheels/ 49 | *.egg-info/ 50 | .installed.cfg 51 | *.egg 52 | MANIFEST 53 | 54 | # PyInstaller 55 | # Usually these files are written by a python script from a template 56 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 57 | *.manifest 58 | *.spec 59 | 60 | # Installer logs 61 | pip-log.txt 62 | pip-delete-this-directory.txt 63 | 64 | # Unit test / coverage reports 65 | htmlcov/ 66 | .tox/ 67 | .nox/ 68 | .coverage 69 | .coverage.* 70 | .cache 71 | nosetests.xml 72 | coverage.xml 73 | *.cover 74 | *.py,cover 75 | .hypothesis/ 76 | .pytest_cache/ 77 | 78 | # Translations 79 | *.mo 80 | *.pot 81 | 82 | # Django stuff: 83 | *.log 84 | local_settings.py 85 | db.sqlite3 86 | db.sqlite3-journal 87 | 88 | # Flask stuff: 89 | instance/ 90 | .webassets-cache 91 | 92 | # Scrapy stuff: 93 | .scrapy 94 | 95 | # Sphinx documentation 96 | docs/_build/ 97 | 98 | # PyBuilder 99 | target/ 100 | 101 | # Jupyter Notebook 102 | .ipynb_checkpoints 103 | 104 | # IPython 105 | profile_default/ 106 | ipython_config.py 107 | 108 | # pyenv 109 | .python-version 110 | 111 | # pipenv 112 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 113 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 114 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 115 | # install all needed dependencies. 116 | #Pipfile.lock 117 | 118 | # celery beat schedule file 119 | celerybeat-schedule 120 | 121 | # SageMath parsed files 122 | *.sage.py 123 | 124 | # Environments 125 | .env 126 | .venv 127 | env/ 128 | venv/ 129 | ENV/ 130 | env.bak/ 131 | venv.bak/ 132 | 133 | # Spyder project settings 134 | .spyderproject 135 | .spyproject 136 | 137 | # Rope project settings 138 | .ropeproject 139 | 140 | # mkdocs documentation 141 | /site 142 | 143 | # mypy 144 | .mypy_cache/ 145 | .dmypy.json 146 | dmypy.json 147 | 148 | # Pyre type checker 149 | .pyre/ 150 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Freqtrade Strategies 2 | 3 | Strategies for [Freqtrade](https://freqtrade.io), most were developed in a partnership between @werkkrew and @JimmyNixx from the Freqtrade Discord. Some are my own. 4 | 5 | Use these strategies at your own risk. We are not responsible for anything. 6 | 7 | ## Repostitory Structure 8 | 9 | Current strategies are found in the root of the `strategies/` folder. The `strategies/archive/` folder contains old strategies and hyperopts. 10 | 11 | 12 | ![Where Lambo?](misc/wherelambo.jpg) 13 | -------------------------------------------------------------------------------- /misc/wherelambo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/werkkrew/freqtrade-strategies/582e9649a88623b6f85f03a63bfa68410cd8ad8a/misc/wherelambo.jpg -------------------------------------------------------------------------------- /strategies/README.md: -------------------------------------------------------------------------------- 1 | # Current Strategies 2 | 3 | 1) Solipsis 4 | -------------------------------------------------------------------------------- /strategies/archived/BinHV45.py: -------------------------------------------------------------------------------- 1 | # --- Do not remove these libs --- 2 | from freqtrade.strategy.interface import IStrategy 3 | from typing import Dict, List 4 | from functools import reduce 5 | from pandas import DataFrame 6 | import numpy as np 7 | # -------------------------------- 8 | 9 | import talib.abstract as ta 10 | import freqtrade.vendor.qtpylib.indicators as qtpylib 11 | 12 | 13 | def bollinger_bands(stock_price, window_size, num_of_std): 14 | rolling_mean = stock_price.rolling(window=window_size).mean() 15 | rolling_std = stock_price.rolling(window=window_size).std() 16 | lower_band = rolling_mean - (rolling_std * num_of_std) 17 | 18 | return rolling_mean, lower_band 19 | 20 | 21 | class BinHV45(IStrategy): 22 | order_types = { 23 | 'buy': 'limit', 24 | 'sell': 'limit', 25 | 'emergencysell': 'market', 26 | 'stoploss': 'market', 27 | 'stoploss_on_exchange': True, 28 | 'stoploss_on_exchange_interval': 60, 29 | 'stoploss_on_exchange_limit_ratio': 0.99 30 | } 31 | 32 | # Buy hyperspace params: 33 | buy_params = { 34 | 'bbdelta': 11, 'closedelta': 15, 'tail': 25 35 | } 36 | 37 | # Sell hyperspace params: 38 | sell_params = { 39 | 40 | } 41 | 42 | # ROI table: 43 | minimal_roi = { 44 | '0': 0.20233, 45 | '26': 0.06166, 46 | '85': 0.01367, 47 | '186': 0 48 | } 49 | 50 | # Stoploss: 51 | stoploss = -0.13348 52 | 53 | # Trailing stop: 54 | trailing_stop = True 55 | trailing_stop_positive = 0.30436 56 | trailing_stop_positive_offset = 0.31289 57 | trailing_only_offset_is_reached = False 58 | 59 | timeframe = '1m' 60 | 61 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 62 | mid, lower = bollinger_bands(dataframe['close'], window_size=40, num_of_std=2) 63 | dataframe['mid'] = np.nan_to_num(mid) 64 | dataframe['lower'] = np.nan_to_num(lower) 65 | dataframe['bbdelta'] = (dataframe['mid'] - dataframe['lower']).abs() 66 | dataframe['pricedelta'] = (dataframe['open'] - dataframe['close']).abs() 67 | dataframe['closedelta'] = (dataframe['close'] - dataframe['close'].shift()).abs() 68 | dataframe['tail'] = (dataframe['close'] - dataframe['low']).abs() 69 | return dataframe 70 | 71 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 72 | dataframe.loc[ 73 | ( 74 | dataframe['lower'].shift().gt(0) & 75 | dataframe['bbdelta'].gt(dataframe['close'] * 11 / 1000) & 76 | dataframe['closedelta'].gt(dataframe['close'] * 15 / 1000) & 77 | dataframe['tail'].lt(dataframe['bbdelta'] * 25 / 1000) & 78 | dataframe['close'].lt(dataframe['lower'].shift()) & 79 | dataframe['close'].le(dataframe['close'].shift()) 80 | ), 81 | 'buy'] = 1 82 | return dataframe 83 | 84 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 85 | """ 86 | no sell signal 87 | """ 88 | dataframe['sell'] = 0 89 | return dataframe 90 | -------------------------------------------------------------------------------- /strategies/archived/Cluc4.py: -------------------------------------------------------------------------------- 1 | import freqtrade.vendor.qtpylib.indicators as qtpylib 2 | import numpy as np 3 | import talib.abstract as ta 4 | from freqtrade.strategy.interface import IStrategy 5 | from freqtrade.strategy import merge_informative_pair 6 | from pandas import DataFrame 7 | 8 | def bollinger_bands(stock_price, window_size, num_of_std): 9 | rolling_mean = stock_price.rolling(window=window_size).mean() 10 | rolling_std = stock_price.rolling(window=window_size).std() 11 | lower_band = rolling_mean - (rolling_std * num_of_std) 12 | return np.nan_to_num(rolling_mean), np.nan_to_num(lower_band) 13 | 14 | class Cluc4(IStrategy): 15 | minimal_roi = { 16 | "0": 0.015, 17 | "20": 0.005, 18 | "30": 0.001 19 | } 20 | 21 | stoploss = -0.01 22 | 23 | timeframe = '1m' 24 | 25 | use_sell_signal = True 26 | sell_profit_only = True 27 | ignore_roi_if_buy_signal = True 28 | 29 | def informative_pairs(self): 30 | pairs = self.dp.current_whitelist() 31 | informative_pairs = [(pair, '1h') for pair in pairs] 32 | return informative_pairs 33 | 34 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 35 | mid, lower = bollinger_bands(dataframe['close'], window_size=40, num_of_std=2) 36 | dataframe['lower'] = lower 37 | dataframe['bbdelta'] = (mid - dataframe['lower']).abs() 38 | dataframe['closedelta'] = (dataframe['close'] - dataframe['close'].shift()).abs() 39 | dataframe['tail'] = (dataframe['close'] - dataframe['low']).abs() 40 | bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2) 41 | dataframe['bb_lowerband'] = bollinger['lower'] 42 | dataframe['bb_middleband'] = bollinger['mid'] 43 | dataframe['ema_slow'] = ta.EMA(dataframe, timeperiod=50) 44 | dataframe['volume_mean_slow'] = dataframe['volume'].rolling(window=30).mean() 45 | dataframe['rocr'] = ta.ROCR(dataframe, timeperiod=28) 46 | inf_tf = '1h' 47 | informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe=inf_tf) 48 | informative['rocr'] = ta.ROCR(informative, timeperiod=168) 49 | dataframe = merge_informative_pair(dataframe, informative, self.timeframe, inf_tf, ffill=True) 50 | 51 | return dataframe 52 | 53 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 54 | dataframe.loc[ 55 | ( 56 | dataframe['rocr_1h'].gt(0.65) 57 | ) & 58 | (( dataframe['lower'].shift().gt(0) & 59 | dataframe['bbdelta'].gt(dataframe['close'] * 0.006) & 60 | dataframe['closedelta'].gt(dataframe['close'] * 0.013) & 61 | dataframe['tail'].lt(dataframe['bbdelta'] * 0.968) & 62 | dataframe['close'].lt(dataframe['lower'].shift()) & 63 | dataframe['close'].le(dataframe['close'].shift()) 64 | ) | 65 | ( (dataframe['close'] < dataframe['ema_slow']) & 66 | (dataframe['close'] < 0.013 * dataframe['bb_lowerband']) & 67 | (dataframe['volume'] < (dataframe['volume_mean_slow'].shift(1) * 28)) 68 | )), 69 | 'buy' 70 | ] = 1 71 | return dataframe 72 | 73 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 74 | """ 75 | """ 76 | dataframe.loc[ 77 | #((qtpylib.crossed_above(dataframe['close'],(dataframe['bb_middleband'] * 1.1))) & 78 | ((qtpylib.crossed_above(dataframe['close'],dataframe['bb_middleband'])) & 79 | (dataframe['volume'] > 0)) 80 | , 81 | 'sell' 82 | ] = 1 83 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/Cluc6werk.py: -------------------------------------------------------------------------------- 1 | import freqtrade.vendor.qtpylib.indicators as qtpylib 2 | import numpy as np 3 | import talib.abstract as ta 4 | from freqtrade.strategy.interface import IStrategy 5 | from freqtrade.strategy import merge_informative_pair 6 | from pandas import DataFrame 7 | 8 | def bollinger_bands(stock_price, window_size, num_of_std): 9 | rolling_mean = stock_price.rolling(window=window_size).mean() 10 | rolling_std = stock_price.rolling(window=window_size).std() 11 | lower_band = rolling_mean - (rolling_std * num_of_std) 12 | return np.nan_to_num(rolling_mean), np.nan_to_num(lower_band) 13 | 14 | class Cluc4werk(IStrategy): 15 | 16 | # Used for "informative pairs" 17 | stake = 'BTC' 18 | fiat = 'USD' 19 | 20 | """ 21 | PASTE OUTPUT FROM HYPEROPT HERE 22 | """ 23 | 24 | # Buy hyperspace params: 25 | buy_params = { 26 | 'bbdelta-close': 0.00793, 27 | 'bbdelta-tail': 0.83802, 28 | 'close-bblower': 0.0034, 29 | 'closedelta-close': 0.00613, 30 | 'rocr-1h': 0.64081, 31 | 'volume': 21 32 | } 33 | 34 | # Sell hyperspace params: 35 | sell_params = { 36 | 'sell-bbmiddle-close': 0.97703 37 | } 38 | 39 | # ROI table: 40 | minimal_roi = { 41 | "0": 0.0155, 42 | "109": 0.01075, 43 | "393": 0.00771, 44 | "587": 0.00643, 45 | "711": 0.00377, 46 | "770": 0.00114, 47 | "1039": 0 48 | } 49 | 50 | # Stoploss: 51 | stoploss = -0.31742 52 | 53 | # Trailing stop: 54 | trailing_stop = True 55 | trailing_stop_positive = 0.31289 56 | trailing_stop_positive_offset = 0.33275 57 | trailing_only_offset_is_reached = True 58 | 59 | """ 60 | END HYPEROPT 61 | """ 62 | 63 | timeframe = '1m' 64 | 65 | # Make sure these match or are not overridden in config 66 | use_sell_signal = True 67 | sell_profit_only = False 68 | sell_profit_offset = 0.0 69 | ignore_roi_if_buy_signal = True 70 | 71 | def informative_pairs(self): 72 | pairs = self.dp.current_whitelist() 73 | informative_pairs = [(pair, '1h') for pair in pairs] 74 | 75 | """ 76 | Idea is to have "STAKE/USD" and "COIN/USD" as informative pairs as they move inverse of COIN/STAKE. 77 | For example, stake currency is BTC, whitelist is */BTC 78 | Current pair being examined (metadata['pair']) is XLM/BTC 79 | Be able to have informative pairs BTC/USD and XLM/USD available for use with some indicators for all pairs in the whitelist. 80 | Ideally have this work gracefully with a change to the stake/whitelist in the config file. 81 | If a desired informative pair does not exist (e.g. if exchange doesnt trade XLM/USD in this example), simply ignore those indicators without errors. 82 | """ 83 | 84 | coin, stake = metadata['pair'].split('/') 85 | 86 | informative_pairs += [("ETH/USD", timeframe), 87 | ("BTC/USD", timeframe), 88 | ] 89 | 90 | 91 | 92 | return informative_pairs 93 | 94 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 95 | # Set Up Bollinger Bands 96 | mid, lower = bollinger_bands(dataframe['close'], window_size=40, num_of_std=2) 97 | dataframe['lower'] = lower 98 | dataframe['bbdelta'] = (mid - dataframe['lower']).abs() 99 | dataframe['closedelta'] = (dataframe['close'] - dataframe['close'].shift()).abs() 100 | dataframe['tail'] = (dataframe['close'] - dataframe['low']).abs() 101 | bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2) 102 | dataframe['bb_lowerband'] = bollinger['lower'] 103 | dataframe['bb_middleband'] = bollinger['mid'] 104 | 105 | dataframe['ema_slow'] = ta.EMA(dataframe, timeperiod=50) 106 | dataframe['volume_mean_slow'] = dataframe['volume'].rolling(window=30).mean() 107 | dataframe['rocr'] = ta.ROCR(dataframe, timeperiod=28) 108 | 109 | inf_tf = '1h' 110 | 111 | """ 112 | informative = self.dp.get_pair_dataframe(pair="ETH/USDT", timeframe="5m") 113 | # ETH/USDT RSI based on 5m candles 114 | informative['rsi'] = ta.RSI(informative, timeperiod=14) 115 | dataframe = merge_informative_pair(dataframe, informative, self.timeframe, '5m', ffill=True) 116 | """ 117 | 118 | informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe=inf_tf) 119 | informative['rocr'] = ta.ROCR(informative, timeperiod=168) 120 | dataframe = merge_informative_pair(dataframe, informative, self.timeframe, inf_tf, ffill=True) 121 | 122 | return dataframe 123 | 124 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 125 | params = self.buy_params 126 | 127 | dataframe.loc[ 128 | ( 129 | dataframe['rocr_1h'].gt(params['rocr-1h']) 130 | ) & 131 | (( 132 | dataframe['lower'].shift().gt(0) & 133 | dataframe['bbdelta'].gt(dataframe['close'] * params['bbdelta-close']) & 134 | dataframe['closedelta'].gt(dataframe['close'] * params['closedelta-close']) & 135 | dataframe['tail'].lt(dataframe['bbdelta'] * params['bbdelta-tail']) & 136 | dataframe['close'].lt(dataframe['lower'].shift()) & 137 | dataframe['close'].le(dataframe['close'].shift()) 138 | ) | 139 | ( 140 | (dataframe['close'] < dataframe['ema_slow']) & 141 | (dataframe['close'] < params['close-bblower'] * dataframe['bb_lowerband']) & 142 | (dataframe['volume'] < (dataframe['volume_mean_slow'].shift(1) * params['volume'])) 143 | )), 144 | 'buy' 145 | ] = 1 146 | return dataframe 147 | 148 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 149 | params = self.sell_params 150 | 151 | dataframe.loc[ 152 | #(dataframe['high'].le(dataframe['high'].shift(1))) & 153 | #(dataframe['close'] > dataframe['bb_middleband']) & 154 | (qtpylib.crossed_above((dataframe['close'] * params['sell-bbmiddle-close']),dataframe['bb_middleband'])) & 155 | #(qtpylib.crossed_above(dataframe['close'],dataframe['bb_middleband'])) & 156 | (dataframe['volume'] > 0) 157 | , 158 | 'sell' 159 | ] = 1 160 | 161 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/Cluc7werk.py: -------------------------------------------------------------------------------- 1 | import freqtrade.vendor.qtpylib.indicators as qtpylib 2 | import numpy as np 3 | import talib.abstract as ta 4 | from freqtrade.strategy.interface import IStrategy 5 | from freqtrade.strategy import merge_informative_pair 6 | from pandas import DataFrame, Series 7 | 8 | class Cluc7werk(IStrategy): 9 | 10 | """ 11 | PASTE OUTPUT FROM HYPEROPT HERE 12 | """ 13 | # Buy hyperspace params: 14 | buy_params = { 15 | 'bbdelta-close': 0.00732, 16 | 'bbdelta-tail': 0.94138, 17 | 'close-bblower': 0.0199, 18 | 'closedelta-close': 0.01825, 19 | 'fisher': -0.22987, 20 | 'volume': 16 21 | } 22 | 23 | # Sell hyperspace params: 24 | sell_params = { 25 | 'sell-bbmiddle-close': 0.99184, 26 | 'sell-fisher': 0.26832 27 | } 28 | 29 | # ROI table: 30 | minimal_roi = { 31 | "0": 0.15373, 32 | "14": 0.1105, 33 | "57": 0.08376, 34 | "147": 0.03427, 35 | "201": 0.01352, 36 | "366": 0.00667, 37 | "469": 0 38 | } 39 | 40 | # Stoploss: 41 | stoploss = -0.02 42 | 43 | # Trailing stop: 44 | trailing_stop = True 45 | trailing_stop_positive = 0.01007 46 | trailing_stop_positive_offset = 0.01258 47 | trailing_only_offset_is_reached = False 48 | 49 | """ 50 | END HYPEROPT 51 | """ 52 | 53 | timeframe = '1m' 54 | 55 | startup_candle_count: int = 72 56 | 57 | # Make sure these match or are not overridden in config 58 | use_sell_signal = True 59 | sell_profit_only = True 60 | sell_profit_offset = 0.01 61 | ignore_roi_if_buy_signal = True 62 | 63 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 64 | 65 | # Set Up Bollinger Bands 66 | upper_bb1, mid_bb1, lower_bb1 = ta.BBANDS(dataframe['close'], timeperiod=40) 67 | upper_bb2, mid_bb2, lower_bb2 = ta.BBANDS(qtpylib.typical_price(dataframe), timeperiod=20) 68 | 69 | # only putting some bands into dataframe as the others are not used elsewhere in the strategy 70 | dataframe['lower-bb1'] = lower_bb1 71 | dataframe['lower-bb2'] = lower_bb2 72 | dataframe['mid-bb2'] = mid_bb2 73 | 74 | dataframe['bb1-delta'] = (mid_bb1 - dataframe['lower-bb1']).abs() 75 | dataframe['closedelta'] = (dataframe['close'] - dataframe['close'].shift()).abs() 76 | dataframe['tail'] = (dataframe['close'] - dataframe['low']).abs() 77 | 78 | dataframe['ema_fast'] = ta.EMA(dataframe['close'], timeperiod=6) 79 | dataframe['ema_slow'] = ta.EMA(dataframe['close'], timeperiod=48) 80 | dataframe['volume_mean_slow'] = dataframe['volume'].rolling(window=24).mean() 81 | 82 | dataframe['rsi'] = ta.RSI(dataframe, timeperiod=9) 83 | 84 | # # Inverse Fisher transform on RSI: values [-1.0, 1.0] (https://goo.gl/2JGGoy) 85 | rsi = 0.1 * (dataframe['rsi'] - 50) 86 | dataframe['fisher-rsi'] = (np.exp(2 * rsi) - 1) / (np.exp(2 * rsi) + 1) 87 | 88 | return dataframe 89 | 90 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 91 | params = self.buy_params 92 | 93 | dataframe.loc[ 94 | ( 95 | dataframe['fisher-rsi'].lt(params['fisher']) 96 | ) & 97 | (( 98 | dataframe['bb1-delta'].gt(dataframe['close'] * params['bbdelta-close']) & 99 | dataframe['closedelta'].gt(dataframe['close'] * params['closedelta-close']) & 100 | dataframe['tail'].lt(dataframe['bb1-delta'] * params['bbdelta-tail']) & 101 | dataframe['close'].lt(dataframe['lower-bb1'].shift()) & 102 | dataframe['close'].le(dataframe['close'].shift()) 103 | ) | 104 | ( 105 | (dataframe['close'] < dataframe['ema_slow']) & 106 | (dataframe['close'] < params['close-bblower'] * dataframe['lower-bb2']) & 107 | (dataframe['volume'] < (dataframe['volume_mean_slow'].shift(1) * params['volume'])) 108 | )), 109 | 'buy' 110 | ] = 1 111 | 112 | return dataframe 113 | 114 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 115 | params = self.sell_params 116 | 117 | dataframe.loc[ 118 | ((dataframe['close'] * params['sell-bbmiddle-close']) > dataframe['mid-bb2']) & 119 | dataframe['ema_fast'].gt(dataframe['close']) & 120 | dataframe['fisher-rsi'].gt(params['sell-fisher']) & 121 | dataframe['volume'].gt(0) 122 | , 123 | 'sell' 124 | ] = 1 125 | 126 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/ClucFiatSlow.py: -------------------------------------------------------------------------------- 1 | import freqtrade.vendor.qtpylib.indicators as qtpylib 2 | import numpy as np 3 | import talib.abstract as ta 4 | from freqtrade.strategy.interface import IStrategy 5 | from freqtrade.strategy import merge_informative_pair 6 | from datetime import datetime 7 | from freqtrade.persistence import Trade 8 | from pandas import DataFrame, Series 9 | 10 | class ClucFiatSlow(IStrategy): 11 | 12 | # Buy hyperspace params: 13 | buy_params = { 14 | 'bbdelta-close': 0.00642, 15 | 'bbdelta-tail': 0.75559, 16 | 'close-bblower': 0.01415, 17 | 'closedelta-close': 0.00883, 18 | 'fisher': -0.97101, 19 | 'volume': 18 20 | } 21 | 22 | # Sell hyperspace params: 23 | sell_params = { 24 | 'sell-bbmiddle-close': 0.95153, 25 | 'sell-fisher': 0.60924 26 | } 27 | 28 | # ROI table: 29 | minimal_roi = { 30 | "0": 0.04354, 31 | "5": 0.03734, 32 | "8": 0.02569, 33 | "10": 0.019, 34 | "76": 0.01283, 35 | "235": 0.007, 36 | "415": 0 37 | } 38 | 39 | # Stoploss: 40 | stoploss = -0.34299 41 | 42 | # Trailing stop: 43 | trailing_stop = True 44 | trailing_stop_positive = 0.01057 45 | trailing_stop_positive_offset = 0.03668 46 | trailing_only_offset_is_reached = True 47 | 48 | """ 49 | END HYPEROPT 50 | """ 51 | 52 | timeframe = '5m' 53 | 54 | use_sell_signal = True 55 | sell_profit_only = False 56 | sell_profit_offset = 0.01 57 | ignore_roi_if_buy_signal = True 58 | 59 | startup_candle_count: int = 48 60 | 61 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 62 | 63 | # Set Up Bollinger Bands 64 | upper_bb1, mid_bb1, lower_bb1 = ta.BBANDS(dataframe['close'], timeperiod=40) 65 | upper_bb2, mid_bb2, lower_bb2 = ta.BBANDS(qtpylib.typical_price(dataframe), timeperiod=20) 66 | 67 | # only putting some bands into dataframe as the others are not used elsewhere in the strategy 68 | dataframe['lower-bb1'] = lower_bb1 69 | dataframe['lower-bb2'] = lower_bb2 70 | dataframe['mid-bb2'] = mid_bb2 71 | 72 | dataframe['bb1-delta'] = (mid_bb1 - dataframe['lower-bb1']).abs() 73 | dataframe['closedelta'] = (dataframe['close'] - dataframe['close'].shift()).abs() 74 | dataframe['tail'] = (dataframe['close'] - dataframe['low']).abs() 75 | 76 | dataframe['ema_fast'] = ta.EMA(dataframe['close'], timeperiod=6) 77 | dataframe['ema_slow'] = ta.EMA(dataframe['close'], timeperiod=48) 78 | dataframe['volume_mean_slow'] = dataframe['volume'].rolling(window=24).mean() 79 | 80 | dataframe['rsi'] = ta.RSI(dataframe, timeperiod=9) 81 | 82 | # # Inverse Fisher transform on RSI: values [-1.0, 1.0] (https://goo.gl/2JGGoy) 83 | rsi = 0.1 * (dataframe['rsi'] - 50) 84 | dataframe['fisher-rsi'] = (np.exp(2 * rsi) - 1) / (np.exp(2 * rsi) + 1) 85 | 86 | return dataframe 87 | 88 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 89 | params = self.buy_params 90 | 91 | dataframe.loc[ 92 | ( 93 | dataframe['fisher-rsi'].lt(params['fisher']) 94 | ) & 95 | (( 96 | dataframe['bb1-delta'].gt(dataframe['close'] * params['bbdelta-close']) & 97 | dataframe['closedelta'].gt(dataframe['close'] * params['closedelta-close']) & 98 | dataframe['tail'].lt(dataframe['bb1-delta'] * params['bbdelta-tail']) & 99 | dataframe['close'].lt(dataframe['lower-bb1'].shift()) & 100 | dataframe['close'].le(dataframe['close'].shift()) 101 | ) | 102 | ( 103 | (dataframe['close'] < dataframe['ema_slow']) & 104 | (dataframe['close'] < params['close-bblower'] * dataframe['lower-bb2']) & 105 | (dataframe['volume'] < (dataframe['volume_mean_slow'].shift(1) * params['volume'])) 106 | )), 107 | 'buy' 108 | ] = 1 109 | 110 | return dataframe 111 | 112 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 113 | params = self.sell_params 114 | 115 | dataframe.loc[ 116 | ((dataframe['close'] * params['sell-bbmiddle-close']) > dataframe['mid-bb2']) & 117 | dataframe['ema_fast'].gt(dataframe['close']) & 118 | dataframe['fisher-rsi'].gt(params['sell-fisher']) & 119 | dataframe['volume'].gt(0) 120 | , 121 | 'sell' 122 | ] = 1 123 | 124 | return dataframe 125 | 126 | """ 127 | https://www.freqtrade.io/en/latest/strategy-advanced/ 128 | 129 | Custom Order Timeouts 130 | """ 131 | def check_buy_timeout(self, pair: str, trade: Trade, order: dict, **kwargs) -> bool: 132 | ob = self.dp.orderbook(pair, 1) 133 | current_price = ob['bids'][0][0] 134 | # Cancel buy order if price is more than 1% above the order. 135 | if current_price > order['price'] * 1.01: 136 | return True 137 | return False 138 | 139 | 140 | def check_sell_timeout(self, pair: str, trade: Trade, order: dict, **kwargs) -> bool: 141 | ob = self.dp.orderbook(pair, 1) 142 | current_price = ob['asks'][0][0] 143 | # Cancel sell order if price is more than 1% below the order. 144 | if current_price < order['price'] * 0.99: 145 | return True 146 | return False 147 | 148 | -------------------------------------------------------------------------------- /strategies/archived/Cluckie.py: -------------------------------------------------------------------------------- 1 | import freqtrade.vendor.qtpylib.indicators as qtpylib 2 | import numpy as np 3 | import talib.abstract as ta 4 | from freqtrade.strategy.interface import IStrategy 5 | from freqtrade.strategy import merge_informative_pair 6 | from pandas import DataFrame, Series 7 | from datetime import datetime 8 | from freqtrade.persistence import Trade 9 | 10 | class Cluckie(IStrategy): 11 | 12 | """ 13 | PASTE OUTPUT FROM HYPEROPT HERE 14 | """ 15 | # Buy hyperspace params: 16 | buy_params = { 17 | 'bbdelta-close': 0.01118, 18 | 'bbdelta-tail': 0.88481, 19 | 'close-bblower': 0.00396, 20 | 'closedelta-close': 0.01232, 21 | 'fisher': -0.8167, 22 | 'volume': 29 23 | } 24 | 25 | # Sell hyperspace params: 26 | sell_params = { 27 | 'sell-adx': 70, 28 | 'sell-fisher': 0.95954 29 | } 30 | 31 | # ROI table: 32 | minimal_roi = { 33 | "0": 100 34 | } 35 | 36 | # Stoploss: 37 | stoploss = -0.015 38 | 39 | """ 40 | END HYPEROPT 41 | """ 42 | 43 | timeframe = '5m' 44 | 45 | 46 | # Make sure these match or are not overridden in config 47 | use_sell_signal = True 48 | #sell_profit_only = True 49 | #sell_profit_offset = 0.01 50 | ignore_roi_if_buy_signal = True 51 | 52 | def check_buy_timeout(self, pair: str, trade: Trade, order: dict, **kwargs) -> bool: 53 | ob = self.dp.orderbook(pair, 1) 54 | current_price = ob['bids'][0][0] 55 | # Cancel buy order if price is more than 1% above the order. 56 | if current_price > order['price'] * 1.01: 57 | return True 58 | return False 59 | 60 | 61 | def check_sell_timeout(self, pair: str, trade: Trade, order: dict, **kwargs) -> bool: 62 | ob = self.dp.orderbook(pair, 1) 63 | current_price = ob['asks'][0][0] 64 | # Cancel sell order if price is more than 1% below the order. 65 | if current_price < order['price'] * 0.99: 66 | return True 67 | return False 68 | 69 | 70 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 71 | 72 | # Set Up Bollinger Bands 73 | upper_bb1, mid_bb1, lower_bb1 = ta.BBANDS(dataframe['close'], timeperiod=40) 74 | upper_bb2, mid_bb2, lower_bb2 = ta.BBANDS(qtpylib.typical_price(dataframe), timeperiod=20) 75 | 76 | # only putting some bands into dataframe as the others are not used elsewhere in the strategy 77 | dataframe['lower-bb1'] = lower_bb1 78 | dataframe['lower-bb2'] = lower_bb2 79 | dataframe['mid-bb2'] = mid_bb2 80 | 81 | dataframe['bb1-delta'] = (mid_bb1 - dataframe['lower-bb1']).abs() 82 | dataframe['closedelta'] = (dataframe['close'] - dataframe['close'].shift()).abs() 83 | dataframe['tail'] = (dataframe['close'] - dataframe['low']).abs() 84 | 85 | dataframe['ema_slow'] = ta.EMA(dataframe['close'], timeperiod=48) 86 | dataframe['volume_mean_slow'] = dataframe['volume'].rolling(window=24).mean() 87 | 88 | dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14) 89 | 90 | # # Inverse Fisher transform on RSI: values [-1.0, 1.0] (https://goo.gl/2JGGoy) 91 | rsi = 0.1 * (dataframe['rsi'] - 50) 92 | dataframe['fisher-rsi'] = (np.exp(2 * rsi) - 1) / (np.exp(2 * rsi) + 1) 93 | 94 | dataframe['tema'] = ta.TEMA(dataframe, timeperiod=9) 95 | dataframe['adx'] = ta.ADX(dataframe) 96 | 97 | return dataframe 98 | 99 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 100 | params = self.buy_params 101 | 102 | dataframe.loc[ 103 | ( 104 | dataframe['fisher-rsi'].lt(params['fisher']) 105 | ) & 106 | (( 107 | (dataframe['bb1-delta'].gt(dataframe['close'] * params['bbdelta-close'])) & 108 | (dataframe['closedelta'].gt(dataframe['close'] * params['closedelta-close'])) & 109 | (dataframe['tail'].lt(dataframe['bb1-delta'] * params['bbdelta-tail'])) & 110 | (dataframe['close'].lt(dataframe['lower-bb1'].shift())) & 111 | (dataframe['close'].le(dataframe['close'].shift())) & 112 | (dataframe['tema'] > dataframe['tema'].shift(1)) 113 | ) | 114 | ( 115 | (dataframe['close'] < dataframe['ema_slow']) & 116 | (dataframe['close'] < params['close-bblower'] * dataframe['lower-bb2']) & 117 | (dataframe['volume'] < (dataframe['volume_mean_slow'].shift(1) * params['volume'])) 118 | )), 119 | 'buy' 120 | ] = 1 121 | 122 | return dataframe 123 | 124 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 125 | params = self.sell_params 126 | 127 | dataframe.loc[ 128 | ( 129 | (dataframe['adx'] > params['sell-adx']) & 130 | (dataframe['tema'] > dataframe['mid-bb2']) & 131 | (dataframe['tema'] < dataframe['tema'].shift(1)) & 132 | (dataframe['fisher-rsi'].gt(params['sell-fisher'])) 133 | ) 134 | , 135 | 'sell' 136 | ] = 1 137 | 138 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/FisherHull.py: -------------------------------------------------------------------------------- 1 | import freqtrade.vendor.qtpylib.indicators as qtpylib 2 | import numpy as np 3 | import talib.abstract as ta 4 | from freqtrade.strategy.interface import IStrategy 5 | from pandas import DataFrame, DatetimeIndex, merge, Series 6 | from technical.indicators import hull_moving_average 7 | 8 | """ 9 | def hull_moving_average(dataframe, period, field='close') -> ndarray: 10 | from pyti.hull_moving_average import hull_moving_average as hma 11 | return hma(dataframe[field], period) 12 | """ 13 | 14 | class YOLO(IStrategy): 15 | 16 | # Buy hyperspace params: 17 | buy_params = { 18 | 19 | } 20 | 21 | # Sell hyperspace params: 22 | sell_params = { 23 | 24 | } 25 | 26 | # ROI table: 27 | minimal_roi = { 28 | '0': 1000 29 | } 30 | 31 | # Stoploss: 32 | stoploss = -0.27654 33 | 34 | # Trailing stop: 35 | trailing_stop = True 36 | trailing_stop_positive = 0.32606 37 | trailing_stop_positive_offset = 0.33314 38 | trailing_only_offset_is_reached = True 39 | """ 40 | END HYPEROPT 41 | """ 42 | 43 | timeframe = '1m' 44 | 45 | use_sell_signal = False 46 | sell_profit_only = False 47 | ignore_roi_if_buy_signal = True 48 | 49 | 50 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 51 | 52 | dataframe['hma'] = hull_moving_average(dataframe, 14, 'close') 53 | dataframe['cci'] = ta.CCI(dataframe, timeperiod=14) 54 | dataframe['rsi'] = ta.RSI(dataframe, timeperiod=14) 55 | 56 | 57 | rsi = 0.1 * (dataframe['rsi'] - 50) 58 | dataframe['fisher_rsi'] = (np.exp(2 * rsi) - 1) / (np.exp(2 * rsi) + 1) 59 | 60 | return dataframe 61 | 62 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 63 | 64 | dataframe.loc[ 65 | 66 | ( 67 | (dataframe['hma'] < dataframe['hma'].shift()) & 68 | (dataframe['cci'] <= -50.0) & 69 | (dataframe['fisher_rsi'] < -0.5) & 70 | (dataframe['volume'] > 0) 71 | ) 72 | 73 | , 74 | 'buy' 75 | ] = 1 76 | 77 | return dataframe 78 | 79 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 80 | 81 | dataframe.loc[ 82 | ( 83 | (dataframe['hma'] > dataframe['hma'].shift()) & 84 | (dataframe['cci'] >= 100.0) & 85 | (dataframe['fisher_rsi'] > 0.5) & 86 | (dataframe['volume'] > 0) 87 | ), 88 | 'sell' 89 | ] = 1 90 | 91 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/Guacamole.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | import freqtrade.vendor.qtpylib.indicators as qtpylib 3 | import numpy as np 4 | import talib.abstract as ta 5 | from freqtrade.strategy.interface import IStrategy 6 | from freqtrade.strategy import merge_informative_pair 7 | from pandas import DataFrame, Series 8 | from functools import reduce 9 | from datetime import datetime 10 | from freqtrade.persistence import Trade 11 | from technical.indicators import RMI, VIDYA 12 | 13 | 14 | class Guacamole(IStrategy): 15 | 16 | """ 17 | PASTE OUTPUT FROM HYPEROPT HERE 18 | """ 19 | 20 | # Buy hyperspace params: 21 | buy_params = { 22 | 'macd': -0.75454, 23 | 'macdhist': -1, 24 | 'rmi': 49 25 | } 26 | 27 | # Sell hyperspace params: 28 | sell_params = { 29 | 30 | } 31 | 32 | # ROI table: 33 | minimal_roi = { 34 | "0": 0.13336, 35 | "19": 0.07455, 36 | "37": 0.04206, 37 | "57": 0.02682, 38 | "73": 0.01225, 39 | "125": 0.0037, 40 | "244": 0.0025 41 | } 42 | 43 | stoploss = -0.99 44 | 45 | # Trailing stop: 46 | trailing_stop = True 47 | trailing_stop_positive = 0.01673 48 | trailing_stop_positive_offset = 0.01851 49 | trailing_only_offset_is_reached = False 50 | 51 | 52 | 53 | """ 54 | END HYPEROPT 55 | """ 56 | 57 | timeframe = '5m' 58 | 59 | use_sell_signal = True 60 | sell_profit_only = False 61 | # sell_profit_offset = 0.01 62 | ignore_roi_if_buy_signal = True 63 | 64 | process_only_new_candles = False 65 | 66 | startup_candle_count: int = 20 67 | 68 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 69 | 70 | dataframe['sar'] = ta.SAR(dataframe) 71 | dataframe['rmi'] = RMI(dataframe) 72 | dataframe['kama-3'] = ta.KAMA(dataframe, timeperiod=3) 73 | dataframe['kama-21'] = ta.KAMA(dataframe, timeperiod=21) 74 | 75 | macd = ta.MACD(dataframe) 76 | dataframe['macd'] = macd['macd'] 77 | dataframe['macdsignal'] = macd['macdsignal'] 78 | dataframe['macdhist'] = macd['macdhist'] 79 | 80 | dataframe['volume_ma'] = dataframe['volume'].rolling(window=24).mean() 81 | 82 | 83 | return dataframe 84 | 85 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 86 | params = self.buy_params 87 | conditions = [] 88 | 89 | active_trade = False 90 | if self.config['runmode'].value in ('live', 'dry_run'): 91 | active_trade = Trade.get_trades([Trade.pair == metadata['pair'], Trade.is_open.is_(True),]).all() 92 | 93 | if not active_trade: 94 | conditions.append(dataframe['kama-3'] > dataframe['kama-21']) 95 | conditions.append(dataframe['macd'] > dataframe['macdsignal']) 96 | conditions.append(dataframe['macd'] > params['macd']) 97 | conditions.append(dataframe['macdhist'] > params['macdhist']) 98 | conditions.append(dataframe['rmi'] > dataframe['rmi'].shift()) 99 | conditions.append(dataframe['rmi'] > params['rmi']) 100 | conditions.append(dataframe['volume'] < (dataframe['volume_ma'] * 20)) 101 | else: 102 | conditions.append(dataframe['close'] > dataframe['sar']) 103 | conditions.append(dataframe['rmi'] >= 75) 104 | 105 | conditions.append(dataframe['volume'] > 0) 106 | 107 | if conditions: 108 | dataframe.loc[ 109 | reduce(lambda x, y: x & y, conditions), 110 | 'buy'] = 1 111 | 112 | return dataframe 113 | 114 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 115 | params = self.sell_params 116 | conditions = [] 117 | 118 | active_trade = False 119 | if self.config['runmode'].value in ('live', 'dry_run'): 120 | active_trade = Trade.get_trades([Trade.pair == metadata['pair'], Trade.is_open.is_(True),]).all() 121 | 122 | if active_trade: 123 | ob = self.dp.orderbook(metadata['pair'], 1) 124 | current_price = ob['asks'][0][0] 125 | current_profit = active_trade[0].calc_profit_ratio(rate=current_price) 126 | 127 | conditions.append( 128 | (dataframe['rmi'] < 30) & 129 | (current_profit > -0.03) & 130 | (dataframe['volume'].gt(0)) 131 | ) 132 | 133 | if conditions: 134 | dataframe.loc[ 135 | reduce(lambda x, y: x & y, conditions), 136 | 'sell'] = 1 137 | else: 138 | dataframe['sell'] = 0 139 | 140 | return dataframe 141 | 142 | def check_buy_timeout(self, pair: str, trade: Trade, order: dict, **kwargs) -> bool: 143 | ob = self.dp.orderbook(pair, 1) 144 | current_price = ob['bids'][0][0] 145 | # Cancel buy order if price is more than 1% above the order. 146 | if current_price > order['price'] * 1.01: 147 | return True 148 | return False 149 | 150 | def check_sell_timeout(self, pair: str, trade: Trade, order: dict, **kwargs) -> bool: 151 | ob = self.dp.orderbook(pair, 1) 152 | current_price = ob['asks'][0][0] 153 | # Cancel sell order if price is more than 1% below the order. 154 | if current_price < order['price'] * 0.99: 155 | return True 156 | return False 157 | 158 | def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str, **kwargs) -> bool: 159 | ob = self.dp.orderbook(pair, 1) 160 | current_price = ob['asks'][0][0] 161 | # Cancel buy order if price is more than 1% above the order. 162 | if current_price > rate * 1.01: 163 | return False 164 | return True 165 | 166 | """ 167 | def min_roi_reached(self, trade: Trade, current_profit: float, current_time: datetime) -> bool: 168 | _, roi = self.min_roi_reached_entry(0) 169 | 170 | if roi is None: 171 | if Trade.max_rate >= Trade.rate * 0.8 and Trade.rate > Trade.open_rate: 172 | return False 173 | if Trade.max_rate < Trade.rate * 0.8 and Trade.rate < Trade.open_rate: 174 | return False 175 | if Trade.max_rate < Trade.rate * 0.8 and Trade.rate > Trade.open_rate: 176 | return current_profit > roi 177 | return False 178 | """ -------------------------------------------------------------------------------- /strategies/archived/Hacklemore2.py: -------------------------------------------------------------------------------- 1 | import freqtrade.vendor.qtpylib.indicators as qtpylib 2 | import numpy as np 3 | import talib.abstract as ta 4 | from freqtrade.strategy.interface import IStrategy 5 | from freqtrade.strategy import merge_informative_pair 6 | from pandas import DataFrame, Series 7 | from functools import reduce 8 | from datetime import datetime 9 | from freqtrade.persistence import Trade 10 | from technical.indicators import RMI 11 | 12 | class Hacklemore2(IStrategy): 13 | 14 | """ 15 | PASTE OUTPUT FROM HYPEROPT HERE 16 | """ 17 | # ROI table: 18 | minimal_roi = { 19 | "0": 0.14509, 20 | "9": 0.07666, 21 | "23": 0.0378, 22 | "36": 0.01987, 23 | "60": 0.0128, 24 | "145": 0.00467, 25 | "285": 0 26 | } 27 | 28 | # Stoploss: 29 | stoploss = -0.99 30 | 31 | trailing_stop = True 32 | trailing_stop_positive = 0.02 33 | trailing_stop_positive_offset = 0.03 34 | trailing_only_offset_is_reached = True 35 | 36 | """ 37 | END HYPEROPT 38 | """ 39 | 40 | timeframe = '15m' 41 | 42 | use_sell_signal = True 43 | sell_profit_only = False 44 | #sell_profit_offset = 0.01 45 | ignore_roi_if_buy_signal = True 46 | 47 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 48 | dataframe['volume_mean_slow'] = dataframe['volume'].rolling(window=24).mean() 49 | 50 | dataframe['RMI'] = RMI(dataframe) 51 | dataframe['sar'] = ta.SAR(dataframe) 52 | 53 | dataframe['max'] = dataframe['high'].rolling(60).max() 54 | 55 | dataframe['min'] = dataframe['low'].rolling(60).min() 56 | 57 | dataframe['upper'] = np.where(dataframe['max'] > dataframe['max'].shift(),1,0) 58 | 59 | dataframe['lower'] = np.where(dataframe['min'] < dataframe['min'].shift(),1,0) 60 | 61 | dataframe['up_trend'] = np.where(dataframe['upper'].rolling(10, min_periods=1).sum() != 0,1,0) 62 | 63 | dataframe['dn_trend'] = np.where(dataframe['lower'].rolling(10, min_periods=1).sum() != 0,1,0) 64 | 65 | return dataframe 66 | 67 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 68 | active_trade = False 69 | 70 | if self.config['runmode'].value in ('live', 'dry_run'): 71 | active_trade = Trade.get_trades([Trade.pair == metadata['pair'], Trade.is_open.is_(True),]).all() 72 | 73 | conditions = [] 74 | 75 | if not active_trade: 76 | conditions.append( 77 | ( (dataframe['up_trend'] == True) & 78 | (dataframe['RMI'] > 55) & 79 | (dataframe['RMI'] >= dataframe['RMI'].rolling(3).mean()) & 80 | (dataframe['close'] > dataframe['close'].shift()) & 81 | (dataframe['close'].shift() > dataframe['close'].shift(2)) & 82 | (dataframe['sar'] < dataframe['close']) & 83 | (dataframe['sar'].shift() < dataframe['close'].shift()) & 84 | (dataframe['sar'].shift(2) < dataframe['close'].shift(2)) & 85 | (dataframe['volume'] < (dataframe['volume_mean_slow'].shift(1) * 30)) 86 | )) 87 | 88 | else: 89 | conditions.append(dataframe['RMI'] >= 75) 90 | 91 | conditions.append(dataframe['volume'].gt(0)) 92 | 93 | if conditions: 94 | dataframe.loc[ 95 | reduce(lambda x, y: x & y, conditions), 96 | 'buy'] = 1 97 | 98 | return dataframe 99 | 100 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 101 | active_trade = False 102 | 103 | if self.config['runmode'].value in ('live', 'dry_run'): 104 | active_trade = Trade.get_trades([Trade.pair == metadata['pair'], Trade.is_open.is_(True),]).all() 105 | 106 | conditions = [] 107 | 108 | if active_trade: 109 | ob = self.dp.orderbook(metadata['pair'], 1) 110 | current_price = ob['asks'][0][0] 111 | # current_profit = Trade.calc_profit_ratio(active_trade[0], rate=current_price) 112 | current_profit = active_trade[0].calc_profit_ratio(rate=current_price) 113 | 114 | conditions.append( 115 | (dataframe['buy'] == 0) & 116 | (dataframe['dn_trend'] == True) & 117 | (dataframe['RMI'] < 30) & 118 | (current_profit > -0.03) & 119 | (dataframe['volume'].gt(0)) 120 | ) 121 | 122 | if conditions: 123 | dataframe.loc[ 124 | reduce(lambda x, y: x & y, conditions), 125 | 'sell'] = 1 126 | else: 127 | dataframe['sell'] = 0 128 | 129 | return dataframe 130 | 131 | def check_buy_timeout(self, pair: str, trade: Trade, order: dict, **kwargs) -> bool: 132 | ob = self.dp.orderbook(pair, 1) 133 | current_price = ob['bids'][0][0] 134 | # Cancel buy order if price is more than 1% above the order. 135 | if current_price > order['price'] * 1.01: 136 | return True 137 | return False 138 | 139 | def check_sell_timeout(self, pair: str, trade: Trade, order: dict, **kwargs) -> bool: 140 | ob = self.dp.orderbook(pair, 1) 141 | current_price = ob['asks'][0][0] 142 | # Cancel sell order if price is more than 1% below the order. 143 | if current_price < order['price'] * 0.99: 144 | return True 145 | return False 146 | 147 | def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str, **kwargs) -> bool: 148 | ob = self.dp.orderbook(pair, 1) 149 | current_price = ob['asks'][0][0] 150 | # Cancel buy order if price is more than 1% above the order. 151 | if current_price > rate * 1.01: 152 | return False 153 | return True 154 | 155 | """ 156 | def min_roi_reached(self, trade: Trade, current_profit: float, current_time: datetime) -> bool: 157 | _, roi = self.min_roi_reached_entry(0) 158 | 159 | if roi is None: 160 | if Trade.max_rate >= Trade.rate * 0.8 and Trade.rate > Trade.open_rate: 161 | return False 162 | if Trade.max_rate < Trade.rate * 0.8 and Trade.rate < Trade.open_rate: 163 | return False 164 | if Trade.max_rate < Trade.rate * 0.8 and Trade.rate > Trade.open_rate: 165 | return current_profit > roi 166 | return False 167 | """ -------------------------------------------------------------------------------- /strategies/archived/Ichis.py: -------------------------------------------------------------------------------- 1 | # --- Do not remove these libs --- 2 | from freqtrade.strategy.interface import IStrategy 3 | from pandas import DataFrame 4 | import talib.abstract as ta 5 | import freqtrade.vendor.qtpylib.indicators as qtpylib 6 | 7 | 8 | # -------------------------------- 9 | import pandas as pd # noqa 10 | pd.options.mode.chained_assignment = None # default='warn' 11 | 12 | import technical.indicators as ftt 13 | #from technical.util import resample_to_interval, resampled_merge 14 | 15 | from functools import reduce 16 | from datetime import datetime, timedelta 17 | from freqtrade.strategy import merge_informative_pair 18 | 19 | import numpy as np 20 | 21 | 22 | class ichi(IStrategy): 23 | 24 | # Optimal timeframe for the strategy 25 | timeframe = '1h' 26 | 27 | #startup_candle_count = 120 28 | process_only_new_candles = False 29 | 30 | # no ROI 31 | minimal_roi = { 32 | "0": 0.05, 33 | "30": 0.04, 34 | "60": 0.03, 35 | "90": 0.025 36 | 37 | } 38 | 39 | # Stoploss: 40 | stoploss = -0.01 41 | trailing_stop = True 42 | trailing_stop_positive = 0.002 43 | trailing_stop_positive_offset = 0.025 44 | trailing_only_offset_is_reached = True 45 | 46 | use_sell_signal = True 47 | sell_profit_only = False 48 | ignore_roi_if_buy_signal = True 49 | 50 | 51 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 52 | 53 | displacement = 30 54 | ichimoku = ftt.ichimoku(dataframe, 55 | conversion_line_period=20, 56 | base_line_periods=60, 57 | laggin_span=120, 58 | displacement=displacement 59 | ) 60 | 61 | #dataframe['chikou_span'] = ichimoku['chikou_span'] 62 | 63 | # cross indicators 64 | dataframe['tenkan_sen'] = ichimoku['tenkan_sen'] 65 | dataframe['kijun_sen'] = ichimoku['kijun_sen'] 66 | 67 | # cloud, green a > b, red a < b 68 | #dataframe['senkou_a'] = ichimoku['senkou_span_a'] 69 | #dataframe['senkou_b'] = ichimoku['senkou_span_b'] 70 | dataframe['leading_senkou_span_a'] = ichimoku['leading_senkou_span_a'] 71 | dataframe['leading_senkou_span_b'] = ichimoku['leading_senkou_span_b'] 72 | #dataframe['cloud_green'] = ichimoku['cloud_green'] * 1 73 | #dataframe['cloud_red'] = ichimoku['cloud_red'] * -1 74 | 75 | # DANGER ZONE START 76 | 77 | # The cloud is normally shifted into the future visually, but it's based on present data. 78 | # So in this case it should be ok to look at the "future" (which is actually the present) 79 | # by shifting it back by displacement. 80 | #dataframe['future_green'] = ichimoku['cloud_green'].shift(-displacement).fillna(0).astype('int') * 2 81 | 82 | # The chikou_span is shifted into the past, so we need to be careful not to read the 83 | # current value. But if we shift it forward again by displacement it should be safe to use. 84 | # We're effectively "looking back" at where it normally appears on the chart. 85 | #dataframe['chikou_high'] = ( 86 | # (dataframe['chikou_span'] > dataframe['senkou_a']) & 87 | # (dataframe['chikou_span'] > dataframe['senkou_b']) 88 | # ).shift(displacement).fillna(0).astype('int') 89 | 90 | # DANGER ZONE END 91 | 92 | dataframe['go_long'] = ( 93 | (dataframe['tenkan_sen'] > dataframe['kijun_sen']) & 94 | (dataframe['close'] > dataframe['leading_senkou_span_a']) & 95 | (dataframe['close'] > dataframe['leading_senkou_span_b']) 96 | #& 97 | #(dataframe['future_green'] > 0) & 98 | #(dataframe['chikou_high'] > 0) 99 | ).astype('int') * 3 100 | 101 | def SSLChannels(dataframe, length = 7, mode='sma'): 102 | df = dataframe.copy() 103 | df['ATR'] = ta.ATR(df, timeperiod=14) 104 | df['smaHigh'] = df['high'].rolling(length).mean() + df['ATR'] 105 | df['smaLow'] = df['low'].rolling(length).mean() - df['ATR'] 106 | df['hlv'] = np.where(df['close'] > df['smaHigh'], 1, np.where(df['close'] < df['smaLow'], -1, np.NAN)) 107 | df['hlv'] = df['hlv'].ffill() 108 | df['sslDown'] = np.where(df['hlv'] < 0, df['smaHigh'], df['smaLow']) 109 | df['sslUp'] = np.where(df['hlv'] < 0, df['smaLow'], df['smaHigh']) 110 | return df['sslDown'], df['sslUp'] 111 | 112 | ssl = SSLChannels(dataframe, 10) 113 | dataframe['sslDown'] = ssl[0] 114 | dataframe['sslUp'] = ssl[1] 115 | 116 | dataframe['max'] = dataframe['high'].rolling(3).max() 117 | dataframe['min'] = dataframe['low'].rolling(6).min() 118 | dataframe['upper'] = np.where(dataframe['max'] > dataframe['max'].shift(),1,0) 119 | dataframe['lower'] = np.where(dataframe['min'] < dataframe['min'].shift(),1,0) 120 | dataframe['up_trend'] = np.where(dataframe['upper'].rolling(5, min_periods=1).sum() != 0,1,0) 121 | dataframe['dn_trend'] = np.where(dataframe['lower'].rolling(5, min_periods=1).sum() != 0,1,0) 122 | 123 | return dataframe 124 | 125 | 126 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 127 | 128 | dataframe.loc[ 129 | (qtpylib.crossed_above(dataframe['go_long'], 0)) & 130 | (dataframe['sslUp'] > dataframe['sslDown']) & 131 | (dataframe['up_trend'] == 1) 132 | , 133 | 'buy'] = 1 134 | 135 | return dataframe 136 | 137 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 138 | 139 | dataframe.loc[ 140 | (qtpylib.crossed_above(dataframe['sslDown'], dataframe['sslUp'])) & 141 | ( 142 | (qtpylib.crossed_below(dataframe['tenkan_sen'], dataframe['kijun_sen'])) 143 | | 144 | (qtpylib.crossed_below(dataframe['close'], dataframe['kijun_sen'])) 145 | ) 146 | 147 | , 148 | 'sell'] = 1 149 | 150 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/Infinite_ROI.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import talib.abstract as ta 3 | import freqtrade.vendor.qtpylib.indicators as qtpylib 4 | import arrow 5 | from freqtrade.strategy.interface import IStrategy 6 | from freqtrade.strategy import merge_informative_pair 7 | from pandas import DataFrame, Series 8 | from functools import reduce 9 | from datetime import datetime 10 | from freqtrade.persistence import Trade 11 | from technical.indicators import RMI 12 | from statistics import mean 13 | from cachetools import TTLCache 14 | from scipy.optimize import curve_fit 15 | 16 | 17 | class Schism(IStrategy): 18 | """ 19 | Strategy Configuration Items 20 | """ 21 | timeframe = '5m' 22 | inf_timeframe = '1h' 23 | 24 | minimal_roi = { 25 | "0": 0.05, 26 | "10": 0.025, 27 | "20": 0.015, 28 | "30": 0.01, 29 | "720": 0.005, 30 | "1440": 0 31 | } 32 | 33 | dynamic_roi = { 34 | 'enabled': True, 35 | 'type': 'exponential', # linear, exponential, or connect 36 | 'decay-rate': 0.015, # bigger is faster, recommended to graph f(t) = start-pct * e(-rate*t) 37 | 'decay-time': 1440, # amount of time to reach zero, only relevant for linear decay 38 | 'start': 0.10, # starting percentage 39 | 'end': 0, # ending percentage 40 | } 41 | 42 | """ 43 | Informative Pair Definitions 44 | """ 45 | def informative_pairs(self): 46 | 47 | return informative_pairs 48 | 49 | """ 50 | Indicator Definitions 51 | """ 52 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 53 | 54 | return dataframe 55 | 56 | """ 57 | Buy Trigger Signals 58 | """ 59 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 60 | 61 | return dataframe 62 | 63 | """ 64 | Sell Trigger Signals 65 | """ 66 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 67 | 68 | return dataframe 69 | 70 | 71 | """ 72 | Override for default Freqtrade ROI table functionality 73 | """ 74 | def min_roi_reached_entry(self, trade_dur: int) -> Tuple[Optional[int], Optional[float]]: 75 | dynamic_roi = self.dynamic_roi 76 | 77 | # if the dynamic_roi dict is defined and enabled, do it, otherwise fallback to default functionality 78 | if dynamic_roi and dynamic_roi['enabled']: 79 | # linear decay: f(t) = start - (rate * t) 80 | if dynamic_roi['type'] == 'linear': 81 | rate = (dynamic_roi['start'] - dynamic_roi['end']) / dynamic_roi['decay-time'] 82 | min_roi = max(dynamic_roi['end'], dynamic_roi['start'] - (rate * trade_dur)) 83 | # exponential decay: f(t) = start * e^(-rate*t) 84 | elif dynamic_roi['type'] == 'exponential': 85 | min_roi = max(dynamic_roi['end'], dynamic_roi['start'] * np.exp(-dynamic_roi['decay-rate']*trade_dur)) 86 | elif dynamic_roi['type'] == 'connect': 87 | # connect the points in the defined table with lines 88 | past_roi = list(filter(lambda x: x <= trade_dur, self.minimal_roi.keys())) 89 | next_roi = list(filter(lambda x: x > trade_dur, self.minimal_roi.keys())) 90 | if not past_roi: 91 | return None, None 92 | current_entry = max(past_roi) 93 | # next entry 94 | if not next_roi: 95 | return current_entry, self.minimal_roi[current_entry] 96 | # use the slope-intercept formula between the two points in the roi table we are between 97 | else: 98 | next_entry = min(next_roi) 99 | # y = mx + b 100 | x1 = current_entry 101 | x2 = next_entry 102 | y1 = self.minimal_roi[current_entry] 103 | y2 = self.minimal_roi[next_entry] 104 | m = (y1-y2)/(x1-x2) 105 | b = (x1*y2 - x2*y1)/(x1-x2) 106 | min_roi = (m * trade_dur) + b 107 | else: 108 | min_roi = 0 109 | 110 | return trade_dur, min_roi 111 | 112 | else: 113 | # Get highest entry in ROI dict where key <= trade-duration 114 | roi_list = list(filter(lambda x: x <= trade_dur, self.minimal_roi.keys())) 115 | if not roi_list: 116 | return None, None 117 | roi_entry = max(roi_list) 118 | return roi_entry, self.minimal_roi[roi_entry] 119 | -------------------------------------------------------------------------------- /strategies/archived/Kamaflage.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | import freqtrade.vendor.qtpylib.indicators as qtpylib 3 | import numpy as np 4 | import talib.abstract as ta 5 | from freqtrade.strategy.interface import IStrategy 6 | from freqtrade.strategy import merge_informative_pair 7 | from pandas import DataFrame, Series 8 | from functools import reduce 9 | from datetime import datetime 10 | from freqtrade.persistence import Trade 11 | from technical.indicators import RMI, VIDYA 12 | 13 | 14 | class Kamaflage(IStrategy): 15 | 16 | """ 17 | PASTE OUTPUT FROM HYPEROPT HERE 18 | """ 19 | 20 | buy_params = { 21 | 'macd': 0, 22 | 'macdhist': 0, 23 | 'rmi': 50 24 | } 25 | 26 | sell_params = { 27 | 28 | } 29 | 30 | minimal_roi = { 31 | "0": 0.15, 32 | "10": 0.10, 33 | "20": 0.05, 34 | "30": 0.025, 35 | "60": 0.01 36 | } 37 | 38 | # Stoploss: 39 | stoploss = -1 40 | 41 | # Trailing stop: 42 | trailing_stop = True 43 | trailing_stop_positive = 0.01125 44 | trailing_stop_positive_offset = 0.04673 45 | trailing_only_offset_is_reached = True 46 | 47 | """ 48 | END HYPEROPT 49 | """ 50 | 51 | timeframe = '5m' 52 | 53 | use_sell_signal = True 54 | sell_profit_only = False 55 | # sell_profit_offset = 0.01 56 | ignore_roi_if_buy_signal = True 57 | 58 | process_only_new_candles = False 59 | 60 | startup_candle_count: int = 20 61 | 62 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 63 | 64 | dataframe['sar'] = ta.SAR(dataframe) 65 | dataframe['rmi'] = RMI(dataframe) 66 | dataframe['kama-3'] = ta.KAMA(dataframe, timeperiod=3) 67 | dataframe['kama-21'] = ta.KAMA(dataframe, timeperiod=21) 68 | 69 | macd = ta.MACD(dataframe) 70 | dataframe['macd'] = macd['macd'] 71 | dataframe['macdsignal'] = macd['macdsignal'] 72 | dataframe['macdhist'] = macd['macdhist'] 73 | 74 | dataframe['volume_ma'] = dataframe['volume'].rolling(window=24).mean() 75 | 76 | 77 | return dataframe 78 | 79 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 80 | params = self.buy_params 81 | conditions = [] 82 | 83 | active_trade = False 84 | if self.config['runmode'].value in ('live', 'dry_run'): 85 | active_trade = Trade.get_trades([Trade.pair == metadata['pair'], Trade.is_open.is_(True),]).all() 86 | 87 | if not active_trade: 88 | conditions.append(dataframe['kama-3'] > dataframe['kama-21']) 89 | conditions.append(dataframe['macd'] > dataframe['macdsignal']) 90 | conditions.append(dataframe['macd'] > params['macd']) 91 | conditions.append(dataframe['macdhist'] > params['macdhist']) 92 | conditions.append(dataframe['rmi'] > dataframe['rmi'].shift()) 93 | conditions.append(dataframe['rmi'] > params['rmi']) 94 | conditions.append(dataframe['volume'] < (dataframe['volume_ma'] * 20)) 95 | else: 96 | conditions.append(dataframe['close'] > dataframe['sar']) 97 | conditions.append(dataframe['rmi'] >= 75) 98 | 99 | conditions.append(dataframe['volume'] > 0) 100 | 101 | if conditions: 102 | dataframe.loc[ 103 | reduce(lambda x, y: x & y, conditions), 104 | 'buy'] = 1 105 | 106 | return dataframe 107 | 108 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 109 | params = self.sell_params 110 | conditions = [] 111 | 112 | active_trade = False 113 | if self.config['runmode'].value in ('live', 'dry_run'): 114 | active_trade = Trade.get_trades([Trade.pair == metadata['pair'], Trade.is_open.is_(True),]).all() 115 | 116 | if active_trade: 117 | ob = self.dp.orderbook(metadata['pair'], 1) 118 | current_price = ob['asks'][0][0] 119 | current_profit = active_trade[0].calc_profit_ratio(rate=current_price) 120 | 121 | conditions.append( 122 | (dataframe['buy'] == 0) & 123 | (dataframe['rmi'] < 30) & 124 | (current_profit > -0.03) & 125 | (dataframe['volume'].gt(0)) 126 | ) 127 | 128 | if conditions: 129 | dataframe.loc[ 130 | reduce(lambda x, y: x & y, conditions), 131 | 'sell'] = 1 132 | else: 133 | dataframe['sell'] = 0 134 | 135 | return dataframe 136 | 137 | def check_buy_timeout(self, pair: str, trade: Trade, order: dict, **kwargs) -> bool: 138 | ob = self.dp.orderbook(pair, 1) 139 | current_price = ob['bids'][0][0] 140 | # Cancel buy order if price is more than 1% above the order. 141 | if current_price > order['price'] * 1.01: 142 | return True 143 | return False 144 | 145 | def check_sell_timeout(self, pair: str, trade: Trade, order: dict, **kwargs) -> bool: 146 | ob = self.dp.orderbook(pair, 1) 147 | current_price = ob['asks'][0][0] 148 | # Cancel sell order if price is more than 1% below the order. 149 | if current_price < order['price'] * 0.99: 150 | return True 151 | return False 152 | 153 | def confirm_trade_entry(self, pair: str, order_type: str, amount: float, rate: float, time_in_force: str, **kwargs) -> bool: 154 | ob = self.dp.orderbook(pair, 1) 155 | current_price = ob['asks'][0][0] 156 | # Cancel buy order if price is more than 1% above the order. 157 | if current_price > rate * 1.01: 158 | return False 159 | return True 160 | 161 | """ 162 | def min_roi_reached(self, trade: Trade, current_profit: float, current_time: datetime) -> bool: 163 | _, roi = self.min_roi_reached_entry(0) 164 | 165 | if roi is None: 166 | if Trade.max_rate >= Trade.rate * 0.8 and Trade.rate > Trade.open_rate: 167 | return False 168 | if Trade.max_rate < Trade.rate * 0.8 and Trade.rate < Trade.open_rate: 169 | return False 170 | if Trade.max_rate < Trade.rate * 0.8 and Trade.rate > Trade.open_rate: 171 | return current_profit > roi 172 | return False 173 | """ -------------------------------------------------------------------------------- /strategies/archived/Pmax.py: -------------------------------------------------------------------------------- 1 | import numpy as np # noqa 2 | import pandas as pd # noqa 3 | from pandas import DataFrame 4 | from technical.indicators import PMAX, zema 5 | from typing import Dict, List 6 | from functools import reduce 7 | from freqtrade.strategy.interface import IStrategy 8 | 9 | # -------------------------------- 10 | # Add your lib to import here 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | 15 | class Pmax(IStrategy): 16 | stoploss = -1 17 | timeframe = '5m' 18 | 19 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 20 | atrperiod = 10 21 | multiplier = 3 22 | matype = 9 23 | malength = 10 24 | source = 2 25 | 26 | dataframe['ZLEMA'] = zema(dataframe, period=malength) 27 | dataframe = PMAX(dataframe, atrperiod=atrperiod, multiplier=multiplier, malength=malength, matype=matype, source=source) 28 | # print(dataframe.keys) 29 | return dataframe 30 | 31 | 32 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 33 | dataframe.loc[ 34 | ( 35 | (qtpylib.crossed_above(dataframe['ZLEMA'], dataframe['pm_40_3_40_9'])) 36 | ), 37 | 'buy'] = 1 38 | 39 | return dataframe 40 | 41 | 42 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 43 | dataframe.loc[ 44 | ( 45 | (qtpylib.crossed_below(dataframe['ZLEMA'], dataframe['pm_40_3_40_9'])) 46 | ), 47 | 'sell'] = 1 48 | 49 | return dataframe 50 | -------------------------------------------------------------------------------- /strategies/archived/Renko.py: -------------------------------------------------------------------------------- 1 | import talib.abstract as ta 2 | from pandas import DataFrame, Series, DatetimeIndex, merge 3 | import pandas as pd 4 | import numpy as np 5 | #import pdb 6 | import freqtrade.vendor.qtpylib.indicators as qtpylib 7 | from freqtrade.strategy.interface import IStrategy 8 | pd.set_option("display.precision", 10) 9 | 10 | class Renko(IStrategy): 11 | 12 | minimal_roi = { 13 | "0": 100 14 | } 15 | 16 | stoploss = -100 17 | 18 | timeframe = '15m' 19 | 20 | use_sell_signal = True 21 | sell_profit_only = True 22 | sell_profit_offset = 0.1 23 | ignore_roi_if_buy_signal = True 24 | 25 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 26 | 27 | dataframe['ATR'] = ta.ATR(dataframe, timeperiod=5) 28 | brick_size = np.mean(dataframe['ATR']) 29 | columns = ['date', 'open', 'high', 'low', 'close', 'volume', 'ATR'] 30 | df = dataframe[columns] 31 | cdf = pd.DataFrame( 32 | columns=columns, 33 | data=[], 34 | ) 35 | cdf.loc[0] = df.loc[0] 36 | close = df.loc[0]['close'] 37 | volume = df.loc[0]['volume'] 38 | cdf.iloc[0, 1:] = [close - brick_size, close, close - brick_size, close, volume, brick_size] 39 | cdf['trend'] = True 40 | columns = ['date', 'open', 'high', 'low', 'close', 'volume', 'ATR', 'trend'] 41 | 42 | for index, row in df.iterrows(): 43 | if not np.isnan(row['ATR']): brick_size = row['ATR'] 44 | close = row['close'] 45 | date = row['date'] 46 | volume = row['volume'] 47 | row_p1 = cdf.iloc[-1] 48 | trend = row_p1['trend'] 49 | close_p1 = row_p1['close'] 50 | bricks = int(np.nan_to_num((close - close_p1) / brick_size)) 51 | data = [] 52 | if trend and bricks >= 1: 53 | for i in range(bricks): 54 | r = [date, close_p1, close_p1 + brick_size, close_p1, close_p1 + brick_size, volume, brick_size, trend] 55 | data.append(r) 56 | close_p1 += brick_size 57 | elif trend and bricks <= -2: 58 | trend = not trend 59 | bricks += 1 60 | close_p1 -= brick_size 61 | for i in range(abs(bricks)): 62 | r = [date, close_p1, close_p1, close_p1 - brick_size, close_p1 - brick_size, volume, brick_size, trend] 63 | data.append(r) 64 | close_p1 -= brick_size 65 | elif not trend and bricks <= -1: 66 | for i in range(abs(bricks)): 67 | r = [date, close_p1, close_p1, close_p1 - brick_size, close_p1 - brick_size, volume, brick_size, trend] 68 | data.append(r) 69 | close_p1 -= brick_size 70 | elif not trend and bricks >= 2: 71 | trend = not trend 72 | bricks -= 1 73 | close_p1 += brick_size 74 | for i in range(abs(bricks)): 75 | r = [date, close_p1, close_p1 + brick_size, close_p1, close_p1 + brick_size, volume, brick_size, trend] 76 | data.append(r) 77 | close_p1 += brick_size 78 | else: 79 | continue 80 | 81 | sdf = pd.DataFrame(data=data, columns=columns) 82 | cdf = pd.concat([cdf, sdf]) 83 | 84 | renko_df = cdf.groupby(['date']).last() 85 | renko_df = renko_df.reset_index() 86 | renko_df['previous-trend'] = renko_df.trend.shift(1) 87 | renko_df['previous-trend2'] = renko_df.trend.shift(2) 88 | 89 | return renko_df 90 | 91 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 92 | for index, row in dataframe.iterrows(): 93 | if row['previous-trend'] == False and row['trend'] == True: 94 | last_row = dataframe.loc[dataframe['date'] == row['date']][-1:] 95 | dataframe.loc[dataframe.index== last_row.index.values[0], 'buy'] = 1 96 | if row['previous-trend'] == True and row['trend'] == True: 97 | last_row = dataframe.loc[dataframe['date'] == row['date']][-1:] 98 | dataframe.loc[dataframe.index== last_row.index.values[0], 'buy'] = 1 99 | else: 100 | last_row = dataframe.loc[dataframe['date'] == row['date']][-1:] 101 | dataframe.loc[dataframe.index== last_row.index.values[0], 'sell'] = 1 102 | 103 | return dataframe 104 | 105 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 106 | 107 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/RenkoYolo.py: -------------------------------------------------------------------------------- 1 | import freqtrade.vendor.qtpylib.indicators as qtpylib 2 | import numpy as np 3 | import talib.abstract as ta 4 | from freqtrade.strategy.interface import IStrategy 5 | from pandas import DataFrame, DatetimeIndex, merge, Series 6 | 7 | 8 | class RenkoYolo(IStrategy): 9 | 10 | # Buy hyperspace params: 11 | buy_params = { 12 | 13 | } 14 | 15 | # Sell hyperspace params: 16 | sell_params = { 17 | 18 | } 19 | 20 | # ROI table: 21 | minimal_roi = { 22 | "0": 0.03, 23 | "7": 0.02, 24 | "33": 0.01, 25 | "71": 0.005 26 | } 27 | 28 | # Stoploss: 29 | stoploss = -100 30 | 31 | # Trailing stop: 32 | trailing_stop = False 33 | 34 | timeframe = '15m' 35 | 36 | use_sell_signal = True 37 | sell_profit_only = True 38 | ignore_roi_if_buy_signal = True 39 | 40 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 41 | 42 | dataframe['adx'] = ta.ADX(dataframe, timeperiod=90) #90 43 | aroon = ta.AROON(dataframe, timeperiod=60) #60 44 | 45 | dataframe['aroon-down'] = aroon['aroondown'] 46 | dataframe['aroon-up'] = aroon['aroonup'] 47 | 48 | return dataframe 49 | 50 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 51 | params = self.buy_params 52 | 53 | dataframe.loc[ 54 | ( 55 | (dataframe['adx'] > params['adx']) & 56 | (dataframe['aroon-up'] > params['aroon-up']) & 57 | (dataframe['aroon-down'] < params['aroon-down']) & 58 | (dataframe['volume'] > 0) 59 | ), 60 | 'buy' 61 | ] = 1 62 | 63 | return dataframe 64 | 65 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 66 | """ 67 | no sell signal 68 | """ 69 | dataframe['sell'] = 0 70 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/Slowbro.py: -------------------------------------------------------------------------------- 1 | # --- Do not remove these libs --- 2 | from freqtrade.strategy import IStrategy, merge_informative_pair 3 | from pandas import DataFrame 4 | import freqtrade.vendor.qtpylib.indicators as qtpylib 5 | # -------------------------------- 6 | 7 | """ 8 | ,-'"-. 9 | __...| .". | 10 | ,--+" ' | ,' 11 | | .' ..--, `-' `. 12 | |/ | ,' | : 13 | |\...-+-".._| | 14 | ," `--. `. _..-'+"/__ 15 | / . | :,-"' `" |_' 16 | ..| . _,....___,' | ,' /\ 17 | ..\'.__.-' /V | ' ,'"" 18 | `. | `: \. | . ,' ,.-. 19 | `: | | ' .^. ,' ,"`. 20 | `. | | / _.\.---..' / | ,-,. 21 | `._ A / j ." / / | .',' | 22 | `. `...-' ,' / /._ / | ,' / | 23 | |"-----' ,' / /-.__ |' / | 24 | | _.--'"'""`. . / / `"^-., | 25 | |" ____\ j j `"--.| 26 | | _.-""' \ | | j 27 | _,+."_ \ | | | 28 | ' . `. _.-"'. , | ' 29 | |_ | `.`. ,' `. | | . 30 | | `-. | ,'.\ .\ \ | / 31 | |\ ;+-' "\ ,' `. \ | / 32 | '\\." \ _.-' ,`. \ ' / 33 | \\\ : .' `.`._ \ / `-..-. 34 | ``. | _." _...,:.._`. `._ ,' -. \' 35 | `.`. |`".'__.' `,...__"--`/ | / | 36 | `.`. _' \| ,' ,'_ `..' |..__,. 37 | `._`--".' \`._ _,-' ,' `-' / | . ,' 38 | `""' `. `"'""' ,-" _,-' _ .' ' `' `. 39 | `-.._____: |" _," ." ,'__,.."' 40 | `.|-...,.<' `,_""'`./ 41 | `.' `"--'" mh 42 | SLOWBRO v100 43 | 44 | """ 45 | 46 | 47 | class Slowbro(IStrategy): 48 | 49 | minimal_roi = { 50 | "0": 0.10, 51 | "1440": 0.20, 52 | "2880": 0.30, 53 | "10080": 1.0 54 | } 55 | 56 | # Stoploss: 57 | stoploss = -0.99 58 | 59 | timeframe = '1h' 60 | inf_timeframe = '1d' 61 | 62 | use_sell_signal = True 63 | sell_profit_only = True 64 | ignore_roi_if_buy_signal = False 65 | 66 | startup_candle_count: int = 30 67 | process_only_new_candles = False 68 | 69 | def informative_pairs(self): 70 | # add all whitelisted pairs on informative timeframe 71 | pairs = self.dp.current_whitelist() 72 | informative_pairs = [(pair, self.inf_timeframe) for pair in pairs] 73 | 74 | return informative_pairs 75 | 76 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 77 | 78 | informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe=self.inf_timeframe) 79 | informative['30d-low'] = informative['close'].rolling(30).min() 80 | informative['30d-high'] = informative['close'].rolling(30).max() 81 | 82 | dataframe = merge_informative_pair(dataframe, informative, self.timeframe, self.inf_timeframe, ffill=True) 83 | 84 | return dataframe 85 | 86 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 87 | dataframe.loc[ 88 | ( 89 | qtpylib.crossed_above(dataframe['close'],dataframe[f"30d-low_{self.inf_timeframe}"]) 90 | ), 91 | 'buy'] = 1 92 | 93 | return dataframe 94 | 95 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 96 | dataframe.loc[ 97 | ( 98 | qtpylib.crossed_above(dataframe['close'],dataframe[f"30d-high_{self.inf_timeframe}"]) 99 | ), 100 | 'sell'] = 1 101 | 102 | return dataframe 103 | -------------------------------------------------------------------------------- /strategies/archived/StochRSITEMA.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | import numpy as np # noqa 6 | import pandas as pd # noqa 7 | from pandas import DataFrame 8 | 9 | from freqtrade.strategy import IStrategy 10 | 11 | # -------------------------------- 12 | # Add your lib to import here 13 | import talib.abstract as ta 14 | import freqtrade.vendor.qtpylib.indicators as qtpylib 15 | 16 | 17 | class StochRSITEMA(IStrategy): 18 | """ 19 | author@: werkkrew 20 | github@: https://github.com/werkkrew/freqtrade-strategies 21 | 22 | Reference: Strategy #1 @ https://tradingsim.com/blog/5-minute-bar/ 23 | 24 | Trade entry signals are generated when the stochastic oscillator and relative strength index provide confirming signals. 25 | 26 | Buy: 27 | - Stoch slowd and slowk below lower band and cross above 28 | - Stoch slowk above slowd 29 | - RSI below lower band and crosses above 30 | 31 | You should exit the trade once the price closes beyond the TEMA in the opposite direction of the primary trend. 32 | There are many cases when candles are move partially beyond the TEMA line. We disregard such exit points and we exit the market when the price fully breaks the TEMA. 33 | 34 | Sell: 35 | - Candle closes below TEMA line (or open+close or average of open/close) 36 | - ROI, Stoploss, Trailing Stop 37 | """ 38 | 39 | # Strategy interface version - allow new iterations of the strategy interface. 40 | # Check the documentation or the Sample strategy to get the latest version. 41 | INTERFACE_VERSION = 2 42 | 43 | """ 44 | PASTE OUTPUT FROM HYPEROPT HERE 45 | """ 46 | 47 | # 47/50: 19 trades. 7/6/6 Wins/Draws/Losses. Avg profit -0.35%. Median profit 0.00%. Total profit -0.00006706 BTC ( -6.69Σ%). Avg duration 80.3 min. Objective: 1.98291 48 | 49 | # Buy hyperspace params: 50 | buy_params = { 51 | 'rsi-lower-band': 36, 'rsi-period': 15, 'stoch-lower-band': 48 52 | } 53 | 54 | # Sell hyperspace params: 55 | sell_params = { 56 | 'tema-period': 5, 'tema-trigger': 'close' 57 | } 58 | 59 | # ROI table: 60 | minimal_roi = { 61 | "0": 0.19503, 62 | "13": 0.09149, 63 | "36": 0.02891, 64 | "64": 0 65 | } 66 | 67 | # Stoploss: 68 | stoploss = -0.02205 69 | 70 | # Trailing stop: 71 | trailing_stop = True 72 | trailing_stop_positive = 0.17251 73 | trailing_stop_positive_offset = 0.2516 74 | trailing_only_offset_is_reached = False 75 | 76 | 77 | """ 78 | END HYPEROPT 79 | """ 80 | 81 | # Ranges for dynamic indicator periods 82 | rsiStart = 5 83 | rsiEnd = 30 84 | temaStart = 5 85 | temaEnd = 50 86 | 87 | # Stochastic Params 88 | fastkPeriod = 14 89 | slowkPeriod = 3 90 | slowdPeriod = 3 91 | 92 | # Make sure these match or are not overridden in config 93 | use_sell_signal = True 94 | sell_profit_only = True 95 | sell_profit_offset = 0.01 96 | ignore_roi_if_buy_signal = False 97 | 98 | timeframe = '5m' 99 | 100 | # Run "populate_indicators()" only for new candle. 101 | process_only_new_candles = False 102 | 103 | # Number of candles the strategy requires before producing valid signals 104 | # Set this to the highest period value in the indicator_params dict or highest of the ranges in the hyperopt settings (default: 72) 105 | startup_candle_count: int = 50 106 | 107 | """ 108 | Populate all of the indicators we need (note: indicators are separate for buy/sell) 109 | """ 110 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 111 | 112 | for rsip in range(self.rsiStart, (self.rsiEnd + 1)): 113 | dataframe[f'rsi({rsip})'] = ta.RSI(dataframe, timeperiod=rsip) 114 | 115 | for temap in range(self.temaStart, (self.temaEnd + 1)): 116 | dataframe[f'tema({temap})'] = ta.TEMA(dataframe, timeperiod=temap) 117 | 118 | # Stochastic Slow 119 | # fastk_period=5, slowk_period=3, slowk_matype=0, slowd_period=3, slowd_matype=0) 120 | stoch_slow = ta.STOCH(dataframe, fastk_period=self.fastkPeriod, 121 | slowk_period=self.slowkPeriod, slowd_period=self.slowdPeriod) 122 | dataframe['stoch-slowk'] = stoch_slow['slowk'] 123 | dataframe['stoch-slowd'] = stoch_slow['slowd'] 124 | 125 | return dataframe 126 | 127 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 128 | params = self.buy_params 129 | 130 | conditions = [] 131 | 132 | conditions.append( 133 | dataframe[f"rsi({params['rsi-period']})"] > params['rsi-lower-band']) 134 | conditions.append(qtpylib.crossed_above( 135 | dataframe['stoch-slowd'], params['stoch-lower-band'])) 136 | conditions.append(qtpylib.crossed_above( 137 | dataframe['stoch-slowk'], params['stoch-lower-band'])) 138 | conditions.append(qtpylib.crossed_above( 139 | dataframe['stoch-slowk'], dataframe['stoch-slowd'])) 140 | 141 | # Check that the candle had volume 142 | conditions.append(dataframe['volume'] > 0) 143 | 144 | if conditions: 145 | dataframe.loc[ 146 | reduce(lambda x, y: x & y, conditions), 147 | 'buy'] = 1 148 | 149 | return dataframe 150 | 151 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 152 | params = self.sell_params 153 | 154 | conditions = [] 155 | 156 | if params.get('tema-trigger') == 'close': 157 | conditions.append( 158 | dataframe['close'] < dataframe[f"tema({params['tema-period']})"]) 159 | if params.get('tema-trigger') == 'both': 160 | conditions.append((dataframe['close'] < dataframe[f"tema({params['tema-period']})"]) & ( 161 | dataframe['open'] < dataframe[f"tema({params['tema-period']})"])) 162 | if params.get('tema-trigger') == 'average': 163 | conditions.append( 164 | ((dataframe['close'] + dataframe['open']) / 2) < dataframe[f"tema({params['tema-period']})"]) 165 | 166 | # Check that the candle had volume 167 | conditions.append(dataframe['volume'] > 0) 168 | 169 | if conditions: 170 | dataframe.loc[ 171 | reduce(lambda x, y: x & y, conditions), 172 | 'sell'] = 1 173 | 174 | return dataframe 175 | -------------------------------------------------------------------------------- /strategies/archived/Supertrend.py: -------------------------------------------------------------------------------- 1 | # --- Do not remove these libs --- 2 | from freqtrade.strategy.interface import IStrategy 3 | from typing import Dict, List 4 | from functools import reduce 5 | from pandas import DataFrame 6 | # -------------------------------- 7 | 8 | import talib.abstract as ta 9 | import freqtrade.vendor.qtpylib.indicators as qtpylib 10 | import pandas as pd 11 | import numpy as np 12 | 13 | 14 | def supertrend(dataframe, multiplier=3, period=10): 15 | """ 16 | Supertrend Indicator 17 | adapted for freqtrade 18 | from: https://github.com/freqtrade/freqtrade-strategies/issues/30 19 | """ 20 | df = dataframe.copy() 21 | 22 | df['TR'] = ta.TRANGE(df) 23 | df['ATR'] = df['TR'].ewm(alpha=1 / period).mean() 24 | 25 | # atr = 'ATR_' + str(period) 26 | st = 'ST_' + str(period) + '_' + str(multiplier) 27 | stx = 'STX_' + str(period) + '_' + str(multiplier) 28 | 29 | # Compute basic upper and lower bands 30 | df['basic_ub'] = (df['high'] + df['low']) / 2 + multiplier * df['ATR'] 31 | df['basic_lb'] = (df['high'] + df['low']) / 2 - multiplier * df['ATR'] 32 | 33 | # Compute final upper and lower bands 34 | df['final_ub'] = 0.00 35 | df['final_lb'] = 0.00 36 | for i in range(period, len(df)): 37 | df['final_ub'].iat[i] = df['basic_ub'].iat[i] if df['basic_ub'].iat[i] < df['final_ub'].iat[i - 1] or df['close'].iat[i - 1] > df['final_ub'].iat[i - 1] else df['final_ub'].iat[i - 1] 38 | df['final_lb'].iat[i] = df['basic_lb'].iat[i] if df['basic_lb'].iat[i] > df['final_lb'].iat[i - 1] or df['close'].iat[i - 1] < df['final_lb'].iat[i - 1] else df['final_lb'].iat[i - 1] 39 | 40 | # Set the Supertrend value 41 | df[st] = 0.00 42 | for i in range(period, len(df)): 43 | df[st].iat[i] = df['final_ub'].iat[i] if df[st].iat[i - 1] == df['final_ub'].iat[i - 1] and df['close'].iat[i] <= df['final_ub'].iat[i] else \ 44 | df['final_lb'].iat[i] if df[st].iat[i - 1] == df['final_ub'].iat[i - 1] and df['close'].iat[i] > df['final_ub'].iat[i] else \ 45 | df['final_lb'].iat[i] if df[st].iat[i - 1] == df['final_lb'].iat[i - 1] and df['close'].iat[i] >= df['final_lb'].iat[i] else \ 46 | df['final_ub'].iat[i] if df[st].iat[i - 1] == df['final_lb'].iat[i - 1] and df['close'].iat[i] < df['final_lb'].iat[i] else 0.00 47 | 48 | # Mark the trend direction up/down 49 | df[stx] = np.where((df[st] > 0.00), np.where((df['close'] < df[st]), 'down', 'up'), np.NaN) 50 | 51 | # Remove basic and final bands from the columns 52 | df.drop(['basic_ub', 'basic_lb', 'final_ub', 'final_lb'], inplace=True, axis=1) 53 | 54 | df.fillna(0, inplace=True) 55 | 56 | # df.to_csv('user_data/Supertrend.csv') 57 | return DataFrame(index=df.index, data={ 58 | 'ST': df[st], 59 | 'STX': df[stx] 60 | }) 61 | 62 | 63 | class Supertrend(IStrategy): 64 | 65 | # Minimal ROI designed for the strategy. 66 | # This attribute will be overridden if the config file contains "minimal_roi" 67 | minimal_roi = { 68 | "0": 0.1, 69 | "2880": 0.01 70 | } 71 | 72 | # Optimal stoploss designed for the strategy 73 | # This attribute will be overridden if the config file contains "stoploss" 74 | stoploss = -0.25 75 | 76 | # Optimal timeframe for the strategy 77 | timeframe = '5m' 78 | 79 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 80 | 81 | dataframe["supertrend_3_12"] = supertrend(dataframe, 3, 12)["STX"] 82 | dataframe["supertrend_1_10"] = supertrend(dataframe, 1, 10)["STX"] 83 | dataframe["supertrend_2_11"] = supertrend(dataframe, 2, 11)["STX"] 84 | 85 | # required for graphing 86 | bollinger = qtpylib.bollinger_bands(dataframe['close'], window=20, stds=2) 87 | dataframe['bb_lowerband'] = bollinger['lower'] 88 | dataframe['bb_middleband'] = bollinger['mid'] 89 | dataframe['bb_upperband'] = bollinger['upper'] 90 | 91 | return dataframe 92 | 93 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 94 | dataframe.loc[ 95 | ( 96 | ( 97 | (dataframe["supertrend_3_12"] == "up") & 98 | (dataframe["supertrend_1_10"] == "up") & 99 | (dataframe["supertrend_2_11"] == "up") 100 | ) 101 | ), 102 | 'buy'] = 1 103 | return dataframe 104 | 105 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 106 | dataframe.loc[ 107 | ( 108 | ( 109 | (dataframe["supertrend_3_12"] == "down") & 110 | (dataframe["supertrend_1_10"] == "down") & 111 | (dataframe["supertrend_2_11"] == "down") 112 | ) 113 | ), 114 | 'sell'] = 1 115 | return dataframe 116 | -------------------------------------------------------------------------------- /strategies/archived/XtraThicc.py: -------------------------------------------------------------------------------- 1 | # --- Do not remove these libs --- 2 | from freqtrade.strategy import IStrategy, merge_informative_pair 3 | from pandas import DataFrame 4 | import freqtrade.vendor.qtpylib.indicators as qtpylib 5 | import talib.abstract as ta 6 | import numpy as np 7 | # -------------------------------- 8 | 9 | """ 10 | 乇乂ㄒ尺卂 ㄒ卄丨匚匚 11 | 12 | XtraThicc v69 13 | """ 14 | 15 | class XtraThicc(IStrategy): 16 | 17 | minimal_roi = { 18 | "0": 100 19 | } 20 | 21 | # Stoploss: 22 | stoploss = -0.10 23 | 24 | timeframe = '5m' 25 | inf_timeframe = '1h' 26 | 27 | use_sell_signal = True 28 | sell_profit_only = True 29 | ignore_roi_if_buy_signal = True 30 | 31 | trailing_stop = False 32 | trailing_stop_positive = 0.002 33 | trailing_stop_positive_offset = 0.02 34 | trailing_only_offset_is_reached = True 35 | 36 | startup_candle_count: int = 72 37 | process_only_new_candles = False 38 | 39 | def informative_pairs(self): 40 | # add all whitelisted pairs on informative timeframe 41 | pairs = self.dp.current_whitelist() 42 | informative_pairs = [(pair, self.inf_timeframe) for pair in pairs] 43 | 44 | return informative_pairs 45 | 46 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 47 | 48 | # Base Thiccness 49 | dataframe['color'] = np.where(dataframe['close'] > dataframe['open'], 'green', 'red') 50 | 51 | dataframe['how-thicc'] = (dataframe['close'] - dataframe['open']).abs() 52 | dataframe['avg-thicc'] = dataframe['how-thicc'].abs().rolling(36).mean() 53 | dataframe['not-thicc'] = dataframe['how-thicc'] < (dataframe['avg-thicc']) 54 | dataframe['rly-thicc'] = dataframe['how-thicc'] > (dataframe['avg-thicc']) 55 | dataframe['xtra-thicc'] = np.where(dataframe['rly-thicc'].rolling(8).sum() >= 5,1,0) 56 | 57 | dataframe['roc'] = ta.ROC(dataframe, timeperiod=6) 58 | 59 | informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe=self.inf_timeframe) 60 | informative['3d-low'] = informative['close'].rolling(72).min() 61 | informative['3d-high'] = informative['close'].rolling(72).max() 62 | 63 | dataframe = merge_informative_pair(dataframe, informative, self.timeframe, self.inf_timeframe, ffill=True) 64 | 65 | return dataframe 66 | 67 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 68 | dataframe.loc[ 69 | ( 70 | (dataframe['color'] == 'green') & 71 | (dataframe['color'].shift(1) == 'green') & 72 | (dataframe['color'].shift(2) == 'red') & 73 | (dataframe['color'].shift(3) == 'red') & 74 | (dataframe['xtra-thicc'] == 1) & 75 | (dataframe['rly-thicc'] == 0) & 76 | (dataframe['close'] > dataframe[f"3d-low_{self.inf_timeframe}"]) & 77 | (dataframe['close'] < dataframe[f"3d-high_{self.inf_timeframe}"]) 78 | ), 79 | 'buy'] = 1 80 | 81 | return dataframe 82 | 83 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 84 | 85 | dataframe['sell'] = 0 86 | 87 | return dataframe 88 | 89 | def custom_sell(self, pair: str, trade: 'Trade', current_time: 'datetime', current_rate: float, 90 | current_profit: float, **kwargs): 91 | 92 | dataframe, _ = self.dp.get_analyzed_dataframe(pair=pair, timeframe=self.timeframe) 93 | last_candle = dataframe.iloc[-1].squeeze() 94 | 95 | if current_profit > 0.01 and last_candle['roc'] < 0.5: 96 | return 'rode_that_ass' 97 | 98 | return None -------------------------------------------------------------------------------- /strategies/archived/YOLO.py: -------------------------------------------------------------------------------- 1 | import freqtrade.vendor.qtpylib.indicators as qtpylib 2 | import numpy as np 3 | import talib.abstract as ta 4 | from freqtrade.strategy.interface import IStrategy 5 | from pandas import DataFrame, DatetimeIndex, merge, Series 6 | 7 | 8 | class YOLO(IStrategy): 9 | 10 | # Buy hyperspace params: 11 | buy_params = { 12 | 'adx': 34, 13 | 'aroon-down': 33, 14 | 'aroon-up': 98 15 | } 16 | 17 | # Sell hyperspace params: 18 | sell_params = { 19 | 20 | } 21 | 22 | # ROI table: 23 | minimal_roi = { 24 | "0": 0.03, 25 | "7": 0.02, 26 | "33": 0.01, 27 | "71": 0.005 28 | } 29 | 30 | # Stoploss: 31 | stoploss = -0.01 32 | 33 | # Trailing stop: 34 | trailing_stop = True 35 | trailing_stop_positive = 0.03289 36 | trailing_stop_positive_offset = 0.05723 37 | trailing_only_offset_is_reached = False 38 | 39 | """ 40 | END HYPEROPT 41 | """ 42 | 43 | timeframe = '1m' 44 | 45 | use_sell_signal = False 46 | sell_profit_only = False 47 | ignore_roi_if_buy_signal = True 48 | 49 | 50 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 51 | 52 | dataframe['adx'] = ta.ADX(dataframe, timeperiod=90) #90 53 | aroon = ta.AROON(dataframe, timeperiod=60) #60 54 | 55 | dataframe['aroon-down'] = aroon['aroondown'] 56 | dataframe['aroon-up'] = aroon['aroonup'] 57 | 58 | return dataframe 59 | 60 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 61 | params = self.buy_params 62 | 63 | dataframe.loc[ 64 | ( 65 | (dataframe['adx'] > params['adx']) & 66 | (dataframe['aroon-up'] > params['aroon-up']) & 67 | (dataframe['aroon-down'] < params['aroon-down']) & 68 | (dataframe['volume'] > 0) 69 | ), 70 | 'buy' 71 | ] = 1 72 | 73 | return dataframe 74 | 75 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 76 | """ 77 | no sell signal 78 | """ 79 | dataframe['sell'] = 0 80 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/consensus_strat.py: -------------------------------------------------------------------------------- 1 | import numpy as np # noqa 2 | import pandas as pd # noqa 3 | from pandas import DataFrame 4 | from freqtrade.strategy.interface import IStrategy 5 | import talib.abstract as ta 6 | import freqtrade.vendor.qtpylib.indicators as qtpylib 7 | from technical.consensus import Consensus 8 | 9 | class conny(IStrategy): 10 | 11 | minimal_roi = { 12 | "0": 0.025, 13 | "10": 0.015, 14 | "20": 0.01, 15 | "30": 0.005, 16 | "120": 0 17 | } 18 | 19 | stoploss = -0.0203 20 | 21 | timeframe = '15m' 22 | 23 | process_only_new_candles = True 24 | 25 | use_sell_signal = True 26 | sell_profit_only = False 27 | ignore_roi_if_buy_signal = True 28 | 29 | startup_candle_count: int = 30 30 | 31 | 32 | def informative_pairs(self): 33 | return [] 34 | 35 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 36 | # Consensus strategy 37 | # add c.evaluate_indicator bellow to include it in the consensus score (look at 38 | # consensus.py in freqtrade technical) 39 | # add custom indicator with c.evaluate_consensus(prefix=) 40 | c = Consensus(dataframe) 41 | c.evaluate_rsi() 42 | c.evaluate_stoch() 43 | c.evaluate_macd_cross_over() 44 | c.evaluate_macd() 45 | c.evaluate_hull() 46 | c.evaluate_vwma() 47 | c.evaluate_tema(period=12) 48 | c.evaluate_ema(period=24) 49 | c.evaluate_sma(period=12) 50 | c.evaluate_laguerre() 51 | c.evaluate_osc() 52 | c.evaluate_cmf() 53 | c.evaluate_cci() 54 | c.evaluate_cmo() 55 | c.evaluate_ichimoku() 56 | c.evaluate_ultimate_oscilator() 57 | c.evaluate_williams() 58 | c.evaluate_momentum() 59 | c.evaluate_adx() 60 | dataframe['consensus_buy'] = c.score()['buy'] 61 | dataframe['consensus_sell'] = c.score()['sell'] 62 | 63 | 64 | print(dataframe) 65 | return dataframe 66 | 67 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 68 | dataframe.loc[ 69 | ( 70 | (dataframe['consensus_buy'] > 45) & 71 | (dataframe['volume'] > 0) 72 | ), 73 | 'buy'] = 1 74 | 75 | return dataframe 76 | 77 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 78 | dataframe.loc[ 79 | ( 80 | (dataframe['consensus_sell'] > 88) & 81 | (dataframe['volume'] > 0) 82 | ), 83 | 'sell'] = 1 84 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/gettinMoist.py: -------------------------------------------------------------------------------- 1 | # --- Do not remove these libs --- 2 | from freqtrade.strategy import IStrategy, merge_informative_pair 3 | from pandas import DataFrame 4 | import freqtrade.vendor.qtpylib.indicators as qtpylib 5 | import talib.abstract as ta 6 | import numpy as np 7 | # -------------------------------- 8 | 9 | """ 10 | Gettin' Moist 11 | 12 | 88 13 | "" ,d 14 | 88 15 | 88,dPYba,,adPYba, ,adPPYba, 88 ,adPPYba, MM88MMM 16 | 88P' "88" "8a a8" "8a 88 I8[ "" 88 17 | 88 88 88 8b d8 88 `"Y8ba, 88 18 | 88 88 88 "8a, ,a8" 88 aa ]8I 88, 19 | 88 88 88 `"YbbdP"' 88 `"YbbdP"' "Y888 20 | 21 | v1 22 | """ 23 | 24 | class gettinMoist(IStrategy): 25 | 26 | minimal_roi = { 27 | "0": 100 28 | } 29 | 30 | # Stoploss: 31 | stoploss = -0.99 32 | 33 | timeframe = '5m' 34 | 35 | use_sell_signal = True 36 | sell_profit_only = False 37 | ignore_roi_if_buy_signal = True 38 | 39 | startup_candle_count: int = 72 40 | process_only_new_candles = False 41 | 42 | def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 43 | 44 | dataframe['color'] = dataframe['close'] > dataframe['open'] 45 | 46 | macd = ta.MACD(dataframe) 47 | dataframe['macd'] = macd['macd'] 48 | dataframe['macdsignal'] = macd['macdsignal'] 49 | dataframe['macdhist'] = macd['macdhist'] 50 | dataframe['rsi'] = ta.RSI(dataframe, timeperiod=7) 51 | dataframe['roc'] = ta.ROC(dataframe, timeperiod=6) 52 | 53 | dataframe['primed'] = np.where(dataframe['color'].rolling(3).sum() == 3,1,0) 54 | dataframe['in-the-mood'] = dataframe['rsi'] > dataframe['rsi'].rolling(12).mean() 55 | dataframe['moist'] = qtpylib.crossed_above(dataframe['macd'], dataframe['macdsignal']) 56 | dataframe['throbbing'] = dataframe['roc'] > dataframe['roc'].rolling(12).mean() 57 | dataframe['ready-to-go'] = np.where(dataframe['close'] > dataframe['open'].rolling(12).mean(), 1,0) 58 | 59 | return dataframe 60 | 61 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 62 | dataframe.loc[ 63 | ( 64 | (dataframe['primed']) & 65 | (dataframe['moist']) & 66 | (dataframe['throbbing']) & 67 | (dataframe['ready-to-go']) 68 | ), 69 | 'buy'] = 1 70 | 71 | return dataframe 72 | 73 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 74 | 75 | dataframe['sell'] = 0 76 | 77 | return dataframe 78 | 79 | def custom_sell(self, pair: str, trade: 'Trade', current_time: 'datetime', current_rate: float, 80 | current_profit: float, **kwargs): 81 | 82 | dataframe, _ = self.dp.get_analyzed_dataframe(pair=pair, timeframe=self.timeframe) 83 | last_candle = dataframe.iloc[-1].squeeze() 84 | 85 | if current_profit > 0.01 and current_profit > last_candle['roc']: 86 | return 'nutted' 87 | 88 | if current_profit < -0.03 and current_profit < last_candle['roc']: 89 | return 'went_soft' 90 | 91 | return None -------------------------------------------------------------------------------- /strategies/archived/hyperopts/BinHV45HyperOpt.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | 12 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 13 | 14 | # -------------------------------- 15 | # Add your lib to import here 16 | import talib.abstract as ta # noqa 17 | import freqtrade.vendor.qtpylib.indicators as qtpylib 18 | 19 | 20 | class BinHV45HyperOpt(IHyperOpt): 21 | """ 22 | Hyperopt file for optimizing BinHV45Strategy. 23 | Uses ranges to find best parameter combination for bbdelta, closedelta and tail 24 | of the buy strategy. 25 | 26 | Sell strategy is ignored, because it's ignored in BinHV45Strategy as well. 27 | This strategy therefor works without explicit sell signal therefor hyperopting 28 | for 'roi' is recommend as well 29 | 30 | Also, this is just ONE way to optimize this strategy - others might also include 31 | disabling certain conditions completely. This file is just a starting point, feel free 32 | to improve and PR. 33 | """ 34 | 35 | @staticmethod 36 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 37 | """ 38 | Define the buy strategy parameters to be used by Hyperopt. 39 | """ 40 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 41 | """ 42 | Buy strategy Hyperopt will build and use. 43 | """ 44 | conditions = [] 45 | 46 | conditions.append(dataframe['lower'].shift().gt(0)) 47 | conditions.append(dataframe['bbdelta'].gt( 48 | dataframe['close'] * params['bbdelta'] / 1000)) 49 | conditions.append(dataframe['closedelta'].gt( 50 | dataframe['close'] * params['closedelta'] / 1000)) 51 | conditions.append(dataframe['tail'].lt(dataframe['bbdelta'] * params['tail'] / 1000)) 52 | conditions.append(dataframe['close'].lt(dataframe['lower'].shift())) 53 | conditions.append(dataframe['close'].le(dataframe['close'].shift())) 54 | 55 | # Check that the candle had volume 56 | conditions.append(dataframe['volume'] > 0) 57 | 58 | if conditions: 59 | dataframe.loc[ 60 | reduce(lambda x, y: x & y, conditions), 61 | 'buy'] = 1 62 | 63 | return dataframe 64 | 65 | return populate_buy_trend 66 | 67 | @staticmethod 68 | def indicator_space() -> List[Dimension]: 69 | """ 70 | Define your Hyperopt space for searching buy strategy parameters. 71 | """ 72 | return [ 73 | Integer(1, 15, name='bbdelta'), 74 | Integer(15, 20, name='closedelta'), 75 | Integer(20, 30, name='tail'), 76 | ] 77 | 78 | @staticmethod 79 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 80 | """ 81 | Define the sell strategy parameters to be used by Hyperopt. 82 | """ 83 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 84 | """ 85 | no sell signal 86 | """ 87 | dataframe['sell'] = 0 88 | return dataframe 89 | 90 | return populate_sell_trend 91 | 92 | @staticmethod 93 | def sell_indicator_space() -> List[Dimension]: 94 | """ 95 | Define your Hyperopt space for searching sell strategy parameters. 96 | """ 97 | return [] 98 | -------------------------------------------------------------------------------- /strategies/archived/hyperopts/FisherHullHyp.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | 12 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 13 | 14 | # -------------------------------- 15 | # Add your lib to import here 16 | import talib.abstract as ta # noqa 17 | import freqtrade.vendor.qtpylib.indicators as qtpylib 18 | from technical.indicators import hull_moving_average 19 | 20 | class FisherHullHyp(IHyperOpt): 21 | 22 | @staticmethod 23 | def indicator_space() -> List[Dimension]: 24 | return [ 25 | Real(-100.0, 100.0, name='cci-buy'), 26 | Real(-1.0, 1.0, name='fisher-buy') 27 | ] 28 | 29 | @staticmethod 30 | def sell_indicator_space() -> List[Dimension]: 31 | return [ 32 | Real(-100.0, 100.0, name='cci-sell'), 33 | Real(-1.0, 1.0, name='fisher-sell') 34 | ] 35 | 36 | @staticmethod 37 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 38 | """ 39 | Define the buy strategy parameters to be used by Hyperopt. 40 | """ 41 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 42 | """ 43 | Buy strategy Hyperopt will build and use. 44 | """ 45 | dataframe.loc[ 46 | ( 47 | (dataframe['hma'] < dataframe['hma'].shift()) & 48 | (dataframe['cci'] <= params['cci-buy']) & 49 | (dataframe['fisher_rsi'] < params['fisher-buy']) 50 | ) 51 | , 52 | 'buy' 53 | ] = 1 54 | 55 | return dataframe 56 | 57 | return populate_buy_trend 58 | 59 | @staticmethod 60 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 61 | """ 62 | Define the sell strategy parameters to be used by hyperopt 63 | """ 64 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 65 | 66 | dataframe.loc[ 67 | ( 68 | (dataframe['hma'] > dataframe['hma'].shift()) & 69 | (dataframe['cci'] >= params['cci-sell']) & 70 | (dataframe['fisher_rsi'] > params['fisher-sell']) & 71 | (dataframe['volume'] > 0) 72 | ) 73 | , 74 | 'sell' 75 | ] = 1 76 | 77 | return dataframe 78 | 79 | return populate_sell_trend 80 | 81 | 82 | @staticmethod 83 | def generate_roi_table(params: Dict) -> Dict[int, float]: 84 | 85 | roi_table = {} 86 | roi_table[0] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] + params['roi_p6'] 87 | roi_table[params['roi_t6']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] 88 | roi_table[params['roi_t6'] + params['roi_t5']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] 89 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] 90 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3']] = params['roi_p1'] + params['roi_p2'] 91 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2']] = params['roi_p1'] 92 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2'] + params['roi_t1']] = 0 93 | 94 | return roi_table 95 | 96 | @staticmethod 97 | def roi_space() -> List[Dimension]: 98 | 99 | return [ 100 | Integer(1, 15, name='roi_t6'), 101 | Integer(1, 45, name='roi_t5'), 102 | Integer(1, 90, name='roi_t4'), 103 | Integer(45, 120, name='roi_t3'), 104 | Integer(45, 180, name='roi_t2'), 105 | Integer(90, 200, name='roi_t1'), 106 | 107 | Real(0.005, 0.10, name='roi_p6'), 108 | Real(0.005, 0.07, name='roi_p5'), 109 | Real(0.005, 0.05, name='roi_p4'), 110 | Real(0.005, 0.025, name='roi_p3'), 111 | Real(0.005, 0.01, name='roi_p2'), 112 | Real(0.003, 0.007, name='roi_p1'), 113 | ] -------------------------------------------------------------------------------- /strategies/archived/hyperopts/GuacamoleHyp.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | 12 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 13 | 14 | # -------------------------------- 15 | # Add your lib to import here 16 | import talib.abstract as ta # noqa 17 | import freqtrade.vendor.qtpylib.indicators as qtpylib 18 | 19 | class GuacamoleHyp(IHyperOpt): 20 | 21 | @staticmethod 22 | def indicator_space() -> List[Dimension]: 23 | return [ 24 | Real(-1.00, 1.00, name='macd'), 25 | Integer(-1.00, 1.00, name='macdhist'), 26 | Integer(40, 90, name='rmi') 27 | ] 28 | 29 | @staticmethod 30 | def sell_indicator_space() -> List[Dimension]: 31 | return [] 32 | 33 | @staticmethod 34 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 35 | 36 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 37 | 38 | conditions = [] 39 | 40 | conditions.append(dataframe['kama-3'] > dataframe['kama-21']) 41 | conditions.append(dataframe['macd'] > dataframe['macdsignal']) 42 | conditions.append(dataframe['macd'] > params['macd']) 43 | conditions.append(dataframe['macdhist'] > params['macdhist']) 44 | conditions.append(dataframe['rmi'] > dataframe['rmi'].shift()) 45 | conditions.append(dataframe['rmi'] > params['rmi']) 46 | conditions.append(dataframe['volume'] < (dataframe['volume_ma'] * 20)) 47 | 48 | conditions.append(dataframe['volume'] > 0) 49 | 50 | if conditions: 51 | dataframe.loc[ 52 | reduce(lambda x, y: x & y, conditions), 53 | 'buy'] = 1 54 | 55 | return dataframe 56 | 57 | return populate_buy_trend 58 | 59 | @staticmethod 60 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 61 | 62 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 63 | """ 64 | no sell signal 65 | """ 66 | dataframe['sell'] = 0 67 | return dataframe 68 | 69 | return populate_sell_trend 70 | 71 | 72 | @staticmethod 73 | def generate_roi_table(params: Dict) -> Dict[int, float]: 74 | 75 | roi_table = {} 76 | roi_table[0] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] + params['roi_p6'] 77 | roi_table[params['roi_t6']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] 78 | roi_table[params['roi_t6'] + params['roi_t5']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] 79 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] 80 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3']] = params['roi_p1'] + params['roi_p2'] 81 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2']] = params['roi_p1'] 82 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2'] + params['roi_t1']] = 0.0025 83 | 84 | return roi_table 85 | 86 | @staticmethod 87 | def roi_space() -> List[Dimension]: 88 | # min / max min / max 89 | return [ # 0 : 0.100 / 0.200 90 | Integer(1, 20, name='roi_t6'), # 1 -> 20 : 0.050 / 0.100 91 | Integer(10, 20, name='roi_t5'), # 11 -> 40 : 0.030 / 0.050 92 | Integer(10, 20, name='roi_t4'), # 21 -> 60 : 0.015 / 0.030 93 | Integer(15, 30, name='roi_t3'), # 36 -> 90 : 0.010 / 0.015 94 | Integer(45, 90, name='roi_t2'), # 81 -> 180 : 0.003 / 0.005 95 | Integer(90, 180, name='roi_t1'), # 171 -> 360 : 0.0025 (should be 0 but I changed it above.) 96 | 97 | Real(0.05, 0.10, name='roi_p6'), 98 | Real(0.02, 0.05, name='roi_p5'), 99 | Real(0.015, 0.020, name='roi_p4'), 100 | Real(0.005, 0.015, name='roi_p3'), 101 | Real(0.007, 0.01, name='roi_p2'), 102 | Real(0.003, 0.005, name='roi_p1'), 103 | ] 104 | 105 | -------------------------------------------------------------------------------- /strategies/archived/hyperopts/KamaflageHyp.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | 12 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 13 | 14 | # -------------------------------- 15 | # Add your lib to import here 16 | import talib.abstract as ta # noqa 17 | import freqtrade.vendor.qtpylib.indicators as qtpylib 18 | 19 | class KamaflageHyp(IHyperOpt): 20 | 21 | @staticmethod 22 | def indicator_space() -> List[Dimension]: 23 | return [ 24 | Real(-1.00, 1.00, name='macd'), 25 | Integer(-1.00, 1.00, name='macdhist'), 26 | Integer(40, 90, name='rmi') 27 | ] 28 | 29 | @staticmethod 30 | def sell_indicator_space() -> List[Dimension]: 31 | return [] 32 | 33 | @staticmethod 34 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 35 | 36 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 37 | 38 | conditions = [] 39 | 40 | conditions.append(dataframe['kama-3'] > dataframe['kama-21']) 41 | conditions.append(dataframe['macd'] > dataframe['macdsignal']) 42 | conditions.append(dataframe['macd'] > params['macd']) 43 | conditions.append(dataframe['macdhist'] > params['macdhist']) 44 | conditions.append(dataframe['rmi'] > dataframe['rmi'].shift()) 45 | conditions.append(dataframe['rmi'] > params['rmi']) 46 | conditions.append(dataframe['volume'] < (dataframe['volume_ma'] * 20)) 47 | 48 | conditions.append(dataframe['volume'] > 0) 49 | 50 | if conditions: 51 | dataframe.loc[ 52 | reduce(lambda x, y: x & y, conditions), 53 | 'buy'] = 1 54 | 55 | return dataframe 56 | 57 | return populate_buy_trend 58 | 59 | @staticmethod 60 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 61 | 62 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 63 | """ 64 | no sell signal 65 | """ 66 | dataframe['sell'] = 0 67 | return dataframe 68 | 69 | return populate_sell_trend 70 | 71 | 72 | @staticmethod 73 | def generate_roi_table(params: Dict) -> Dict[int, float]: 74 | 75 | roi_table = {} 76 | roi_table[0] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] + params['roi_p6'] 77 | roi_table[params['roi_t6']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] 78 | roi_table[params['roi_t6'] + params['roi_t5']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] 79 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] 80 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3']] = params['roi_p1'] + params['roi_p2'] 81 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2']] = params['roi_p1'] 82 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2'] + params['roi_t1']] = 0.0025 83 | 84 | return roi_table 85 | 86 | @staticmethod 87 | def roi_space() -> List[Dimension]: 88 | # min / max min / max 89 | return [ # 0 : 0.100 / 0.200 90 | Integer(1, 20, name='roi_t6'), # 1 -> 20 : 0.050 / 0.100 91 | Integer(10, 20, name='roi_t5'), # 11 -> 40 : 0.030 / 0.050 92 | Integer(10, 20, name='roi_t4'), # 21 -> 60 : 0.015 / 0.030 93 | Integer(15, 30, name='roi_t3'), # 36 -> 90 : 0.010 / 0.015 94 | Integer(45, 90, name='roi_t2'), # 81 -> 180 : 0.003 / 0.005 95 | Integer(90, 180, name='roi_t1'), # 171 -> 360 : 0.0025 (should be 0 but I changed it above.) 96 | 97 | Real(0.05, 0.10, name='roi_p6'), 98 | Real(0.02, 0.05, name='roi_p5'), 99 | Real(0.015, 0.020, name='roi_p4'), 100 | Real(0.005, 0.015, name='roi_p3'), 101 | Real(0.007, 0.01, name='roi_p2'), 102 | Real(0.003, 0.005, name='roi_p1'), 103 | ] 104 | 105 | -------------------------------------------------------------------------------- /strategies/archived/hyperopts/LateralusHyp.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | 12 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 13 | 14 | # -------------------------------- 15 | # Add your lib to import here 16 | import talib.abstract as ta # noqa 17 | import freqtrade.vendor.qtpylib.indicators as qtpylib 18 | 19 | class LateralusHyp(IHyperOpt): 20 | 21 | @staticmethod 22 | def indicator_space() -> List[Dimension]: 23 | return [ 24 | Real(0.0005, 0.03, name='bbdelta-close'), 25 | Real(0.0005, 0.02, name='closedelta-close'), 26 | Real(0.0005, 0.02, name='close-bblower'), 27 | Real(0.5, 1.0, name='bbdelta-tail'), 28 | Integer(1, 30, name='volume') 29 | ] 30 | 31 | @staticmethod 32 | def sell_indicator_space() -> List[Dimension]: 33 | return [] 34 | 35 | @staticmethod 36 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 37 | 38 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 39 | 40 | inf_timeframe = '1h' 41 | conditions = [] 42 | 43 | conditions.append( 44 | ( 45 | (dataframe[f"ema-fast_{inf_timeframe}"] > dataframe[f"ema-slow_{inf_timeframe}"]) & 46 | (dataframe[f"macd_{inf_timeframe}"] > dataframe[f"macdsignal_{inf_timeframe}"]) 47 | ) & 48 | (( 49 | (dataframe['bb1-delta'] > (dataframe['close'] * params['bbdelta-close'])) & 50 | (dataframe['closedelta'] > (dataframe['close'] * params['closedelta-close'])) & 51 | (dataframe['tail'] < (dataframe['bb1-delta'] * params['bbdelta-tail'])) & 52 | (dataframe['close'] < dataframe['lower-bb1'].shift()) & 53 | (dataframe['close'] <= dataframe['close'].shift()) 54 | ) | 55 | ( 56 | (dataframe['close'] < dataframe['ema-slow']) & 57 | (dataframe['close'] < params['close-bblower'] * dataframe['lower-bb2']) & 58 | (dataframe['volume'] < (dataframe['volume-mean-slow'].shift(1) * params['volume'])) 59 | )) 60 | ) 61 | 62 | conditions.append(dataframe['volume'].gt(0)) 63 | 64 | if conditions: 65 | dataframe.loc[ 66 | reduce(lambda x, y: x & y, conditions), 67 | 'buy'] = 1 68 | return dataframe 69 | 70 | return populate_buy_trend 71 | 72 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 73 | """ 74 | no sell signal 75 | """ 76 | dataframe['sell'] = 0 77 | return dataframe 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /strategies/archived/hyperopts/PmaxHyper.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | # isort: skip_file 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | from technical.indicators import PMAX, zema 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | import multiprocessing 12 | import time 13 | import sys 14 | import threading 15 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 16 | 17 | # -------------------------------- 18 | # Add your lib to import here 19 | import talib.abstract as ta # noqa 20 | import freqtrade.vendor.qtpylib.indicators as qtpylib 21 | 22 | 23 | class PmaxHyper(IHyperOpt): 24 | 25 | @staticmethod 26 | def populate_indicators(dataframe: DataFrame, metadata: dict) -> DataFrame: 27 | """ 28 | This method can also be loaded from the strategy, if it doesn't exist in the hyperopt class. 29 | """ 30 | n=0 31 | length = 10 32 | dframe = dataframe.copy() 33 | default = dataframe.copy() 34 | jobs = [] 35 | tuples = [] 36 | 37 | def thr(default, length, MAtype, multiplier, src_val, ns): 38 | DAT = PMAX(default, period=length, multiplier=multiplier, length=length, MAtype=MAtype, 39 | src=src_val) 40 | xdata = ns.df 41 | xdata[list(DAT.keys())[-1]] = DAT[list(DAT.keys())[-1]] 42 | ns.df = xdata 43 | 44 | mgr = multiprocessing.Manager() 45 | ns = mgr.Namespace() 46 | ns.df = dataframe 47 | print(dataframe.head()) 48 | def wrapper(mpobject): 49 | mpobject.start() 50 | mpobject.join() 51 | for length in range(2, 200): 52 | for MAtype in range(1, 8): 53 | for multiplier in range(1, 30): 54 | for src_val in range(1, 3): 55 | p = multiprocessing.Process(target=thr, args=(default, length, MAtype, multiplier, src_val, ns)) 56 | # p.start() 57 | # print(p.exitcode) 58 | # thr(default, length, MAtype, multiplier, src_val, ns) 59 | # jobs.append(p) 60 | # print(ns.df) 61 | # print(dataframe) 62 | jobs.append(p) 63 | # tuples.append(tuple([length, MAtype, multiplier, src_val, default])) 64 | # pool = multiprocessing.Pool(processes=16) 65 | # pool.map_async(wrapper, jobs) 66 | # pool.close() 67 | # pool.join() 68 | for process in jobs: 69 | th = threading.Thread(target=wrapper, args=(process,)) 70 | th.start() 71 | n=n+1 72 | if n==512: 73 | th.join() 74 | n=0 75 | print(sys.getsizeof(ns.df)) 76 | dataframe = ns.df 77 | for i in range(2, 200): 78 | EMA = '' 79 | EMA = 'EMA' + str(i) 80 | dataframe[EMA] = zema(dataframe, period=length) 81 | return dataframe 82 | 83 | @staticmethod 84 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 85 | """ 86 | Define the buy strategy parameters to be used by hyperopt 87 | """ 88 | 89 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 90 | EMA = "EMA" + str(params['length']) 91 | pmax = "pm_" + str(params['length']) + "_" + str(params['multiplier']) + "_" + str( 92 | params['length']) + "_" + str(params['MAtype']) 93 | dataframe.loc[ 94 | ( 95 | (qtpylib.crossed_above(dataframe[EMA], dataframe[pmax])) 96 | ), 97 | 'buy'] = 1 98 | 99 | return dataframe 100 | 101 | return populate_buy_trend 102 | 103 | @staticmethod 104 | def indicator_space() -> List[Dimension]: 105 | """ 106 | Define your Hyperopt space for searching strategy parameters 107 | """ 108 | return [ 109 | Integer(1, 30, name='multiplier'), 110 | Integer(1, 200, name='length'), 111 | Integer(1, 3, name='src_val'), 112 | Integer(1, 8, name='MAtype') 113 | ] 114 | 115 | @staticmethod 116 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 117 | """ 118 | Define the sell strategy parameters to be used by hyperopt 119 | """ 120 | 121 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 122 | EMA = "EMA" + str(params['length']) 123 | pmax = "pm_" + str(params['length']) + "_" + str(params['multiplier']) + "_" + str( 124 | params['length']) + "_" + str(params['MAtype']) 125 | dataframe.loc[ 126 | ( 127 | (qtpylib.crossed_below(dataframe[EMA], dataframe[pmax])) 128 | ), 129 | 'sell'] = 1 130 | return dataframe 131 | 132 | return populate_sell_trend 133 | 134 | @staticmethod 135 | def sell_indicator_space() -> List[Dimension]: 136 | """ 137 | Define your Hyperopt space for searching sell strategy parameters 138 | """ 139 | return [ 140 | Integer(1, 30, name='multiplier'), 141 | Integer(1, 200, name='length'), 142 | Integer(1, 3, name='src_val'), 143 | Integer(1, 8, name='MAtype') 144 | ] 145 | -------------------------------------------------------------------------------- /strategies/archived/hyperopts/RenkoHyp.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | 12 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 13 | 14 | # -------------------------------- 15 | # Add your lib to import here 16 | import talib.abstract as ta # noqa 17 | import freqtrade.vendor.qtpylib.indicators as qtpylib 18 | 19 | class RenkoHyp(IHyperOpt): 20 | 21 | @staticmethod 22 | def indicator_space() -> List[Dimension]: 23 | return [] 24 | 25 | @staticmethod 26 | def sell_indicator_space() -> List[Dimension]: 27 | return [] 28 | 29 | @staticmethod 30 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 31 | 32 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 33 | 34 | buy_mode = True 35 | for index, row in dataframe.iterrows(): 36 | if row['previous-trend'] == False and row['trend'] == True and buy_mode == True: 37 | last_row = dataframe.loc[dataframe['date'] == row['date']][-1:] 38 | dataframe.loc[dataframe.index== last_row.index.values[0], 'buy'] = 1 39 | buy_mode = False 40 | 41 | if row['previous-trend'] == True and row['trend'] == False and buy_mode == False: 42 | last_row = dataframe.loc[dataframe['date'] == row['date']][-1:] 43 | dataframe.loc[dataframe.index== last_row.index.values[0], 'sell'] = 1 44 | buy_mode = True 45 | 46 | return dataframe 47 | 48 | return populate_buy_trend 49 | 50 | @staticmethod 51 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 52 | 53 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 54 | 55 | dataframe['sell'] = 0 56 | return dataframe 57 | 58 | return populate_sell_trend 59 | 60 | @staticmethod 61 | def generate_roi_table(params: Dict) -> Dict[int, float]: 62 | 63 | roi_table = {} 64 | roi_table[0] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] + params['roi_p6'] 65 | roi_table[params['roi_t6']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] 66 | roi_table[params['roi_t6'] + params['roi_t5']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] 67 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] 68 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3']] = params['roi_p1'] + params['roi_p2'] 69 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2']] = params['roi_p1'] 70 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2'] + params['roi_t1']] = 0 71 | 72 | return roi_table 73 | 74 | @staticmethod 75 | def roi_space() -> List[Dimension]: 76 | 77 | return [ 78 | Integer(1, 15, name='roi_t6'), 79 | Integer(1, 45, name='roi_t5'), 80 | Integer(1, 90, name='roi_t4'), 81 | Integer(45, 120, name='roi_t3'), 82 | Integer(45, 180, name='roi_t2'), 83 | Integer(90, 200, name='roi_t1'), 84 | 85 | Real(0.005, 0.10, name='roi_p6'), 86 | Real(0.005, 0.07, name='roi_p5'), 87 | Real(0.005, 0.05, name='roi_p4'), 88 | Real(0.005, 0.025, name='roi_p3'), 89 | Real(0.005, 0.01, name='roi_p2'), 90 | Real(0.003, 0.007, name='roi_p1'), 91 | ] 92 | 93 | -------------------------------------------------------------------------------- /strategies/archived/hyperopts/Schism2HypMM.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | 12 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 13 | 14 | # -------------------------------- 15 | # Add your lib to import here 16 | import talib.abstract as ta # noqa 17 | import freqtrade.vendor.qtpylib.indicators as qtpylib 18 | 19 | class Schism2HypMM(IHyperOpt): 20 | 21 | @staticmethod 22 | def indicator_space() -> List[Dimension]: 23 | return [ 24 | Integer(15, 70, name='rmi-slow'), 25 | Integer(5, 50, name='rmi-fast'), 26 | Integer(5, 70, name='mp'), 27 | Integer(10, 100, name='inf-rsi'), 28 | Real(0.70, 0.99, name='inf-pct-adr') 29 | ] 30 | 31 | @staticmethod 32 | def sell_indicator_space() -> List[Dimension]: 33 | return [] 34 | 35 | @staticmethod 36 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 37 | 38 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 39 | 40 | inf_timeframe = '1h' 41 | conditions = [] 42 | 43 | conditions.append( 44 | (dataframe[f"rsi_{inf_timeframe}"] >= params['inf-rsi']) & 45 | (dataframe['close'] <= dataframe[f"3d_low_{inf_timeframe}"] + (params['inf-pct-adr'] * dataframe[f"adr_{inf_timeframe}"])) & 46 | (dataframe['rmi-dn-trend'] == 1) & 47 | (dataframe['rmi-slow'] >= params['rmi-slow']) & 48 | (dataframe['rmi-fast'] <= params['rmi-fast']) & 49 | (dataframe['mp'] <= params['mp']) 50 | ) 51 | 52 | conditions.append(dataframe['volume'].gt(0)) 53 | conditions.append(dataframe['buy_signal']) 54 | 55 | if conditions: 56 | dataframe.loc[ 57 | reduce(lambda x, y: x & y, conditions), 58 | 'buy'] = 1 59 | return dataframe 60 | 61 | return populate_buy_trend 62 | 63 | @staticmethod 64 | def generate_roi_table(params: Dict) -> Dict[int, float]: 65 | 66 | roi_table = {} 67 | roi_table[0] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] + params['roi_p6'] 68 | roi_table[params['roi_t6']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] 69 | roi_table[params['roi_t6'] + params['roi_t5']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] 70 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] 71 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3']] = params['roi_p1'] + params['roi_p2'] 72 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2']] = params['roi_p1'] 73 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2'] + params['roi_t1']] = 0.0025 74 | 75 | return roi_table 76 | 77 | @staticmethod 78 | def roi_space() -> List[Dimension]: 79 | # min / max min / max 80 | return [ # 0 : 0.100 / 0.205 81 | Integer(1, 20, name='roi_t6'), # 1 -> 20 : 0.050 / 0.105 82 | Integer(10, 20, name='roi_t5'), # 11 -> 40 : 0.030 / 0.055 83 | Integer(10, 20, name='roi_t4'), # 21 -> 60 : 0.015 / 0.035 84 | Integer(15, 30, name='roi_t3'), # 36 -> 90 : 0.010 / 0.020 85 | Integer(264, 630, name='roi_t2'), # 300 -> 720 : 0.005 / 0.010 86 | Integer(420, 720, name='roi_t1'), # 720 -> 1440 : 0 87 | 88 | Real(0.05, 0.10, name='roi_p6'), 89 | Real(0.02, 0.05, name='roi_p5'), 90 | Real(0.015, 0.020, name='roi_p4'), 91 | Real(0.005, 0.015, name='roi_p3'), 92 | Real(0.005, 0.01, name='roi_p2'), 93 | Real(0.005, 0.01, name='roi_p1'), 94 | ] 95 | 96 | @staticmethod 97 | def stoploss_space() -> List[Dimension]: 98 | 99 | return [ 100 | Real(-0.99, -0.01, name='stoploss'), 101 | ] 102 | 103 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 104 | """ 105 | no sell signal 106 | """ 107 | dataframe['sell'] = 0 108 | return dataframe 109 | -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SchismHyp-Badstreak.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | 12 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 13 | 14 | # -------------------------------- 15 | # Add your lib to import here 16 | import talib.abstract as ta # noqa 17 | import freqtrade.vendor.qtpylib.indicators as qtpylib 18 | 19 | class SchismHyp(IHyperOpt): 20 | 21 | @staticmethod 22 | def indicator_space() -> List[Dimension]: 23 | return [ 24 | Integer(10, 50, name='mp') 25 | ] 26 | 27 | @staticmethod 28 | def sell_indicator_space() -> List[Dimension]: 29 | return [] 30 | 31 | @staticmethod 32 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 33 | 34 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 35 | 36 | conditions = [] 37 | 38 | conditions.append( 39 | (dataframe['mp'] < params['mp']) & 40 | (dataframe['streak-roc'] > dataframe['pcc-lowerband']) & 41 | (dataframe['mac'] == 1) 42 | ) 43 | 44 | conditions.append(dataframe['volume'].gt(0)) 45 | 46 | if conditions: 47 | dataframe.loc[ 48 | reduce(lambda x, y: x & y, conditions), 49 | 'buy'] = 1 50 | return dataframe 51 | 52 | return populate_buy_trend 53 | 54 | @staticmethod 55 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 56 | """ 57 | Define the sell strategy parameters to be used by Hyperopt. 58 | """ 59 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 60 | """ 61 | no sell signal 62 | """ 63 | dataframe['sell'] = 0 64 | return dataframe 65 | 66 | return populate_sell_trend 67 | 68 | @staticmethod 69 | def generate_roi_table(params: Dict) -> Dict[int, float]: 70 | 71 | roi_table = {} 72 | roi_table[0] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] + params['roi_p6'] 73 | roi_table[params['roi_t6']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] 74 | roi_table[params['roi_t6'] + params['roi_t5']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] 75 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] 76 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3']] = params['roi_p1'] + params['roi_p2'] 77 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2']] = params['roi_p1'] 78 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2'] + params['roi_t1']] = 0 79 | 80 | return roi_table 81 | 82 | @staticmethod 83 | def roi_space() -> List[Dimension]: 84 | # min / max min / max 85 | return [ # 0 : 0.100 / 0.205 86 | Integer(1, 20, name='roi_t6'), # 1 -> 20 : 0.050 / 0.105 87 | Integer(10, 20, name='roi_t5'), # 11 -> 40 : 0.030 / 0.055 88 | Integer(10, 20, name='roi_t4'), # 21 -> 60 : 0.015 / 0.035 89 | Integer(15, 30, name='roi_t3'), # 36 -> 90 : 0.010 / 0.020 90 | Integer(264, 630, name='roi_t2'), # 300 -> 720 : 0.005 / 0.010 91 | Integer(420, 720, name='roi_t1'), # 720 -> 1440 : 0 92 | 93 | Real(0.05, 0.10, name='roi_p6'), 94 | Real(0.02, 0.05, name='roi_p5'), 95 | Real(0.015, 0.020, name='roi_p4'), 96 | Real(0.005, 0.015, name='roi_p3'), 97 | Real(0.005, 0.01, name='roi_p2'), 98 | Real(0.005, 0.01, name='roi_p1'), 99 | ] 100 | 101 | @staticmethod 102 | def stoploss_space() -> List[Dimension]: 103 | 104 | return [ 105 | Real(-0.99, -0.01, name='stoploss'), 106 | ] 107 | 108 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 109 | """ 110 | no sell signal 111 | """ 112 | dataframe['sell'] = 0 113 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SchismHyp-Badstreak2.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class SchismHyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | Integer(10, 50, name='mp'), 20 | Integer(10, 70, name='inf-rsi-1'), 21 | Integer(10, 70, name='inf-rsi-2'), 22 | Integer(10, 40, name='rmi-above'), 23 | Integer(50, 80, name='rmi-below'), 24 | Integer(10, 70, name='xinf-stake-rmi'), 25 | Integer(50, 90, name='xtf-stake-rsi'), 26 | Integer(10, 70, name='xtf-fiat-rsi') 27 | ] 28 | 29 | @staticmethod 30 | def sell_indicator_space() -> List[Dimension]: 31 | return [] 32 | 33 | @staticmethod 34 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 35 | 36 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 37 | 38 | inf_timeframe = '4h' 39 | stake_currency = 'USD' 40 | fiat = 'USD' 41 | conditions = [] 42 | 43 | conditions.append( 44 | ( 45 | (dataframe[f"rsi_{inf_timeframe}"] < params['inf-rsi-1']) & 46 | (dataframe['mp'] < params['mp']) & 47 | (dataframe['streak-roc'] > dataframe['pcc-lowerband']) & 48 | (dataframe['mac'] == 1) 49 | ) | 50 | ( 51 | (dataframe[f"rsi_{inf_timeframe}"] < params['inf-rsi-2']) & 52 | (dataframe['rmi-up-trend'] == 1) & 53 | (dataframe['rmi'] < params['rmi-below']) & 54 | (dataframe['rmi'] > params['rmi-above']) 55 | ) 56 | ) 57 | 58 | if stake_currency in ('BTC', 'ETH'): 59 | conditions.append( 60 | (dataframe[f"{stake_currency}_rsi"] > params['xtf-stake-rsi']) | 61 | (dataframe[f"{fiat}_rsi"] < params['xtf-fiat-rsi']) 62 | ) 63 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xinf-stake-rmi']) 64 | 65 | conditions.append(dataframe['volume'].gt(0)) 66 | 67 | if conditions: 68 | dataframe.loc[ 69 | reduce(lambda x, y: x & y, conditions), 70 | 'buy'] = 1 71 | return dataframe 72 | 73 | return populate_buy_trend 74 | 75 | @staticmethod 76 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 77 | 78 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 79 | 80 | dataframe['sell'] = 0 81 | return dataframe 82 | 83 | return populate_sell_trend 84 | 85 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 86 | 87 | dataframe['sell'] = 0 88 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SchismHyp-v1.3.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class Schism3Hyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | Categorical(['min', 'max', 'mean', 'median'], name='bounce-price'), 20 | Integer(1, 10, name='bounce-lookback'), # 1, 10 21 | Integer(20, 50, name='down-inf-rsi'), # 20, 50 22 | Integer(20, 50, name='down-rmi-slow'), # 20, 50 23 | Integer(10, 50, name='down-rmi-fast'), # 10, 50 24 | Integer(10, 70, name='down-mp'), # 10, 70 25 | Integer(30, 70, name='up-inf-rsi'), # 30, 70 26 | Integer(10, 70, name='xinf-stake-rmi'), # 10, 70 27 | Integer(50, 90, name='xtf-stake-rsi'), # 50, 90 28 | Integer(10, 70, name='xtf-fiat-rsi') # 10, 70 29 | ] 30 | 31 | @staticmethod 32 | def sell_indicator_space() -> List[Dimension]: 33 | return [] 34 | 35 | @staticmethod 36 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 37 | 38 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 39 | 40 | inf_timeframe = '1h' 41 | stake_currency = 'USD' 42 | fiat = 'USD' 43 | conditions = [] 44 | 45 | dataframe['bounce-pending'] = np.where( 46 | (dataframe[f"rsi_{inf_timeframe}"] >= params['down-inf-rsi']) & 47 | (dataframe['rmi-dn-trend'] == 1) & 48 | (dataframe['rmi-slow'] >= params['down-rmi-slow']) & 49 | (dataframe['rmi-fast'] <= params['down-rmi-fast']) & 50 | (dataframe['mp'] <= params['down-mp']), 51 | 1,0 52 | ) 53 | 54 | dataframe['bounce-price'] = np.where( 55 | dataframe['bounce-pending'] == 1, 56 | dataframe['close'], 57 | getattr(dataframe['close'].rolling(params['bounce-lookback'], min_periods=1), params['bounce-price'])() 58 | ) 59 | 60 | dataframe['bounce-range'] = np.where(dataframe['bounce-pending'].rolling(params['bounce-lookback'], min_periods=1).sum() >= 1,1,0) 61 | 62 | conditions.append( 63 | (dataframe[f"rsi_{inf_timeframe}"] >= params['up-inf-rsi']) & 64 | (dataframe['bounce-range'] == 1) & 65 | (dataframe['rmi-up-trend'] == 1) & 66 | (dataframe['close'] >= dataframe['bounce-price']) 67 | ) 68 | 69 | if stake_currency in ('BTC', 'ETH'): 70 | conditions.append( 71 | (dataframe[f"{stake_currency}_rsi"] < params['xtf-stake-rsi']) | 72 | (dataframe[f"{fiat}_rsi"] > params['xtf-fiat-rsi']) 73 | ) 74 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xinf-stake-rmi']) 75 | 76 | conditions.append(dataframe['volume'].gt(0)) 77 | 78 | if conditions: 79 | dataframe.loc[ 80 | reduce(lambda x, y: x & y, conditions), 81 | 'buy'] = 1 82 | return dataframe 83 | 84 | return populate_buy_trend 85 | 86 | @staticmethod 87 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 88 | 89 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 90 | 91 | dataframe['sell'] = 0 92 | return dataframe 93 | 94 | return populate_sell_trend 95 | 96 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 97 | 98 | dataframe['sell'] = 0 99 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SchismHyp-v1.4.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class Schism4Hyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | Integer(15, 70, name='rmi-slow'), 20 | Integer(10, 50, name='rmi-fast'), 21 | Integer(10, 70, name='mp'), 22 | Integer(10, 70, name='inf-rsi'), 23 | Integer(10, 70, name='xinf-stake-rmi'), 24 | Integer(50, 90, name='xtf-stake-rsi'), 25 | Integer(10, 70, name='xtf-fiat-rsi') 26 | ] 27 | 28 | @staticmethod 29 | def sell_indicator_space() -> List[Dimension]: 30 | return [] 31 | 32 | @staticmethod 33 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 34 | 35 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 36 | 37 | inf_timeframe = '1h' 38 | stake_currency = 'USD' 39 | fiat = 'USD' 40 | conditions = [] 41 | 42 | conditions.append( 43 | (dataframe[f"rsi_{inf_timeframe}"] <= params['inf-rsi']) & 44 | (dataframe['rmi-up-trend'] == 1) & 45 | (dataframe['rmi-slow'] <= params['rmi-slow']) & 46 | (dataframe['rmi-fast'] >= params['rmi-fast']) & 47 | (dataframe['mp'] >= params['mp']) 48 | ) 49 | 50 | if stake_currency in ('BTC', 'ETH'): 51 | conditions.append( 52 | (dataframe[f"{stake_currency}_rsi"] < params['xtf-stake-rsi']) | 53 | (dataframe[f"{fiat}_rsi"] > params['xtf-fiat-rsi']) 54 | ) 55 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xinf-stake-rmi']) 56 | 57 | conditions.append(dataframe['volume'].gt(0)) 58 | 59 | if conditions: 60 | dataframe.loc[ 61 | reduce(lambda x, y: x & y, conditions), 62 | 'buy'] = 1 63 | return dataframe 64 | 65 | return populate_buy_trend 66 | 67 | @staticmethod 68 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 69 | 70 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 71 | 72 | dataframe['sell'] = 0 73 | return dataframe 74 | 75 | return populate_sell_trend 76 | 77 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 78 | 79 | dataframe['sell'] = 0 80 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SchismHyp-v1.5.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class Schism5Hyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | Integer(10, 50, name='bull-buy-rsi'), 20 | Integer(10, 50, name='bear-buy-rsi') 21 | ] 22 | 23 | @staticmethod 24 | def sell_indicator_space() -> List[Dimension]: 25 | return [ 26 | Integer(50, 90, name='bull-sell-rsi'), 27 | Integer(50, 90, name='bear-sell-rsi') 28 | ] 29 | 30 | @staticmethod 31 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 32 | 33 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 34 | conditions = [] 35 | 36 | conditions.append( 37 | ((dataframe['bull'] > 0) & qtpylib.crossed_below(dataframe['rsi'], params['bull-buy-rsi'])) | 38 | (~(dataframe['bull'] > 0) & qtpylib.crossed_below(dataframe['rsi'], params['bear-buy-rsi'])) 39 | ) 40 | 41 | conditions.append(dataframe['volume'].gt(0)) 42 | 43 | if conditions: 44 | dataframe.loc[ 45 | reduce(lambda x, y: x & y, conditions), 46 | 'buy'] = 1 47 | return dataframe 48 | 49 | return populate_buy_trend 50 | 51 | @staticmethod 52 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 53 | 54 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 55 | conditions = [] 56 | 57 | conditions.append( 58 | ((dataframe['bull'] > 0) & (dataframe['rsi'] > params['bull-sell-rsi'])) | 59 | (~(dataframe['bull'] > 0) & (dataframe['rsi'] > params['bear-sell-rsi'])) 60 | ) 61 | 62 | conditions.append(dataframe['volume'].gt(0)) 63 | 64 | if conditions: 65 | dataframe.loc[ 66 | reduce(lambda x, y: x & y, conditions), 67 | 'sell'] = 1 68 | return dataframe 69 | 70 | return populate_sell_trend -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SchismHyp-v1.6.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class Schism6Hyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | # Base Timeframe 20 | Integer(15, 70, name='base-rmi-slow'), 21 | Integer(10, 50, name='base-rmi-fast'), 22 | Integer(10, 70, name='base-mp'), 23 | # Informative Timeframe 24 | Integer(10, 70, name='inf-rsi'), 25 | Categorical(['lower', 'upper', 'both', 'none'], name='inf-guard'), 26 | Real(0.70, 0.99, name='inf-pct-adr-top'), 27 | Real(0.01, 0.20, name='inf-pct-adr-bot'), 28 | # Exra BTC/ETH Stakes 29 | Integer(10, 70, name='xtra-inf-stake-rmi'), 30 | Integer(50, 90, name='xtra-base-stake-rsi'), 31 | Integer(10, 70, name='xtra-base-fiat-rsi') 32 | ] 33 | 34 | @staticmethod 35 | def sell_indicator_space() -> List[Dimension]: 36 | return [] 37 | 38 | @staticmethod 39 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 40 | 41 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 42 | 43 | inf_timeframe = '1h' 44 | stake_currency = 'USD' 45 | fiat = 'USD' 46 | conditions = [] 47 | 48 | if params['inf-guard'] == 'upper' or params['inf-guard'] == 'both': 49 | conditions.append( 50 | (dataframe['close'] <= dataframe[f"3d_low_{inf_timeframe}"] + 51 | (params['inf-pct-adr-top'] * dataframe[f"adr_{inf_timeframe}"])) 52 | ) 53 | 54 | if params['inf-guard'] == 'lower' or params['inf-guard'] == 'both': 55 | conditions.append( 56 | (dataframe['close'] >= dataframe[f"3d_low_{inf_timeframe}"] + 57 | (params['inf-pct-adr-bot'] * dataframe[f"adr_{inf_timeframe}"])) 58 | ) 59 | 60 | conditions.append( 61 | (dataframe[f"rsi_{inf_timeframe}"] >= params['inf-rsi']) & 62 | (dataframe['rmi-dn-trend'] == 1) & 63 | (dataframe['rmi-slow'] >= params['base-rmi-slow']) & 64 | (dataframe['rmi-fast'] <= params['base-rmi-fast']) & 65 | (dataframe['mp'] <= params['base-mp']) 66 | ) 67 | 68 | if stake_currency in ('BTC', 'ETH'): 69 | conditions.append( 70 | (dataframe[f"{stake_currency}_rsi"] < params['xtra-base-stake-rsi']) | 71 | (dataframe[f"{fiat}_rsi"] > params['xtra-base-fiat-rsi']) 72 | ) 73 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xtra-inf-stake-rmi']) 74 | 75 | conditions.append(dataframe['volume'].gt(0)) 76 | 77 | if conditions: 78 | dataframe.loc[ 79 | reduce(lambda x, y: x & y, conditions), 80 | 'buy'] = 1 81 | return dataframe 82 | 83 | return populate_buy_trend 84 | 85 | @staticmethod 86 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 87 | 88 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 89 | 90 | dataframe['sell'] = 0 91 | return dataframe 92 | 93 | return populate_sell_trend 94 | 95 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 96 | 97 | dataframe['sell'] = 0 98 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SchismHyp-v2.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class Schism2Hyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | Integer(15, 70, name='rmi-slow'), 20 | Integer(10, 50, name='rmi-fast'), 21 | Integer(10, 70, name='mp'), 22 | Integer(10, 70, name='inf-rsi'), 23 | Real(0.70, 0.99, name='inf-pct-adr'), 24 | Integer(10, 70, name='xinf-stake-rmi'), 25 | Integer(50, 90, name='xtf-stake-rsi'), 26 | Integer(10, 70, name='xtf-fiat-rsi') 27 | ] 28 | 29 | @staticmethod 30 | def sell_indicator_space() -> List[Dimension]: 31 | return [] 32 | 33 | @staticmethod 34 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 35 | 36 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 37 | 38 | inf_timeframe = '1h' 39 | stake_currency = 'USD' 40 | fiat = 'USD' 41 | conditions = [] 42 | 43 | conditions.append( 44 | (dataframe[f"rsi_{inf_timeframe}"] >= params['inf-rsi']) & 45 | (dataframe['close'] <= dataframe[f"3d_low_{inf_timeframe}"] + (params['inf-pct-adr'] * dataframe[f"adr_{inf_timeframe}"])) & 46 | (dataframe['rmi-dn-trend'] == 1) & 47 | (dataframe['rmi-slow'] >= params['rmi-slow']) & 48 | (dataframe['rmi-fast'] <= params['rmi-fast']) & 49 | (dataframe['mp'] <= params['mp']) 50 | ) 51 | 52 | if stake_currency in ('BTC', 'ETH'): 53 | conditions.append( 54 | (dataframe[f"{stake_currency}_rsi"] < params['xtf-stake-rsi']) | 55 | (dataframe[f"{fiat}_rsi"] > params['xtf-fiat-rsi']) 56 | ) 57 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xinf-stake-rmi']) 58 | 59 | conditions.append(dataframe['volume'].gt(0)) 60 | 61 | if conditions: 62 | dataframe.loc[ 63 | reduce(lambda x, y: x & y, conditions), 64 | 'buy'] = 1 65 | return dataframe 66 | 67 | return populate_buy_trend 68 | 69 | @staticmethod 70 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 71 | 72 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 73 | 74 | dataframe['sell'] = 0 75 | return dataframe 76 | 77 | return populate_sell_trend 78 | 79 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 80 | 81 | dataframe['sell'] = 0 82 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SchismHyp.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class SchismHyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | Integer(1, 10, name='bounce-lookback'), 20 | Integer(20, 50, name='down-inf-rsi'), 21 | Integer(20, 50, name='down-rmi-slow'), 22 | Integer(10, 50, name='down-rmi-fast'), 23 | Integer(10, 70, name='down-mp'), 24 | Integer(30, 70, name='up-inf-rsi'), 25 | Integer(30, 70, name='up-rmi-slow'), 26 | Integer(10, 50, name='up-rmi-fast'), 27 | Integer(10, 70, name='xinf-stake-rmi'), 28 | Integer(50, 90, name='xtf-stake-rsi'), 29 | Integer(10, 70, name='xtf-fiat-rsi') 30 | ] 31 | 32 | @staticmethod 33 | def sell_indicator_space() -> List[Dimension]: 34 | return [ 35 | Integer(30, 70, name='rmi-high'), 36 | Integer(10, 30, name='rmi-low') 37 | ] 38 | 39 | @staticmethod 40 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 41 | 42 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 43 | 44 | inf_timeframe = '1h' 45 | stake_currency = 'USD' 46 | fiat = 'USD' 47 | conditions = [] 48 | 49 | dataframe['bounce-pending'] = np.where( 50 | (dataframe[f"rsi_{inf_timeframe}"] < params['down-inf-rsi']) & 51 | (dataframe['rmi-dn-trend'] == 1) & 52 | (dataframe['rmi-slow'] > params['down-rmi-slow']) & 53 | (dataframe['rmi-fast'] < params['down-rmi-fast']) & 54 | (dataframe['mp'] <= params['down-mp']), 55 | 1,0 56 | ) 57 | 58 | dataframe['bounce-price'] = np.where( 59 | dataframe['bounce-pending'] == 1, 60 | dataframe['close'], 61 | dataframe['close'].rolling(params['bounce-lookback'], min_periods=1).min() #min/max/mean? 62 | ) 63 | 64 | dataframe['bounce-range'] = np.where(dataframe['bounce-pending'].rolling(params['bounce-lookback'], min_periods=1).sum() >= 1,1,0) 65 | 66 | conditions.append( 67 | (dataframe[f"rsi_{inf_timeframe}"] > params['up-inf-rsi']) & 68 | (dataframe['bounce-range'] == 1) & 69 | (dataframe['rmi-up-trend'] == 1) & 70 | # 3 (dataframe['rmi-slow'] < params['up-rmi-slow']) & 71 | # 3 (dataframe['rmi-fast'] > params['up-rmi-fast']) & 72 | (dataframe['close'] > dataframe['bounce-price']) 73 | ) 74 | 75 | """ 76 | if stake_currency in ('BTC', 'ETH'): 77 | conditions.append( 78 | (dataframe[f"{stake_currency}_rsi"] > params['xtf-stake-rsi']) | 79 | (dataframe[f"{fiat}_rsi"] < params['xtf-fiat-rsi']) 80 | ) 81 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xinf-stake-rmi']) 82 | """ 83 | 84 | conditions.append(dataframe['volume'].gt(0)) 85 | 86 | if conditions: 87 | dataframe.loc[ 88 | reduce(lambda x, y: x & y, conditions), 89 | 'buy'] = 1 90 | return dataframe 91 | 92 | return populate_buy_trend 93 | 94 | @staticmethod 95 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 96 | 97 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 98 | 99 | conditions.append((dataframe['rmi-dn-trend'] == 1)) 100 | conditions.append( 101 | qtpylib.crossed_below(dataframe['rmi-slow'], params['rmi-high']) | 102 | qtpylib.crossed_below(dataframe['rmi-slow'], params['rmi-low']) 103 | ) 104 | 105 | conditions.append(dataframe['volume'].gt(0)) 106 | 107 | if conditions: 108 | dataframe.loc[ 109 | reduce(lambda x, y: x & y, conditions), 110 | 'sell'] = 1 111 | 112 | return dataframe 113 | 114 | return populate_sell_trend -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SchismLessHyp.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | 12 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 13 | 14 | # -------------------------------- 15 | # Add your lib to import here 16 | import talib.abstract as ta # noqa 17 | import freqtrade.vendor.qtpylib.indicators as qtpylib 18 | 19 | class SchismHyp(IHyperOpt): 20 | 21 | @staticmethod 22 | def indicator_space() -> List[Dimension]: 23 | return [ 24 | Integer(15, 70, name='rmi-slow'), 25 | Integer(10, 50, name='rmi-fast'), 26 | Integer(10, 70, name='mp'), 27 | Integer(10, 70, name='inf-rsi') 28 | ] 29 | 30 | @staticmethod 31 | def sell_indicator_space() -> List[Dimension]: 32 | return [] 33 | 34 | @staticmethod 35 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 36 | 37 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 38 | 39 | inf_timeframe = '4h' 40 | conditions = [] 41 | 42 | conditions.append( 43 | (dataframe[f"rsi_{inf_timeframe}"] < params['inf-rsi']) & 44 | (dataframe['rmi-dn-trend'] == 1) & 45 | (dataframe['rmi-slow'] >= params['rmi-slow']) & 46 | (dataframe['rmi-fast'] <= params['rmi-fast']) & 47 | (dataframe['mp'] <= params['mp']) 48 | ) 49 | 50 | conditions.append(dataframe['volume'].gt(0)) 51 | 52 | if conditions: 53 | dataframe.loc[ 54 | reduce(lambda x, y: x & y, conditions), 55 | 'buy'] = 1 56 | return dataframe 57 | 58 | return populate_buy_trend 59 | 60 | @staticmethod 61 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 62 | """ 63 | Define the sell strategy parameters to be used by Hyperopt. 64 | """ 65 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 66 | """ 67 | no sell signal 68 | """ 69 | dataframe['sell'] = 0 70 | return dataframe 71 | 72 | return populate_sell_trend 73 | 74 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 75 | """ 76 | no sell signal 77 | """ 78 | dataframe['sell'] = 0 79 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SolipsisHyp-Con-v1.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class SolipsisConHyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | Integer(0, 100, name='consensus-buy'), 20 | # Informative Timeframe 21 | Categorical(['lower', 'upper', 'both', 'none'], name='inf-guard'), 22 | Real(0.70, 0.99, name='inf-pct-adr-top'), 23 | Real(0.01, 0.20, name='inf-pct-adr-bot'), 24 | # Extra BTC/ETH Stakes 25 | Integer(10, 70, name='xtra-inf-stake-rmi'), 26 | Integer(10, 70, name='xtra-base-stake-rmi'), 27 | Integer(10, 70, name='xtra-base-fiat-rmi'), 28 | # Extra BTC/STAKE if not in whitelist 29 | Integer(0, 100, name='xbtc-consensus-buy') 30 | ] 31 | 32 | @staticmethod 33 | def sell_indicator_space() -> List[Dimension]: 34 | return [ 35 | Integer(0, 100, name='consensus-sell') 36 | ] 37 | 38 | @staticmethod 39 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 40 | 41 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 42 | conditions = [] 43 | 44 | inf_timeframe = '1h' 45 | stake_currency = 'USD' 46 | custom_fiat = 'USD' 47 | btc_in_whitelist = False 48 | 49 | if params['inf-guard'] == 'upper' or params['inf-guard'] == 'both': 50 | conditions.append( 51 | (dataframe['close'] <= dataframe[f"3d_low_{inf_timeframe}"] + 52 | (params['inf-pct-adr-top'] * dataframe[f"adr_{inf_timeframe}"])) 53 | ) 54 | 55 | if params['inf-guard'] == 'lower' or params['inf-guard'] == 'both': 56 | conditions.append( 57 | (dataframe['close'] >= dataframe[f"3d_low_{inf_timeframe}"] + 58 | (params['inf-pct-adr-bot'] * dataframe[f"adr_{inf_timeframe}"])) 59 | ) 60 | 61 | conditions.append(dataframe['consensus_buy'] > params['consensus-buy']) 62 | 63 | if stake_currency in ('BTC', 'ETH'): 64 | conditions.append( 65 | (dataframe[f"{stake_currency}_rmi"] < params['xtra-base-stake-rmi']) | 66 | (dataframe[f"{custom_fiat}_rmi"] > params['xtra-base-fiat-rmi']) 67 | ) 68 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xtra-inf-stake-rmi']) 69 | else: 70 | if btc_in_whitelist == False: 71 | conditions.append(dataframe['BTC_consensus_buy'] > params['xbtc-consensus-buy']) 72 | 73 | conditions.append(dataframe['volume'].gt(0)) 74 | 75 | if conditions: 76 | dataframe.loc[ 77 | reduce(lambda x, y: x & y, conditions), 78 | 'buy'] = 1 79 | return dataframe 80 | 81 | return populate_buy_trend 82 | 83 | @staticmethod 84 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 85 | 86 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 87 | conditions = [] 88 | 89 | conditions.append(dataframe['consensus_sell'] > params['consensus-sell']) 90 | 91 | if conditions: 92 | dataframe.loc[ 93 | reduce(lambda x, y: x & y, conditions), 94 | 'sell'] = 1 95 | 96 | # dataframe['sell'] = 0 97 | return dataframe 98 | 99 | return populate_sell_trend 100 | 101 | # If not optimizing the sell space assume it is disabled entirely. 102 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 103 | 104 | dataframe['sell'] = 0 105 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SolipsisHyp-Con.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class SolipsisConHyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | Integer(0, 100, name='consensus-buy'), 20 | # Informative Timeframe 21 | Categorical(['lower', 'upper', 'both', 'none'], name='inf-guard'), 22 | Real(0.70, 0.99, name='inf-pct-adr-top'), 23 | Real(0.01, 0.20, name='inf-pct-adr-bot'), 24 | # Extra BTC/ETH Stakes 25 | Integer(10, 70, name='xtra-inf-stake-rmi'), 26 | Integer(10, 70, name='xtra-base-stake-rmi'), 27 | Integer(10, 70, name='xtra-base-fiat-rmi'), 28 | # Extra BTC/STAKE if not in whitelist 29 | Integer(0, 100, name='xbtc-consensus-buy') 30 | ] 31 | 32 | @staticmethod 33 | def sell_indicator_space() -> List[Dimension]: 34 | return [ 35 | Integer(0, 100, name='consensus-sell') 36 | ] 37 | 38 | @staticmethod 39 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 40 | 41 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 42 | conditions = [] 43 | 44 | inf_timeframe = '1h' 45 | stake_currency = 'USD' 46 | custom_fiat = 'USD' 47 | btc_in_whitelist = False 48 | 49 | if params['inf-guard'] == 'upper' or params['inf-guard'] == 'both': 50 | conditions.append( 51 | (dataframe['close'] <= dataframe[f"3d_low_{inf_timeframe}"] + 52 | (params['inf-pct-adr-top'] * dataframe[f"adr_{inf_timeframe}"])) 53 | ) 54 | 55 | if params['inf-guard'] == 'lower' or params['inf-guard'] == 'both': 56 | conditions.append( 57 | (dataframe['close'] >= dataframe[f"3d_low_{inf_timeframe}"] + 58 | (params['inf-pct-adr-bot'] * dataframe[f"adr_{inf_timeframe}"])) 59 | ) 60 | 61 | conditions.append(dataframe['consensus_buy'] > params['consensus-buy']) 62 | 63 | if stake_currency in ('BTC', 'ETH'): 64 | conditions.append( 65 | (dataframe[f"{stake_currency}_rmi"] < params['xtra-base-stake-rmi']) | 66 | (dataframe[f"{custom_fiat}_rmi"] > params['xtra-base-fiat-rmi']) 67 | ) 68 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xtra-inf-stake-rmi']) 69 | else: 70 | if btc_in_whitelist == False: 71 | conditions.append(dataframe['BTC_consensus_buy'] > params['xbtc-consensus-buy']) 72 | 73 | conditions.append(dataframe['volume'].gt(0)) 74 | 75 | if conditions: 76 | dataframe.loc[ 77 | reduce(lambda x, y: x & y, conditions), 78 | 'buy'] = 1 79 | return dataframe 80 | 81 | return populate_buy_trend 82 | 83 | @staticmethod 84 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 85 | 86 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 87 | conditions = [] 88 | 89 | conditions.append(dataframe['consensus_sell'] > params['consensus-sell']) 90 | 91 | if conditions: 92 | dataframe.loc[ 93 | reduce(lambda x, y: x & y, conditions), 94 | 'sell'] = 1 95 | 96 | # dataframe['sell'] = 0 97 | return dataframe 98 | 99 | return populate_sell_trend 100 | 101 | # If not optimizing the sell space assume it is disabled entirely. 102 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 103 | 104 | dataframe['sell'] = 0 105 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SolipsisHyp-v1.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class SolipsisHyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | # Base Timeframe 20 | Categorical(['up', 'down'], name='base-trend'), 21 | Categorical([True, False], name='base-pmax-enable'), 22 | Categorical(['up', 'down'], name='base-pmax'), 23 | Integer(10, 90, name='base-rmi-slow'), 24 | Integer(10, 90, name='base-rmi-fast'), 25 | Integer(10, 90, name='base-mp'), 26 | Categorical([1.0, 0.786, 0.618, 0.5, 0.382, 0.236, 0.0], name='base-fib-level'), 27 | # Informative Timeframe 28 | Integer(10, 70, name='inf-rsi'), 29 | Categorical(['lower', 'upper', 'both', 'none'], name='inf-guard'), 30 | Real(0.70, 0.99, name='inf-pct-adr-top'), 31 | Real(0.01, 0.20, name='inf-pct-adr-bot'), 32 | Categorical([1.0, 0.786, 0.618, 0.5, 0.382, 0.236, 0.0], name='inf-fib-level'), 33 | # Exra BTC/ETH Stakes 34 | Integer(10, 70, name='xtra-inf-stake-rmi'), 35 | Integer(10, 70, name='xtra-base-stake-rsi'), 36 | Integer(10, 70, name='xtra-base-fiat-rsi') 37 | ] 38 | 39 | @staticmethod 40 | def sell_indicator_space() -> List[Dimension]: 41 | return [ 42 | Real(0.10, 0.90, name='sell-rmi-drop'), 43 | Categorical([True, False], name='sell-pmax-enable'), 44 | ] 45 | 46 | @staticmethod 47 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 48 | 49 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 50 | conditions = [] 51 | 52 | inf_timeframe = '1h' 53 | stake_currency = 'USD' 54 | custom_fiat = 'USD' 55 | 56 | if params['inf-guard'] == 'upper' or params['inf-guard'] == 'both': 57 | conditions.append( 58 | (dataframe['close'] <= dataframe[f"3d_low_{inf_timeframe}"] + 59 | (params['inf-pct-adr-top'] * dataframe[f"adr_{inf_timeframe}"])) 60 | ) 61 | 62 | if params['inf-guard'] == 'lower' or params['inf-guard'] == 'both': 63 | conditions.append( 64 | (dataframe['close'] >= dataframe[f"3d_low_{inf_timeframe}"] + 65 | (params['inf-pct-adr-bot'] * dataframe[f"adr_{inf_timeframe}"])) 66 | ) 67 | 68 | conditions.append( 69 | (dataframe[f"rsi_{inf_timeframe}"] >= params['inf-rsi']) & 70 | (dataframe[f"fib-ret_{inf_timeframe}"] >= params['inf-fib-level']) 71 | ) 72 | 73 | if params['base-pmax-enable'] == True: 74 | conditions.append((dataframe['pmax-trend'] == params['base-pmax'])) 75 | 76 | if params['base-trend'] == 'down': 77 | conditions.append( 78 | (dataframe['fib-ret'] <= params['base-fib-level']) & 79 | (dataframe['rmi-dn-trend'] == 1) & 80 | (dataframe['rmi-slow'] >= params['base-rmi-slow']) & 81 | (dataframe['rmi-fast'] <= params['base-rmi-fast']) & 82 | (dataframe['mp'] <= params['base-mp']) 83 | ) 84 | 85 | elif params['base-trend'] == 'up': 86 | conditions.append( 87 | (dataframe['fib-ret'] >= params['base-fib-level']) & 88 | (dataframe['rmi-up-trend'] == 1) & 89 | (dataframe['rmi-slow'] <= params['base-rmi-slow']) & 90 | (dataframe['rmi-fast'] >= params['base-rmi-fast']) & 91 | (dataframe['mp'] >= params['base-mp']) 92 | ) 93 | 94 | if stake_currency in ('BTC', 'ETH'): 95 | conditions.append( 96 | (dataframe[f"{stake_currency}_rsi"] < params['xtra-base-stake-rsi']) | 97 | (dataframe[f"{custom_fiat}_rsi"] > params['xtra-base-fiat-rsi']) 98 | ) 99 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xtra-inf-stake-rmi']) 100 | 101 | conditions.append(dataframe['volume'].gt(0)) 102 | 103 | if conditions: 104 | dataframe.loc[ 105 | reduce(lambda x, y: x & y, conditions), 106 | 'buy'] = 1 107 | return dataframe 108 | 109 | return populate_buy_trend 110 | 111 | @staticmethod 112 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 113 | 114 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 115 | conditions = [] 116 | 117 | rmi_drop = dataframe['rmi-max'] - (dataframe['rmi-max'] * params['sell-rmi-drop']) 118 | conditions.append( 119 | (dataframe['rmi-dn-trend'] == 1) & 120 | (qtpylib.crossed_below(dataframe['rmi-slow'], rmi_drop)) & 121 | (dataframe['volume'].gt(0)) 122 | ) 123 | 124 | if params['sell-pmax-enable'] == True: 125 | conditions.append((dataframe['pmax-trend'] == 'down')) 126 | 127 | if conditions: 128 | dataframe.loc[ 129 | reduce(lambda x, y: x & y, conditions), 130 | 'sell'] = 1 131 | 132 | # dataframe['sell'] = 0 133 | return dataframe 134 | 135 | return populate_sell_trend 136 | 137 | # If not optimizing the sell space assume it is disabled entirely. 138 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 139 | 140 | dataframe['sell'] = 0 141 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SolipsisHyp-v2.4.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class SolipsisHyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | Integer(0, 100, name='consensus-buy'), 20 | # Informative Timeframe 21 | Categorical(['lower', 'upper', 'both', 'none'], name='inf-guard'), 22 | Real(0.70, 0.99, name='inf-pct-adr-top'), 23 | Real(0.01, 0.20, name='inf-pct-adr-bot'), 24 | # Extra BTC/ETH Stakes 25 | Integer(10, 70, name='xtra-inf-stake-rmi'), 26 | Integer(10, 70, name='xtra-base-stake-rmi'), 27 | Integer(10, 70, name='xtra-base-fiat-rmi'), 28 | # Extra BTC/STAKE if not in whitelist 29 | Integer(0, 100, name='xbtc-consensus-buy') 30 | ] 31 | 32 | @staticmethod 33 | def sell_indicator_space() -> List[Dimension]: 34 | return [] 35 | 36 | @staticmethod 37 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 38 | 39 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 40 | conditions = [] 41 | 42 | inf_timeframe = '1h' 43 | stake_currency = 'USD' 44 | custom_fiat = 'USD' 45 | btc_in_whitelist = False 46 | 47 | if params['inf-guard'] == 'upper' or params['inf-guard'] == 'both': 48 | conditions.append( 49 | (dataframe['close'] <= dataframe[f"3d_low_{inf_timeframe}"] + 50 | (params['inf-pct-adr-top'] * dataframe[f"adr_{inf_timeframe}"])) 51 | ) 52 | 53 | if params['inf-guard'] == 'lower' or params['inf-guard'] == 'both': 54 | conditions.append( 55 | (dataframe['close'] >= dataframe[f"3d_low_{inf_timeframe}"] + 56 | (params['inf-pct-adr-bot'] * dataframe[f"adr_{inf_timeframe}"])) 57 | ) 58 | 59 | conditions.append(dataframe['consensus-buy'] > params['consensus-buy']) 60 | 61 | if stake_currency in ('BTC', 'ETH'): 62 | conditions.append( 63 | (dataframe[f"{stake_currency}_rmi"] < params['xtra-base-stake-rmi']) | 64 | (dataframe[f"{custom_fiat}_rmi"] > params['xtra-base-fiat-rmi']) 65 | ) 66 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xtra-inf-stake-rmi']) 67 | else: 68 | if btc_in_whitelist == False: 69 | conditions.append(dataframe['BTC_consensus-buy'] > params['xbtc-consensus-buy']) 70 | 71 | conditions.append(dataframe['volume'].gt(0)) 72 | 73 | if conditions: 74 | dataframe.loc[ 75 | reduce(lambda x, y: x & y, conditions), 76 | 'buy'] = 1 77 | return dataframe 78 | 79 | return populate_buy_trend 80 | 81 | @staticmethod 82 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 83 | 84 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 85 | 86 | dataframe['sell'] = 0 87 | return dataframe 88 | 89 | return populate_sell_trend 90 | 91 | # If not optimizing the sell space assume it is disabled entirely. 92 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 93 | 94 | dataframe['sell'] = 0 95 | return dataframe 96 | 97 | @staticmethod 98 | def generate_roi_table(params: Dict) -> Dict[int, float]: 99 | 100 | roi_table = {} 101 | roi_table[0] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] + params['roi_p6'] 102 | roi_table[params['roi_t6']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] 103 | roi_table[params['roi_t6'] + params['roi_t5']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] 104 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] 105 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3']] = params['roi_p1'] + params['roi_p2'] 106 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2']] = params['roi_p1'] 107 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2'] + params['roi_t1']] = 0 108 | 109 | return roi_table 110 | 111 | @staticmethod 112 | def roi_space() -> List[Dimension]: 113 | # min / max min / max 114 | return [ # 0 : 0.100 / 0.205 115 | Integer(1, 20, name='roi_t6'), # 1 -> 20 : 0.050 / 0.105 116 | Integer(10, 20, name='roi_t5'), # 11 -> 40 : 0.030 / 0.055 117 | Integer(10, 20, name='roi_t4'), # 21 -> 60 : 0.015 / 0.035 118 | Integer(15, 30, name='roi_t3'), # 36 -> 90 : 0.010 / 0.020 119 | Integer(264, 630, name='roi_t2'), # 300 -> 720 : 0.005 / 0.010 120 | Integer(420, 720, name='roi_t1'), # 720 -> 1440 : 0 121 | 122 | Real(0.05, 0.10, name='roi_p6'), 123 | Real(0.02, 0.05, name='roi_p5'), 124 | Real(0.015, 0.020, name='roi_p4'), 125 | Real(0.005, 0.015, name='roi_p3'), 126 | Real(0.005, 0.01, name='roi_p2'), 127 | Real(0.005, 0.01, name='roi_p1'), 128 | ] 129 | 130 | @staticmethod 131 | def stoploss_space() -> List[Dimension]: 132 | 133 | return [ 134 | Real(-0.99, -0.01, name='stoploss'), 135 | ] -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SolipsisHyp-v2.5.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class Solipsis5Hyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | # Base Timeframe 20 | Integer(5, 15, name='base-yolo'), 21 | # Informative Timeframe 22 | Categorical(['lower', 'upper', 'both', 'none'], name='inf-guard'), 23 | Real(0.70, 0.99, name='inf-pct-adr-top'), 24 | Real(0.01, 0.20, name='inf-pct-adr-bot'), 25 | # Extra BTC/ETH Stakes 26 | Integer(10, 70, name='xtra-inf-stake-rmi'), 27 | Integer(10, 70, name='xtra-base-stake-rmi'), 28 | Integer(10, 70, name='xtra-base-fiat-rmi'), 29 | # Extra BTC/STAKE if not in whitelist 30 | Integer(10, 70, name='xbtc-base-rmi'), 31 | Integer(10, 70, name='xbtc-inf-rmi') 32 | ] 33 | 34 | @staticmethod 35 | def sell_indicator_space() -> List[Dimension]: 36 | return [] 37 | 38 | @staticmethod 39 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 40 | 41 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 42 | conditions = [] 43 | 44 | inf_timeframe = '1h' 45 | stake_currency = 'USD' 46 | custom_fiat = 'USD' 47 | btc_in_whitelist = False 48 | 49 | if params['inf-guard'] == 'upper' or params['inf-guard'] == 'both': 50 | conditions.append( 51 | (dataframe['close'] <= dataframe[f"3d_low_{inf_timeframe}"] + 52 | (params['inf-pct-adr-top'] * dataframe[f"adr_{inf_timeframe}"])) 53 | ) 54 | 55 | if params['inf-guard'] == 'lower' or params['inf-guard'] == 'both': 56 | conditions.append( 57 | (dataframe['close'] >= dataframe[f"3d_low_{inf_timeframe}"] + 58 | (params['inf-pct-adr-bot'] * dataframe[f"adr_{inf_timeframe}"])) 59 | ) 60 | 61 | # YOLO ON THE BASE 62 | conditions.append(dataframe['yolo'] > params['base-yolo']) 63 | 64 | if stake_currency in ('BTC', 'ETH'): 65 | conditions.append( 66 | (dataframe[f"{stake_currency}_rmi"] < params['xtra-base-stake-rmi']) | 67 | (dataframe[f"{custom_fiat}_rmi"] > params['xtra-base-fiat-rmi']) 68 | ) 69 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xtra-inf-stake-rmi']) 70 | else: 71 | if btc_in_whitelist == False: 72 | conditions.append( 73 | (dataframe['BTC_rmi'] < params['xbtc-base-rmi']) & 74 | (dataframe[f"BTC_rmi_{inf_timeframe}"] > params['xbtc-inf-rmi']) 75 | ) 76 | 77 | conditions.append(dataframe['volume'].gt(0)) 78 | 79 | if conditions: 80 | dataframe.loc[ 81 | reduce(lambda x, y: x & y, conditions), 82 | 'buy'] = 1 83 | return dataframe 84 | 85 | return populate_buy_trend 86 | 87 | @staticmethod 88 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 89 | 90 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 91 | 92 | dataframe['sell'] = 0 93 | return dataframe 94 | 95 | return populate_sell_trend 96 | 97 | # If not optimizing the sell space assume it is disabled entirely. 98 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 99 | 100 | dataframe['sell'] = 0 101 | return dataframe 102 | 103 | @staticmethod 104 | def generate_roi_table(params: Dict) -> Dict[int, float]: 105 | 106 | roi_table = {} 107 | roi_table[0] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] + params['roi_p6'] 108 | roi_table[params['roi_t6']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] 109 | roi_table[params['roi_t6'] + params['roi_t5']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] 110 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] 111 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3']] = params['roi_p1'] + params['roi_p2'] 112 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2']] = params['roi_p1'] 113 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2'] + params['roi_t1']] = 0 114 | 115 | return roi_table 116 | 117 | @staticmethod 118 | def roi_space() -> List[Dimension]: 119 | # min / max min / max 120 | return [ # 0 : 0.100 / 0.205 121 | Integer(1, 20, name='roi_t6'), # 1 -> 20 : 0.050 / 0.105 122 | Integer(10, 20, name='roi_t5'), # 11 -> 40 : 0.030 / 0.055 123 | Integer(10, 20, name='roi_t4'), # 21 -> 60 : 0.015 / 0.035 124 | Integer(15, 30, name='roi_t3'), # 36 -> 90 : 0.010 / 0.020 125 | Integer(264, 630, name='roi_t2'), # 300 -> 720 : 0.005 / 0.010 126 | Integer(420, 720, name='roi_t1'), # 720 -> 1440 : 0 127 | 128 | Real(0.05, 0.10, name='roi_p6'), 129 | Real(0.02, 0.05, name='roi_p5'), 130 | Real(0.015, 0.020, name='roi_p4'), 131 | Real(0.005, 0.015, name='roi_p3'), 132 | Real(0.005, 0.01, name='roi_p2'), 133 | Real(0.005, 0.01, name='roi_p1'), 134 | ] 135 | 136 | @staticmethod 137 | def stoploss_space() -> List[Dimension]: 138 | 139 | return [ 140 | Real(-0.99, -0.01, name='stoploss'), 141 | ] -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SolipsisHyp-v2.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class SolipsisHyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | # Base Timeframe 20 | Integer(20, 70, name='base-rmi-slow'), 21 | Integer(10, 50, name='base-rmi-fast'), 22 | Integer(10, 50, name='base-mp'), 23 | # Informative Timeframe 24 | Categorical(['lower', 'upper', 'both', 'none'], name='inf-guard'), 25 | Real(0.70, 0.99, name='inf-pct-adr-top'), 26 | Real(0.01, 0.20, name='inf-pct-adr-bot'), 27 | # Extra BTC/ETH Stakes 28 | Integer(10, 70, name='xtra-inf-stake-rmi'), 29 | Integer(10, 70, name='xtra-base-stake-rmi'), 30 | Integer(10, 70, name='xtra-base-fiat-rmi'), 31 | # Extra BTC/STAKE if not in whitelist 32 | Integer(10, 70, name='xbtc-base-rmi'), 33 | Integer(10, 70, name='xbtc-inf-rmi') 34 | ] 35 | 36 | @staticmethod 37 | def sell_indicator_space() -> List[Dimension]: 38 | return [ 39 | Real(0.10, 0.90, name='sell-rmi-drop') 40 | ] 41 | 42 | @staticmethod 43 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 44 | 45 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 46 | conditions = [] 47 | 48 | inf_timeframe = '1h' 49 | stake_currency = 'USD' 50 | custom_fiat = 'USD' 51 | btc_in_whitelist = False 52 | 53 | if params['inf-guard'] == 'upper' or params['inf-guard'] == 'both': 54 | conditions.append( 55 | (dataframe['close'] <= dataframe[f"3d_low_{inf_timeframe}"] + 56 | (params['inf-pct-adr-top'] * dataframe[f"adr_{inf_timeframe}"])) 57 | ) 58 | 59 | if params['inf-guard'] == 'lower' or params['inf-guard'] == 'both': 60 | conditions.append( 61 | (dataframe['close'] >= dataframe[f"3d_low_{inf_timeframe}"] + 62 | (params['inf-pct-adr-bot'] * dataframe[f"adr_{inf_timeframe}"])) 63 | ) 64 | 65 | conditions.append( 66 | (dataframe['rmi-dn-trend'] == 1) & 67 | (dataframe['rmi-slow'] >= params['base-rmi-slow']) & 68 | (dataframe['rmi-fast'] <= params['base-rmi-fast']) & 69 | (dataframe['mp'] <= params['base-mp']) 70 | ) 71 | 72 | if stake_currency in ('BTC', 'ETH'): 73 | conditions.append( 74 | (dataframe[f"{stake_currency}_rmi"] < params['xtra-base-stake-rmi']) | 75 | (dataframe[f"{custom_fiat}_rmi"] > params['xtra-base-fiat-rmi']) 76 | ) 77 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xtra-inf-stake-rmi']) 78 | else: 79 | if btc_in_whitelist == False: 80 | conditions.append( 81 | (dataframe['BTC_rmi'] < params['xbtc-base-rmi']) & 82 | (dataframe[f"BTC_rmi_{inf_timeframe}"] > params['xbtc-inf-rmi']) 83 | ) 84 | 85 | conditions.append(dataframe['volume'].gt(0)) 86 | 87 | if conditions: 88 | dataframe.loc[ 89 | reduce(lambda x, y: x & y, conditions), 90 | 'buy'] = 1 91 | return dataframe 92 | 93 | return populate_buy_trend 94 | 95 | @staticmethod 96 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 97 | 98 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 99 | conditions = [] 100 | 101 | rmi_drop = dataframe['rmi-max'] - (dataframe['rmi-max'] * params['sell-rmi-drop']) 102 | conditions.append( 103 | (dataframe['rmi-dn-trend'] == 1) & 104 | (qtpylib.crossed_below(dataframe['rmi-slow'], rmi_drop)) & 105 | (dataframe['volume'].gt(0)) 106 | ) 107 | 108 | if conditions: 109 | dataframe.loc[ 110 | reduce(lambda x, y: x & y, conditions), 111 | 'sell'] = 1 112 | 113 | # dataframe['sell'] = 0 114 | return dataframe 115 | 116 | return populate_sell_trend 117 | 118 | # If not optimizing the sell space assume it is disabled entirely. 119 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 120 | 121 | dataframe['sell'] = 0 122 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/SolipsisMMHyp.py: -------------------------------------------------------------------------------- 1 | from functools import reduce 2 | from typing import Any, Callable, Dict, List 3 | 4 | import numpy as np 5 | import pandas as pd 6 | from pandas import DataFrame 7 | from skopt.space import Categorical, Dimension, Integer, Real 8 | 9 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 10 | 11 | import talib.abstract as ta 12 | import freqtrade.vendor.qtpylib.indicators as qtpylib 13 | 14 | class SolipsisMMHyp(IHyperOpt): 15 | 16 | @staticmethod 17 | def indicator_space() -> List[Dimension]: 18 | return [ 19 | # Base Timeframe 20 | Categorical(['up', 'down'], name='base-trend'), 21 | Categorical([True, False], name='base-pmax-enable'), 22 | Categorical(['up', 'down'], name='base-pmax'), 23 | Integer(10, 90, name='base-rmi-slow'), 24 | Integer(10, 90, name='base-rmi-fast'), 25 | Integer(10, 90, name='base-mp'), 26 | Categorical([1.0, 0.786, 0.618, 0.5, 0.382, 0.236, 0.0], name='base-fib-level'), 27 | # Informative Timeframe 28 | Integer(10, 70, name='inf-rsi'), 29 | Categorical(['lower', 'upper', 'both', 'none'], name='inf-guard'), 30 | Real(0.70, 0.99, name='inf-pct-adr-top'), 31 | Real(0.01, 0.20, name='inf-pct-adr-bot'), 32 | Categorical([1.0, 0.786, 0.618, 0.5, 0.382, 0.236, 0.0], name='inf-fib-level'), 33 | # Exra BTC/ETH Stakes 34 | Integer(10, 70, name='xtra-inf-stake-rmi'), 35 | Integer(10, 70, name='xtra-base-stake-rsi'), 36 | Integer(10, 70, name='xtra-base-fiat-rsi') 37 | ] 38 | 39 | @staticmethod 40 | def sell_indicator_space() -> List[Dimension]: 41 | return [ 42 | Real(0.10, 0.90, name='sell-rmi-drop'), 43 | Categorical([True, False], name='sell-pmax-enable'), 44 | ] 45 | 46 | @staticmethod 47 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 48 | 49 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 50 | conditions = [] 51 | 52 | inf_timeframe = '1h' 53 | stake_currency = 'USD' 54 | custom_fiat = 'USD' 55 | 56 | if params['inf-guard'] == 'upper' or params['inf-guard'] == 'both': 57 | conditions.append( 58 | (dataframe['close'] <= dataframe[f"3d_low_{inf_timeframe}"] + 59 | (params['inf-pct-adr-top'] * dataframe[f"adr_{inf_timeframe}"])) 60 | ) 61 | 62 | if params['inf-guard'] == 'lower' or params['inf-guard'] == 'both': 63 | conditions.append( 64 | (dataframe['close'] >= dataframe[f"3d_low_{inf_timeframe}"] + 65 | (params['inf-pct-adr-bot'] * dataframe[f"adr_{inf_timeframe}"])) 66 | ) 67 | 68 | conditions.append( 69 | (dataframe[f"rsi_{inf_timeframe}"] >= params['inf-rsi']) & 70 | (dataframe[f"fib-ret_{inf_timeframe}"] >= params['inf-fib-level']) 71 | ) 72 | 73 | if params['base-pmax-enable'] == True: 74 | conditions.append((dataframe['pmax-trend'] == params['base-pmax'])) 75 | 76 | if params['base-trend'] == 'down': 77 | conditions.append( 78 | (dataframe['fib-ret'] <= params['base-fib-level']) & 79 | (dataframe['rmi-dn-trend'] == 1) & 80 | (dataframe['rmi-slow'] >= params['base-rmi-slow']) & 81 | (dataframe['rmi-fast'] <= params['base-rmi-fast']) & 82 | (dataframe['mp'] <= params['base-mp']) 83 | ) 84 | 85 | elif params['base-trend'] == 'up': 86 | conditions.append( 87 | (dataframe['fib-ret'] >= params['base-fib-level']) & 88 | (dataframe['rmi-up-trend'] == 1) & 89 | (dataframe['rmi-slow'] <= params['base-rmi-slow']) & 90 | (dataframe['rmi-fast'] >= params['base-rmi-fast']) & 91 | (dataframe['mp'] >= params['base-mp']) 92 | ) 93 | 94 | if stake_currency in ('BTC', 'ETH'): 95 | conditions.append( 96 | (dataframe[f"{stake_currency}_rsi"] < params['xtra-base-stake-rsi']) | 97 | (dataframe[f"{custom_fiat}_rsi"] > params['xtra-base-fiat-rsi']) 98 | ) 99 | conditions.append(dataframe[f"{stake_currency}_rmi_{inf_timeframe}"] < params['xtra-inf-stake-rmi']) 100 | 101 | conditions.append(dataframe['buy_signal']) 102 | conditions.append(dataframe['volume'].gt(0)) 103 | 104 | if conditions: 105 | dataframe.loc[ 106 | reduce(lambda x, y: x & y, conditions), 107 | 'buy'] = 1 108 | return dataframe 109 | 110 | return populate_buy_trend 111 | 112 | @staticmethod 113 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 114 | 115 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 116 | conditions = [] 117 | 118 | rmi_drop = dataframe['rmi-max'] - (dataframe['rmi-max'] * params['sell-rmi-drop']) 119 | conditions.append( 120 | (dataframe['rmi-dn-trend'] == 1) & 121 | (qtpylib.crossed_below(dataframe['rmi-slow'], rmi_drop)) & 122 | (dataframe['volume'].gt(0)) 123 | ) 124 | 125 | if params['sell-pmax-enable'] == True: 126 | conditions.append((dataframe['pmax-trend'] == 'down')) 127 | 128 | if conditions: 129 | dataframe.loc[ 130 | reduce(lambda x, y: x & y, conditions), 131 | 'sell'] = 1 132 | 133 | # dataframe['sell'] = 0 134 | return dataframe 135 | 136 | return populate_sell_trend 137 | 138 | # If not optimizing the sell space assume it is disabled entirely. 139 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 140 | 141 | dataframe['sell'] = 0 142 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/StinkfistHyp.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | 12 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 13 | 14 | # -------------------------------- 15 | # Add your lib to import here 16 | import talib.abstract as ta # noqa 17 | import freqtrade.vendor.qtpylib.indicators as qtpylib 18 | 19 | class StinkfistHyp(IHyperOpt): 20 | 21 | @staticmethod 22 | def indicator_space() -> List[Dimension]: 23 | return [ 24 | Integer(5, 70, name='mp'), 25 | Real(0.70, 0.99, name='inf-pct-adr') 26 | ] 27 | 28 | @staticmethod 29 | def sell_indicator_space() -> List[Dimension]: 30 | return [] 31 | 32 | @staticmethod 33 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 34 | 35 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 36 | 37 | inf_timeframe = '1h' 38 | conditions = [] 39 | 40 | # Primary buy triggers 41 | conditions.append( 42 | # informative timeframe conditions 43 | (dataframe['close'] <= dataframe[f"3d_low_{inf_timeframe}"] + (params['inf-pct-adr'] * dataframe[f"adr_{inf_timeframe}"])) & 44 | # default timeframe conditions 45 | (dataframe['mp'] < params['mp']) & 46 | (dataframe['streak-roc'] > dataframe['pcc-lowerband']) & 47 | (dataframe['mac'] == 1) 48 | ) 49 | 50 | # Anything below here applies to persisting and new buy signal 51 | conditions.append(dataframe['volume'].gt(0)) 52 | 53 | if conditions: 54 | dataframe.loc[ 55 | reduce(lambda x, y: x & y, conditions), 56 | 'buy'] = 1 57 | return dataframe 58 | 59 | return populate_buy_trend 60 | 61 | @staticmethod 62 | def generate_roi_table(params: Dict) -> Dict[int, float]: 63 | 64 | roi_table = {} 65 | roi_table[0] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] + params['roi_p6'] 66 | roi_table[params['roi_t6']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] 67 | roi_table[params['roi_t6'] + params['roi_t5']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] 68 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] 69 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3']] = params['roi_p1'] + params['roi_p2'] 70 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2']] = params['roi_p1'] 71 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2'] + params['roi_t1']] = 0 72 | 73 | return roi_table 74 | 75 | @staticmethod 76 | def roi_space() -> List[Dimension]: 77 | # min / max min / max 78 | return [ # 0 : 0.100 / 0.205 79 | Integer(1, 20, name='roi_t6'), # 1 -> 20 : 0.050 / 0.105 80 | Integer(10, 20, name='roi_t5'), # 11 -> 40 : 0.030 / 0.055 81 | Integer(10, 20, name='roi_t4'), # 21 -> 60 : 0.015 / 0.035 82 | Integer(15, 30, name='roi_t3'), # 36 -> 90 : 0.010 / 0.020 83 | Integer(264, 630, name='roi_t2'), # 300 -> 720 : 0.005 / 0.010 84 | Integer(420, 720, name='roi_t1'), # 720 -> 1440 : 0 85 | 86 | Real(0.05, 0.10, name='roi_p6'), 87 | Real(0.02, 0.05, name='roi_p5'), 88 | Real(0.015, 0.020, name='roi_p4'), 89 | Real(0.005, 0.015, name='roi_p3'), 90 | Real(0.005, 0.01, name='roi_p2'), 91 | Real(0.005, 0.01, name='roi_p1'), 92 | ] 93 | 94 | @staticmethod 95 | def stoploss_space() -> List[Dimension]: 96 | 97 | return [ 98 | Real(-0.99, -0.01, name='stoploss'), 99 | ] 100 | 101 | def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 102 | """ 103 | no sell signal 104 | """ 105 | dataframe['sell'] = 0 106 | return dataframe -------------------------------------------------------------------------------- /strategies/archived/hyperopts/StochRSITEMAHyperopt.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | 12 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 13 | 14 | # -------------------------------- 15 | # Add your lib to import here 16 | import talib.abstract as ta # noqa 17 | import freqtrade.vendor.qtpylib.indicators as qtpylib 18 | 19 | """ 20 | author@: werkkrew 21 | github@: https://github.com/werkkrew/freqtrade-strategies 22 | 23 | Hyperopt for my KAMACCIRSI strategy. 24 | 25 | Optimizes: 26 | - Period for indicators within specified ranges 27 | - RSI and Stoch lower band location 28 | - TEMA trigger method 29 | 30 | Default Ranges for dynamic indicator periods: 31 | 32 | rsiStart = 5 33 | rsiEnd = 30 34 | temaStart = 5 35 | temaEnd = 50 36 | 37 | Default ranges for lower bands: 38 | RSI: 10-50 39 | Stoch: 10-50 40 | 41 | Default Stochasitc Periods: 42 | fastkPeriod = 14 43 | slowkPeriod = 3 44 | slowdPeriod = 3 45 | """ 46 | 47 | # Ranges for dynamic indicator periods 48 | rsiStart = 5 49 | rsiEnd = 30 50 | temaStart = 5 51 | temaEnd = 50 52 | 53 | # Settings for Stochastic 54 | # These do not get optimized 55 | fastkPeriod = 14 56 | slowkPeriod = 3 57 | slowdPeriod = 3 58 | 59 | class StochRSITEMAHyperopt(IHyperOpt): 60 | 61 | @staticmethod 62 | def indicator_space() -> List[Dimension]: 63 | """ 64 | Ranges and Options for BUY strategy 65 | """ 66 | return [ 67 | Integer(10, 50, name='stoch-lower-band'), 68 | Integer(rsiStart, rsiEnd, name='rsi-period'), 69 | Integer(10, 50, name='rsi-lower-band') 70 | ] 71 | 72 | @staticmethod 73 | def sell_indicator_space() -> List[Dimension]: 74 | """ 75 | Ranges and Options for SELL strategy 76 | """ 77 | return [ 78 | Integer(temaStart, temaEnd, name='tema-period'), 79 | Categorical(['close', 'both', 'average'], name='tema-trigger') 80 | ] 81 | 82 | @staticmethod 83 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 84 | """ 85 | Define the buy strategy parameters to be used by Hyperopt. 86 | """ 87 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 88 | """ 89 | Buy strategy Hyperopt will build and use. 90 | """ 91 | conditions = [] 92 | 93 | conditions.append( 94 | dataframe[f"rsi({params['rsi-period']})"] > params['rsi-lower-band']) 95 | conditions.append(qtpylib.crossed_above( 96 | dataframe['stoch-slowd'], params['stoch-lower-band'])) 97 | conditions.append(qtpylib.crossed_above( 98 | dataframe['stoch-slowk'], params['stoch-lower-band'])) 99 | conditions.append(qtpylib.crossed_above( 100 | dataframe['stoch-slowk'], dataframe['stoch-slowd'])) 101 | 102 | # Check that the candle had volume 103 | conditions.append(dataframe['volume'] > 0) 104 | 105 | if conditions: 106 | dataframe.loc[ 107 | reduce(lambda x, y: x & y, conditions), 108 | 'buy'] = 1 109 | 110 | return dataframe 111 | 112 | return populate_buy_trend 113 | 114 | @staticmethod 115 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 116 | """ 117 | Define the sell strategy parameters to be used by Hyperopt. 118 | """ 119 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 120 | """ 121 | Sell strategy Hyperopt will build and use. 122 | """ 123 | 124 | conditions = [] 125 | if params.get('tema-trigger') == 'close': 126 | conditions.append( 127 | dataframe['close'] < dataframe[f"tema({params['tema-period']})"]) 128 | if params.get('tema-trigger') == 'both': 129 | conditions.append((dataframe['close'] < dataframe[f"tema({params['tema-period']})"]) & ( 130 | dataframe['open'] < dataframe[f"tema({params['tema-period']})"])) 131 | if params.get('tema-trigger') == 'average': 132 | conditions.append( 133 | ((dataframe['close'] + dataframe['open']) / 2) < dataframe[f"tema({params['tema-period']})"]) 134 | 135 | # Check that the candle had volume 136 | conditions.append(dataframe['volume'] > 0) 137 | 138 | if conditions: 139 | dataframe.loc[ 140 | reduce(lambda x, y: x & y, conditions), 141 | 'sell'] = 1 142 | 143 | return dataframe 144 | 145 | return populate_sell_trend 146 | 147 | -------------------------------------------------------------------------------- /strategies/archived/hyperopts/YOLOHyp.py: -------------------------------------------------------------------------------- 1 | # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement 2 | 3 | # --- Do not remove these libs --- 4 | from functools import reduce 5 | from typing import Any, Callable, Dict, List 6 | 7 | import numpy as np # noqa 8 | import pandas as pd # noqa 9 | from pandas import DataFrame 10 | from skopt.space import Categorical, Dimension, Integer, Real # noqa 11 | 12 | from freqtrade.optimize.hyperopt_interface import IHyperOpt 13 | 14 | # -------------------------------- 15 | # Add your lib to import here 16 | import talib.abstract as ta # noqa 17 | import freqtrade.vendor.qtpylib.indicators as qtpylib 18 | 19 | class YOLOHyp(IHyperOpt): 20 | 21 | buy_params = { 22 | 'adx': 34, 23 | 'aroon-down': 33, 24 | 'aroon-up': 98 25 | } 26 | 27 | @staticmethod 28 | def indicator_space() -> List[Dimension]: 29 | return [ 30 | Integer(0, 100.0, name='adx'), 31 | Integer(0, 100.0, name='aroon-up'), 32 | Integer(0, 100.0, name='aroon-down') 33 | ] 34 | 35 | @staticmethod 36 | def sell_indicator_space() -> List[Dimension]: 37 | return [] 38 | 39 | @staticmethod 40 | def buy_strategy_generator(params: Dict[str, Any]) -> Callable: 41 | 42 | def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 43 | 44 | dataframe.loc[ 45 | ( 46 | (dataframe['adx'] > params['adx']) & 47 | (dataframe['aroon-up'] > params['aroon-up']) & 48 | (dataframe['aroon-down'] < params['aroon-down']) & 49 | (dataframe['volume'] > 0) 50 | ), 51 | 'buy' 52 | ] = 1 53 | 54 | return dataframe 55 | 56 | return populate_buy_trend 57 | 58 | @staticmethod 59 | def sell_strategy_generator(params: Dict[str, Any]) -> Callable: 60 | 61 | def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: 62 | 63 | dataframe['sell'] = 0 64 | return dataframe 65 | 66 | return populate_sell_trend 67 | 68 | @staticmethod 69 | def generate_roi_table(params: Dict) -> Dict[int, float]: 70 | 71 | roi_table = {} 72 | roi_table[0] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] + params['roi_p6'] 73 | roi_table[params['roi_t6']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] + params['roi_p5'] 74 | roi_table[params['roi_t6'] + params['roi_t5']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] + params['roi_p4'] 75 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4']] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] 76 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3']] = params['roi_p1'] + params['roi_p2'] 77 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2']] = params['roi_p1'] 78 | roi_table[params['roi_t6'] + params['roi_t5'] + params['roi_t4'] + params['roi_t3'] + params['roi_t2'] + params['roi_t1']] = 0 79 | 80 | return roi_table 81 | 82 | @staticmethod 83 | def roi_space() -> List[Dimension]: 84 | 85 | return [ 86 | Integer(1, 15, name='roi_t6'), 87 | Integer(1, 45, name='roi_t5'), 88 | Integer(1, 90, name='roi_t4'), 89 | Integer(45, 120, name='roi_t3'), 90 | Integer(45, 180, name='roi_t2'), 91 | Integer(90, 200, name='roi_t1'), 92 | 93 | Real(0.005, 0.10, name='roi_p6'), 94 | Real(0.005, 0.07, name='roi_p5'), 95 | Real(0.005, 0.05, name='roi_p4'), 96 | Real(0.005, 0.025, name='roi_p3'), 97 | Real(0.005, 0.01, name='roi_p2'), 98 | Real(0.003, 0.007, name='roi_p1'), 99 | ] 100 | 101 | def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: 102 | params = self.buy_params 103 | 104 | dataframe.loc[ 105 | ( 106 | (dataframe['adx'] > params['adx']) & 107 | (dataframe['aroon-up'] > params['aroon-up']) & 108 | (dataframe['aroon-down'] < params['aroon-down']) & 109 | (dataframe['volume'] > 0) 110 | ), 111 | 'buy' 112 | ] = 1 113 | 114 | return dataframe 115 | -------------------------------------------------------------------------------- /strategies/archived/hyperopts/avgprofit_hyperopt_loss.py: -------------------------------------------------------------------------------- 1 | """ 2 | OnlyProfitHyperOptLoss 3 | 4 | This module defines the alternative HyperOptLoss class which can be used for 5 | Hyperoptimization. 6 | """ 7 | from pandas import DataFrame 8 | 9 | from freqtrade.optimize.hyperopt import IHyperOptLoss 10 | 11 | # Optimize around the "average profit" result 12 | EXPECTED_AVG_PROFIT = 2.0 13 | 14 | 15 | class AvgProfitHyperOptLoss(IHyperOptLoss): 16 | """ 17 | Defines the loss function for hyperopt. 18 | 19 | This implementation takes only avg profit into account. 20 | """ 21 | 22 | @staticmethod 23 | def hyperopt_loss_function(results: DataFrame, trade_count: int, 24 | *args, **kwargs) -> float: 25 | """ 26 | Objective function, returns smaller number for better results. 27 | """ 28 | 29 | profit_mean = results['profit_ratio'].mean() if len(results) > 0 else 0.0, 30 | profit_mean_pct = results['profit_ratio'].mean() * 100.0 if len(results) > 0 else 0.0, 31 | 32 | return 1 - profit_mean_pct / EXPECTED_AVG_PROFIT 33 | -------------------------------------------------------------------------------- /strategies/archived/hyperopts/winrate_hyperopt_loss.py: -------------------------------------------------------------------------------- 1 | from datetime import datetime 2 | from math import exp 3 | 4 | from pandas import DataFrame 5 | 6 | from freqtrade.optimize.hyperopt import IHyperOptLoss 7 | 8 | 9 | # Define some constants: 10 | 11 | # set TARGET_RATIO to your desired ratio of winning:losing trades 12 | # a value of 10 would look for a win rate of 10:1, e.g. in 100 trades only 10 are losing. 13 | TARGET_RATIO = 10 14 | 15 | class WinRateHyperOptLoss(IHyperOptLoss): 16 | 17 | @staticmethod 18 | def hyperopt_loss_function(results: DataFrame, trade_count: int, 19 | min_date: datetime, max_date: datetime, 20 | *args, **kwargs) -> float: 21 | """ 22 | Objective function, returns smaller number for better results 23 | """ 24 | 25 | wins = len(results[results['profit_abs'] > 0]) 26 | drawss = len(results[results['profit_abs'] == 0]) 27 | losses = len(results[results['profit_abs'] < 0]) 28 | 29 | winrate = wins / losses 30 | 31 | return 1 - winrate / TARGET_RATIO 32 | -------------------------------------------------------------------------------- /strategies/solipsis/Solipsis.py: -------------------------------------------------------------------------------- 1 | # Strategy specific imports, files must reside in same folder as strategy 2 | import sys 3 | from pathlib import Path 4 | sys.path.append(str(Path(__file__).parent)) 5 | 6 | from Solipsis_v5 import Solipsis5 as Solipsis 7 | 8 | """ 9 | *** THIS IS YOUR LIVE TRADING COPY *** 10 | *** THIS IS A CHILD STRATEGY, REQUIRES IMPORT OF PARENT STRATEGY ** 11 | *** CURRENTLY MAPS TO PARENT STRATEGY: Solipsis_v5 *** 12 | 13 | LAST OPTIMIZED: 14 | 15 | EXCHANGE: Kraken, full pairlists with some personally selected blacklisted coins 16 | 17 | Stake Date Optimized 18 | ----------|---------------- 19 | USD 20 | BTC 21 | ETH 22 | 23 | 24 | Optimization / Backtest Results for Current Live Instance Settings 25 | USD 26 | 27 | 28 | 29 | """ 30 | # Sub-strategy with parameters specific to USD stake 31 | class Solipsis_USD(Solipsis): 32 | 33 | timeframe = '5m' 34 | inf_timeframe = '1h' 35 | 36 | minimal_roi = { 37 | "0": 100 38 | } 39 | 40 | buy_params = {} 41 | 42 | sell_params = {} 43 | 44 | stoploss = -0.10 45 | 46 | use_sell_signal = True 47 | sell_profit_only = False 48 | ignore_roi_if_buy_signal = False 49 | 50 | startup_candle_count: int = 233 51 | process_only_new_candles = False 52 | 53 | custom_trade_info = {} 54 | custom_fiat = "USD" 55 | custom_btc_inf = False 56 | 57 | """ 58 | Optimization / Backtest Results for Current Live Instance Settings 59 | BTC 60 | 61 | 62 | """ 63 | # Sub-strategy with parameters specific to BTC stake 64 | class Solipsis_BTC(Solipsis): 65 | 66 | timeframe = '5m' 67 | inf_timeframe = '1h' 68 | 69 | minimal_roi = { 70 | "0": 100 71 | } 72 | 73 | buy_params = {} 74 | 75 | sell_params = {} 76 | 77 | stoploss = -0.10 78 | 79 | use_sell_signal = True 80 | sell_profit_only = False 81 | ignore_roi_if_buy_signal = False 82 | 83 | startup_candle_count: int = 233 84 | process_only_new_candles = False 85 | 86 | custom_trade_info = {} 87 | custom_fiat = "USD" 88 | custom_btc_inf = False 89 | 90 | """ 91 | Optimization / Backtest Results for Current Live Instance Settings 92 | ETH 93 | 94 | 95 | """ 96 | # Sub-strategy with parameters specific to ETH stake 97 | class Solipsis_ETH(Solipsis): 98 | 99 | timeframe = '5m' 100 | inf_timeframe = '1h' 101 | 102 | minimal_roi = { 103 | "0": 100 104 | } 105 | 106 | buy_params = {} 107 | 108 | sell_params = {} 109 | 110 | stoploss = -0.10 111 | 112 | use_sell_signal = True 113 | sell_profit_only = False 114 | ignore_roi_if_buy_signal = False 115 | 116 | startup_candle_count: int = 233 117 | process_only_new_candles = False 118 | 119 | custom_trade_info = {} 120 | custom_fiat = "USD" 121 | custom_btc_inf = False --------------------------------------------------------------------------------