Book Image

Hands-On Bitcoin Programming with Python

By : BignumWorks Software LLP
Book Image

Hands-On Bitcoin Programming with Python

By: BignumWorks Software LLP

Overview of this book

Bitcoin is a cryptocurrency that’s changing the face of online payments. Hands-On Bitcoin Programming with Python teaches you to build software applications for mining and creating Bitcoins using Python. This book starts with the basics of both Bitcoin and blockchain and gives you an overview of these inherent concepts by showing you how to build Bitcoin-driven applications with Python. Packed with clear instructions and practical examples, you will learn to understand simple Python coding examples that work with this cryptocurrency. By the end of the book, you’ll be able to mine Bitcoins, accept Bitcoin payments on the app, and work with the basics of blockchain technology to create simply distributed ledgers.
Table of Contents (6 chapters)

How to get a current bid and asking price for bitcoin

Google search is the simplest way to search for the current bid rate. In order to achieve the buying and selling of bitcoin, the triggering of both should be done accordingly.

The triggering of buy bitcoin

The following are the steps to go through to get the current bid:

  1. First, check the bitcoin price online.
  2. Modify the script so that the buy alert triggers first. Set the buy threshold to higher than the current price. Here, we set the buy threshold to 6500, as shown in the following code:
# define buy and sell thresholds for Bitcoin
buy_thresh = 6500
sell_thresh = 6500
  1. Save the script and execute it. The following screenshot shows the executed script:

The script has...