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)
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 def on_register(self, name):
     logger.info('register datasource: {cls} => {name}',
                 cls=self.cls,
                 name=name)
Ejemplo n.º 4
0
 def on_register(self, name):
     logger.info('register datasource: {cls} => {name}',
                 cls=self.cls, name=name)