mirror of
https://github.com/freqtrade/freqtrade.git
synced 2026-01-20 05:50:36 +00:00
docs: add visual documentation for plot annotations
This commit is contained in:
BIN
docs/assets/frequi-chart-annotations-dark.png
Normal file
BIN
docs/assets/frequi-chart-annotations-dark.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 90 KiB |
BIN
docs/assets/frequi-chart-annotations-light.png
Normal file
BIN
docs/assets/frequi-chart-annotations-light.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
@@ -1170,3 +1170,53 @@ class AwesomeStrategy(IStrategy):
|
||||
return annotations
|
||||
|
||||
```
|
||||
|
||||
!!! Warning "Many annotations"
|
||||
Using too many annotations can cause the UI to hang, especially when plotting large amounts of historic data.
|
||||
Use the annotation feature with care.
|
||||
|
||||
|
||||
### Plot annotations example
|
||||
|
||||

|
||||

|
||||
|
||||
??? Info "Code used for the plot above"
|
||||
This is an example code and should be treated as such.
|
||||
|
||||
``` python
|
||||
# Default imports
|
||||
|
||||
class AwesomeStrategy(IStrategy):
|
||||
def plot_annotations(
|
||||
self, pair: str, start_date: datetime, end_date: datetime, dataframe: DataFrame, **kwargs
|
||||
) -> list[AnnotationType]:
|
||||
annotations = []
|
||||
while start_dt < end_date:
|
||||
start_dt += timedelta(hours=1)
|
||||
if (start_dt.hour % 4) == 0:
|
||||
mark_areas.append(
|
||||
{
|
||||
"type": "area",
|
||||
"label": "4h",
|
||||
"start": start_dt,
|
||||
"end": start_dt + timedelta(hours=1),
|
||||
"color": "rgba(133, 133, 133, 0.4)",
|
||||
}
|
||||
)
|
||||
elif (start_dt.hour % 2) == 0:
|
||||
mark_areas.append(
|
||||
{
|
||||
"type": "area",
|
||||
"label": "2h",
|
||||
"start": start_dt,
|
||||
"end": start_dt + timedelta(hours=1),
|
||||
"y_end": 1830,
|
||||
"y_start": 1860,
|
||||
"color": "rgba(0, 255, 0, 0.4)",
|
||||
}
|
||||
)
|
||||
|
||||
return annotations
|
||||
|
||||
```
|
||||
|
||||
Reference in New Issue
Block a user