예제 #1
0
    def handle(self, **options):
#TODO replace settings dict with market table
        exchange = []
        if options.get('exchange'):
            # force download of the specified exchange
            for x in settings.TSB['downloads']:
                if x['exchange'] == options.get('exchange'):
                    exchange.append(x)
                    break
            if not exchange:
                raise SystemExit('Nothing to do: exchange {} not found'.format(
                        options.get('exchange')))
        else:
            # for each exchange, check if it needs to be downloaded
            for x in settings.TSB['downloads']:
                exchange_time = datetime.now(timezone(x.get('timezone')))
                if not is_weekday(exchange_time):
                    continue
                if exchange_time.hour == x.get('time_h'):
                    exchange.append(x)
        for x in exchange:
            #FIXME: retries will cause delay *before* running next exchange!
                # implementing delays in hours could be easy-ish (but how to 
                # remember which symbols need retrying?? - NoRedis??)
            #TODO: implement datasource (now yahoo is always used)
            #TODO: use -verbosity to see output when using cmd line
            #TODO: with -verbosity=0 send *certain* messages to admin
            Price.download_prices_today(currency=x.get('currency'),
                    num_retries=x.get('num_retries'))
예제 #2
0
파일: tests.py 프로젝트: EdwinvO/pyutillib
 def test_is_weekday(self):
     for date in self.weekdays:
         self.assertTrue(du.is_weekday(date))
     for date in self.weekend:
         self.assertFalse(du.is_weekday(date))