Remove checks for dataprovider existance - it's available in all modes.

This commit is contained in:
Matthias 2022-08-17 10:57:25 +02:00
parent e0883a4ea0
commit e7902bffa0
2 changed files with 20 additions and 31 deletions

View File

@ -617,7 +617,6 @@ Please always check the mode of operation to select the correct method to get da
### *available_pairs* ### *available_pairs*
``` python ``` python
if self.dp:
for pair, timeframe in self.dp.available_pairs: for pair, timeframe in self.dp.available_pairs:
print(f"available {pair}, {timeframe}") print(f"available {pair}, {timeframe}")
``` ```
@ -653,7 +652,6 @@ This is where calling `self.dp.current_whitelist()` comes in handy.
``` python ``` python
# fetch live / historical candle (OHLCV) data for the first informative pair # fetch live / historical candle (OHLCV) data for the first informative pair
if self.dp:
inf_pair, inf_timeframe = self.informative_pairs()[0] inf_pair, inf_timeframe = self.informative_pairs()[0]
informative = self.dp.get_pair_dataframe(pair=inf_pair, informative = self.dp.get_pair_dataframe(pair=inf_pair,
timeframe=inf_timeframe) timeframe=inf_timeframe)
@ -671,7 +669,6 @@ It can also be used in specific callbacks to get the signal that caused the acti
``` python ``` python
# fetch current dataframe # fetch current dataframe
if self.dp:
if self.dp.runmode.value in ('live', 'dry_run'): if self.dp.runmode.value in ('live', 'dry_run'):
dataframe, last_updated = self.dp.get_analyzed_dataframe(pair=metadata['pair'], dataframe, last_updated = self.dp.get_analyzed_dataframe(pair=metadata['pair'],
timeframe=self.timeframe) timeframe=self.timeframe)
@ -684,7 +681,6 @@ if self.dp:
### *orderbook(pair, maximum)* ### *orderbook(pair, maximum)*
``` python ``` python
if self.dp:
if self.dp.runmode.value in ('live', 'dry_run'): if self.dp.runmode.value in ('live', 'dry_run'):
ob = self.dp.orderbook(metadata['pair'], 1) ob = self.dp.orderbook(metadata['pair'], 1)
dataframe['best_bid'] = ob['bids'][0][0] dataframe['best_bid'] = ob['bids'][0][0]
@ -717,7 +713,6 @@ Therefore, using `ob['bids'][0][0]` as demonstrated above will result in using t
### *ticker(pair)* ### *ticker(pair)*
``` python ``` python
if self.dp:
if self.dp.runmode.value in ('live', 'dry_run'): if self.dp.runmode.value in ('live', 'dry_run'):
ticker = self.dp.ticker(metadata['pair']) ticker = self.dp.ticker(metadata['pair'])
dataframe['last_price'] = ticker['last'] dataframe['last_price'] = ticker['last']

View File

@ -617,9 +617,6 @@ class IStrategy(ABC, HyperStrategyMixin):
) )
informative_pairs.append(pair_tf) informative_pairs.append(pair_tf)
else: else:
if not self.dp:
raise OperationalException('@informative decorator with unspecified asset '
'requires DataProvider instance.')
for pair in self.dp.current_whitelist(): for pair in self.dp.current_whitelist():
informative_pairs.append((pair, inf_data.timeframe, candle_type)) informative_pairs.append((pair, inf_data.timeframe, candle_type))
return list(set(informative_pairs)) return list(set(informative_pairs))
@ -713,7 +710,6 @@ class IStrategy(ABC, HyperStrategyMixin):
# Defs that only make change on new candle data. # Defs that only make change on new candle data.
dataframe = self.analyze_ticker(dataframe, metadata) dataframe = self.analyze_ticker(dataframe, metadata)
self._last_candle_seen_per_pair[pair] = dataframe.iloc[-1]['date'] self._last_candle_seen_per_pair[pair] = dataframe.iloc[-1]['date']
if self.dp:
self.dp._set_cached_df( self.dp._set_cached_df(
pair, self.timeframe, dataframe, pair, self.timeframe, dataframe,
candle_type=self.config.get('candle_type_def', CandleType.SPOT)) candle_type=self.config.get('candle_type_def', CandleType.SPOT))
@ -737,8 +733,6 @@ class IStrategy(ABC, HyperStrategyMixin):
The analyzed dataframe is then accessible via `dp.get_analyzed_dataframe()`. The analyzed dataframe is then accessible via `dp.get_analyzed_dataframe()`.
:param pair: Pair to analyze. :param pair: Pair to analyze.
""" """
if not self.dp:
raise OperationalException("DataProvider not found.")
dataframe = self.dp.ohlcv( dataframe = self.dp.ohlcv(
pair, self.timeframe, candle_type=self.config.get('candle_type_def', CandleType.SPOT) pair, self.timeframe, candle_type=self.config.get('candle_type_def', CandleType.SPOT)
) )