Reinstate mfi ...

This commit is contained in:
Matthias 2019-11-21 20:01:08 +01:00
parent 5f8fcebb88
commit 210d468a9b
3 changed files with 50 additions and 36 deletions

View File

@ -131,8 +131,8 @@ class SampleStrategy(IStrategy):
dataframe['macdsignal'] = macd['macdsignal']
dataframe['macdhist'] = macd['macdhist']
# # MFI
# dataframe['mfi'] = ta.MFI(dataframe)
# MFI
dataframe['mfi'] = ta.MFI(dataframe)
# # Minus Directional Indicator / Movement
# dataframe['minus_dm'] = ta.MINUS_DM(dataframe)

View File

@ -26,8 +26,8 @@ dataframe['macd'] = macd['macd']
dataframe['macdsignal'] = macd['macdsignal']
dataframe['macdhist'] = macd['macdhist']
# # MFI
# dataframe['mfi'] = ta.MFI(dataframe)
# MFI
dataframe['mfi'] = ta.MFI(dataframe)
# # Minus Directional Indicator / Movement
# dataframe['minus_dm'] = ta.MINUS_DM(dataframe)

View File

@ -91,6 +91,25 @@ def start_create_userdir(args: Dict[str, Any]) -> None:
sys.exit(1)
def deploy_new_strategy(strategy_name, strategy_path: Path, subtemplate: str):
"""
Deploy new strategy from template to strategy_path
"""
indicators = render_template(templatefile=f"subtemplates/indicators_{subtemplate}.j2",)
buy_trend = render_template(templatefile=f"subtemplates/buy_trend_{subtemplate}.j2",)
sell_trend = render_template(templatefile=f"subtemplates/sell_trend_{subtemplate}.j2",)
strategy_text = render_template(templatefile='base_strategy.py.j2',
arguments={"strategy": strategy_name,
"indicators": indicators,
"buy_trend": buy_trend,
"sell_trend": sell_trend,
})
logger.info(f"Writing strategy to `{strategy_path}`.")
strategy_path.write_text(strategy_text)
def start_new_strategy(args: Dict[str, Any]) -> None:
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
@ -105,23 +124,37 @@ def start_new_strategy(args: Dict[str, Any]) -> None:
raise OperationalException(f"`{new_path}` already exists. "
"Please choose another Strategy Name.")
indicators = render_template(templatefile=f"subtemplates/indicators_{args['template']}.j2",)
buy_trend = render_template(templatefile=f"subtemplates/buy_trend_{args['template']}.j2",)
sell_trend = render_template(templatefile=f"subtemplates/sell_trend_{args['template']}.j2",)
deploy_new_strategy(args['strategy'], new_path, args['template'])
strategy_text = render_template(templatefile='base_strategy.py.j2',
arguments={"strategy": args["strategy"],
"indicators": indicators,
"buy_trend": buy_trend,
"sell_trend": sell_trend,
})
logger.info(f"Writing strategy to `{new_path}`.")
new_path.write_text(strategy_text)
else:
raise OperationalException("`new-strategy` requires --strategy to be set.")
def deploy_new_hyperopt(hyperopt_name, hyperopt_path: Path, subtemplate: str):
"""
Deploys a new hyperopt template to hyperopt_path
"""
buy_guards = render_template(
templatefile=f"subtemplates/hyperopt_buy_guards_{subtemplate}.j2",)
sell_guards = render_template(
templatefile=f"subtemplates/hyperopt_sell_guards_{subtemplate}.j2",)
buy_space = render_template(
templatefile=f"subtemplates/hyperopt_buy_space_{subtemplate}.j2",)
sell_space = render_template(
templatefile=f"subtemplates/hyperopt_sell_space_{subtemplate}.j2",)
strategy_text = render_template(templatefile='base_hyperopt.py.j2',
arguments={"hyperopt": hyperopt_name,
"buy_guards": buy_guards,
"sell_guards": sell_guards,
"buy_space": buy_space,
"sell_space": sell_space,
})
logger.info(f"Writing hyperopt to `{hyperopt_path}`.")
hyperopt_path.write_text(strategy_text)
def start_new_hyperopt(args: Dict[str, Any]) -> None:
config = setup_utils_configuration(args, RunMode.UTIL_NO_EXCHANGE)
@ -135,26 +168,7 @@ def start_new_hyperopt(args: Dict[str, Any]) -> None:
if new_path.exists():
raise OperationalException(f"`{new_path}` already exists. "
"Please choose another Strategy Name.")
buy_guards = render_template(
templatefile=f"subtemplates/hyperopt_buy_guards_{args['template']}.j2",)
sell_guards = render_template(
templatefile=f"subtemplates/hyperopt_sell_guards_{args['template']}.j2",)
buy_space = render_template(
templatefile=f"subtemplates/hyperopt_buy_space_{args['template']}.j2",)
sell_space = render_template(
templatefile=f"subtemplates/hyperopt_sell_space_{args['template']}.j2",)
strategy_text = render_template(templatefile='base_hyperopt.py.j2',
arguments={"hyperopt": args["hyperopt"],
"buy_guards": buy_guards,
"sell_guards": sell_guards,
"buy_space": buy_space,
"sell_space": sell_space,
})
logger.info(f"Writing hyperopt to `{new_path}`.")
new_path.write_text(strategy_text)
deploy_new_hyperopt(args['hyperopt'], new_path, args['template'])
else:
raise OperationalException("`new-hyperopt` requires --hyperopt to be set.")