Created
December 2, 2019 20:57
-
-
Save hroff-1902/c07f25d820aa0fef26a243ca3e1ce00a to your computer and use it in GitHub Desktop.
IsNotItTheHolyGrailManStrategy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement | |
| import talib.abstract as ta | |
| from pandas import DataFrame | |
| import freqtrade.vendor.qtpylib.indicators as qtpylib | |
| from freqtrade.strategy.interface import IStrategy | |
| class IsNotItTheHolyGrailManStrategy(IStrategy): | |
| """ | |
| Default Strategy provided by freqtrade bot. | |
| Please do not modify this strategy, it's intended for internal use only. | |
| Please look at the SampleStrategy in the user_data/strategy directory | |
| or strategy repository https://github.com/freqtrade/freqtrade-strategies | |
| for samples and inspiration. | |
| """ | |
| INTERFACE_VERSION = 2 | |
| # Minimal ROI designed for the strategy | |
| minimal_roi = {"0": 0.26457, "11": 0.07775, "33": 0.02212, "47": 0} | |
| # Optimal stoploss designed for the strategy | |
| stoploss = -0.02082 | |
| # Optimal ticker interval for the strategy | |
| ticker_interval = '5m' | |
| # Optional order type mapping | |
| order_types = { | |
| 'buy': 'limit', | |
| 'sell': 'limit', | |
| 'stoploss': 'limit', | |
| 'stoploss_on_exchange': False | |
| } | |
| # Number of candles the strategy requires before producing valid signals | |
| startup_candle_count: int = 0 | |
| # Optional time in force for orders | |
| order_time_in_force = { | |
| 'buy': 'gtc', | |
| 'sell': 'gtc', | |
| } | |
| def informative_pairs(self): | |
| """ | |
| Define additional, informative pair/interval combinations to be cached from the exchange. | |
| These pair/interval combinations are non-tradeable, unless they are part | |
| of the whitelist as well. | |
| For more information, please consult the documentation | |
| :return: List of tuples in the format (pair, interval) | |
| Sample: return [("ETH/USDT", "5m"), | |
| ("BTC/USDT", "15m"), | |
| ] | |
| """ | |
| return [] | |
| def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: | |
| """ | |
| Adds several different TA indicators to the given DataFrame | |
| Performance Note: For the best performance be frugal on the number of indicators | |
| you are using. Let uncomment only the indicator you are using in your strategies | |
| or your hyperopt configuration, otherwise you will waste your memory and CPU usage. | |
| :param dataframe: Raw data from the exchange and parsed by parse_ticker_dataframe() | |
| :param metadata: Additional information, like the currently traded pair | |
| :return: a Dataframe with all mandatory indicators for the strategies | |
| """ | |
| # MFI | |
| dataframe['mfi'] = ta.MFI(dataframe) | |
| # RSI | |
| dataframe['rsi'] = ta.RSI(dataframe) | |
| # Bollinger bands | |
| bollinger = qtpylib.bollinger_bands(qtpylib.typical_price(dataframe), window=20, stds=2) | |
| dataframe['bb_lowerband'] = bollinger['lower'] | |
| dataframe['bb_middleband'] = bollinger['mid'] | |
| dataframe['bb_upperband'] = bollinger['upper'] | |
| return dataframe | |
| def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: | |
| """ | |
| Based on TA indicators, populates the buy signal for the given dataframe | |
| :param dataframe: DataFrame | |
| :param metadata: Additional information, like the currently traded pair | |
| :return: DataFrame with buy column | |
| """ | |
| dataframe.loc[ | |
| ( | |
| (dataframe['mfi'] < 12) & | |
| (dataframe['rsi'] < 35) & | |
| (dataframe['close'] < dataframe['bb_lowerband']) | |
| ), | |
| 'buy'] = 1 | |
| return dataframe | |
| def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: | |
| """ | |
| Based on TA indicators, populates the sell signal for the given dataframe | |
| :param dataframe: DataFrame | |
| :param metadata: Additional information, like the currently traded pair | |
| :return: DataFrame with buy column | |
| """ | |
| dataframe.loc[ | |
| ( | |
| (dataframe['mfi'] > 98) & | |
| (dataframe['rsi'] > 98) & | |
| (dataframe['close'] > dataframe['bb_upperband']) | |
| ), | |
| 'sell'] = 1 | |
| return dataframe |
Author
hroff-1902
commented
Jan 15, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment