Allow selection of templates for strategy
This commit is contained in:
parent
b3dbb81838
commit
f26c40082d
@ -39,9 +39,9 @@ ARGS_LIST_PAIRS = ["exchange", "print_list", "list_pairs_print_json", "print_one
|
|||||||
|
|
||||||
ARGS_CREATE_USERDIR = ["user_data_dir", "reset"]
|
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",
|
ARGS_DOWNLOAD_DATA = ["pairs", "pairs_file", "days", "download_trades", "exchange",
|
||||||
"timeframes", "erase"]
|
"timeframes", "erase"]
|
||||||
|
@ -339,6 +339,14 @@ AVAILABLE_CLI_OPTIONS = {
|
|||||||
help='Clean all existing data for the selected exchange/pairs/timeframes.',
|
help='Clean all existing data for the selected exchange/pairs/timeframes.',
|
||||||
action='store_true',
|
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
|
# Plot dataframe
|
||||||
"indicators1": Arg(
|
"indicators1": Arg(
|
||||||
'--indicators1',
|
'--indicators1',
|
||||||
|
1
freqtrade/templates/subtemplates/buy_trend_minimal.j2
Normal file
1
freqtrade/templates/subtemplates/buy_trend_minimal.j2
Normal file
@ -0,0 +1 @@
|
|||||||
|
(qtpylib.crossed_above(dataframe['rsi'], 30)) & # Signal: RSI crosses above 30
|
@ -154,8 +154,8 @@ dataframe['htleadsine'] = hilbert['leadsine']
|
|||||||
"""
|
"""
|
||||||
# first check if dataprovider is available
|
# first check if dataprovider is available
|
||||||
if self.dp:
|
if self.dp:
|
||||||
if self.dp.runmode in ('live', 'dry_run'):
|
if self.dp.runmode in ('live', 'dry_run'):
|
||||||
ob = self.dp.orderbook(metadata['pair'], 1)
|
ob = self.dp.orderbook(metadata['pair'], 1)
|
||||||
dataframe['best_bid'] = ob['bids'][0][0]
|
dataframe['best_bid'] = ob['bids'][0][0]
|
||||||
dataframe['best_ask'] = ob['asks'][0][0]
|
dataframe['best_ask'] = ob['asks'][0][0]
|
||||||
"""
|
"""
|
||||||
|
17
freqtrade/templates/subtemplates/indicators_minimal.j2
Normal file
17
freqtrade/templates/subtemplates/indicators_minimal.j2
Normal 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]
|
||||||
|
"""
|
1
freqtrade/templates/subtemplates/sell_trend_minimal.j2
Normal file
1
freqtrade/templates/subtemplates/sell_trend_minimal.j2
Normal file
@ -0,0 +1 @@
|
|||||||
|
(qtpylib.crossed_above(dataframe['rsi'], 70)) & # Signal: RSI crosses above 70
|
@ -107,7 +107,7 @@ def start_new_strategy(args: Dict[str, Any]) -> None:
|
|||||||
|
|
||||||
strategy_text = render_template(templatefile='base_strategy.py.j2',
|
strategy_text = render_template(templatefile='base_strategy.py.j2',
|
||||||
arguments={"strategy": args["strategy"],
|
arguments={"strategy": args["strategy"],
|
||||||
"subtemplates": 'full'})
|
"subtemplates": args['template']})
|
||||||
|
|
||||||
logger.info(f"Writing strategy to `{new_path}`.")
|
logger.info(f"Writing strategy to `{new_path}`.")
|
||||||
new_path.write_text(strategy_text)
|
new_path.write_text(strategy_text)
|
||||||
@ -130,7 +130,9 @@ def start_new_hyperopt(args: Dict[str, Any]) -> None:
|
|||||||
"Please choose another Strategy Name.")
|
"Please choose another Strategy Name.")
|
||||||
|
|
||||||
strategy_text = render_template(templatefile='base_hyperopt.py.j2',
|
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}`.")
|
logger.info(f"Writing hyperopt to `{new_path}`.")
|
||||||
new_path.write_text(strategy_text)
|
new_path.write_text(strategy_text)
|
||||||
|
Loading…
Reference in New Issue
Block a user