There is now way to make binance server notify you when the price has changed.
The only solution you have is to implement a job which can listen for any changes.
For example like this
last_price = None
try:
price_file = 'price.txt'
f = open(price_file, "r")
last_price = f.read()
except Exception as e:
# failed to read last price
pass
price_file = 'price.txt'
def get_last_price():
last_price = None
try:
f = open(price_file, "r")
last_price = f.read()
except Exception as e:
# failed to read last price
pass
return last_price
def update_price(new_price):
f = open(price_file, "w")
f.write(new_price)
f.close()
def get_biance_price():
url = requests.get('https://api.binance.com/api/v1/ticker/price?symbol=BTCUSDT')
data = url.json()
return data['price']
last_price = get_last_price()
new_price = get_biance_price()
if last_price != new_price:
print('price changed!') # implement notification
update_price(new_price)
else:
print('price is the same')
Now calling this script will save the newest price in 'price.txt' and notify you if the new price is different. Now you can put the scirpt in some linux cron job for example and configure it to call the script with interval