add last_analyzed to emitted dataframe
This commit is contained in:
parent
38f14349e9
commit
3535aa7724
@ -121,7 +121,7 @@ class DataProvider:
|
|||||||
'type': RPCMessageType.ANALYZED_DF,
|
'type': RPCMessageType.ANALYZED_DF,
|
||||||
'data': {
|
'data': {
|
||||||
'key': pair_key,
|
'key': pair_key,
|
||||||
'value': dataframe
|
'value': (dataframe, datetime.now(timezone.utc))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@ -130,6 +130,7 @@ class DataProvider:
|
|||||||
self,
|
self,
|
||||||
pair: str,
|
pair: str,
|
||||||
dataframe: DataFrame,
|
dataframe: DataFrame,
|
||||||
|
last_analyzed: Optional[str] = None,
|
||||||
timeframe: Optional[str] = None,
|
timeframe: Optional[str] = None,
|
||||||
candle_type: Optional[CandleType] = None,
|
candle_type: Optional[CandleType] = None,
|
||||||
producer_name: str = "default"
|
producer_name: str = "default"
|
||||||
@ -149,7 +150,12 @@ class DataProvider:
|
|||||||
if producer_name not in self.__producer_pairs_df:
|
if producer_name not in self.__producer_pairs_df:
|
||||||
self.__producer_pairs_df[producer_name] = {}
|
self.__producer_pairs_df[producer_name] = {}
|
||||||
|
|
||||||
self.__producer_pairs_df[producer_name][pair_key] = (dataframe, datetime.now(timezone.utc))
|
if not last_analyzed:
|
||||||
|
_last_analyzed = datetime.now(timezone.utc)
|
||||||
|
else:
|
||||||
|
_last_analyzed = datetime.fromisoformat(last_analyzed)
|
||||||
|
|
||||||
|
self.__producer_pairs_df[producer_name][pair_key] = (dataframe, _last_analyzed)
|
||||||
logger.debug(f"External DataFrame for {pair_key} from {producer_name} added.")
|
logger.debug(f"External DataFrame for {pair_key} from {producer_name} added.")
|
||||||
|
|
||||||
def get_external_df(
|
def get_external_df(
|
||||||
|
@ -10,7 +10,6 @@ import socket
|
|||||||
from threading import Thread
|
from threading import Thread
|
||||||
from typing import Any, Dict, List, Optional
|
from typing import Any, Dict, List, Optional
|
||||||
|
|
||||||
import pandas
|
|
||||||
import websockets
|
import websockets
|
||||||
|
|
||||||
from freqtrade.data.dataprovider import DataProvider
|
from freqtrade.data.dataprovider import DataProvider
|
||||||
@ -225,9 +224,12 @@ class ExternalMessageConsumer:
|
|||||||
timeout=self.reply_timeout
|
timeout=self.reply_timeout
|
||||||
)
|
)
|
||||||
|
|
||||||
|
try:
|
||||||
async with lock:
|
async with lock:
|
||||||
# Handle the message
|
# Handle the message
|
||||||
self.handle_producer_message(producer, message)
|
self.handle_producer_message(producer, message)
|
||||||
|
except Exception as e:
|
||||||
|
logger.exception(f"Error handling producer message: {e}")
|
||||||
|
|
||||||
except (asyncio.TimeoutError, websockets.exceptions.ConnectionClosed):
|
except (asyncio.TimeoutError, websockets.exceptions.ConnectionClosed):
|
||||||
# We haven't received data yet. Check the connection and continue.
|
# We haven't received data yet. Check the connection and continue.
|
||||||
@ -300,17 +302,20 @@ class ExternalMessageConsumer:
|
|||||||
|
|
||||||
key, value = message_data.get('key'), message_data.get('value')
|
key, value = message_data.get('key'), message_data.get('value')
|
||||||
|
|
||||||
if key and isinstance(value, pandas.DataFrame):
|
if key and value:
|
||||||
pair, timeframe, candle_type = key
|
pair, timeframe, candle_type = key
|
||||||
dataframe = value
|
dataframe, last_analyzed = value
|
||||||
|
|
||||||
# If set, remove the Entry and Exit signals from the Producer
|
# If set, remove the Entry and Exit signals from the Producer
|
||||||
if self._emc_config.get('remove_entry_exit_signals', False):
|
if self._emc_config.get('remove_entry_exit_signals', False):
|
||||||
dataframe = remove_entry_exit_signals(dataframe)
|
dataframe = remove_entry_exit_signals(dataframe)
|
||||||
|
|
||||||
# Add the dataframe to the dataprovider
|
# Add the dataframe to the dataprovider
|
||||||
self._dp._add_external_df(pair, dataframe, timeframe,
|
self._dp._add_external_df(pair, dataframe,
|
||||||
candle_type, producer_name=producer_name)
|
last_analyzed=last_analyzed,
|
||||||
|
timeframe=timeframe,
|
||||||
|
candle_type=candle_type,
|
||||||
|
producer_name=producer_name)
|
||||||
|
|
||||||
logger.debug(
|
logger.debug(
|
||||||
f"Consumed message from {producer_name} of type RPCMessageType.ANALYZED_DF")
|
f"Consumed message from {producer_name} of type RPCMessageType.ANALYZED_DF")
|
||||||
|
@ -1064,7 +1064,8 @@ class RPC:
|
|||||||
|
|
||||||
for pair in pairlist:
|
for pair in pairlist:
|
||||||
dataframe, last_analyzed = self.__rpc_analysed_dataframe_raw(pair, timeframe, limit)
|
dataframe, last_analyzed = self.__rpc_analysed_dataframe_raw(pair, timeframe, limit)
|
||||||
_data[pair] = {"key": (pair, timeframe, candle_type), "value": dataframe}
|
_data[pair] = {"key": (pair, timeframe, candle_type),
|
||||||
|
"value": (dataframe, last_analyzed)}
|
||||||
|
|
||||||
return _data
|
return _data
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user