chore: rename Annotation type

This commit is contained in:
Matthias
2024-12-28 15:41:10 +01:00
parent 8cdae5f56e
commit 4c3e477667
5 changed files with 12 additions and 10 deletions

View File

@@ -5,5 +5,5 @@ from freqtrade.ft_types.backtest_result_type import (
BacktestResultType,
get_BacktestResultType_default,
)
from freqtrade.ft_types.plot_annotation_type import MarkArea
from freqtrade.ft_types.plot_annotation_type import AnnotationType
from freqtrade.ft_types.valid_exchanges_type import ValidExchangesType

View File

@@ -1,9 +1,11 @@
from datetime import datetime
from typing import Literal
from typing_extensions import NotRequired, TypedDict
class MarkArea(TypedDict):
class AnnotationType(TypedDict):
type: Literal["area"] = "area"
start: NotRequired[str | datetime]
end: NotRequired[str | datetime]
y_start: NotRequired[float]

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 MarkArea, ValidExchangesType
from freqtrade.ft_types import AnnotationType, ValidExchangesType
from freqtrade.rpc.api_server.webserver_bgwork import ProgressTask
@@ -537,7 +537,7 @@ class PairHistory(BaseModel):
columns: list[str]
all_columns: list[str] = []
data: SerializeAsAny[list[Any]]
mark_areas: list[MarkArea] | None = None
mark_areas: list[AnnotationType] | None = None
length: int
buy_signals: int
sell_signals: int

View File

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

View File

@@ -26,7 +26,7 @@ from freqtrade.enums import (
)
from freqtrade.exceptions import OperationalException, StrategyError
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_next_date, timeframe_to_seconds
from freqtrade.ft_types import MarkArea
from freqtrade.ft_types import AnnotationType
from freqtrade.misc import remove_entry_exit_signals
from freqtrade.persistence import Order, PairLocks, Trade
from freqtrade.strategy.hyper import HyperStrategyMixin
@@ -737,7 +737,7 @@ class IStrategy(ABC, HyperStrategyMixin):
def plot_annotations(
self, pair: str, start_date: datetime, end_date: datetime, dataframe: DataFrame, **kwargs
) -> list[MarkArea]:
) -> list[AnnotationType]:
"""
Retrieve area annotations for a chart.
Must be returned as array, with label, start, end, y_start, y_end and color.
@@ -748,7 +748,7 @@ class IStrategy(ABC, HyperStrategyMixin):
:param end_date: End date of the chart data being requested
:param dataframe: DataFrame with the analyzed data for the chart
:param **kwargs: Ensure to keep this here so updates to this won't break your strategy.
:return: List of MarkArea objects
:return: List of AnnotationType objects
"""
return []
@@ -1688,7 +1688,7 @@ class IStrategy(ABC, HyperStrategyMixin):
df = df.rename({"sell": "exit_long"}, axis="columns")
return df
def ft_plot_annotations(self, pair: str, dataframe: DataFrame) -> list[MarkArea]:
def ft_plot_annotations(self, pair: str, dataframe: DataFrame) -> list[AnnotationType]:
"""
Internal wrapper around plot_dataframe
"""