feat: Expand pair_candles with plot_annotations call

This commit is contained in:
Matthias
2024-12-28 15:18:02 +01:00
parent 7272204d58
commit 347295ecaf
3 changed files with 18 additions and 3 deletions

View File

@@ -5,7 +5,7 @@ from pydantic import AwareDatetime, BaseModel, RootModel, SerializeAsAny, model_
from freqtrade.constants import DL_DATA_TIMEFRAMES, IntOrInf
from freqtrade.enums import MarginMode, OrderTypeValues, SignalDirection, TradingMode
from freqtrade.ft_types import ValidExchangesType
from freqtrade.ft_types import MarkArea, ValidExchangesType
from freqtrade.rpc.api_server.webserver_bgwork import ProgressTask
@@ -537,6 +537,7 @@ class PairHistory(BaseModel):
columns: list[str]
all_columns: list[str] = []
data: SerializeAsAny[list[Any]]
mark_areas: list[MarkArea] | None = None
length: int
buy_signals: int
sell_signals: int

View File

@@ -1299,7 +1299,8 @@ class RPC:
timeframe: str,
dataframe: DataFrame,
last_analyzed: datetime,
selected_cols: list[str] | None,
selected_cols: list[str],
mark_areas: list[dict[str, Any]] = None,
) -> dict[str, Any]:
has_content = len(dataframe) != 0
dataframe_columns = list(dataframe.columns)
@@ -1355,6 +1356,7 @@ class RPC:
"data_start_ts": 0,
"data_stop": "",
"data_stop_ts": 0,
"mark_areas": mark_areas,
}
if has_content:
res.update(
@@ -1373,8 +1375,16 @@ class RPC:
"""Analyzed dataframe in Dict form"""
_data, last_analyzed = self.__rpc_analysed_dataframe_raw(pair, timeframe, limit)
mark_areas = self._freqtrade.strategy.ft_plot_annotations(pair=pair, dataframe=_data)
return RPC._convert_dataframe_to_dict(
self._freqtrade.config["strategy"], pair, timeframe, _data, last_analyzed, selected_cols
self._freqtrade.config["strategy"],
pair,
timeframe,
_data,
last_analyzed,
selected_cols,
mark_areas,
)
def __rpc_analysed_dataframe_raw(
@@ -1458,6 +1468,7 @@ class RPC:
df_analyzed = strategy.analyze_ticker(_data[pair], {"pair": pair})
df_analyzed = trim_dataframe(df_analyzed, timerange_parsed, startup_candles=startup_candles)
mark_areas = strategy.ft_plot_annotations(pair=pair, dataframe=df_analyzed)
return RPC._convert_dataframe_to_dict(
strategy.get_strategy_name(),
@@ -1466,6 +1477,7 @@ class RPC:
df_analyzed.copy(),
dt_now(),
selected_cols,
mark_areas,
)
def _rpc_plot_config(self) -> dict[str, Any]:

View File

@@ -6,6 +6,7 @@ from freqtrade.exchange import (
timeframe_to_prev_date,
timeframe_to_seconds,
)
from freqtrade.ft_types import MarkArea
from freqtrade.persistence import Order, PairLocks, Trade
from freqtrade.strategy.informative_decorator import informative
from freqtrade.strategy.interface import IStrategy
@@ -44,4 +45,5 @@ __all__ = [
"merge_informative_pair",
"stoploss_from_absolute",
"stoploss_from_open",
"MarkArea",
]