Ejemplo n.º 1
0
    def is_pair_locked(self, pair: str, candle_date: datetime = None) -> bool:
        """
        Checks if a pair is currently locked
        The 2nd, optional parameter ensures that locks are applied until the new candle arrives,
        and not stop at 14:00:00 - while the next candle arrives at 14:00:02 leaving a gap
        of 2 seconds for a buy to happen on an old signal.
        :param: pair: "Pair to check"
        :param candle_date: Date of the last candle. Optional, defaults to current date
        :returns: locking state of the pair in question.
        """

        if not candle_date:
            # Simple call ...
            return PairLocks.is_pair_locked(pair)
        else:
            lock_time = timeframe_to_next_date(self.timeframe, candle_date)
            return PairLocks.is_pair_locked(pair, lock_time)
Ejemplo n.º 2
0
 def is_pair_locked(self, pair: str, candle_date: datetime = None) -> bool:
     """
     Checks if a pair is currently locked
     The 2nd, optional parameter ensures that locks are applied until the new candle arrives,
     and not stop at 14:00:00 - while the next candle arrives at 14:00:02 leaving a gap
     of 2 seconds for a buy to happen on an old signal.
     :param: pair: "Pair to check"
     :param candle_date: Date of the last candle. Optional, defaults to current date
     :returns: locking state of the pair in question.
     """
     if pair not in self._pair_locked_until:
         return False
     if not candle_date:
         return self._pair_locked_until[pair] >= datetime.now(timezone.utc)
     else:
         # Locking should happen until a new candle arrives
         lock_time = timeframe_to_next_date(self.timeframe, candle_date)
         # lock_time = candle_date + timedelta(minutes=timeframe_to_minutes(self.timeframe))
         return self._pair_locked_until[pair] > lock_time