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,9 +617,8 @@ 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}")
``` ```
### *current_whitelist()* ### *current_whitelist()*
@ -653,10 +652,9 @@ 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)
``` ```
!!! Warning "Warning about backtesting" !!! Warning "Warning about backtesting"
@ -671,10 +669,9 @@ 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)
``` ```
!!! Note "No data available" !!! Note "No data available"
@ -684,11 +681,10 @@ 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] dataframe['best_ask'] = ob['asks'][0][0]
dataframe['best_ask'] = ob['asks'][0][0]
``` ```
The orderbook structure is aligned with the order structure from [ccxt](https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure), so the result will look as follows: The orderbook structure is aligned with the order structure from [ccxt](https://github.com/ccxt/ccxt/wiki/Manual#order-book-structure), so the result will look as follows:
@ -717,12 +713,11 @@ 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'] dataframe['volume24h'] = ticker['quoteVolume']
dataframe['volume24h'] = ticker['quoteVolume'] dataframe['vwap'] = ticker['vwap']
dataframe['vwap'] = ticker['vwap']
``` ```
!!! Warning !!! Warning

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,10 +710,9 @@ 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))
else: else:
logger.debug("Skipping TA Analysis for already analyzed candle") logger.debug("Skipping TA Analysis for already analyzed candle")
dataframe[SignalType.ENTER_LONG.value] = 0 dataframe[SignalType.ENTER_LONG.value] = 0
@ -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)
) )