Add plot_config to optional plot

This commit is contained in:
Matthias 2020-01-08 19:35:00 +01:00
parent c3fd894a6c
commit c9b0b4c7a4
6 changed files with 39 additions and 1 deletions

View File

@ -161,6 +161,8 @@ Sample configuration with inline comments explaining the process:
# Specifies `ema10` to be red, and `ema50` to be a shade of gray
'ema10': {'color': 'red'},
'ema50': {'color': '#CCCCCC'},
# By omitting color, a random color is selected.
'sar': {},
},
'subplots': {
# Create subplot MACD

View File

@ -78,7 +78,7 @@ class {{ strategy }}(IStrategy):
'buy': 'gtc',
'sell': 'gtc'
}
{{ plot_config | indent(4) }}
def informative_pairs(self):
"""
Define additional, informative pair/interval combinations to be cached from the exchange.

View File

@ -80,6 +80,22 @@ class SampleStrategy(IStrategy):
'sell': 'gtc'
}
plot_config = {
'main_plot': {
'tema': {},
'sar': {'color': 'white'},
},
'subplots': {
"MACD": {
'macd': {'color': 'blue'},
'macdsignal': {'color': 'orange'},
},
"RSI": {
'rsi': {'color': 'red'},
}
}
}
def informative_pairs(self):
"""
Define additional, informative pair/interval combinations to be cached from the exchange.

View File

@ -0,0 +1,18 @@
plot_config = {
# Main plot indicators (Moving averages, ...)
'main_plot': {
'tema': {},
'sar': {'color': 'white'},
},
'subplots': {
# Subplots - each dict defines one additional plot
"MACD": {
'macd': {'color': 'blue'},
'macdsignal': {'color': 'orange'},
},
"RSI": {
'rsi': {'color': 'red'},
}
}
}

View File

@ -102,12 +102,14 @@ def deploy_new_strategy(strategy_name, strategy_path: Path, subtemplate: str):
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",)
plot_config = render_template(templatefile=f"subtemplates/plot_config_{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,
"plot_config": plot_config,
})
logger.info(f"Writing strategy to `{strategy_path}`.")