Bitcoin-price-alert Project by Yash Sinha

AttainU
AttainU

Bitcoin-price-alert

Introduction :

Bitcoin emerged out of the 2008 global economic crisis when big banks were caught misusing borrowers' money, manipulating the system, and charging exorbitant fees. To address such issues, Bitcoin creators wanted to put the owners of bitcoins in-charge of the transactions, eliminate the middleman, cut high interest rates and transaction fees, and make transactions transparent. They created a distributed network system, where people could control their funds in a transparent way. Bitcoin has grown rapidly and spread far in a relatively short period of time. Across the world, companies from a large jewellery chain in the US, to a private hospital in Poland, accept bitcoin currency. Multi-billion-dollar corporations such as Dell, PayPal, Microsoft, Expedia, etc., are dealing in bitcoins. Websites promote bitcoins, magazines are publishing bitcoin news, and forums are discussing cryptocurrencies and trading in bitcoins. Bitcoin has its own Application Programming Interface (API), price index, trading exchanges and exchange rate.

However, there are issues with bitcoins such as hackers breaking into accounts, high volatility of bitcoins, and long transaction delays. Elsewhere, particularly people in third world countries find Bitcoins as a reliable channel for transacting money bypassing pesky intermediaries.

What is IFTTT?

If This Then That, also known as IFTTT is a freeware web-based service that creates chains of simple conditional statements, called applets. An applet is triggered by changes that occur within other web services such as Gmail, Facebook, Telegram, Instagram, or Pinterest.

Sending IFTTT Notification: 

Now we can move onto the IFTTT side of things. To use IFTTT you’ll first need to set up a new account and install their mobile app (if you want to receive phone notifications from your Python app). Once you set that up, we’re going to create a new IFTTT applet for the notification. 

To create a new test applet follow these steps: 

  • Click on the big “this” button 2. Search for the “webhooks” service and select the “Receive a web request” trigger 3. Let’s name the event 'Bitcoin_Price_Emergency' 4. Now select the big “that” button 5. For the action select the “Notifications” service and select the “Send a rich notification from the IFTTT app” action. 6. Give it a title, like “Bitcoin price emergency!” 7. Set the message to Bitcoin price is at ${{Value1}}. Buy or sell now! (we’ll return to the {{Value1}} part later on) To see the documentation on how to use the IFTTT webhooks go to the main applet page and click on the 

“Documentation” button in the top right corner. The documentation page contains the webhook URL and it 

looks like this: 

https://maker.ifttt.com/trigger/{event}/with/key/{your-IFTTT-key} Next up, you’ll need to substitute the {event} part with whatever name you gave our event in step 3, when you created the applet. The {your-IFTTT-key} part is already populated with your IFTTT key. Now will make a variable and will store the webhook url. 

Now whenever we call the post_ifttt_webhook function it'll trigger the notification. The event parameter corresponds to whatever event name we gave to our trigger when setting up the IFTTT applet. Also, the IFTTT webhooks allow us to send additional data along with the request as JSON-formatted data.

What is Telegram?

Telegram is a cloud-based instant messaging and voice over IP service. Telegram client apps are available for Android, iOS, Windows Phone, Windows NT, macOS and Linux. Users can send messages and exchange photos, videos, stickers, audio and files of any type. Telegram's client-side code is open-source software but the source code for recent versions is not always immediately published, whereas its server-side code is closed-source and proprietary. The service also provides APIs to independent developers. In March 2018, Telegram stated that it had 200 million monthly active users. Default messages and media in Telegram are encrypted when stored on its servers, but can be accessed by the Telegram service provider, who holds the encryption keys. In addition Telegram provides optional end-to-end encrypted "secret" chats between two online users, yet not for groups or channels. The client-server communication is also encrypted. The service provides end-to-end encryption for voice calls.

Telegram notification update: 

  • Again choose the “webhooks” service and select the “Receive a web request” trigger 2. Name the event bitcoin_price_update 3. For the action select the “Telegram” service and select the “Send message” action 4. Set the message text to: Latest bitcoin prices:<br>{{Value1}} 5. Create the action and finish with the applet 

To receive the notification in telegram, I created a public channel called BTC_Price and gave the access to the IFTTT telegram bot and make it the administrative section. 

Now coming to the python console. We have to create two separate function to get the latest bitcoin price and to update that in our telegram channel. For that in run function we took two separate 'Bitcoin_Price_Update' and 'Bitcoin_Price_Update'. While getting the data from 'get_latest_bitcoin_price' under run function we are returning the value through 'Bitcoin_Price_Update' function which is triggering the Webhook notification applet. And the 'Bitcoin_Price_Update' on the other hand triggering the telegram notification applet. this two applet name and function name needs to be exact same. And lastly the time sleep function imported from datetime package will take care of the current time and the time when we need the data. The only thing missing is the format_bitcoin_history function. It takes the bitcoin_history as an argument and formats it using some of the basic HTML tags allowed by Telegram, like <br>, <b>, <i>, and so on.

What is twitter ?                                                                                                                 Is an American microblogging and social networking service on which users post and interact with messages known as "tweets". Registered users can post, like, and retweet tweets, but unregistered users can only read them. Users access Twitter through its website interface, through Short Message Service (SMS) or its mobile-device application software ("app"). Twitter, Inc.

Twitter notification update: 

  • Again choose the “webhooks” service and select the “Receive a web request” trigger 2. Name the event bitcoin_price_update 3. For the action select the “Twitter” service and select the “Send message” action 4. Set the message text to: Latest bitcoin prices:<br>{{Value1}} 5. Create the action and finish with the applet 
  • Now just register your twitter account email and all is set and ready

What is trello ?

Trello is a web-based Kanban-style list-making application which is a subsidiary of Atlassian. Originally created by Fog Creek Software in 2011.sers can create their task boards with different columns and move the tasks between them. Typically columns include task statuses such as To Do, In Progress, Done. The tool can be used for personal and business purposes including real estate management, software project management, school bulletin boards, lesson planning, accounting, web design, gaming, and law office case management. A rich API as well as email-in capability enables integration with enterprise systems, or with cloud-based integration services like IFTTT and Zapier. 

Trello notification update: 

  • Again choose the “webhooks” service and select the “Receive a web request” trigger 2. Name the event bitcoin_price_update 3. For the action select the “Trello” service and select the “Send message” action 4. Set the message text to: Latest bitcoin prices:<br>{{Value1}} 5. Create the action and finish with the applet 
  • Now just register your trello account email and all is ready

Demo :