diff --git a/freqtrade/configuration/arguments.py b/freqtrade/configuration/arguments.py index 5cc56a8bc..b23366d7a 100644 --- a/freqtrade/configuration/arguments.py +++ b/freqtrade/configuration/arguments.py @@ -39,9 +39,9 @@ ARGS_LIST_PAIRS = ["exchange", "print_list", "list_pairs_print_json", "print_one ARGS_CREATE_USERDIR = ["user_data_dir", "reset"] -ARGS_BUILD_STRATEGY = ["user_data_dir", "strategy"] +ARGS_BUILD_STRATEGY = ["user_data_dir", "strategy", "template"] -ARGS_BUILD_HYPEROPT = ["user_data_dir", "hyperopt"] +ARGS_BUILD_HYPEROPT = ["user_data_dir", "hyperopt", "template"] ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "download_trades", "exchange", "timeframes", "erase"] diff --git a/freqtrade/configuration/cli_options.py b/freqtrade/configuration/cli_options.py index d7a496aa7..be9397975 100644 --- a/freqtrade/configuration/cli_options.py +++ b/freqtrade/configuration/cli_options.py @@ -339,6 +339,14 @@ AVAILABLE_CLI_OPTIONS = { help='Clean all existing data for the selected exchange/pairs/timeframes.', action='store_true', ), + # Templating options + "template": Arg( + '--template', + help='Use a template which is either `minimal` or ' + '`full` (containing multiple sample indicators).', + choices=['full', 'minimal'], + default='full', + ), # Plot dataframe "indicators1": Arg( '--indicators1', diff --git a/freqtrade/templates/subtemplates/buy_trend_minimal.j2 b/freqtrade/templates/subtemplates/buy_trend_minimal.j2 new file mode 100644 index 000000000..6a4079cf3 --- /dev/null +++ b/freqtrade/templates/subtemplates/buy_trend_minimal.j2 @@ -0,0 +1 @@ +(qtpylib.crossed_above(dataframe['rsi'], 30)) & # Signal: RSI crosses above 30 diff --git a/freqtrade/templates/subtemplates/indicators_full.j2 b/freqtrade/templates/subtemplates/indicators_full.j2 index 395808776..33dd85311 100644 --- a/freqtrade/templates/subtemplates/indicators_full.j2 +++ b/freqtrade/templates/subtemplates/indicators_full.j2 @@ -154,8 +154,8 @@ dataframe['htleadsine'] = hilbert['leadsine'] """ # 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] + 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] """ diff --git a/freqtrade/templates/subtemplates/indicators_minimal.j2 b/freqtrade/templates/subtemplates/indicators_minimal.j2 new file mode 100644 index 000000000..7d75b4610 --- /dev/null +++ b/freqtrade/templates/subtemplates/indicators_minimal.j2 @@ -0,0 +1,17 @@ + +# Momentum Indicators +# ------------------------------------ + +# RSI +dataframe['rsi'] = ta.RSI(dataframe) + +# Retrieve best bid and best ask from the orderbook +# ------------------------------------ +""" +# 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] +""" diff --git a/freqtrade/templates/subtemplates/sell_trend_minimal.j2 b/freqtrade/templates/subtemplates/sell_trend_minimal.j2 new file mode 100644 index 000000000..42a7b81a2 --- /dev/null +++ b/freqtrade/templates/subtemplates/sell_trend_minimal.j2 @@ -0,0 +1 @@ +(qtpylib.crossed_above(dataframe['rsi'], 70)) & # Signal: RSI crosses above 70 diff --git a/freqtrade/utils.py b/freqtrade/utils.py index 47bb5e3f6..4657e58fc 100644 --- a/freqtrade/utils.py +++ b/freqtrade/utils.py @@ -107,7 +107,7 @@ def start_new_strategy(args: Dict[str, Any]) -> None: strategy_text = render_template(templatefile='base_strategy.py.j2', arguments={"strategy": args["strategy"], - "subtemplates": 'full'}) + "subtemplates": args['template']}) logger.info(f"Writing strategy to `{new_path}`.") new_path.write_text(strategy_text) @@ -130,7 +130,9 @@ def start_new_hyperopt(args: Dict[str, Any]) -> None: "Please choose another Strategy Name.") strategy_text = render_template(templatefile='base_hyperopt.py.j2', - arguments={"hyperopt": args["hyperopt"]}) + arguments={"hyperopt": args["hyperopt"], + "subtemplates": args['template'] + }) logger.info(f"Writing hyperopt to `{new_path}`.") new_path.write_text(strategy_text)