• Complain

Harish Kumar Garg [Harish Kumar Garg] - Hands-On Bitcoin Programming with Python

Here you can read online Harish Kumar Garg [Harish Kumar Garg] - Hands-On Bitcoin Programming with Python full text of the book (entire story) in english for free. Download pdf and epub, get meaning, cover and reviews about this ebook. year: 2018, publisher: Packt Publishing, genre: Home and family. Description of the work, (preface) as well as reviews are available. Best literature library LitArk.com created for fans of good reading and offers a wide selection of genres:

Romance novel Science fiction Adventure Detective Science History Home and family Prose Art Politics Computer Non-fiction Religion Business Children Humor

Choose a favorite category and find really read worthwhile books. Enjoy immersion in the world of imagination, feel the emotions of the characters or learn something new for yourself, make an fascinating discovery.

Harish Kumar Garg [Harish Kumar Garg] Hands-On Bitcoin Programming with Python

Hands-On Bitcoin Programming with Python: summary, description and annotation

We offer to read an annotation, description, summary or preface (depends on what the author of the book "Hands-On Bitcoin Programming with Python" wrote himself). If you haven't found the necessary information about the book — write in the comments, we will try to find it.

Simplified Python programming for Bitcoin and blockchain

Key Features
  • Build Bitcoin applications in Python with the help of simple examples
  • Mine Bitcoins, program Bitcoin-enabled APIs and transaction graphs, and build trading bots
  • Analyze Bitcoin transactions and produce visualizations using Python data analysis tools
Book Description

Bitcoin is a cryptocurrency thats 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, youll be able to mine Bitcoins, accept Bitcoin payments on the app, and work with the basics of blockchain technology to create simply distributed ledgers.

What you will learn
  • Master the Bitcoin APIs in Python to manipulate Bitcoin from your Python apps
  • Build your own Bitcoin trading bots to buy Bitcoins at a lower price and sell them at a higher price
  • Write scripts to process Bitcoin payments through a website or app
  • Develop software for Bitcoin mining to create Bitcoin currency on your own computer hardware
  • Create your own keys, addresses, and wallets in Python code
  • Write software to analyze Bitcoin transactions and produce reports, graphs, and other visualizations
Who this book is for

Hands-On Bitcoin Programming with Python consists of examples that will teach you to build your own Bitcoin application. You will learn to write scripts, build software for mining, and create Bitcoins using Python. Anyone with prior Python experience, who wants to explore Python Bitcoin programming and start building Bitcoin-driven Python apps, will find this book useful.

Downloading the example code for this book You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Harish Kumar Garg [Harish Kumar Garg]: author's other books


Who wrote Hands-On Bitcoin Programming with Python? Find out the surname, the name of the author of the book and a list of all author's works by series.

Hands-On Bitcoin Programming with Python — read online for free the complete book (whole text) full work

Below is the text of the book, divided by pages. System saving the place of the last page read, allows you to conveniently read the book "Hands-On Bitcoin Programming with Python" online for free, without having to search again every time where you left off. Put a bookmark, and you can go to the page where you finished reading at any time.

Light

Font size:

Reset

Interval:

Bookmark:

Make
Programming bitcoin with Python

In this section, we are going to introduce the following topics:

  • The Raspberry Pi Bitcoin tools library and how to start using it
  • How to generate private keys and public keys
  • How to create a simple bitcoin address from the private keys and public keys you generated
To get started with bitcoin using Python, you must install Python 3.x and the bitcoin Python library called Pi Bitcoin tools in the system.
Block explorer methods

For block explorer methods, start by importing the relevant classes from the blockchain library. To get a particular block, call the get_block method as shown in the following code. It expects a block to be passed in as the parameter.

# import blockchain library
from blockchain import blockexplorer
# get a particular block
block = blockexplorer.get_block('')

By taking an example block from the web, from Blockc hain.info , copy the hash for this block ( Block #536081 ) and pass it to the get_block method, as shown in the following screenshot:

Now lets get some information about this block For example the block fee - photo 1

Now lets get some information about this block. For example, the block fee, block size, and block transactions can be obtained by using fee, size, and transactions properties respectively on the block object created, as shown in the following code:

#!/usr/bin/env python
# import blockchain library
from blockchain import blockexplorer
# get a particular block
block = blockexplorer.get_block('0000000000000000002e90b284607359f3415647626447643b9b880ee00e41fa')
print("Block Fee: %s\n" % block.fee)
print("Block size: %s\n" % block.size)
print("Block transactions: %s\n" % block.transactions)
# get the latest block
block = blockexplorer.get_latest_block()

The following screenshot shows the block fee, block size, and block transactions output:

There are also many available features in the Blockchaininfo library there - photo 2

There are also many available features in the Blockchain.info library; there are a few that are more related to, for example, wallets, creating wallets, and so on.

In order to explore this library further, visit the link https://github.com/blockchain/api-v1-client-python.
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 been executed and the buy alert should have gone Check it in - photo 3

The script has been executed and the buy alert should have gone. Check it in the email.

The following screenshot shows that we have received the bitcoin alert email advising us to buy bitcoin, according to the criteria that we have set up in the script:

Introduction to bitcoin and blockchains In this section we will explore the - photo 4

Introduction to bitcoin and blockchains

In this section, we will explore the following topics:

  • Bitcoin
  • The uses of bitcoin
  • Blockchains
  • Attributes of bitcoin and blockchain
The triggering of sell bitcoin
  1. Initially, we should set the sell threshold as lower than the current price. So, for example, let's set the threshold for 6400 and execute the script again. The following code shows that the sell_thresh is set to 6400 :
# define buy and sell thresholds for bitcoin
buy_thresh = 6400
sell_thresh = 6400

Now, the sell alert should execute. Verify it in the email again.

  1. After verifying this, we should see that we have received the email alert advising us to sell bitcoin because the current asking price is higher than what we are willing to sell for:

The script is ready You can now set it to run automatically on all kinds of - photo 5

  1. The script is ready. You can now set it to run automatically on all kinds of operating systems. On Windows, use the Task Scheduler .
  2. From the Action menu, choose Create Task... , and give it the name Bitcoin trade alert, as shown in the following screenshot:

From the Triggers tab click on New as shown in the following screenshot - photo 6

  1. From the Triggers tab, click on New... , as shown in the following screenshot:

Choose the Daily radio button Then in Advanced settings choose to repeat - photo 7

  1. Choose the Daily radio button.
  1. Then, in Advanced settings , choose to repeat the task after the required number of minutes or hours. Here, we will set it to every 1 hour, as shown in the following screenshot:

Next from the Actions tab click on the New button Choose the script - photo 8

  1. Next, from the Actions tab, click on the New... button.
  1. Choose the script that was created to be executed whenever the task runs by clicking on the Browse... button. Now, this task will run automatically every hour, and will check for bitcoin prices and send an email advising us whether to buy or sell bitcoin.

You can also choose to trigger the trade right from the script itself using - photo 9

You can also choose to trigger the trade right from the script itself, using any of the bitcoin exchange APIs, such as coinbase.com. As it involves actual money, the user needs to be careful with it.

Summary

In this chapter, we learned how to get started programming bitcoin with Python. We explored Blockchain.info API programming with Python to get statistics and other bitcoin market data.

We also learned how to get started with mining bitcoin. We looked at the various ways to mine bitcoin, and we learned about why bitcoin mining may not be for everybody because of its increasing competition and difficulty.

In the next chapter, we will learn how to start running bitcoin programmatically by way of accepting bitcoin on your website, running API-based microservices, or by building a bitcoin trading bot.

DataFrame

The data in a pandas data object is called a DataFrame. A DataFrame is in a tabular data format. Now, print out some records to see how this looks. To print this out, we can call a method called head() on the price DataFrame.

When we do this, we get two columnsDate and Close Pricefor the bitcoin in USD for that day. We also have a default index for the rows starting from 0, which was inserted by pandas by default while reading in the data. The following screenshot shows the two columns, Date and Close Price:

Next page
Light

Font size:

Reset

Interval:

Bookmark:

Make

Similar books «Hands-On Bitcoin Programming with Python»

Look at similar books to Hands-On Bitcoin Programming with Python. We have selected literature similar in name and meaning in the hope of providing readers with more options to find new, interesting, not yet read works.


Reviews about «Hands-On Bitcoin Programming with Python»

Discussion, reviews of the book Hands-On Bitcoin Programming with Python and just readers' own opinions. Leave your comments, write what you think about the work, its meaning or the main characters. Specify what exactly you liked and what you didn't like, and why you think so.