mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-11-29 08:33:07 +00:00
feat: Expand pair_candles with plot_annotations call
This commit is contained in:
@@ -5,7 +5,7 @@ from pydantic import AwareDatetime, BaseModel, RootModel, SerializeAsAny, model_
|
|||||||
|
|
||||||
from freqtrade.constants import DL_DATA_TIMEFRAMES, IntOrInf
|
from freqtrade.constants import DL_DATA_TIMEFRAMES, IntOrInf
|
||||||
from freqtrade.enums import MarginMode, OrderTypeValues, SignalDirection, TradingMode
|
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
|
from freqtrade.rpc.api_server.webserver_bgwork import ProgressTask
|
||||||
|
|
||||||
|
|
||||||
@@ -537,6 +537,7 @@ class PairHistory(BaseModel):
|
|||||||
columns: list[str]
|
columns: list[str]
|
||||||
all_columns: list[str] = []
|
all_columns: list[str] = []
|
||||||
data: SerializeAsAny[list[Any]]
|
data: SerializeAsAny[list[Any]]
|
||||||
|
mark_areas: list[MarkArea] | None = None
|
||||||
length: int
|
length: int
|
||||||
buy_signals: int
|
buy_signals: int
|
||||||
sell_signals: int
|
sell_signals: int
|
||||||
|
|||||||
@@ -1299,7 +1299,8 @@ class RPC:
|
|||||||
timeframe: str,
|
timeframe: str,
|
||||||
dataframe: DataFrame,
|
dataframe: DataFrame,
|
||||||
last_analyzed: datetime,
|
last_analyzed: datetime,
|
||||||
selected_cols: list[str] | None,
|
selected_cols: list[str],
|
||||||
|
mark_areas: list[dict[str, Any]] = None,
|
||||||
) -> dict[str, Any]:
|
) -> dict[str, Any]:
|
||||||
has_content = len(dataframe) != 0
|
has_content = len(dataframe) != 0
|
||||||
dataframe_columns = list(dataframe.columns)
|
dataframe_columns = list(dataframe.columns)
|
||||||
@@ -1355,6 +1356,7 @@ class RPC:
|
|||||||
"data_start_ts": 0,
|
"data_start_ts": 0,
|
||||||
"data_stop": "",
|
"data_stop": "",
|
||||||
"data_stop_ts": 0,
|
"data_stop_ts": 0,
|
||||||
|
"mark_areas": mark_areas,
|
||||||
}
|
}
|
||||||
if has_content:
|
if has_content:
|
||||||
res.update(
|
res.update(
|
||||||
@@ -1373,8 +1375,16 @@ class RPC:
|
|||||||
"""Analyzed dataframe in Dict form"""
|
"""Analyzed dataframe in Dict form"""
|
||||||
|
|
||||||
_data, last_analyzed = self.__rpc_analysed_dataframe_raw(pair, timeframe, limit)
|
_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(
|
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(
|
def __rpc_analysed_dataframe_raw(
|
||||||
@@ -1458,6 +1468,7 @@ class RPC:
|
|||||||
|
|
||||||
df_analyzed = strategy.analyze_ticker(_data[pair], {"pair": pair})
|
df_analyzed = strategy.analyze_ticker(_data[pair], {"pair": pair})
|
||||||
df_analyzed = trim_dataframe(df_analyzed, timerange_parsed, startup_candles=startup_candles)
|
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(
|
return RPC._convert_dataframe_to_dict(
|
||||||
strategy.get_strategy_name(),
|
strategy.get_strategy_name(),
|
||||||
@@ -1466,6 +1477,7 @@ class RPC:
|
|||||||
df_analyzed.copy(),
|
df_analyzed.copy(),
|
||||||
dt_now(),
|
dt_now(),
|
||||||
selected_cols,
|
selected_cols,
|
||||||
|
mark_areas,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _rpc_plot_config(self) -> dict[str, Any]:
|
def _rpc_plot_config(self) -> dict[str, Any]:
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ from freqtrade.exchange import (
|
|||||||
timeframe_to_prev_date,
|
timeframe_to_prev_date,
|
||||||
timeframe_to_seconds,
|
timeframe_to_seconds,
|
||||||
)
|
)
|
||||||
|
from freqtrade.ft_types import MarkArea
|
||||||
from freqtrade.persistence import Order, PairLocks, Trade
|
from freqtrade.persistence import Order, PairLocks, Trade
|
||||||
from freqtrade.strategy.informative_decorator import informative
|
from freqtrade.strategy.informative_decorator import informative
|
||||||
from freqtrade.strategy.interface import IStrategy
|
from freqtrade.strategy.interface import IStrategy
|
||||||
@@ -44,4 +45,5 @@ __all__ = [
|
|||||||
"merge_informative_pair",
|
"merge_informative_pair",
|
||||||
"stoploss_from_absolute",
|
"stoploss_from_absolute",
|
||||||
"stoploss_from_open",
|
"stoploss_from_open",
|
||||||
|
"MarkArea",
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user