remove data waiting, remove explicit analyzing of external df
This commit is contained in:
@@ -12,14 +12,13 @@ from pandas import DataFrame
|
||||
|
||||
from freqtrade.constants import ListPairsWithTimeframes
|
||||
from freqtrade.data.dataprovider import DataProvider
|
||||
from freqtrade.enums import (CandleType, ExitCheckTuple, ExitType, RPCMessageType, SignalDirection,
|
||||
SignalTagType, SignalType, TradingMode)
|
||||
from freqtrade.enums import (CandleType, ExitCheckTuple, ExitType, SignalDirection, SignalTagType,
|
||||
SignalType, TradingMode)
|
||||
from freqtrade.enums.runmode import RunMode
|
||||
from freqtrade.exceptions import OperationalException, StrategyError
|
||||
from freqtrade.exchange import timeframe_to_minutes, timeframe_to_next_date, timeframe_to_seconds
|
||||
from freqtrade.misc import dataframe_to_json, remove_entry_exit_signals
|
||||
from freqtrade.misc import remove_entry_exit_signals
|
||||
from freqtrade.persistence import Order, PairLocks, Trade
|
||||
from freqtrade.rpc import RPCManager
|
||||
from freqtrade.strategy.hyper import HyperStrategyMixin
|
||||
from freqtrade.strategy.informative_decorator import (InformativeData, PopulateIndicators,
|
||||
_create_and_merge_informative_pair,
|
||||
@@ -113,7 +112,6 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
# and wallets - access to the current balance.
|
||||
dp: DataProvider
|
||||
wallets: Optional[Wallets] = None
|
||||
rpc: RPCManager
|
||||
# Filled from configuration
|
||||
stake_currency: str
|
||||
# container variable for strategy source code
|
||||
@@ -731,16 +729,8 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
candle_type = self.config.get('candle_type_def', CandleType.SPOT)
|
||||
self.dp._set_cached_df(pair, self.timeframe, dataframe, candle_type=candle_type)
|
||||
|
||||
if not external_data:
|
||||
self.rpc.send_msg(
|
||||
{
|
||||
'type': RPCMessageType.ANALYZED_DF,
|
||||
'data': {
|
||||
'key': (pair, self.timeframe, candle_type),
|
||||
'value': dataframe_to_json(dataframe)
|
||||
}
|
||||
}
|
||||
)
|
||||
if populate_indicators:
|
||||
self.dp.emit_df((pair, self.timeframe, candle_type), dataframe)
|
||||
|
||||
else:
|
||||
logger.debug("Skipping TA Analysis for already analyzed candle")
|
||||
@@ -763,10 +753,7 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
"""
|
||||
candle_type = self.config.get('candle_type_def', CandleType.SPOT)
|
||||
|
||||
if not external_data:
|
||||
dataframe = self.dp.ohlcv(pair, self.timeframe, candle_type)
|
||||
else:
|
||||
dataframe, _ = self.dp.get_external_df(pair, self.timeframe, candle_type)
|
||||
dataframe = self.dp.ohlcv(pair, self.timeframe, candle_type)
|
||||
|
||||
if not isinstance(dataframe, DataFrame) or dataframe.empty:
|
||||
logger.warning('Empty candle (OHLCV) data for pair %s', pair)
|
||||
@@ -790,38 +777,15 @@ class IStrategy(ABC, HyperStrategyMixin):
|
||||
|
||||
def analyze(
|
||||
self,
|
||||
pairs: List[str]
|
||||
pairs: List[str],
|
||||
external_data: bool = False
|
||||
) -> None:
|
||||
"""
|
||||
Analyze all pairs using analyze_pair().
|
||||
:param pairs: List of pairs to analyze
|
||||
"""
|
||||
for pair in pairs:
|
||||
self.analyze_pair(pair)
|
||||
|
||||
def analyze_external(self, pairs: List[str], leader_pairs: List[str]) -> None:
|
||||
"""
|
||||
Analyze the pre-populated dataframes from the Leader
|
||||
|
||||
:param pairs: The active pair whitelist
|
||||
:param leader_pairs: The list of pairs from the Leaders
|
||||
"""
|
||||
|
||||
# Get the extra pairs not listed in Leader pairs, and process
|
||||
# them normally.
|
||||
# List order is not preserved when doing this!
|
||||
# We use ^ instead of - for symmetric difference
|
||||
extra_pairs = list(set(pairs) ^ set(leader_pairs))
|
||||
# These would be the pairs that we have trades in, which means
|
||||
# we would have to analyze them normally
|
||||
# Eventually maybe request data from the Leader if we don't have it?
|
||||
|
||||
for pair in leader_pairs:
|
||||
# Analyze the pairs, but get the dataframe from the external data
|
||||
self.analyze_pair(pair, external_data=True)
|
||||
|
||||
for pair in extra_pairs:
|
||||
self.analyze_pair(pair)
|
||||
self.analyze_pair(pair, external_data)
|
||||
|
||||
@ staticmethod
|
||||
def preserve_df(dataframe: DataFrame) -> Tuple[int, float, datetime]:
|
||||
|
Reference in New Issue
Block a user