store dataprovider to self instead of strategy
This commit is contained in:
parent
6ff0e66ddf
commit
6746868ea7
@ -177,10 +177,10 @@ class BaseReinforcementLearningModel(IFreqaiModel):
|
|||||||
trade_duration = 0
|
trade_duration = 0
|
||||||
for trade in open_trades:
|
for trade in open_trades:
|
||||||
if trade.pair == pair:
|
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.')
|
logger.error('No exchange available.')
|
||||||
else:
|
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)
|
pair, refresh=False, side="exit", is_short=trade.is_short)
|
||||||
openrate = trade.open_rate
|
openrate = trade.open_rate
|
||||||
now = datetime.now(timezone.utc).timestamp()
|
now = datetime.now(timezone.utc).timestamp()
|
||||||
|
@ -15,6 +15,7 @@ from pandas import DataFrame
|
|||||||
|
|
||||||
from freqtrade.configuration import TimeRange
|
from freqtrade.configuration import TimeRange
|
||||||
from freqtrade.constants import DATETIME_PRINT_FORMAT, Config
|
from freqtrade.constants import DATETIME_PRINT_FORMAT, Config
|
||||||
|
from freqtrade.data.dataprovider import DataProvider
|
||||||
from freqtrade.enums import RunMode
|
from freqtrade.enums import RunMode
|
||||||
from freqtrade.exceptions import OperationalException
|
from freqtrade.exceptions import OperationalException
|
||||||
from freqtrade.exchange import timeframe_to_seconds
|
from freqtrade.exchange import timeframe_to_seconds
|
||||||
@ -99,7 +100,7 @@ class IFreqaiModel(ABC):
|
|||||||
self.get_corr_dataframes: bool = True
|
self.get_corr_dataframes: bool = True
|
||||||
self._threads: List[threading.Thread] = []
|
self._threads: List[threading.Thread] = []
|
||||||
self._stop_event = threading.Event()
|
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)
|
self.max_system_threads = max(int(psutil.cpu_count() * 2 - 2), 1)
|
||||||
|
|
||||||
record_params(config, self.full_path)
|
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.live = strategy.dp.runmode in (RunMode.DRY_RUN, RunMode.LIVE)
|
||||||
self.dd.set_pair_dict_info(metadata)
|
self.dd.set_pair_dict_info(metadata)
|
||||||
self.strategy = strategy
|
self.data_provider = strategy.dp
|
||||||
|
|
||||||
if self.live:
|
if self.live:
|
||||||
self.inference_timer('start')
|
self.inference_timer('start')
|
||||||
|
Loading…
Reference in New Issue
Block a user