bitcoin-price-api icon indicating copy to clipboard operation
bitcoin-price-api copied to clipboard

dead simple example of price monitor with notifications.

Open rocket-pig opened this issue 6 years ago • 0 comments

Not actually an issue. Just thought I'd share. If you think its alright, please use it or your revision of it in README/example. Thanks for sharing your module, very convenient.

#!/usr/bin/python
from sys import argv
from subprocess import check_output
from exchanges.bitfinex import Bitfinex
from time import sleep
above = 11900
below = 11450

def get_price():
    try:
        price = int(Bitfinex().get_current_price())
    except:
        price = 0
    return(price)

while True:
    print("Checking price...")
    price = get_price()
    print("----------------- "+str(price))

    if price > above:
        tmp = check_output('notify-send "BTC price is ABOVE '+str(above)+'" -u critical -t 9999999',shell=True, universal_newlines=True)

    if price < below and price != 0:
        tmp = check_output('notify-send "BTC price is BELOW '+str(below)+'" -u critical -t 9999999',shell=True, universal_newlines=True)

    sleep(35)

rocket-pig avatar Aug 06 '19 00:08 rocket-pig