Coder Social home page Coder Social logo

btc-ticker / btc-ticker Goto Github PK

View Code? Open in Web Editor NEW
46.0 3.0 10.0 3.68 MB

BTC Ticker on a 2.7 inch e-paper attached to a rasberry zero WH

Home Page: https://btc-ticker.com

License: MIT License

Python 62.37% Shell 36.39% HCL 1.23%
e-paper raspbian raspberry-pi ticker bitcoin mempool

btc-ticker's Introduction

bitcoin-ticker

bitcoin-ticker is a E-ink ticker that shows usefull information about bitcoin. Due to the limited refresh lifetime, new information is currently shown every 5 minutes and whenever a new block arrives.

Hardware

More e-paper that are supportet:

The config.ini needs the following settings when using the 7.5 inch:

epd_type = 7in5_V2
orientation = 270
layout_list=ohlc

Usage

Ticker view

The Tickers the following information:

  • Block height, Mean block intervall in minutes, Time
  • Minimal Block fee for the first 7 blocks in mempool
  • Dollar price of a bitcoin
  • Satoshi per Dollar (also know as moskow time)
  • Sotoshi per Euro
  • Euro price of a bitcoin

Whenever a new block has arrived on the blockchain, the following information is shown for 120 seconds (can be disabled in the config.ini):

  • Euro price of a bitcoin, mean block intervall in minutes, Time
  • Minimal Block fee for the first 7 blocks in mempool
  • Blocks in mempook, Number of transaction in mempool
  • Blocks until next difficulty retargeting, est. difficulty multiplier, est. retarget time
  • Block height

Due to the limited lifetime of 1000000 refreshes and an expected lifetime of 5 years, the refresh period has been set to 216 seconds.

Buttons

There are four buttons which the following behaviour (Please be patient after pressing, the e-ink is quite slow):

  1. Switch through different ticker views (views can be selected in the config.ini)
  2. Switch BTC/fiat graph through 1, 3 and 7 days (Can be changed in the config.ini)
  3. Switch the layout of the ticker (layouts can be selected in the config.ini)
  4. Switch inverted mode

Switching to ro-mode

Per default, the file system is mounted writable. When there is a empty ro file in /boot, the filesystem will remounted readonly.

sudo touch /boot/ro

enables the readonly remount. The file can also be created with a PC, similar to the ssh file.

Switching between ro and rw mode

After logging in with ssh,

rw

remounts the file system with write support.

ro

switches back to readonly.

Config.ini

It possible to personalize the ticker to your needs. After logging into your raspi with SSH, the config can be edited with

rw
nano config.ini
ro

After writing the change to the ini file, a restart of the btc-ticker service is needed:

sudo systemctl restart btcticker

Update btc-ticker without reflashing the sdcard

After logging into the btc-ticker with SSH, the update can be started with

rw
./99updateMenu.sh

Select now:

  • PATCH
  • Patch menu
  • PATCH to update the ticker to the newest updates from git.

Download image

  • Downlad version 0.6.0 from btc-ticker-0_6_0.img.gz
  • Verify SHA256 checksum. It should be: ebeb7e615237853f7388f3f8b00268c2e88b560104f711f11e76ed6e0e59805d

Flash SDcard with Raspberry Pi Imager

Use https://www.raspberrypi.com/software/ for flashing the image to the sd-card.

  • Select btc-ticker img file
  • select sdcard
  • Before writing click on settings and modify the following settings
  • enable ssh with Use password authentication
  • set username and password and write Username: admin Password: btcticker
  • enable WiFi and enter your WiFi connection details
  • start with clicking on write

wpa_supplicant.conf (only when not using settings on Imager)

When you use the Raspberry Pi Imager with settings, there is no need for adding wpa_supplicant.conf manually. When you did not enter your wifi credentials in the settings menu, you need to do thefollowing:

  • add wpa_supplicant.conf to the boot partition when mounted on PC
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=[COUNTRY_CODE]
network={
  ssid="[WIFI_SSID]"
  psk="[WIFI_PASSWORD]"
  key_mgmt=WPA-PSK
}
  • replace [COUNTRY_CODE] with the ISO2 code (e.g. DE)
  • Set [WIFI_SSID] and [WIFI_PASSWORD]
  • On the first boot, the filesystem is mounted writable (Necessary for coping the wpa_supplicant.conf).
  • When there is no wpa_supplicant.conf at /boot, the filesystem will be mounten readonly.

Build SDcard from scratch

The SDcard build process is inspired by the great raspiblitz.

  • Download lastest raspios image
  • Write the Image to a SD card Tutorial
  • Add a ssh file to the boot partition when mounted on PC
  • Add a wpa_supplicant.conf file, as shown in the section before. More information are also available here
  • Login via SSH to ssh pi@[IP-OF-YOUR-RASPI] using password raspberry

The image can now be build with:

wget https://raw.githubusercontent.com/btc-ticker/btc-ticker/main/build_sdcard.sh && sudo bash build_sdcard.sh

After everything run through, it is possible to login with the password btcticker In order to prepare everyting for release, run /home/admin/XXprepareRelease.sh. When you just want to use it for yourself, you do not need to run /home/admin/XXprepareRelease.sh.

Changing the ssh password

In order to secure your btc-ticker in your local network, you should change the SSH password after setting up everything.

  • Login via SSH to ssh admin@[IP-OF-YOUR-RASPI] using the password btcticker
  • Change the password (this will be improved in the next release)
echo "pi:NEWPASSWORD" | sudo chpasswd
echo "root:NEWPASSWORD" | sudo chpasswd
echo "admin:NEWPASSWORD" | sudo chpasswd

Replace NEWPASSWORD with the new password.

Used APIs

btc-ticker is using the following APIs:

Pre-commit-config

Installation

$ pip install pre-commit

Using homebrew:

$ brew install pre-commit
$ pre-commit --version
pre-commit 2.10.0

Install the git hook scripts

$ pre-commit install

Run against all the files

pre-commit run --all-files
pre-commit run --show-diff-on-failure --color=always --all-files

Update package rev in pre-commit yaml

pre-commit autoupdate
pre-commit run --show-diff-on-failure --color=always --all-files

btc-ticker's People

Contributors

axelhamburch avatar holgern avatar pleb4fun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

btc-ticker's Issues

% change in price is calculated wrong imho

I just reactivated my old btc-ticker and I notice that over the last 180 days it shows +36% when it should be more like +56%

In https://github.com/btc-ticker/btc-ticker/blame/5819148abb949d577a0c1b2dcfafc0164b4befc4/btcticker/price.py#LL37C92-L37C116 the price diff is put in relation to the current price and not the old price.

So currently (in EUR) price is 25k but was like 16k 180days ago
25-16/25 => 36% (which is shown by the ticker and is wrong imho)
25-16/16 => 56% which it should be...

Changing

pricechange = str("%+d" % round((self.timeseriesstack[-1]-self.timeseriesstack[0])/self.timeseriesstack[-1]*100,2))+"%"

to

pricechange = str("%+d" % round((self.timeseriesstack[-1]-self.timeseriesstack[0])/self.timeseriesstack[0]*100,2))+"%"

should do the trick. Is this repo still maintained? Otherwise I would fork it for myself...

congecko complains on rate limit

Since 15. Dec 2023:

Dec 16 10:11:55 raspberrypi systemd[1]: Starting btcticker...
Dec 16 10:12:10 raspberrypi run.sh[1917]: Matplotlib is building the font cache; this may take a moment.
Dec 16 10:12:55 raspberrypi systemd[1]: Started btcticker.
Dec 16 10:12:56 raspberrypi run.sh[1917]: {'status': {'error_code': 429, 'error_message': "You've exceeded the Rate Limit. Please visit https://www.coingecko.com/en/api/pricing to subscribe to our API plans for higher rate limits."}}
Dec 16 10:12:56 raspberrypi run.sh[1917]: 'ValueError' object has no attribute 'split'
Dec 16 10:12:56 raspberrypi run.sh[1917]: Traceback (most recent call last):
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/pycoingecko-2.2.0-py3.9.egg/pycoingecko/api.py", line 29, in __request
Dec 16 10:12:56 raspberrypi run.sh[1917]: response.raise_for_status()
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/requests/models.py", line 1022, in raise_for_status
Dec 16 10:12:56 raspberrypi run.sh[1917]: raise HTTPError(http_error_msg, response=self)
Dec 16 10:12:56 raspberrypi run.sh[1917]: requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=eur&days=1
Dec 16 10:12:56 raspberrypi run.sh[1917]: During handling of the above exception, another exception occurred:
Dec 16 10:12:56 raspberrypi run.sh[1917]: Traceback (most recent call last):
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/home/admin/tickerEink.py", line 234, in fullupdate
Dec 16 10:12:56 raspberrypi run.sh[1917]: ticker.refresh()
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/btc_ticker-0.5.0-py3.9.egg/btcticker/ticker.py", line 88, in refresh
Dec 16 10:12:56 raspberrypi run.sh[1917]: self.price.refresh()
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/btc_ticker-0.5.0-py3.9.egg/btcticker/price.py", line 24, in refresh
Dec 16 10:12:56 raspberrypi run.sh[1917]: self.timeseriesstack = self.coingecko.getHistoryPrice(self.fiat)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/btc_ticker-0.5.0-py3.9.egg/btcticker/coingecko.py", line 34, in getHistoryPrice
Dec 16 10:12:56 raspberrypi run.sh[1917]: rawtimeseries = self.cg.get_coin_market_chart_by_id(self.whichcoin, currency, self.days_ago)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/pycoingecko-2.2.0-py3.9.egg/pycoingecko/utils.py", line 12, in input_args
Dec 16 10:12:56 raspberrypi run.sh[1917]: return func(*args, **kwargs)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/pycoingecko-2.2.0-py3.9.egg/pycoingecko/api.py", line 169, in get_coin_market_chart_by_id
Dec 16 10:12:56 raspberrypi run.sh[1917]: return self.__request(api_url)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/pycoingecko-2.2.0-py3.9.egg/pycoingecko/api.py", line 36, in __request
Dec 16 10:12:56 raspberrypi run.sh[1917]: raise ValueError(content)
Dec 16 10:12:56 raspberrypi run.sh[1917]: ValueError: {'status': {'error_code': 429, 'error_message': "You've exceeded the Rate Limit. Please visit https://www.coingecko.com/en/api/pricing to subscribe to our API plans for higher rate limits."}}
Dec 16 10:12:56 raspberrypi run.sh[1917]: During handling of the above exception, another exception occurred:
Dec 16 10:12:56 raspberrypi run.sh[1917]: Traceback (most recent call last):
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/home/admin/tickerEink.py", line 359, in
Dec 16 10:12:56 raspberrypi run.sh[1917]: main(config, args.config)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/home/admin/tickerEink.py", line 328, in main
Dec 16 10:12:56 raspberrypi run.sh[1917]: lastcoinfetch=fullupdate(mode_list[last_mode_ind], days_list[days_ind], layout_list[last_layout_ind], inverted)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/home/admin/tickerEink.py", line 241, in fullupdate
Dec 16 10:12:56 raspberrypi run.sh[1917]: showmessage(epd_type, ticker, e, mirror, inverted)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/home/admin/tickerEink.py", line 141, in showmessage
Dec 16 10:12:56 raspberrypi run.sh[1917]: ticker.build_message(message, mirror=mirror)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/btc_ticker-0.5.0-py3.9.egg/btcticker/ticker.py", line 151, in build_message
Dec 16 10:12:56 raspberrypi run.sh[1917]: message_per_line = message.split("\n")
Dec 16 10:12:56 raspberrypi run.sh[1917]: AttributeError: 'ValueError' object has no attribute 'split'
Dec 16 10:12:56 raspberrypi run.sh[1917]: Traceback (most recent call last):
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/pycoingecko-2.2.0-py3.9.egg/pycoingecko/api.py", line 29, in __request
Dec 16 10:12:56 raspberrypi run.sh[1917]: response.raise_for_status()
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/requests/models.py", line 1022, in raise_for_status
Dec 16 10:12:56 raspberrypi run.sh[1917]: raise HTTPError(http_error_msg, response=self)
Dec 16 10:12:56 raspberrypi run.sh[1917]: requests.exceptions.HTTPError: 429 Client Error: Too Many Requests for url: https://api.coingecko.com/api/v3/coins/bitcoin/market_chart?vs_currency=eur&days=1
Dec 16 10:12:56 raspberrypi run.sh[1917]: During handling of the above exception, another exception occurred:
Dec 16 10:12:56 raspberrypi run.sh[1917]: Traceback (most recent call last):
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/home/admin/tickerEink.py", line 234, in fullupdate
Dec 16 10:12:56 raspberrypi run.sh[1917]: ticker.refresh()
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/btc_ticker-0.5.0-py3.9.egg/btcticker/ticker.py", line 88, in refresh
Dec 16 10:12:56 raspberrypi run.sh[1917]: self.price.refresh()
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/btc_ticker-0.5.0-py3.9.egg/btcticker/price.py", line 24, in refresh
Dec 16 10:12:56 raspberrypi run.sh[1917]: self.timeseriesstack = self.coingecko.getHistoryPrice(self.fiat)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/btc_ticker-0.5.0-py3.9.egg/btcticker/coingecko.py", line 34, in getHistoryPrice
Dec 16 10:12:56 raspberrypi run.sh[1917]: rawtimeseries = self.cg.get_coin_market_chart_by_id(self.whichcoin, currency, self.days_ago)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/pycoingecko-2.2.0-py3.9.egg/pycoingecko/utils.py", line 12, in input_args
Dec 16 10:12:56 raspberrypi run.sh[1917]: return func(*args, **kwargs)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/pycoingecko-2.2.0-py3.9.egg/pycoingecko/api.py", line 169, in get_coin_market_chart_by_id
Dec 16 10:12:56 raspberrypi run.sh[1917]: return self.__request(api_url)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/pycoingecko-2.2.0-py3.9.egg/pycoingecko/api.py", line 36, in __request
Dec 16 10:12:56 raspberrypi run.sh[1917]: raise ValueError(content)
Dec 16 10:12:56 raspberrypi run.sh[1917]: ValueError: {'status': {'error_code': 429, 'error_message': "You've exceeded the Rate Limit. Please visit https://www.coingecko.com/en/api/pricing to subscribe to our API plans for higher rate limits."}}
Dec 16 10:12:56 raspberrypi run.sh[1917]: During handling of the above exception, another exception occurred:
Dec 16 10:12:56 raspberrypi run.sh[1917]: Traceback (most recent call last):
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/home/admin/tickerEink.py", line 359, in
Dec 16 10:12:56 raspberrypi run.sh[1917]: main(config, args.config)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/home/admin/tickerEink.py", line 328, in main
Dec 16 10:12:56 raspberrypi run.sh[1917]: lastcoinfetch=fullupdate(mode_list[last_mode_ind], days_list[days_ind], layout_list[last_layout_ind], inverted)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/home/admin/tickerEink.py", line 241, in fullupdate
Dec 16 10:12:56 raspberrypi run.sh[1917]: showmessage(epd_type, ticker, e, mirror, inverted)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/home/admin/tickerEink.py", line 141, in showmessage
Dec 16 10:12:56 raspberrypi run.sh[1917]: ticker.build_message(message, mirror=mirror)
Dec 16 10:12:56 raspberrypi run.sh[1917]: File "/usr/local/lib/python3.9/dist-packages/btc_ticker-0.5.0-py3.9.egg/btcticker/ticker.py", line 151, in build_message
Dec 16 10:12:56 raspberrypi run.sh[1917]: message_per_line = message.split("\n")
Dec 16 10:12:56 raspberrypi run.sh[1917]: AttributeError: 'ValueError' object has no attribute 'split'
Dec 16 10:12:58 raspberrypi systemd[1]: btcticker.service: Main process exited, code=exited, status=1/FAILURE
Dec 16 10:12:58 raspberrypi systemd[1]: btcticker.service: Failed with result 'exit-code'.

Ticker stopped updating on 2022-03-11 -> 502 Bad Gateway

The Ticker stopped updating for me 3hrs ago.
Looking at the logs I assume it's an issue with the used library/api from blockchain.com

Mar 11 14:03:01 raspberrypi run.sh[459]:   File "/usr/local/lib/python3.7/dist-packages/btc_ticker-0.4.2-py3.7.egg/btcticker/ticker.py", line 83, in refresh
Mar 11 14:03:01 raspberrypi run.sh[459]:     self.stats = statistics.get()
Mar 11 14:03:01 raspberrypi run.sh[459]:   File "/usr/local/lib/python3.7/dist-packages/blockchain-1.4.4-py3.7.egg/blockchain/statistics.py", line 20, in get
Mar 11 14:03:01 raspberrypi run.sh[459]:     response = util.call_api(resource)
Mar 11 14:03:01 raspberrypi run.sh[459]:   File "/usr/local/lib/python3.7/dist-packages/blockchain-1.4.4-py3.7.egg/blockchain/util.py", line 30, in call_api
Mar 11 14:03:01 raspberrypi run.sh[459]:     raise APIException(handle_response(e.read()), e.code)
Mar 11 14:03:01 raspberrypi run.sh[459]: blockchain.exceptions.APIException: Bad Gateway

curl https://api.blockchain.info/stats => 200 OK
curl https://api.blockchain.info/stats?format=json => 502 Bad Gateway

I created a ticket over there: https://github.com/blockchain/api-v1-client-python/issues/188
But the blockchain repo seems pretty dead - no activity for 4 years...

Any good idea how this could be quick-fixed just for the ticker?
Directly using the API without the library?
Patching the library?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.