Allow selection of templates for strategy

This commit is contained in:
Matthias 2019-11-21 07:21:19 +01:00
parent b3dbb81838
commit f26c40082d
7 changed files with 37 additions and 8 deletions

View File

@ -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"]

View File

@ -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',

View File

@ -0,0 +1 @@
(qtpylib.crossed_above(dataframe['rsi'], 30)) & # Signal: RSI crosses above 30

View File

@ -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]
"""

View File

@ -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]
"""

View File

@ -0,0 +1 @@
(qtpylib.crossed_above(dataframe['rsi'], 70)) & # Signal: RSI crosses above 70

View File

@ -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)