def get_bars(self, pcontract, dt_start, dt_end): try: logger.info('trying to load from cache') return self.cache.get_bars(pcontract, dt_start, dt_end) except LoadCacheException as e: logger.info('updating cache') missing_range = e.missing_range logger.info('missing range: {0}', missing_range) missing_data = [] for start, end in missing_range: wrapper = self.datasource.get_bars(pcontract, start, end) missing_data.append( HashObject.new(data=wrapper.data, start=start, end=end)) self.cache.save_data(missing_data, pcontract) logger.info('loading cache') return self.cache.get_bars(pcontract, dt_start, dt_end)
def get_bars(self, pcontract, dt_start, dt_end): try: logger.info('trying to load from cache') return self.cache.get_bars(pcontract, dt_start, dt_end) except LoadCacheException as e: logger.info('updating cache') missing_range = e.missing_range logger.info('missing range: {0}', missing_range) missing_data = [] for start, end in missing_range: wrapper = self.datasource.get_bars(pcontract, start, end) missing_data.append(HashObject.new(data=wrapper.data, start=start, end=end)) self.cache.save_data(missing_data, pcontract) logger.info('loading cache') return self.cache.get_bars(pcontract, dt_start, dt_end)
def on_register(self, name): logger.info('register datasource: {cls} => {name}', cls=self.cls, name=name)