|
|
|
@ -1,6 +1,7 @@ |
|
|
|
# note: This module takes 1-2 seconds to import. It should be imported *on-demand*. |
|
|
|
# note: This module takes 1-2 seconds to import. It should be imported *on-demand*. |
|
|
|
|
|
|
|
|
|
|
|
import datetime |
|
|
|
import datetime |
|
|
|
|
|
|
|
from decimal import Decimal |
|
|
|
from collections import defaultdict |
|
|
|
from collections import defaultdict |
|
|
|
|
|
|
|
|
|
|
|
import matplotlib |
|
|
|
import matplotlib |
|
|
|
@ -20,15 +21,15 @@ class NothingToPlotException(Exception): |
|
|
|
def plot_history(history): |
|
|
|
def plot_history(history): |
|
|
|
if len(history) == 0: |
|
|
|
if len(history) == 0: |
|
|
|
raise NothingToPlotException() |
|
|
|
raise NothingToPlotException() |
|
|
|
hist_in = defaultdict(int) |
|
|
|
hist_in = defaultdict(Decimal) |
|
|
|
hist_out = defaultdict(int) |
|
|
|
hist_out = defaultdict(Decimal) |
|
|
|
for item in history: |
|
|
|
for item in history: |
|
|
|
is_lightning = item.get("lightning", False) |
|
|
|
is_lightning = item.get("lightning", False) |
|
|
|
if not is_lightning and not item['confirmations']: |
|
|
|
if not is_lightning and not item['confirmations']: |
|
|
|
continue |
|
|
|
continue |
|
|
|
if item['timestamp'] is None: |
|
|
|
if item['timestamp'] is None: |
|
|
|
continue |
|
|
|
continue |
|
|
|
value = item['value'].value/COIN |
|
|
|
value = Decimal(item['value'].value)/COIN |
|
|
|
date = item['date'] |
|
|
|
date = item['date'] |
|
|
|
datenum = int(md.date2num(datetime.date(date.year, date.month, 1))) |
|
|
|
datenum = int(md.date2num(datetime.date(date.year, date.month, 1))) |
|
|
|
if value > 0: |
|
|
|
if value > 0: |
|
|
|
|