Type WS messagetypes

This commit is contained in:
Matthias 2023-03-24 20:54:28 +01:00
parent 8928d3616a
commit ad58bac810
2 changed files with 26 additions and 5 deletions

View File

@ -21,6 +21,7 @@ from freqtrade.exchange import Exchange, timeframe_to_seconds
from freqtrade.exchange.types import OrderBook
from freqtrade.misc import append_candles_to_dataframe
from freqtrade.rpc import RPCManager
from freqtrade.rpc.rpc_types import RPCAnalyzedDFMsg
from freqtrade.util import PeriodicCache
@ -118,8 +119,7 @@ class DataProvider:
:param new_candle: This is a new candle
"""
if self.__rpc:
self.__rpc.send_msg(
{
msg: RPCAnalyzedDFMsg = {
'type': RPCMessageType.ANALYZED_DF,
'data': {
'key': pair_key,
@ -127,7 +127,7 @@ class DataProvider:
'la': datetime.now(timezone.utc)
}
}
)
self.__rpc.send_msg(msg)
if new_candle:
self.__rpc.send_msg({
'type': RPCMessageType.NEW_CANDLE,

View File

@ -1,6 +1,7 @@
from datetime import datetime
from typing import List, Literal, Optional, TypedDict, Union
from typing import Any, List, Literal, Optional, TypedDict, Union
from freqtrade.constants import PairWithTimeframe
from freqtrade.enums import RPCMessageType
@ -95,6 +96,24 @@ class RPCSellCancelMsg(__RPCBuyMsgBase):
close_date: datetime
class __AnalyzedDFData(TypedDict):
key: PairWithTimeframe
df: Any
la: datetime
class RPCAnalyzedDFMsg(RPCSendMsgBase):
"""New Analyzed dataframe message"""
type: Literal[RPCMessageType.ANALYZED_DF]
data: __AnalyzedDFData
class RPCNewCandleMsg(RPCSendMsgBase):
"""New candle ping message, issued once per new candle/pair"""
type: Literal[RPCMessageType.NEW_CANDLE]
data: PairWithTimeframe
RPCSendMsg = Union[
RPCStatusMsg,
RPCStrategyMsg,
@ -103,5 +122,7 @@ RPCSendMsg = Union[
RPCBuyMsg,
RPCCancelMsg,
RPCSellMsg,
RPCSellCancelMsg
RPCSellCancelMsg,
RPCAnalyzedDFMsg,
RPCNewCandleMsg
]