Beispiel #1
0
    def __init__(self, channel, importer):
        super().__init__(channel)
        self.exchange_data_importer = importer

        self.initial_timestamp = api.get_backtesting_current_time(
            self.channel.exchange_manager.exchange.backtesting)
        self.last_pushed_timestamp = 0
        self.time_consumer = None
    def __init__(self, channel, importer):
        super().__init__(channel)
        self.exchange_data_importer = importer
        self.exchange_name = self.channel.exchange_manager.exchange_name

        self.initial_timestamp = api.get_backtesting_current_time(self.channel.exchange_manager.exchange.backtesting)
        self.last_timestamp_pushed = 0
        self.time_consumer = None

        self.future_candle_time_frame = self.channel.exchange_manager.exchange_config.get_shortest_time_frame()
        self.future_candle_sec_length = enums.TimeFramesMinutes[self.future_candle_time_frame] * \
                                        constants.MINUTE_TO_SECONDS

        self.last_candles_by_pair_by_time_frame = {}
        self.require_last_init_candles_pairs_push = False
        self.traded_pairs = self._get_traded_pairs()
        self.traded_time_frame = self._get_time_frames()
Beispiel #3
0
 async def handle_timestamp(self, timestamp, **kwargs):
     try:
         current_time = api.get_backtesting_current_time(
             self.channel.exchange_manager.exchange.backtesting)
         if current_time - self.last_pushed_timestamp > self.FUNDING_REFRESH_TIME_MAX \
                 or self.last_pushed_timestamp == 0:
             self.last_pushed_timestamp = current_time
             for pair in self.channel.exchange_manager.exchange_config.traded_symbol_pairs:
                 funding_rate = await self.channel.exchange_manager.exchange.get_funding_rate(
                     symbol=pair)
                 await self._push_funding(
                     symbol=pair,
                     funding_rate=funding_rate,
                     predicted_funding_rate=funding_rate)
     except errors.DataBaseNotExists as e:
         self.logger.warning(f"Not enough data : {e}")
         await self.pause()
         await self.stop()
     except IndexError as e:
         self.logger.warning(f"Failed to access funding_data : {e}")
     except Exception as e:
         self.logger.exception(e, True,
                               f"Error when updating from timestamp: {e}")
Beispiel #4
0
 def get_exchange_current_time(self):
     return backtesting_api.get_backtesting_current_time(self.backtesting)