def time_to_work(self): now = datetime.now() if now.weekday() not in [0, 1, 2, 3, 4]: raise Exception("Today it's Saturnday or Sunday") template = "SELECT date FROM ticker WHERE date == '{today}'" context = {'today': now.strftime("%Y-%m-%d")} query = template.format(**context) dbr = DbReader(self.model) result = dbr.select(query) if result: raise Exception("The Robot already fetched the ticker") return True
def time_to_work(self): now = datetime.now() if now.weekday() not in [0, 1, 2, 3, 4]: raise Exception("Today it's Saturnday or Sunday") template = "SELECT date FROM ticker WHERE date == '{today}'" context = { 'today': now.strftime("%Y-%m-%d") } query = template.format(**context) dbr = DbReader(self.model) result = dbr.select(query) if result: raise Exception("The Robot already fetched the ticker") return True
def not_measured_yet(self): dbr = DbReader(self.model) query = "SELECT pk, future_date, price FROM prediction"\ " as t WHERE t.pk NOT IN (SELECT fk FROM truth);" qs = dbr.select(query) return qs