Skip to content
Permalink
Browse files
getting rid of "length" values/kwargs. not needed and complicates.
  • Loading branch information
stnbu committed Sep 8, 2018
1 parent 91f95d8 commit 9a34b9193755b0b819265923f69446470262135f
Showing with 2 additions and 12 deletions.
  1. +1 −10 coincharts/data.py
  2. +1 −2 coincharts/views.py
@@ -15,9 +15,8 @@

class SymbolInfo(object):

def __init__(self, symbol, length, since=None):
def __init__(self, symbol, since=None):
self.symbol = symbol
self.length = length # this is set below when we access the "history". Being as lazy as possible.
self.since = since

@property
@@ -54,14 +53,6 @@ class SymbolComparison(dict):
def __init__(self, *args, **kwargs):
self.update(*args, **kwargs)

@property
def length(self):
# `self.length` has to be a calculated value, we may be truncating other symbol histories
# so we're only dealing with time periods where they all overlap (are present).
# So it's up to me* to set self.length as soon as practical.
# For now we'll just grab an arbitrary symbol and use its lenght attribute
return list(self.values())[0].length # <-- only a few symbols. not expensive.

def normalized_history_averages(self):
normalized_history_generators = []
for symbol, data in self.items():
@@ -18,15 +18,14 @@ def index(request):
symbols = config['history_symbols']
comparison = SymbolComparison()
for symbol in symbols:
comparison[symbol] = SymbolInfo(symbol, length=967, since='2018-08-16T06:59:59.0000000Z')
comparison[symbol] = SymbolInfo(symbol)
history_generator = comparison.normalized_history_averages()

graph = svg_graph.LineGraph(
title='Price history averages',
height=580,
width=1200,
points=history_generator,
length=comparison.length
)

context = {

0 comments on commit 9a34b91

Please sign in to comment.