fix mypy error for strategy

This commit is contained in:
robcaulk
2022-09-15 00:56:51 +02:00
parent 8aac644009
commit 3b97b3d5c8
4 changed files with 146 additions and 5 deletions

View File

@@ -155,12 +155,13 @@ class BaseReinforcementLearningModel(IFreqaiModel):
trade_duration = 0
for trade in open_trades:
if trade.pair == pair:
# FIXME: mypy typing doesnt like that strategy may be "None" (it never will be)
# FIXME: get_rate and trade_udration shouldn't work with backtesting,
# we need to use candle dates and prices to compute that.
pytest.set_trace()
current_value = self.strategy.dp._exchange.get_rate(
pair, refresh=False, side="exit", is_short=trade.is_short)
if self.strategy.dp._exchange is None:
logger.error('No exchange available.')
else:
current_value = self.strategy.dp._exchange.get_rate(
pair, refresh=False, side="exit", is_short=trade.is_short)
openrate = trade.open_rate
now = datetime.now(timezone.utc).timestamp()
trade_duration = int((now - trade.open_date.timestamp()) / self.base_tf_seconds)

View File

@@ -92,6 +92,7 @@ class IFreqaiModel(ABC):
self._threads: List[threading.Thread] = []
self._stop_event = threading.Event()
self.strategy: IStrategy = None
def __getstate__(self):
"""
@@ -119,6 +120,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
if self.live:
self.inference_timer('start')