Permalink
Browse files

forgot to package `daemon`. adding `__init__.py`. handling case where…

… no `time_period_end` exist for `symbol_id`.
  • Loading branch information...
stnbu committed Sep 3, 2018
1 parent 448d8a8 commit 725ba0a64f10e6176b11d2ba6a3b9cc02a9650bf
Showing with 10 additions and 1 deletion.
  1. +3 −0 coincharts/daemon/__init__.py
  2. +7 −1 coincharts/daemon/base.py
@@ -0,0 +1,3 @@
# -*- mode: python; coding: utf-8 -*-
from .base import main
@@ -46,6 +46,8 @@ class PriceSeries(object):
@classmethod
def validate_datetime_object(cls, dt):
if isinstance(dt, str):
dt = parse_dt(dt)
assert dt.tzname() == 'UTC', 'tzname==`{}`. Expected `UTC`'.format(dt.tzname())
assert not dt.hour % 6, 'hour==`{}` not a multiple of `6`'.format(dt.hour)
for attr in 'minute', 'second', 'microsecond':
@@ -117,7 +119,11 @@ def fetch(self, symbol_id):
return data
def get_last_date_from_store(self, symbol_id):
obj = db.Prices.objects.filter(symbol_id=symbol_id).order_by('id').latest()
try:
obj = db.Prices.objects.filter(symbol_id=symbol_id).order_by('id').latest()
except db.Prices.DoesNotExist:
logging.info('No `time_period_end` value found for {}'.format(symbol_id))
return None
dt = getattr(obj, 'time_period_end')
return parse_dt(dt)

0 comments on commit 725ba0a

Please sign in to comment.