Permalink
Browse files

relocate `date_format_template` from `daemonize` -> `data`; graph fro…

…m "one week ago"; installation administrivia
  • Loading branch information...
stnbu committed Sep 8, 2018
1 parent 6acd979 commit 395450d270754612967ef66fd4b711e7e558112c
Showing with 17 additions and 5 deletions.
  1. +2 −2 coincharts/daemonize.py
  2. +1 −0 coincharts/data.py
  3. +12 −2 coincharts/views.py
  4. +1 −0 requirements.txt
  5. +1 −1 setup.py
@@ -19,6 +19,7 @@
from coincharts import config, db
from coincharts.models import THE_DATETIME_FIELD, THE_PRICE_FIELD
from coincharts.data import date_format_template
# We're replacing the module with a dict. Importing the file shouldn't result in reading from disk, etc. That's why.
config = config.get_config()
@@ -38,7 +39,6 @@ class PriceSeries(object):
time_end='',
limit=100000,
)
date_format_template = '%Y-%m-%dT%H:%M:%S.%f0Z' # magic
headers = {'X-CoinAPI-Key': config['api_key']}
# this is the beginning of time if we don't have any local data
@@ -58,7 +58,7 @@ def validate_datetime_object(cls, dt):
def get_normalized_datetime(cls, dt):
if not isinstance(dt, datetime.datetime):
dt = parse_dt(dt)
return dt.strftime(cls.date_format_template)
return dt.strftime(date_format_template)
@classmethod
def round_up_hour(cls, dt):
@@ -12,6 +12,7 @@
from coincharts import config
config = config.get_config()
date_format_template = '%Y-%m-%dT%H:%M:%S.%f0Z' # magic
class SymbolInfo(object):
@@ -1,3 +1,8 @@
import time
import datetime
import pytz
from django.shortcuts import render
from django.shortcuts import get_object_or_404, render
@@ -7,18 +12,23 @@
from dateutil.parser import parse as parse_dt
import time
from coincharts import config
from coincharts.data import SymbolComparison, SymbolInfo
from coincharts.data import SymbolComparison, SymbolInfo, date_format_template
config = config.get_config()
import svg_graph
def index(request):
# this is the totally intuitive way of getting the ISO8601 formatted date for one week ago UTC
one_week_ago = datetime.datetime.fromtimestamp(
time.time() - 7 * 24 * 60 * 60,
tz=pytz.UTC).strftime(date_format_template)
symbols = config['history_symbols']
comparison = SymbolComparison()
for symbol in symbols:
comparison[symbol] = SymbolInfo(symbol)
comparison[symbol] = SymbolInfo(symbol, since=one_week_ago)
history_generator = comparison.normalized_history_averages()
eth = comparison['BITSTAMP_SPOT_ETH_USD']
@@ -2,3 +2,4 @@ python-daemon>=2.2
requests>=2.18
python-dateutil>=2.7
PyYAML>=3.13
git+https://github.com/stnbu/mutils.git
@@ -24,6 +24,6 @@ def read(file):
provides=[name],
packages=[name],
entry_points = {
'console_scripts': ['coincharts-daemon=coincharts.daemon:main'],
'console_scripts': ['coincharts-daemon=coincharts.daemonize:main'],
}
)

0 comments on commit 395450d

Please sign in to comment.