Add plotconfig as property documentation and sample
This commit is contained in:
parent
2414c0bd9f
commit
cf5ff9257d
@ -164,7 +164,7 @@ The resulting plot will have the following elements:
|
|||||||
|
|
||||||
An advanced plot configuration can be specified in the strategy in the `plot_config` parameter.
|
An advanced plot configuration can be specified in the strategy in the `plot_config` parameter.
|
||||||
|
|
||||||
Additional features when using plot_config include:
|
Additional features when using `plot_config` include:
|
||||||
|
|
||||||
* Specify colors per indicator
|
* Specify colors per indicator
|
||||||
* Specify additional subplots
|
* Specify additional subplots
|
||||||
@ -174,6 +174,7 @@ The sample plot configuration below specifies fixed colors for the indicators. O
|
|||||||
It also allows multiple subplots to display both MACD and RSI at the same time.
|
It also allows multiple subplots to display both MACD and RSI at the same time.
|
||||||
|
|
||||||
Plot type can be configured using `type` key. Possible types are:
|
Plot type can be configured using `type` key. Possible types are:
|
||||||
|
|
||||||
* `scatter` corresponding to `plotly.graph_objects.Scatter` class (default).
|
* `scatter` corresponding to `plotly.graph_objects.Scatter` class (default).
|
||||||
* `bar` corresponding to `plotly.graph_objects.Bar` class.
|
* `bar` corresponding to `plotly.graph_objects.Bar` class.
|
||||||
|
|
||||||
@ -181,6 +182,54 @@ Extra parameters to `plotly.graph_objects.*` constructor can be specified in `pl
|
|||||||
|
|
||||||
Sample configuration with inline comments explaining the process:
|
Sample configuration with inline comments explaining the process:
|
||||||
|
|
||||||
|
``` python
|
||||||
|
@property
|
||||||
|
def plot_config(self):
|
||||||
|
"""
|
||||||
|
There are a lot of solutions how to build the return dictionary.
|
||||||
|
The only important point is the return value.
|
||||||
|
Example:
|
||||||
|
plot_config = {'main_plot': {}, 'subplots': {}}
|
||||||
|
|
||||||
|
"""
|
||||||
|
plot_config = {}
|
||||||
|
plot_config['main_plot'] = {
|
||||||
|
# Configuration for main plot indicators.
|
||||||
|
# Assumes 2 parameters, emashort and emalong to be specified.
|
||||||
|
f'ema_{self.emashort.value}': {'color': 'red'},
|
||||||
|
f'ema_{self.emalong.value}': {'color': '#CCCCCC'},
|
||||||
|
# By omitting color, a random color is selected.
|
||||||
|
'sar': {},
|
||||||
|
# fill area between senkou_a and senkou_b
|
||||||
|
'senkou_a': {
|
||||||
|
'color': 'green', #optional
|
||||||
|
'fill_to': 'senkou_b',
|
||||||
|
'fill_label': 'Ichimoku Cloud', #optional
|
||||||
|
'fill_color': 'rgba(255,76,46,0.2)', #optional
|
||||||
|
},
|
||||||
|
# plot senkou_b, too. Not only the area to it.
|
||||||
|
'senkou_b': {}
|
||||||
|
}
|
||||||
|
plot_config['subplots'] = {
|
||||||
|
# Create subplot MACD
|
||||||
|
"MACD": {
|
||||||
|
'macd': {'color': 'blue', 'fill_to': 'macdhist'},
|
||||||
|
'macdsignal': {'color': 'orange'},
|
||||||
|
'macdhist': {'type': 'bar', 'plotly': {'opacity': 0.9}}
|
||||||
|
},
|
||||||
|
# Additional subplot RSI
|
||||||
|
"RSI": {
|
||||||
|
'rsi': {'color': 'red'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return plot_config
|
||||||
|
```
|
||||||
|
|
||||||
|
??? Note "As attribute (former method)"
|
||||||
|
Assigning plot_config is also possible as Attribute (this used to be the default way).
|
||||||
|
This has the disadvantage that strategy parameters are not available, preventing certain configurations from working.
|
||||||
|
|
||||||
``` python
|
``` python
|
||||||
plot_config = {
|
plot_config = {
|
||||||
'main_plot': {
|
'main_plot': {
|
||||||
@ -216,6 +265,7 @@ Sample configuration with inline comments explaining the process:
|
|||||||
|
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
!!! Note
|
!!! Note
|
||||||
The above configuration assumes that `ema10`, `ema50`, `senkou_a`, `senkou_b`,
|
The above configuration assumes that `ema10`, `ema50`, `senkou_a`, `senkou_b`,
|
||||||
`macd`, `macdsignal`, `macdhist` and `rsi` are columns in the DataFrame created by the strategy.
|
`macd`, `macdsignal`, `macdhist` and `rsi` are columns in the DataFrame created by the strategy.
|
||||||
|
@ -87,6 +87,7 @@ class {{ strategy }}(IStrategy):
|
|||||||
'sell': 'gtc'
|
'sell': 'gtc'
|
||||||
}
|
}
|
||||||
{{ plot_config | indent(4) }}
|
{{ plot_config | indent(4) }}
|
||||||
|
|
||||||
def informative_pairs(self):
|
def informative_pairs(self):
|
||||||
"""
|
"""
|
||||||
Define additional, informative pair/interval combinations to be cached from the exchange.
|
Define additional, informative pair/interval combinations to be cached from the exchange.
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
|
|
||||||
plot_config = {
|
@property
|
||||||
|
def plot_config(self):
|
||||||
|
return {
|
||||||
# Main plot indicators (Moving averages, ...)
|
# Main plot indicators (Moving averages, ...)
|
||||||
'main_plot': {
|
'main_plot': {
|
||||||
'tema': {},
|
'tema': {},
|
||||||
|
Loading…
Reference in New Issue
Block a user