From 153ecf2ab5e9316aa9c434a0d8959d0baffb6b9e Mon Sep 17 00:00:00 2001 From: crypto_rahino Date: Sun, 28 Mar 2021 19:26:17 +0300 Subject: [PATCH] btc update --- .env/bin/data_analysis.py | 14 +- .../user_data/config_binance_multiple.json | 8 +- .env/bin/user_data/config_btcusdt_1m.json | 6 +- .env/bin/user_data/config_ethusdt_1m.json | 2 + .env/bin/user_data/config_ltcusdt_1h.json | 25 +- .../user_data/hyperopts/hyper_ltcusdt_1h.py | 136 ++++++++-- .../user_data/hyperopts/hyper_ltcusdt_1hpy | 240 ------------------ .../strategies/ethusdt2_safe_prod1.py | 208 --------------- .env/bin/user_data/strategies/ltcusdt_1h.py | 163 ++++++++++-- .../user_data/strategies/quick_btcusdt_1m.py | 201 ++++++++++----- 10 files changed, 420 insertions(+), 583 deletions(-) delete mode 100644 .env/bin/user_data/hyperopts/hyper_ltcusdt_1hpy delete mode 100644 .env/bin/user_data/strategies/ethusdt2_safe_prod1.py diff --git a/.env/bin/data_analysis.py b/.env/bin/data_analysis.py index 6a90e9a58..bcdffb56e 100644 --- a/.env/bin/data_analysis.py +++ b/.env/bin/data_analysis.py @@ -15,18 +15,18 @@ import matplotlib # # Initialize empty configuration object from freqtrade.strategy import IStrategy -config = Configuration.from_files(["user_data/config_ltcusdt_1h.json"]) +config = Configuration.from_files(["user_data/config_btcusdt_1m.json"]) # # Optionally, use existing configuration file # config = Configuration.from_files(["config.json"]) # # # Define some constants # config["timeframe"] = "1m" # # Name of the strategy class -config["strategy"] = "ltcusdt_1h" +config["strategy"] = "quick_btcusdt_1m" # # Location of the data data_location = Path(config['user_data_dir'], 'data', 'binance') # # Pair to analyze - Only use one pair here -pair = "LTC/USDT" +pair = "BTC/USDT" # # # Load data using values set above # @@ -102,7 +102,7 @@ def plot_db(path): graph = generate_candlestick_graph(pair=pair, data=data_red, trades=trades_red, - indicators1=['tsf_mid'], + indicators1=['tsf_mid', 'match_low'], indicators2=['correl_tsf_mid_close', 'correl_angle_short_close', 'correl_angle_long_close', 'correl_hist_close'] ) @@ -148,12 +148,12 @@ def plot_backtest(start_date, stop_date): graph = generate_candlestick_graph(pair=pair, data=data_red, trades=trades, - indicators1=['sar', 'tsf_mid'], - indicators2=['sine', 'leadsine', 'angle_trend_mid', 'inphase', 'quadrature' ] + indicators1=['tsf_mid', 'fib', 'kama', 'fib_1h'], + indicators2=['macd', 'bop_1h', 'macdsignal', 'mode', 'period_1h', 'sine', 'leadsine', 'period'] ) graph.show() -plot_backtest(start_date='2020-01-01', stop_date='2021-03-18') +plot_backtest(start_date='2021-03-01', stop_date='2021-03-26') diff --git a/.env/bin/user_data/config_binance_multiple.json b/.env/bin/user_data/config_binance_multiple.json index 63def2442..535dc290b 100644 --- a/.env/bin/user_data/config_binance_multiple.json +++ b/.env/bin/user_data/config_binance_multiple.json @@ -1,10 +1,10 @@ { - "max_open_trades": 3, + "max_open_trades": 10, "stake_currency": "USDT", - "stake_amount": 0.05, + "stake_amount": 100, "tradable_balance_ratio": 0.99, "fiat_display_currency": "USD", - "timeframe": "1m", + "timeframe": "1h", "dry_run": true, "cancel_open_orders_on_exit": false, "unfilledtimeout": { @@ -44,7 +44,7 @@ "DOGE/USDT", "BTC/USDT", "ADA/USDT", - "TRX/XRP" + "LTC/USDT" ], "pair_blacklist": [ "BNB/BTC" diff --git a/.env/bin/user_data/config_btcusdt_1m.json b/.env/bin/user_data/config_btcusdt_1m.json index 936f01e45..85cf4fe66 100644 --- a/.env/bin/user_data/config_btcusdt_1m.json +++ b/.env/bin/user_data/config_btcusdt_1m.json @@ -1,18 +1,19 @@ { "max_open_trades": 3, "stake_currency": "USDT", - "stake_amount": 1000.0, + "stake_amount": 990.0, "tradable_balance_ratio": 0.99, "fiat_display_currency": "USD", "timeframe": "1m", "dry_run": true, - "position_stacking": true, + "position_stacking": false, "cancel_open_orders_on_exit": true, "unfilledtimeout": { "buy": 10, "sell": 30 }, "bid_strategy": { + "price_side": "ask", "use_order_book": false, "ask_last_balance": 0.0, "order_book_top": 1, @@ -22,6 +23,7 @@ } }, "ask_strategy":{ + "price_side": "bid", "use_order_book": false, "order_book_min": 1, "order_book_max": 1, diff --git a/.env/bin/user_data/config_ethusdt_1m.json b/.env/bin/user_data/config_ethusdt_1m.json index e152c31c2..e833b49c8 100644 --- a/.env/bin/user_data/config_ethusdt_1m.json +++ b/.env/bin/user_data/config_ethusdt_1m.json @@ -13,6 +13,7 @@ "sell": 30 }, "bid_strategy": { + "price_side": "ask", "use_order_book": false, "ask_last_balance": 0.0, "order_book_top": 1, @@ -22,6 +23,7 @@ } }, "ask_strategy":{ + "price_side": "bid", "use_order_book": false, "order_book_min": 1, "order_book_max": 1, diff --git a/.env/bin/user_data/config_ltcusdt_1h.json b/.env/bin/user_data/config_ltcusdt_1h.json index ed8e062d8..990a361f4 100644 --- a/.env/bin/user_data/config_ltcusdt_1h.json +++ b/.env/bin/user_data/config_ltcusdt_1h.json @@ -1,18 +1,19 @@ { - "max_open_trades": 3, + "max_open_trades": 2, "stake_currency": "USDT", - "stake_amount": 100.0, + "stake_amount": 990, "tradable_balance_ratio": 0.99, "fiat_display_currency": "USD", "timeframe": "1h", "dry_run": true, - "position_stacking": true, + "position_stacking": false, "cancel_open_orders_on_exit": false, "unfilledtimeout": { "buy": 10, "sell": 30 }, "bid_strategy": { + "price_side": "ask", "use_order_book": false, "ask_last_balance": 0.0, "order_book_top": 1, @@ -22,12 +23,13 @@ } }, "ask_strategy":{ - "use_order_book": true, + "price_side": "bid", + "use_order_book": false, "order_book_min": 1, "order_book_max": 1, "use_sell_signal": true, - "sell_profit_only": true, - "ignore_roi_if_buy_signal": true + "sell_profit_only": false, + "ignore_roi_if_buy_signal": false }, "exchange": { "name": "binance", @@ -40,6 +42,7 @@ }, "pair_whitelist": [ "LTC/USDT" + ], "pair_blacklist": [ "BNB/BTC" @@ -49,22 +52,22 @@ {"method": "StaticPairList"} ], "edge": { - "enabled": false, + "enabled": true, "process_throttle_secs": 3600, - "calculate_since_number_of_days": 7, - "allowed_risk": 0.01, + "calculate_since_number_of_days": 14, + "allowed_risk": 0.02, "stoploss_range_min": -0.01, "stoploss_range_max": -0.1, "stoploss_range_step": -0.01, "minimum_winrate": 0.60, "minimum_expectancy": 0.20, "min_trade_number": 10, - "max_trade_duration_minute": 1440, + "max_trade_duration_minute": 14400, "remove_pumps": false }, "telegram": { "enabled": false, - "token": "1661670711:AAEjHFL_wnvc-hN0V8NKe0G53mzrz9rWnzk", + "token": "1725064196:AAGvqiJEC_uv8THpsZG1F_Or7T2dGYRFuqU", "chat_id": "1288347675", "keyboard": [ ["/daily", "/stats", "/balance", "/profit"], diff --git a/.env/bin/user_data/hyperopts/hyper_ltcusdt_1h.py b/.env/bin/user_data/hyperopts/hyper_ltcusdt_1h.py index dd4037130..b7dbeee8e 100644 --- a/.env/bin/user_data/hyperopts/hyper_ltcusdt_1h.py +++ b/.env/bin/user_data/hyperopts/hyper_ltcusdt_1h.py @@ -53,13 +53,29 @@ class hyper_ltcusdt_1h(IHyperOpt): # GUARDS AND TRENDS if params.get('ao-enabled'): - conditions.append(dataframe['ao'] > params['ao1-value']) - conditions.append(dataframe['ao'] < params['ao2-value']) + conditions.append(dataframe['ao'] > params['ao-value']) + if params.get('uo-enabled'): + conditions.append(dataframe['uo'] > params['uo-value']) + if params.get('sar_close-enabled'): + conditions.append(dataframe['sar_close'] < params['sar_close-value']) + if params.get('natr-enabled'): + conditions.append(dataframe['natr'] > params['natr-value']) if params.get('angle_tsf_mid-enabled'): conditions.append(dataframe['angle_tsf_mid'] < params['angle_tsf_mid-value']) - if params.get('rsi-enabled'): - conditions.append(params['rsi1-value'] < dataframe['rsi']) - conditions.append(params['rsi2-value'] > dataframe['rsi']) + if params.get('angle_trend_mid-enabled'): + conditions.append(dataframe['angle_trend_mid'] < params['angle_trend_mid-value']) + if params.get('mfi-enabled'): + conditions.append(params['mfi-value'] < dataframe['mfi']) + if params.get('angle-enabled'): + conditions.append(params['angle-value'] < dataframe['angle']) + if params.get('angle_macdsignal-enabled'): + conditions.append(params['angle_macdsignal-value'] < dataframe['angle_macdsignal']) + if params.get('macdhist-enabled'): + conditions.append(params['macdhist-value'] < dataframe['macdhist']) + if params.get('macdsignal-enabled'): + conditions.append(params['macdsignal-value'] < dataframe['macdsignal']) + if params.get('macd-enabled'): + conditions.append(params['macd-value'] < (dataframe['macd'] - dataframe['macdsignal'])) # TRIGGERS if 'trigger' in params: @@ -71,6 +87,14 @@ class hyper_ltcusdt_1h(IHyperOpt): conditions.append(qtpylib.crossed_above( dataframe['leadsine'], dataframe['sine'] )) + if params['trigger'] == 'phase': + conditions.append(qtpylib.crossed_above( + dataframe['quadrature'], dataframe['inphase'] + )) + if params['trigger'] == 'angle_tsf_mid': + conditions.append(qtpylib.crossed_above( + dataframe['angle_tsf_mid'], 0 + )) if conditions: dataframe.loc[ @@ -87,15 +111,31 @@ class hyper_ltcusdt_1h(IHyperOpt): Define your Hyperopt space for searching buy strategy parameters. """ return [ - Integer(-50, 50, name='ao1-value'), - Integer(-50, 50, name='ao2-value'), - Integer(-87, 85, name='angle_tsf_mid-value'), - Integer(8, 92, name='rsi1-value'), - Integer(8, 92, name='rsi2-value'), + Integer(-50, 35, name='ao-value'), + Integer(-86, 70, name='sar_close-value'), + Integer(-75, 72, name='angle_tsf_mid-value'), + Integer(-73, 68, name='angle_trend_mid-value'), + Integer(-2, 80, name='uo-value'), + Real(0.36, 11, name='natr-value'), + Integer(0, 100, name='mfi-value'), + Integer(-81, 78, name='angle-value'), + Integer(-38, 50, name='angle_macdsignal-value'), + Real(-4, 5.3, name='macdhist-value'), + Integer(-15, 11, name='macdsignal-value'), + Real(-4, 5, name='macd-value'), Categorical([True, False], name='ao-enabled'), Categorical([True, False], name='angle_tsf_mid-enabled'), - Categorical([True, False], name='rsi-enabled'), - Categorical(['sar', 'sine'], name='trigger') + Categorical([True, False], name='sar_close-enabled'), + Categorical([True, False], name='angle_trend_mid-enabled'), + Categorical([True, False], name='uo-enabled'), + Categorical([True, False], name='natr-enabled'), + Categorical([True, False], name='mfi-enabled'), + Categorical([True, False], name='angle-enabled'), + Categorical([True, False], name='angle_macdsignal-enabled'), + Categorical([True, False], name='macdhist-enabled'), + Categorical([True, False], name='macdsignal-enabled'), + Categorical([True, False], name='macd-enabled'), + Categorical(['sar', 'sine', 'angle_tsf_mid', 'angle_trend_mid', 'phase'], name='trigger') ] @staticmethod @@ -112,13 +152,29 @@ class hyper_ltcusdt_1h(IHyperOpt): # GUARDS AND TRENDS if params.get('ao-enabled'): - conditions.append(dataframe['ao'] > params['ao1-value_sell']) - conditions.append(dataframe['ao'] < params['ao2-value_sell']) + conditions.append(dataframe['ao'] > params['ao-value_sell']) + if params.get('uo-enabled'): + conditions.append(dataframe['uo'] > params['uo-value_sell']) + if params.get('sar_close-enabled'): + conditions.append(dataframe['sar_close'] < params['sar_close-value_sell']) + if params.get('natr-enabled'): + conditions.append(dataframe['natr'] > params['natr-value_sell']) if params.get('angle_tsf_mid-enabled'): - conditions.append(dataframe['angle_tsf_mid'] > params['angle_tsf_mid-value_sell']) - if params.get('rsi-enabled'): - conditions.append(params['rsi1-value_sell'] < dataframe['rsi']) - conditions.append(params['rsi2-value_sell'] > dataframe['rsi']) + conditions.append(dataframe['angle_tsf_mid'] < params['angle_tsf_mid-value_sell']) + if params.get('angle_trend_mid-enabled'): + conditions.append(dataframe['angle_trend_mid'] < params['angle_trend_mid-value_sell']) + if params.get('mfi-enabled'): + conditions.append(params['mfi-value_sell'] < dataframe['mfi']) + if params.get('angle-enabled'): + conditions.append(params['angle-value_sell'] < dataframe['angle']) + if params.get('angle_macdsignal-enabled'): + conditions.append(params['angle_macdsignal-value_sell'] < dataframe['angle_macdsignal']) + if params.get('macdhist-enabled'): + conditions.append(params['macdhist-value_sell'] < dataframe['macdhist']) + if params.get('macdsignal-enabled'): + conditions.append(params['macdsignal-value_sell'] < dataframe['macdsignal']) + if params.get('macd-enabled'): + conditions.append(params['macd-value_sell'] < (dataframe['macd'] - dataframe['macdsignal'])) # TRIGGERS if 'trigger' in params: @@ -130,6 +186,18 @@ class hyper_ltcusdt_1h(IHyperOpt): conditions.append(qtpylib.crossed_below( dataframe['leadsine'], dataframe['sine'] )) + if params['trigger'] == 'phase': + conditions.append(qtpylib.crossed_below( + dataframe['quadrature'], dataframe['inphase'] + )) + if params['trigger'] == 'angle_trend_mid': + conditions.append(qtpylib.crossed_below( + dataframe['angle_trend_mid'], 0 + )) + if params['trigger'] == 'angle_tsf_mid': + conditions.append(qtpylib.crossed_below( + dataframe['angle_tsf_mid'], 0 + )) if conditions: @@ -147,15 +215,31 @@ class hyper_ltcusdt_1h(IHyperOpt): Define your Hyperopt space for searching sell strategy parameters. """ return [ - Integer(-50, 50, name='ao1-value_sell'), - Integer(-50, 50, name='ao2-value_sell'), - Integer(-87, 85, name='angle_tsf_mid-value_sell'), - Integer(8, 92, name='rsi1-value_sell'), - Integer(8, 92, name='rsi2-value_sell'), + Integer(-50, 35, name='ao-value_sell'), + Integer(-86, 70, name='sar_close-value_sell'), + Integer(-75, 72, name='angle_tsf_mid-value_sell'), + Integer(-73, 68, name='angle_trend_mid-value_sell'), + Integer(-2, 80, name='uo-value_sell'), + Real(0.36, 11, name='natr-value_sell'), + Integer(0, 100, name='mfi-value_sell'), + Integer(-81, 78, name='angle-value_sell'), + Integer(-38, 50, name='angle_macdsignal-value_sell'), + Real(-4, 5.3, name='macdhist-value_sell'), + Integer(-15, 11, name='macdsignal-value_sell'), + Real(-4, 5, name='macd-value_sell'), Categorical([True, False], name='ao-enabled'), Categorical([True, False], name='angle_tsf_mid-enabled'), - Categorical([True, False], name='rsi-enabled'), - Categorical(['sar', 'sine'], name='trigger') + Categorical([True, False], name='sar_close-enabled'), + Categorical([True, False], name='angle_trend_mid-enabled'), + Categorical([True, False], name='uo-enabled'), + Categorical([True, False], name='natr-enabled'), + Categorical([True, False], name='mfi-enabled'), + Categorical([True, False], name='angle-enabled'), + Categorical([True, False], name='angle_macdsignal-enabled'), + Categorical([True, False], name='macdhist-enabled'), + Categorical([True, False], name='macdsignal-enabled'), + Categorical([True, False], name='macd-enabled'), + Categorical(['sar', 'sine', 'angle_tsf_mid', 'angle_trend_mid', 'phase'], name='trigger') ] @staticmethod @@ -208,7 +292,7 @@ class hyper_ltcusdt_1h(IHyperOpt): 'stoploss' optimization hyperspace. """ return [ - Real(-0.25, -0.02, name='stoploss'), + Real(-0.3, -0.02, name='stoploss'), ] @staticmethod diff --git a/.env/bin/user_data/hyperopts/hyper_ltcusdt_1hpy b/.env/bin/user_data/hyperopts/hyper_ltcusdt_1hpy deleted file mode 100644 index 7a95c8d4f..000000000 --- a/.env/bin/user_data/hyperopts/hyper_ltcusdt_1hpy +++ /dev/null @@ -1,240 +0,0 @@ -# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement - -# --- Do not remove these libs --- -from functools import reduce -from typing import Any, Callable, Dict, List - -import numpy as np # noqa -import pandas as pd # noqa -from pandas import DataFrame -from skopt.space import Categorical, Dimension, Integer, Real # noqa - -from freqtrade.optimize.hyperopt_interface import IHyperOpt - -# -------------------------------- -# Add your lib to import here -import talib.abstract as ta # noqa -import freqtrade.vendor.qtpylib.indicators as qtpylib - - -class hyper_ethusdt2(IHyperOpt): - """ - This is a Hyperopt template to get you started. - - More information in the documentation: https://www.freqtrade.io/en/latest/hyperopt/ - - You should: - - Add any lib you need to build your hyperopt. - - You must keep: - - The prototypes for the methods: populate_indicators, indicator_space, buy_strategy_generator. - - The methods roi_space, generate_roi_table and stoploss_space are not required - and are provided by default. - However, you may override them if you need 'roi' and 'stoploss' spaces that - differ from the defaults offered by Freqtrade. - Sample implementation of these methods will be copied to `user_data/hyperopts` when - creating the user-data directory using `freqtrade create-userdir --userdir user_data`, - or is available online under the following URL: - https://github.com/freqtrade/freqtrade/blob/develop/freqtrade/templates/sample_hyperopt_advanced.py. - """ - - @staticmethod - def buy_strategy_generator(params: Dict[str, Any]) -> Callable: - """ - Define the buy strategy parameters to be used by Hyperopt. - """ - - def populate_buy_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: - """ - Buy strategy Hyperopt will build and use. - """ - conditions = [] - - # GUARDS AND TRENDS - if params.get('ao-enabled'): - conditions.append(dataframe['ao'] > params['ao1-value']) - conditions.append(dataframe['ao'] < params['ao2-value']) - if params.get('angle_tsf_mid-enabled'): - conditions.append(dataframe['angle_tsf_mid'] < params['angle_tsf_mid-value']) - if params.get('rsi-enabled'): - conditions.append(params['rsi1-value'] < dataframe['rsi']) - conditions.append(params['rsi2-value'] > dataframe['rsi']) - - # TRIGGERS - if 'trigger' in params: - if params['trigger'] == 'ao_cross': - conditions.append(qtpylib.crossed_above( - dataframe['ao'], 0 - )) - if params['trigger'] == 'angle_tsf_mid_cross_up': - conditions.append(qtpylib.crossed_above( - dataframe['angle_tsf_mid'], -50 - )) - - if conditions: - dataframe.loc[ - reduce(lambda x, y: x & y, conditions), - 'buy'] = 1 - - return dataframe - - return populate_buy_trend - - @staticmethod - def indicator_space() -> List[Dimension]: - """ - Define your Hyperopt space for searching buy strategy parameters. - """ - return [ - Integer(-50, 50, name='ao1-value'), - Integer(-50, 50, name='ao2-value'), - Integer(-87, 85, name='angle_tsf_mid-value'), - Integer(8, 92, name='rsi1-value'), - Integer(8, 92, name='rsi2-value'), - Categorical([True, False], name='ao-enabled'), - Categorical([True, False], name='angle_tsf_mid-enabled'), - Categorical([True, False], name='rsi-enabled'), - Categorical(['ao_cross', 'angle_tsf_mid_cross_up'], name='trigger') - ] - - @staticmethod - def sell_strategy_generator(params: Dict[str, Any]) -> Callable: - """ - Define the sell strategy parameters to be used by Hyperopt. - """ - - def populate_sell_trend(dataframe: DataFrame, metadata: dict) -> DataFrame: - """ - Sell strategy Hyperopt will build and use. - """ - conditions = [] - - # GUARDS AND TRENDS - if params.get('ao-enabled'): - conditions.append(dataframe['ao'] > params['ao1-value_sell']) - conditions.append(dataframe['ao'] < params['ao2-value_sell']) - if params.get('angle_tsf_mid-enabled'): - conditions.append(dataframe['angle_tsf_mid'] > params['angle_tsf_mid-value_sell']) - if params.get('rsi-enabled'): - conditions.append(params['rsi1-value_sell'] < dataframe['rsi']) - conditions.append(params['rsi2-value_sell'] > dataframe['rsi']) - - # TRIGGERS - if 'trigger' in params: - if params['trigger'] == 'ao_cross_dw': - conditions.append(qtpylib.crossed_below( - dataframe['ao'], 0 - )) - if params['trigger'] == 'angle_tsf_mid_cross_dw': - conditions.append(qtpylib.crossed_below( - dataframe['angle_tsf_mid'], 50 - )) - - - if conditions: - dataframe.loc[ - reduce(lambda x, y: x & y, conditions), - 'sell'] = 1 - - return dataframe - - return populate_sell_trend - - @staticmethod - def sell_indicator_space() -> List[Dimension]: - """ - Define your Hyperopt space for searching sell strategy parameters. - """ - return [ - Integer(-50, 50, name='ao1-value_sell'), - Integer(-50, 50, name='ao2-value_sell'), - Integer(-87, 85, name='angle_tsf_mid-value_sell'), - Integer(8, 92, name='rsi1-value_sell'), - Integer(8, 92, name='rsi2-value_sell'), - Categorical([True, False], name='ao-enabled'), - Categorical([True, False], name='angle_tsf_mid-enabled'), - Categorical([True, False], name='rsi-enabled'), - Categorical(['angle_tsf_mid_cross_dw', 'ao_cross_dw'], name='trigger') - ] - - @staticmethod - def generate_roi_table(params: Dict) -> Dict[int, float]: - """ - Generate the ROI table that will be used by Hyperopt - - This implementation generates the default legacy Freqtrade ROI tables. - - Change it if you need different number of steps in the generated - ROI tables or other structure of the ROI tables. - - Please keep it aligned with parameters in the 'roi' optimization - hyperspace defined by the roi_space method. - """ - roi_table = {} - roi_table[0] = params['roi_p1'] + params['roi_p2'] + params['roi_p3'] - roi_table[params['roi_t3']] = params['roi_p1'] + params['roi_p2'] - roi_table[params['roi_t3'] + params['roi_t2']] = params['roi_p1'] - roi_table[params['roi_t3'] + params['roi_t2'] + params['roi_t1']] = 0 - - return roi_table - - @staticmethod - def roi_space() -> List[Dimension]: - """ - Values to search for each ROI steps - - Override it if you need some different ranges for the parameters in the - 'roi' optimization hyperspace. - - Please keep it aligned with the implementation of the - generate_roi_table method. - """ - return [ - Integer(60, 600, name='roi_t1'), - Integer(300, 1000, name='roi_t2'), - Integer(500, 1500, name='roi_t3'), - Real(0.01, 0.04, name='roi_p1'), - Real(0.01, 0.07, name='roi_p2'), - Real(0.01, 0.20, name='roi_p3'), - ] - - @staticmethod - def stoploss_space() -> List[Dimension]: - """ - Stoploss Value to search - - Override it if you need some different range for the parameter in the - 'stoploss' optimization hyperspace. - """ - return [ - Real(-0.25, -0.02, name='stoploss'), - ] - - @staticmethod - def trailing_space() -> List[Dimension]: - """ - Create a trailing stoploss space. - - You may override it in your custom Hyperopt class. - """ - return [ - # It was decided to always set trailing_stop is to True if the 'trailing' hyperspace - # is used. Otherwise hyperopt will vary other parameters that won't have effect if - # trailing_stop is set False. - # This parameter is included into the hyperspace dimensions rather than assigning - # it explicitly in the code in order to have it printed in the results along with - # other 'trailing' hyperspace parameters. - Categorical([True], name='trailing_stop'), - - Real(0.01, 0.35, name='trailing_stop_positive'), - - # 'trailing_stop_positive_offset' should be greater than 'trailing_stop_positive', - # so this intermediate parameter is used as the value of the difference between - # them. The value of the 'trailing_stop_positive_offset' is constructed in the - # generate_trailing_params() method. - # This is similar to the hyperspace dimensions used for constructing the ROI tables. - Real(0.001, 0.1, name='trailing_stop_positive_offset_p1'), - - Categorical([True, False], name='trailing_only_offset_is_reached'), - ] diff --git a/.env/bin/user_data/strategies/ethusdt2_safe_prod1.py b/.env/bin/user_data/strategies/ethusdt2_safe_prod1.py deleted file mode 100644 index 65f396266..000000000 --- a/.env/bin/user_data/strategies/ethusdt2_safe_prod1.py +++ /dev/null @@ -1,208 +0,0 @@ -# pragma pylint: disable=missing-docstring, invalid-name, pointless-string-statement -# isort: skip_file -# --- Do not remove these libs --- -import numpy as np # noqa -import pandas as pd # noqa -from pandas import DataFrame -from talib._ta_lib import ULTOSC, MACD, LINEARREG_ANGLE, TSF, MFI, EMA, MA, BBANDS, CORREL, MAX, MIN, SAR, CCI, \ - HT_TRENDLINE, HT_DCPERIOD, HT_TRENDMODE, HT_SINE, RSI - -from freqtrade.strategy import merge_informative_pair -from freqtrade.strategy.interface import IStrategy - -# -------------------------------- -# Add your lib to import here -import freqtrade.vendor.qtpylib.indicators as qtpylib - -""" - -""" - - -# This class is a sample. Feel free to customize it. -class strg2_ETHUSDT_1h_prod1(IStrategy): - """ - This is a sample strategy to inspire you. - More information in https://github.com/freqtrade/freqtrade/blob/develop/docs/bot-optimization.md - - You can: - :return: a Dataframe with all mandatory indicators for the strategies - - Rename the class name (Do not forget to update class_name) - - Add any methods you want to build your strategy - - Add any lib you need to build your strategy - - You must keep: - - the lib in the section "Do not remove these libs" - - the prototype for the methods: minimal_roi, stoploss, populate_indicators, populate_buy_trend, - populate_sell_trend, hyperopt_space, buy_strategy_generator - """ - # Strategy interface version - allow new iterations of the strategy interface. - # Check the documentation or the Sample strategy to get the latest version. - INTERFACE_VERSION = 2 - - # Minimal ROI designed for the strategy. - # This attribute will be overridden if the config file contains "minimal_roi". - minimal_roi = { - "0": 0.07371, - "9817": 0.0461, - "14487": 0.0254, - "15960": 0 - } - order_types = { - 'buy': 'market', - 'sell': 'market', - 'stoploss': 'market', - 'stoploss_on_exchange': False - } - # Optimal stoploss designed for the strategy. - # This attribute will be overridden if the config file contains "stoploss". - stoploss = -0.23371 - - # Trailing stop: - trailing_stop = True - trailing_stop_positive = 0.11193 - trailing_stop_positive_offset = 0.20381 - trailing_only_offset_is_reached = True - - plot_config = { - 'main_plot': { - 'upperband': {'upperband': 'green'}, - 'middleband': {'color': 'green'}, - 'lowerband': {'color': 'green'}, - 'tsf_mid': {'color': 'white'}, - 'ema': {'color': 'white'}, - }, - 'subplots': { - "corr": { - 'correl_h_l': {'color': 'black'}, - }, - "correl_tsf_mid_close": { - 'correl_tsf_mid_close': {'color': 'grey'}, - }, - "correl_angle_short_close": { - 'correl_angle_short_close': {'color': 'blue'}, - }, - "correl_angle_long_close": { - 'correl_angle_long_close': {'color': 'red'}, - }, - "correl_mfi_close": { - 'correl_mfi_close': {'color': 'black'}, - }, - "correl_hist_close": { - 'correl_tsf_mid_close': {'color': 'red'}, - }, - "mfi": { - 'mfi': {'color': 'yellow'}, - }, - } - } - - def informative_pairs(self): - """ - Define additional, informative pair/interval combinations to be cached from the exchange. - These pair/interval combinations are non-tradeable, unless they are part - of the whitelist as well. - For more information, please consult the documentation - :return: List of tuples in the format (pair, interval) - Sample: return [("ETH/USDT", "5m"), - ("BTC/USDT", "15m"), - ] - """ - return [("ETH/USDT", "1d")] - - def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: - """ - Adds several different TA indicators to the given DataFrame - - Performance Note: For the best performance be frugal on the number of indicators - you are using. Let uncomment only the indicator you are using in your strategies - or your hyperopt configuration, otherwise you will waste your memory and CPU usage. - :param dataframe: Dataframe with data from the exchange - :param metadata: Additional information, like the currently traded pair - :return: a Dataframe with all mandatory indicators for the strategies - """ - - # dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12, - # slowperiod=26, signalperiod=7) - - # dataframe['cci'] = CCI(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=30) - dataframe['ao'] = qtpylib.awesome_oscillator(dataframe, weighted=False, fast=5, slow=34) - # dataframe['vwap'] = qtpylib.vwap(dataframe) - # dataframe['vwap'] = qtpylib.rolling_vwap(dataframe) - dataframe['rsi'] = RSI(dataframe['close'], timeperiod=14) - # dataframe['tsf_long'] = TSF(dataframe['close'], timeperiod=200) - # dataframe['tsf_short'] = TSF(dataframe['close'], timeperiod=7) - dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=50) - - dataframe['angle_tsf_mid'] = LINEARREG_ANGLE(dataframe['tsf_mid'], timeperiod=10) - # dataframe['angle'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=50) - - # dataframe['tsf_max'] = MAX(dataframe['tsf_mid'], timeperiod=30) - # dataframe['tsf_min'] = MIN(dataframe['tsf_mid'], timeperiod=30) - # dataframe['sar'] = SAR(dataframe['high'], dataframe['low']) - # dataframe['sine'], dataframe['leadsine'] = HT_SINE(dataframe['close']) - # dataframe['trend'] = HT_TRENDLINE(dataframe['close']) - # dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'], - # timeperiod=5) - # dataframe['angle_trend_mid'] = LINEARREG_ANGLE(dataframe['trend'], timeperiod=10) - - # dataframe['upperband'], dataframe['middleband'], dataframe['lowerband'] = BBANDS(dataframe['close'], - # timeperiod=30, nbdevup=2, - # nbdevdn=2, matype=0) - # if not self.dp: - # # Don't do anything if DataProvider is not available. - # return dataframe - # # Get the informative pair - # informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe='1d') - # informative['trend'] = HT_TRENDLINE(informative['close']) - # informative['period'] = HT_DCPERIOD(informative['close']) - # informative['mode'] = HT_TRENDMODE(informative['close']) - # # informative['sine'], informative['leadsine'] = HT_SINE(informative['close']) - # informative['angle_trend'] = LINEARREG_ANGLE(informative['trend'], timeperiod=5) - # # informative['sar'] = SAR(informative['high'], informative['low']) - # dataframe = merge_informative_pair(dataframe, informative, self.timeframe, '1d', ffill=True) - # return dataframe.set_index('date')['2021-01-01':].reset_index() - return dataframe - - def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: - """ - Based on TA indicators, populates the buy signal for the given dataframe - :param dataframe: DataFrame populated with indicators - :param metadata: Additional information, like the currently traded pair - :return: DataFrame with buy column - """ - dataframe.loc[ - ( - (qtpylib.crossed_above(dataframe['angle_tsf_mid'], -50)) & - - # (dataframe['sine_1h'] < dataframe['leadsine_1h']) & - # (dataframe['tsf_mid'] > dataframe['close']) & - # (dataframe['ao'] > -5) & - # (dataframe['rsi'] < 36) & - (dataframe['rsi'] > 14) & - - (dataframe['volume'] > 0) # Make sure Volume is not 0 - ), - 'buy'] = 1 - - return dataframe - - def populate_sell_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: - """ - Based on TA indicators, populates the sell signal for the given dataframe - :param dataframe: DataFrame populated with indicators - :param metadata: Additional information, like the currently traded pair - :return: DataFrame with buy column - """ - dataframe.loc[ - ( - (qtpylib.crossed_below(dataframe['angle_tsf_mid'], 50)) & - # (dataframe['sine_1h'] > dataframe['leadsine_1h']) & - # (dataframe['sar_1d'] < dataframe['close']) & - # (dataframe['tsf_mid'] < dataframe['close']) & - (dataframe['rsi'] > 50) & - (dataframe['ao'] < -10) & - (dataframe['volume'] > 0) # Make sure Volume is not 0 - ), - 'sell'] = 1 - return dataframe diff --git a/.env/bin/user_data/strategies/ltcusdt_1h.py b/.env/bin/user_data/strategies/ltcusdt_1h.py index 5d848eb05..473302bed 100644 --- a/.env/bin/user_data/strategies/ltcusdt_1h.py +++ b/.env/bin/user_data/strategies/ltcusdt_1h.py @@ -43,10 +43,11 @@ class ltcusdt_1h(IStrategy): # Minimal ROI designed for the strategy. # This attribute will be overridden if the config file contains "minimal_roi". minimal_roi = { - "0": 0.04371, - "300": 0.0461, - "14487": 0.0254, - "15960": 0 + "0": 0.11465, + "607": 0.08395, + "1517": 0.01583, + "1780": 0 + } order_types = { 'buy': 'market', @@ -56,14 +57,15 @@ class ltcusdt_1h(IStrategy): } # Optimal stoploss designed for the strategy. # This attribute will be overridden if the config file contains "stoploss". - stoploss = -0.23 + stoploss = -0.23987 # Trailing stop: trailing_stop = True - trailing_stop_positive = 0.11193 - trailing_stop_positive_offset = 0.20381 + trailing_stop_positive = 0.29213 + trailing_stop_positive_offset = 0.3379 trailing_only_offset_is_reached = True + plot_config = { 'main_plot': { 'upperband': {'upperband': 'green'}, @@ -123,26 +125,30 @@ class ltcusdt_1h(IStrategy): """ dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12, - slowperiod=26, signalperiod=7) + slowperiod=24, signalperiod=7) dataframe['mfi'] = MFI(dataframe['high'], dataframe['low'], dataframe['close'], dataframe['volume'], - timeperiod=14) - dataframe['ao'] = qtpylib.awesome_oscillator(dataframe, weighted=False, fast=5, slow=34) + timeperiod=12) + dataframe['uo'] = ULTOSC(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod1=7, timeperiod2=12, + timeperiod3=24) + dataframe['ao'] = qtpylib.awesome_oscillator(dataframe, weighted=False, fast=5, slow=36) dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=48) dataframe['sar'] = SAR(dataframe['high'], dataframe['low']) + dataframe['sar_close'] = dataframe['sar'] - dataframe['close'] dataframe['natr'] = NATR(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=14) - dataframe['angle_tsf_mid'] = LINEARREG_ANGLE(dataframe['tsf_mid'], timeperiod=10) + dataframe['angle_tsf_mid'] = LINEARREG_ANGLE(dataframe['tsf_mid'], timeperiod=14) dataframe['sine'], dataframe['leadsine'] = HT_SINE(dataframe['close']) - dataframe['sine'] = dataframe['sine'].multiply(10) - dataframe['leadsine'] = dataframe['leadsine'].multiply(10) dataframe['trend'] = HT_TRENDLINE(dataframe['close']) - dataframe['mode'] = HT_TRENDMODE(dataframe['close']) dataframe['inphase'], dataframe['quadrature'] = HT_PHASOR(dataframe['close']) - dataframe['angle_trend_mid'] = LINEARREG_ANGLE(dataframe['trend'], timeperiod=10) + dataframe['angle_trend_mid'] = LINEARREG_ANGLE(dataframe['trend'], timeperiod=12) dataframe['angle'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=12) - dataframe['angle_macdsignal'] = LINEARREG_ANGLE(dataframe['macdsignal'], timeperiod=15) + dataframe['angle_min'] = MIN(dataframe['angle_trend_mid'], timeperiod=7) + dataframe['angle_min_lead'] = MIN(dataframe['angle_trend_mid'], timeperiod=3) + dataframe['angle_max_lead'] = MAX(dataframe['angle_trend_mid'], timeperiod=3) + dataframe['angle_max'] = MAX(dataframe['angle_trend_mid'], timeperiod=7) + dataframe['angle_macdsignal'] = LINEARREG_ANGLE(dataframe['macdsignal'], timeperiod=12) return dataframe @@ -155,12 +161,12 @@ class ltcusdt_1h(IStrategy): """ dataframe.loc[ ( - (qtpylib.crossed_above(dataframe['leadsine'], dataframe['sine'])) & - - # (dataframe['sine_1h'] < dataframe['leadsine_1h']) & - # (dataframe['tsf_mid'] > dataframe['close']) & - (dataframe['ao'] > -5) & - (dataframe['angle_tsf_mid'] > -3) & + (qtpylib.crossed_above(dataframe['angle_trend_mid'], 0)) & + (dataframe['angle'] > -48) & + (-21 < dataframe['angle_macdsignal']) & + (dataframe['uo'] > 9) & + (-0.90098 < (dataframe['macd'] - dataframe['macdsignal'])) & + (-50 < dataframe['ao']) & (dataframe['volume'] > 0) # Make sure Volume is not 0 ), @@ -177,13 +183,114 @@ class ltcusdt_1h(IStrategy): """ dataframe.loc[ ( - (qtpylib.crossed_below(dataframe['leadsine'], dataframe['sine'])) & - # (dataframe['sine_1h'] > dataframe['leadsine_1h']) & - # (dataframe['sar_1d'] < dataframe['close']) & - # (dataframe['tsf_mid'] < dataframe['close']) & - # (dataframe['natr'] > 2.5) & - (dataframe['angle_tsf_mid'] < 5) & + (qtpylib.crossed_below(dataframe['angle_trend_mid'], 0)) & + (dataframe['uo'] > 10) & + (dataframe['angle'] > 58) & + (10 < dataframe['ao']) & + + (-3.60339 < (dataframe['macd'] - dataframe['macdsignal'])) & + (10 > dataframe['angle_trend_mid']) & (dataframe['volume'] > 0) # Make sure Volume is not 0 ), 'sell'] = 1 return dataframe + + +""" + +freqtrade hyperopt --config user_data/config_ltcusdt_1h.json --hyperopt hyper_ltcusdt_1h --hyperopt-loss OnlyProfitHyperOptLoss --strategy ltcusdt_1h -e 500 --spaces all --timerange 20200601- + + ++--------+---------+----------+------------------+--------------+-------------------------------+----------------+-------------+ +| Best | Epoch | Trades | Win Draw Loss | Avg profit | Profit | Avg duration | Objective | +|--------+---------+----------+------------------+--------------+-------------------------------+----------------+-------------| +| * Best | 8/500 | 1 | 1 0 0 | 17.74% | 17.75689174 USDT (17.74%) | 660.0 m | 0.94087 | +| * Best | 24/500 | 71 | 43 25 3 | 1.30% | 92.24310471 USDT (92.15%) | 1,950.4 m | 0.69283 | +| Best | 98/500 | 52 | 34 15 3 | 2.56% | 133.14323340 USDT (133.01%) | 2,576.5 m | 0.55663 | +| Best | 134/500 | 119 | 61 52 6 | 1.19% | 141.48585752 USDT (141.34%) | 2,884.5 m | 0.52885 | +| Best | 149/500 | 120 | 63 48 9 | 1.22% | 146.96457805 USDT (146.82%) | 3,091.5 m | 0.51061 | +| Best | 163/500 | 56 | 38 18 0 | 3.21% | 180.15476192 USDT (179.97%) | 4,530.0 m | 0.40008 | + [Epoch 500 of 500 (100%)] || | [Time: 0:24:40, Elapsed Time: 0:24:40] +2021-03-20 23:04:51,078 - freqtrade.optimize.hyperopt - INFO - 500 epochs saved to '/home/crypto_rahino/freqtrade/user_data/hyperopt_results/strategy_ltcusdt_1h_hyperopt_results_2021-03-20_22-40-07.pickle'. + +Best result: + + 163/500: 56 trades. 38/18/0 Wins/Draws/Losses. Avg profit 3.21%. Median profit 1.58%. Total profit 180.15476192 USDT ( 179.97Σ%). Avg duration 4530.0 min. Objective: 0.40008 + + + # Buy hyperspace params: + buy_params = { + 'angle-enabled': True, + 'angle-value': -48, + 'angle_macdsignal-enabled': True, + 'angle_macdsignal-value': -21, + 'angle_trend_mid-enabled': False, + 'angle_trend_mid-value': -9, + 'angle_tsf_mid-enabled': False, + 'angle_tsf_mid-value': -18, + 'ao-enabled': True, + 'ao-value': -50, + 'macd-enabled': True, + 'macd-value': -0.90098, + 'macdhist-enabled': False, + 'macdhist-value': 1.44126, + 'macdsignal-enabled': False, + 'macdsignal-value': 10, + 'mfi-enabled': False, + 'mfi-value': 63, + 'natr-enabled': False, + 'natr-value': 1.38067, + 'sar_close-enabled': False, + 'sar_close-value': -3, + 'trigger': 'angle_trend_mid', + 'uo-enabled': True, + 'uo-value': 9 + } + + # Sell hyperspace params: + sell_params = { + 'angle-enabled': True, + 'angle-value_sell': 58, + 'angle_macdsignal-enabled': True, + 'angle_macdsignal-value_sell': -14, + 'angle_trend_mid-enabled': False, + 'angle_trend_mid-value_sell': -73, + 'angle_tsf_mid-enabled': False, + 'angle_tsf_mid-value_sell': -11, + 'ao-enabled': True, + 'ao-value_sell': 10, + 'macd-enabled': True, + 'macd-value_sell': -3.60339, + 'macdhist-enabled': False, + 'macdhist-value_sell': 4.06627, + 'macdsignal-enabled': False, + 'macdsignal-value_sell': -1, + 'mfi-enabled': False, + 'mfi-value_sell': 13, + 'natr-enabled': False, + 'natr-value_sell': 7.852, + 'sar_close-enabled': False, + 'sar_close-value_sell': 17, + 'trigger': 'angle_trend_mid', + 'uo-enabled': True, + 'uo-value_sell': 10 + } + + # ROI table: + minimal_roi = { + "0": 0.11465, + "607": 0.08395, + "1517": 0.01583, + "1780": 0 + } + + # Stoploss: + stoploss = -0.20987 + + # Trailing stop: + trailing_stop = True + trailing_stop_positive = 0.29213 + trailing_stop_positive_offset = 0.3379 + trailing_only_offset_is_reached = True + +""" diff --git a/.env/bin/user_data/strategies/quick_btcusdt_1m.py b/.env/bin/user_data/strategies/quick_btcusdt_1m.py index 6bdb20cdd..fd8b367d8 100644 --- a/.env/bin/user_data/strategies/quick_btcusdt_1m.py +++ b/.env/bin/user_data/strategies/quick_btcusdt_1m.py @@ -4,8 +4,10 @@ import numpy as np # noqa import pandas as pd # noqa from pandas import DataFrame -from talib._ta_lib import ULTOSC, MACD, SAR, LINEARREG_ANGLE, TEMA, STOCHRSI, STOCH, STOCHF, RSI +from talib._ta_lib import ULTOSC, MACD, SAR, LINEARREG_ANGLE, TEMA, TSF, CCI, ATR, CORREL, \ + BOP, WMA, KAMA, HT_DCPERIOD, HT_TRENDMODE, HT_SINE +from freqtrade.strategy import merge_informative_pair from freqtrade.strategy.interface import IStrategy # -------------------------------- @@ -33,38 +35,36 @@ class quick_btcusdt_1m(IStrategy): """ # Strategy interface version - allow new iterations of the strategy interface. # Check the documentation or the Sample strategy to get the latest version. - INTERFACE_VERSION = 1 + INTERFACE_VERSION = 2 # Minimal ROI designed for the strategy. # This attribute will be overridden if the config file contains "minimal_roi". minimal_roi = { - "0": 0.07186329732926479, - "6": 0.03610260437996321, - "14": 0.014117594921808408, - "23": 0 + "0": 0.06443, + "360": 0.06597, + "1790": 0.0108, + "2116": 0 + } # Optimal stoploss designed for the strategy. # This attribute will be overridden if the config file contains "stoploss". - stoploss = -0.073946396013718 + # Stoploss: + stoploss = -0.15825 - # Trailing stoploss + # Trailing stop: trailing_stop = True - trailing_stop_positive = 0.11645094244761 - trailing_stop_positive_offset = 0.20201226976340847 + trailing_stop_positive = 0.3274 + trailing_stop_positive_offset = 0.38967 trailing_only_offset_is_reached = True + # Optimal ticker interval for the strategy. timeframe = '1m' # Run "populate_indicators()" only for new candle. process_only_new_candles = False - # These values can be overridden in the "ask_strategy" section in the config. - use_sell_signal = True - sell_profit_only = True - ignore_roi_if_buy_signal = False - # Number of candles the strategy requires before producing valid signals startup_candle_count: int = 30 @@ -78,8 +78,8 @@ class quick_btcusdt_1m(IStrategy): # Optional order time in force. order_time_in_force = { - 'buy': 'gtc', - 'sell': 'gtc' + 'buy': 'fok', + 'sell': 'fok' } plot_config = { @@ -109,7 +109,7 @@ class quick_btcusdt_1m(IStrategy): ("BTC/USDT", "15m"), ] """ - return [("BTC/USDT", "1m")] + return [("BTC/USDT", "1h")] def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame: """ @@ -122,38 +122,39 @@ class quick_btcusdt_1m(IStrategy): :return: a Dataframe with all mandatory indicators for the strategies """ - # MACD + dataframe['period'] = HT_DCPERIOD(dataframe['close']) + dataframe['macd'], dataframe['macdsignal'], dataframe['macdhist'] = MACD(dataframe['close'], fastperiod=12, slowperiod=26, signalperiod=9) - dataframe['macd_angle'] = LINEARREG_ANGLE(dataframe['macd'], timeperiod=3) - dataframe['macdhist_angle'] = LINEARREG_ANGLE(dataframe['macd'], timeperiod=3) + dataframe['cci'] = CCI(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=30) + dataframe['sar'] = SAR(dataframe['high'], dataframe['low']) + dataframe['wma'] = WMA(dataframe['close'], timeperiod=30) + dataframe['wma_ratio'] = (dataframe['close'] - dataframe['wma']) + dataframe['kama'] = KAMA(dataframe['close'], timeperiod=30) + dataframe['angle_kama'] = LINEARREG_ANGLE(dataframe['kama'], timeperiod=10) + dataframe['tsf_mid'] = TSF(dataframe['close'], timeperiod=30) + dataframe['angle_tsf_mid'] = LINEARREG_ANGLE(dataframe['tsf_mid'], timeperiod=10) + dataframe['atr'] = ATR(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod=30) + dataframe['uo'] = ULTOSC(dataframe['high'], dataframe['low'], dataframe['close'], timeperiod1=7, timeperiod2=14, + timeperiod3=28) + dataframe['tema'] = TEMA(dataframe['close'], timeperiod=50) + dataframe['macd_ratio'] = (dataframe['macd'] - dataframe['macdsignal']) + dataframe['tsf_ratio'] = (dataframe['tsf_mid'] - dataframe['close']) + dataframe['correl_h_l'] = CORREL(dataframe['high'], dataframe['low'], timeperiod=30) + dataframe['correl_tsf_mid_close'] = CORREL(dataframe['tsf_mid'], dataframe['close'], timeperiod=12) + dataframe['bop'] = BOP(dataframe['open'], dataframe['high'], dataframe['low'], dataframe['close']) - # Linear angle - dataframe['angle'] = LINEARREG_ANGLE(dataframe['close'], timeperiod=14) + if not self.dp: + # Don't do anything if DataProvider is not available. + return dataframe + # Get the informative pair + informative = self.dp.get_pair_dataframe(pair=metadata['pair'], timeframe='1h') + informative['bop'] = BOP(informative['open'], informative['high'], informative['low'], informative['close']) + informative['period'] = HT_DCPERIOD(informative['close']) + informative['mode'] = HT_TRENDMODE(informative['close']) + informative['sine'], informative['leadsine'] = HT_SINE(informative['close']) - dataframe['tema'] = TEMA(dataframe['close'], timeperiod=30) - dataframe['sr_fastk'], dataframe['sr_fastd'] = STOCHRSI(dataframe['close'], timeperiod=14, fastk_period=5, - fastd_period=3, fastd_matype=0) - dataframe['sr_fastd_angle'] = LINEARREG_ANGLE(dataframe['sr_fastd'], timeperiod=4) - - dataframe['slowk'], dataframe['slowd'] = STOCH(dataframe['high'], dataframe['low'], dataframe['close'], - fastk_period=5, slowk_period=3, slowk_matype=0, slowd_period=3, - slowd_matype=0) - dataframe['slowd_angle'] = LINEARREG_ANGLE(dataframe['slowd'], timeperiod=3) - dataframe['sf_fastk'], dataframe['sf_fastd'] = STOCHF(dataframe['high'], dataframe['low'], dataframe['close'], fastk_period=5, fastd_period=3, fastd_matype=0) - dataframe['sf_fastd_angle'] = LINEARREG_ANGLE(dataframe['sf_fastd'], timeperiod=3) - - dataframe['rsi'] = RSI(dataframe['close'], timeperiod=14) - dataframe['rsi_angle'] = LINEARREG_ANGLE(dataframe['rsi'], timeperiod=5) - - - # # first check if dataprovider is available - # if self.dp: - # if self.dp.runmode in ('live', 'dry_run'): - # ob = self.dp.orderbook(metadata['pair'], 1) - # dataframe['best_bid'] = ob['bids'][0][0] - # dataframe['best_ask'] = ob['asks'][0][0] - # + dataframe = merge_informative_pair(dataframe, informative, self.timeframe, '1h', ffill=True) return dataframe def populate_buy_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame: @@ -165,12 +166,8 @@ class quick_btcusdt_1m(IStrategy): """ dataframe.loc[ ( - (qtpylib.crossed_above(dataframe['macd'], dataframe['macdsignal'])) & - (dataframe['sr_fastd_angle'] > -39) & - (dataframe['sf_fastk'] > 33) & - (dataframe['sf_fastd_angle'] > -80) & - (dataframe['rsi_angle'] > 24) & - (dataframe['volume'] > 0) # Make sure Volume is not 0 + (qtpylib.crossed_above(dataframe['low'], dataframe['tsf_mid'])) + ), 'buy'] = 1 @@ -185,12 +182,102 @@ class quick_btcusdt_1m(IStrategy): """ dataframe.loc[ ( - ((dataframe['macdhist']) < 0.000241872676925719) & - (dataframe['sr_fastd_angle'] > 71) & - (dataframe['sf_fastd_angle'] < 21) & - (dataframe['rsi_angle'] < 1) & - (dataframe['volume'] > 0) # Make sure Volume is not 0 + (qtpylib.crossed_below(dataframe['high'], dataframe['tsf_mid'])) + ), 'sell'] = 1 return dataframe + +""" +freqtrade hyperopt --config user_data/config_btcusdt_1m.json --hyperopt hyper_btcusdt_1m --hyperopt-loss OnlyProfitHyperOptLoss --strategy quick_btcusdt_1m -e 500 --spaces all + ++--------+---------+----------+------------------+--------------+-------------------------------+----------------+-------------+ +| Best | Epoch | Trades | Win Draw Loss | Avg profit | Profit | Avg duration | Objective | +|--------+---------+----------+------------------+--------------+-------------------------------+----------------+-------------| +| * Best | 1/500 | 2 | 1 0 1 | -3.39% | -67.10930706 USDT (-6.77%) | 4,154.0 m | 1.02257 | +| * Best | 2/500 | 2 | 1 0 1 | 0.08% | 1.60699817 USDT (0.16%) | 1,156.5 m | 0.99946 | +| * Best | 8/500 | 4 | 4 0 0 | 3.59% | 142.17731149 USDT (14.35%) | 981.5 m | 0.95218 | +| Best | 39/500 | 13 | 11 0 2 | 3.80% | 489.61841267 USDT (49.41%) | 736.2 m | 0.83531 | +| Best | 70/500 | 25 | 19 4 2 | 2.99% | 740.67168932 USDT (74.74%) | 1,597.7 m | 0.75086 | +| Best | 106/500 | 52 | 35 12 5 | 1.82% | 937.66182441 USDT (94.62%) | 1,666.9 m | 0.6846 | +| Best | 427/500 | 52 | 32 17 3 | 2.83% | 1,460.67464976 USDT (147.40%) | 2,592.9 m | 0.50868 | +| Best | 439/500 | 179 | 101 57 21 | 0.83% | 1,480.44117660 USDT (149.39%) | 3,457.9 m | 0.50203 | + [Epoch 500 of 500 (100%)] || | [Time: 1:22:09, Elapsed Time: 1:22:09] +2021-03-26 22:31:08,615 - freqtrade.optimize.hyperopt - INFO - 500 epochs saved to '/home/crypto_rahino/freqtrade/user_data/hyperopt_results/strategy_quick_btcusdt_1m_hyperopt_results_2021-03-26_21-08-16.pickle'. + +Best result: + + 439/500: 179 trades. 101/57/21 Wins/Draws/Losses. Avg profit 0.83%. Median profit 0.82%. Total profit 1480.44117660 USDT ( 149.39Σ%). Avg duration 3457.9 min. Objective: 0.50203 + + + # Buy hyperspace params: + buy_params = { + 'angle_tsf_mid-enabled': False, + 'angle_tsf_mid-value': 9, + 'atr-enabled': False, + 'atr-value': 180, + 'bop-value': 0.7274, + 'cci-enabled': False, + 'cci-value': 57, + 'correl_h_l-enabled': True, + 'correl_h_l-value': -0.5389, + 'correl_tsf_mid_close-enabled': False, + 'correl_tsf_mid_close-value': -0.8364, + 'macd_ratio-enabled': False, + 'macd_ratio-value': 101, + 'macdhist-enabled': True, + 'macdhist-value': 22, + 'macdsignal-enabled': False, + 'macdsignal-value': -478, + 'trigger': 'macd', + 'tsf_ratio-enabled': False, + 'tsf_ratio-value': -1323, + 'uo-enabled': False, + 'uo-value': 33.5021 + } + + # Sell hyperspace params: + sell_params = { + 'angle_tsf_mid-enabled': False, + 'angle_tsf_mid-value': 9, + 'atr-enabled': False, + 'atr-value': 180, + 'cci-enabled': False, + 'cci-value': 57, + 'correl_h_l-enabled': True, + 'correl_h_l-value': -0.5389, + 'correl_tsf_mid_close-enabled': False, + 'correl_tsf_mid_close-value': -0.8364, + 'macd_ratio-enabled': False, + 'macd_ratio-value': 101, + 'macdhist-enabled': True, + 'macdhist-value': 22, + 'macdsignal-enabled': False, + 'macdsignal-value': -478, + 'trigger': 'macd', + 'tsf_ratio-enabled': False, + 'tsf_ratio-value': -1323, + 'uo-enabled': False, + 'uo-value': 33.5021 + } + + # ROI table: + minimal_roi = { + "0": 0.16344, + "793": 0.05931, + "1121": 0.03143, + "1474": 0 + } + + # Stoploss: + stoploss = -0.2884 + + # Trailing stop: + trailing_stop = True + trailing_stop_positive = 0.21554 + trailing_stop_positive_offset = 0.23749 + trailing_only_offset_is_reached = False + + +""" \ No newline at end of file