store dataprovider to self instead of strategy

This commit is contained in:
robcaulk 2022-11-12 11:33:03 +01:00
parent 6ff0e66ddf
commit 6746868ea7
2 changed files with 5 additions and 4 deletions

View File

@ -177,10 +177,10 @@ class BaseReinforcementLearningModel(IFreqaiModel):
trade_duration = 0
for trade in open_trades:
if trade.pair == pair:
if self.strategy.dp._exchange is None: # type: ignore
if self.data_provider._exchange is None: # type: ignore
logger.error('No exchange available.')
else:
current_value = self.strategy.dp._exchange.get_rate( # type: ignore
current_value = self.data_provider._exchange.get_rate( # type: ignore
pair, refresh=False, side="exit", is_short=trade.is_short)
openrate = trade.open_rate
now = datetime.now(timezone.utc).timestamp()

View File

@ -15,6 +15,7 @@ from pandas import DataFrame
from freqtrade.configuration import TimeRange
from freqtrade.constants import DATETIME_PRINT_FORMAT, Config
from freqtrade.data.dataprovider import DataProvider
from freqtrade.enums import RunMode
from freqtrade.exceptions import OperationalException
from freqtrade.exchange import timeframe_to_seconds
@ -99,7 +100,7 @@ class IFreqaiModel(ABC):
self.get_corr_dataframes: bool = True
self._threads: List[threading.Thread] = []
self._stop_event = threading.Event()
self.strategy: Optional[IStrategy] = None
self.data_provider: Optional[DataProvider] = None
self.max_system_threads = max(int(psutil.cpu_count() * 2 - 2), 1)
record_params(config, self.full_path)
@ -129,7 +130,7 @@ class IFreqaiModel(ABC):
self.live = strategy.dp.runmode in (RunMode.DRY_RUN, RunMode.LIVE)
self.dd.set_pair_dict_info(metadata)
self.strategy = strategy
self.data_provider = strategy.dp
if self.live:
self.inference_timer('start')