diff --git a/freqtrade/freqai/RL/BaseReinforcementLearningModel.py b/freqtrade/freqai/RL/BaseReinforcementLearningModel.py index a9f406c9d..360cbf9d4 100644 --- a/freqtrade/freqai/RL/BaseReinforcementLearningModel.py +++ b/freqtrade/freqai/RL/BaseReinforcementLearningModel.py @@ -142,7 +142,7 @@ class BaseReinforcementLearningModel(IFreqaiModel): current_profit = 0 for trade in open_trades: if trade.pair == pair: - current_value = self.strategy.dp._exchange.get_rate(pair, refresh=False) + current_value = self.strategy.dp._exchange.get_rate(pair, refresh=False) #, side="buy", is_short=True) openrate = trade.open_rate if 'long' in trade.enter_tag: market_side = 1 diff --git a/freqtrade/freqai/freqai_interface.py b/freqtrade/freqai/freqai_interface.py index b6fde9357..21b79e003 100644 --- a/freqtrade/freqai/freqai_interface.py +++ b/freqtrade/freqai/freqai_interface.py @@ -7,7 +7,7 @@ import time from abc import ABC, abstractmethod from pathlib import Path from threading import Lock -from typing import Any, Dict, Tuple +from typing import Any, Dict, Tuple, Optional import numpy as np import pandas as pd @@ -90,6 +90,7 @@ class IFreqaiModel(ABC): self.begin_time: float = 0 self.begin_time_train: float = 0 self.base_tf_seconds = timeframe_to_seconds(self.config['timeframe']) + self.strategy: Optional[IStrategy] = None def assert_config(self, config: Dict[str, Any]) -> None: diff --git a/freqtrade/strategy/interface.py b/freqtrade/strategy/interface.py index 79dbd4c69..fe301eb30 100644 --- a/freqtrade/strategy/interface.py +++ b/freqtrade/strategy/interface.py @@ -152,6 +152,7 @@ class IStrategy(ABC, HyperStrategyMixin): self.freqai = FreqaiModelResolver.load_freqaimodel(self.config) self.freqai_info = self.config["freqai"] + self.freqai.strategy = self else: # Gracious failures if freqAI is disabled but "start" is called. class DummyClass():