btcticker

eInk Bitcoin price ticker
git clone https://git.parazyd.org/btcticker
Log | Files | Refs | README | LICENSE

commit 523b662f54231d027378c5164aa42dc3d59ffede
parent 00fa1310e22a73e4915fce06bca58fa16da8e1ef
Author: parazyd <parazyd@dyne.org>
Date:   Sun, 21 Feb 2021 12:47:41 +0100

Use defined constants for currency/coin.

Diffstat:
Mticker.py | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/ticker.py b/ticker.py @@ -41,7 +41,10 @@ fontdir = join(dirname(realpath(__file__)), 'fonts') font = ImageFont.truetype(join(fontdir, 'googlefonts/Roboto-Medium.ttf'), 40) font_date = ImageFont.truetype(join(fontdir, 'PixelSplitter-Bold.ttf'), 11) -tokenfilename = join(picdir, 'currency/bitcoin.bmp') +currency = 'usd' +coin = 'bitcoin' + +tokenfilename = join(picdir, 'currency/%s.bmp' % currency) athbitmap = Image.open(join(picdir, 'ATH.bmp')) tokenimage = Image.open(tokenfilename) @@ -54,14 +57,14 @@ def get_data(other): endtime = int(time()) starttime = endtime - 60*60*24*days_ago - geckourl = '%s/markets?vs_currency=%s&ids=%s' % (API, 'usd', 'bitcoin') + geckourl = '%s/markets?vs_currency=%s&ids=%s' % (API, currency, coin) liveprice = requests.get(geckourl).json()[0] pricenow = float(liveprice['current_price']) alltimehigh = float(liveprice['ath']) other['volume'] = float(liveprice['total_volume']) url_hist = '%s/%s/market_chart/range?vs_currency=%s&from=%s&to=%s' % ( - API, 'bitcoin', 'usd', str(starttime), str(endtime)) + API, coin, currency, str(starttime), str(endtime)) try: timeseriesarray = requests.get(url_hist).json()['prices']