import conf
import cryptocompare
from boltiot import Sms, Bolt
import json, time
bolt = Bolt(conf.API_KEY, conf.DEVICE_ID)#connecting to bolt cloud
sms = Sms(conf.SID, conf.AUTH_TOKEN, conf.TO_NUMBER, conf.FROM_NUMBER)
selling_price = 1000000.00#amount that is available with us (in rupees)
#getting details of bitcoin and ethereum cryptocurrencies in rupees,us dollars,euros
cryptocompare.get_price(['BTC','ETH'],['INR','USD','EUR'])
def price_check(b):
if(b=="b"):
p=cryptocompare.get_price('BTC',curr='INR')#to get the value of bitcoin in rupees
else:
p=cryptocompare.get_price('ETH',curr='INR')#to get value of ethereum in rupees
#converting price data type(p) into float datatype
for i in p.values():
pr=i
for t in pr.values():
return t
while True:
bitcoin_market_price = price_check("b")
ethereum_market_price=price_check("e")
print ('market price is: ',bitcoin_market_price)
print ('market price is: ',ethereum_market_price)
print ('Selling price is: ',selling_price)
try:
if bitcoin_market_price < selling_price:#indicates u can buy both currencies by both led's glow
bolt.digitalWrite("0","HIGH")#buzzer notifies
bolt.digitalWrite("1","HIGH")#LED'S GLOW
bolt.digitalWrite("2","HIGH")
print("Making request to Twilio to send a SMS")
response = sms.send_sms("bit coin and ethereum coin are available at prices "+str(bitcoin_market_price))
print("Response received from Twilio is: " + str(response))
print("Status of SMS at Twilio is :" + str(response.status))
elif ethereum_market_price < selling_price :#one led glow means u can buy ethereum but not bit coin
bolt.digitalWrite("0","HIGH")#buzzer
bolt.digitalWrite("1","HIGH")
bolt.digitalWrite("2","LOW")
print("Making request to Twilio to send a SMS")
response = sms.send_sms("ethereum is available at price "+str(ethereum_market_price))
print("Response received from Twilio is: " + str(response))
print("Status of SMS at Twilio is :" + str(response.status))
except Exception as e:
print ("Error occured: Below are the details")
print (e)
time.sleep(10)
bolt.digitalWrite("0","LOW")
bolt.digitalWrite("1","LOW")
bolt.digitalWrite("2","LOW")
Comments