A Beginner’s Guide to Blockchain Programming

<img src="https://www.javacodegeeks.com/wp-content/uploads/2019/01/A-Beginners-Guide-to-Blockchain-Programming-square-300x300.png.webp">

You’ve likely heard of the concept of cryptocurrency and their mining process, which means you have likely heard the term “blockchain” at least once or twice.

If you still aren’t really sure what it’s all about, don’t worry. You aren’t alone, as there are many programmers out there who can’t accurately describe blockchain and cryptocurrency, and a far smaller number actually puts one or both terms to use on a regular basis.


Getting to Know Blockchain Technology

As you might have deduced from the name, a blockchain is a type of digital ledger that stores blocks of data in an interconnected fashion. New data is added to the blockchain from a theoretically limitless number of nodes that a blockchain can support. As the digital ledger is also decentralized, these nodes can be located anywhere in the world.

Being decentralized also means that there does not need to be a single controlling authority telling the blockchain how to operate; it will go through the motions of taking in data, offloading the verification process, adding new blocks to the chain, and updating the nodes with the newest version of the chain, all automatically.

Aside from storing a wide variety of data, each block also includes a timestamp about its generation along with other classification data to ensure the chain easily knows how to sort the data. This is only one of the ways in which blockchain technology promotes automation and ensures its decentralized nature never needs to be compromised.

Blockchain offers an unprecedented ability to allow users access to their own transactions while at the same time ensuring that all of the data in the blockchain remains both secure and immutable. If a transaction ends up not matching what the chain expects, either when the block is first added to the chain or at a later point, it is automatically deleted and replaced with an earlier, already verified, version of the corrupted data (if applicable).

Additionally, if somehow a block is added that includes false data, it will still be detected, as 51 percent of all currently active nodes have to sign off on the logical legitimacy of the new block before it will be accepted permanently into the blockchain as a whole.

While this security protocol makes blockchain technology virtually tamper-proof these days, this may not always be the case. The way to successfully crack blockchain’s security is well-known; it is just a matter of someone coming along who is able to execute it.

Now, let’s move on to learn how one can become a blockchain programmer. Remember, learning to program a blockchain is not a sprint. It’s a marathon. You first need to learn programming languages, take blockchain programming courses online, and read eBooks and the latest news to come up with a working protocol.


The Best Programming Languages for Blockchain

Here is a look at a few blockchain programming languages, the purpose they serve, and some resources for further learning. Each section will be purely introductory, as the topic can get pretty extensive and full of code.


1. C++

Let’s start with the oldest of them all, C++. The language came to life in 1985 through the efforts of Bjarne Stroustrup. By then, the rudimentary C language existed, but it was process-oriented; C++ cropped up as an upgraded extension that is object-oriented (where data and functions are bundled up into a package called “Objects”). For the complete freshman, an object-oriented product can be reused on other platforms without the need for fresh coding.

C++ retained the efficiency, security, and flexibility of C. Its evergreen nature has made it the core language for blockchain coding, including the bitcoin blockchain. Warning to the newbies, though: As a type-only language with fairly outdated syntax, the learning curve is a bit steep. However, as most blockchain technologies are written in this language, any efforts you put in to learn this language will pay forth abundantly.

Here are a few more reasons why C++ is preferred for blockchain coding:

Better memory control. There are a lot of demands in the blockchain ecosystem. For instance, the platform needs to be a secure fortress but at the same time execute transactions and interact with all the nodes at a faster speed. For all these to happen, you need to have better control over memory and CPU usage. C++ can offer you that.

Superb multithreading. Threads are a bundle of instructions that are to be executed at the same time. During blockchain development, you will come across tasks that parallelize and those that do not. Most languages can only handle one of these tasks and not both. Guess what, C++ allows you to handle both simultaneously.

Compile time polymorphism. As was said before, C++ is an object-oriented programming (OOP) language. It also happens that polymorphism (using a certain feature in several ways) is a property of OOP. Now, by coding your blockchain through C++, you will be able to execute some tasks separately, thus enhancing the performance of the entire digital ledger.

Code isolation. This archaic but revolutionary coding language has namespace features that can be shipped from one place to another. But at times, collisions can occur and distort the entire system. However, thanks to the language’s segmentation ability that groups various APIs differently, code isolation/separation can become a little easier.

Maturity. As one of the oldest coding languages, C++ is mature and gets updated on a regular basis. Besides that, the language sports practical features like debuggers and special analytical tools that can detect or optimize various functions. This complexity and up-to-dateness of the language may be some of the reasons why Satoshi used it for bitcoin’s source code.


2. Python

Python is another simple coding language for a beginner programmer who is afraid of C++’s complex nature. It was developed in 1991 by a Dutch programmer by the name of Guido van Rossum. The language’s structure is based on a simple premise: simplicity, readability, and minimalism.

The simple nature of this language has seen it be supported by a massive crowd of both new and established developers. Rather than the curly brackets and keywords used in C++ to represent code blocks, Python uses simple and less-scary white spaces.

Simplicity can be easily translated to mean inefficiency. However, Python is good enough to build complex digital ledgers that are stable and reliable. And here is the best part: This language is scripted and can be compiled and uncompiled. For instance, when you find a bug in your code, you just fix it and reload your application.

For other languages like C++, you need to stop the app, fix the bug in your source code, and recompile it before restarting the application. It’s quite a lot of work that can be avoided by choosing Python. Additionally, the language offers developers a vast, free resource center that they can use to write their blockchain code.


3. JavaScript

JavaScript is one of the most-used languages on the World Wide Web. If you want an interactive site with beautiful UIs, this is the language to use. All the major browsers such as Google Chrome and Firefox support it.

We already said that a blockchain is, roughly put, a system of blocks placed one after the other. However, there is something special about this ledger—it’s immutable, meaning once data has been written, there is no undoing. JavaScript is one of the go-to languages when making a simple but tamperproof blockchain that is impossible for hackers and other deceitful individuals to alter. Just one setback, though: The language lacks the SHA256 hash function.


4. Solidity


This is the most complex, high-level language that applies JavaScript’s scripts and functions as well as C++’s classes. The language is not only beginner-friendly but also offers tips and instructions on how to go about using its code. While the language is not very complicated, those who have a fair grasp of modern programming languages have an advantage.

Even though Solidity is still trying to establish its footing in the coding world, Ethereum (the second-biggest cryptocurrency after bitcoin) is already using it. Well, they made the language, so it makes sense that they be the first ones to use it. Nevertheless, Ethereum blockchain is one of the most efficient when it comes to speed and ease of creating smart contracts.

So if you are looking to create a decentralized app, hold an initial coin offering, or build a secure, immutable, and multipurpose blockchain, Solidity is the language to use. It’s a must-know language for anyone who wishes to integrate smart contracts in their digital ledger. For tutorials on Solidity, you can check out ConsenSys Academy or the languages’ documentation from readthedocs.io.


5. GO

GO is the short form of GOLang, a relatively modern coding language that was developed in 2007 at Google and officially released for public use in 2012. This robust and multipurpose coding language was created in an effort to combine both the syntax and user-friendliness of other common languages like JavaScript while retaining the reliable security aspects of older languages like C and C++.

GO inherently runs in an operating system, and this means maximum flexibility, especially when dealing with several parts of a blockchain simultaneously. Ethereum’s SDK protocol is written in GO, and there are many other blockchain applicationsof this language.


How to Become a Blockchain Developer

Although blockchain represents only a single item, there are different parts in it that developers can work on. No one is restricting you from learning everything there is to a digital ledger, but it’s usually easier to start with a smaller branch and master it fully before moving to the next. The core parts of a blockchain you can develop include:

Decentralized applications (Dapps)

Smart contracts

ICOs

Don’t roll up your sleeves just yet. The most skilled programmers usually browse through a storm of resources on anything before getting started. So, once you are familiar with your preferred programming language, the next best thing to do would be to read bitcoin’s white paper (unless you don’t dream of becoming as good as Satoshi) and check out several books that go deeper into the technical details of the blockchain.

It doesn’t hurt to familiarize yourself with some of the terms and lexicons within the industry. If you want to immerse yourself deeper into the blockchain world, then you need to buy some cryptocurrencies (just a few) and play around with them to see how the platform works.

There are many entertaining yet in-depth courses out there that will teach you blockchain programming step by step. Space Doggos and CryptoZombies are some of the gamified courses that turn work into play so beginners can have an easier time coding.

Space Doggos is a space adventure game that teaches learners how to develop the Ethereum blockchain. The game is detailed with several chapters and notes for gamers. The player will code the game’s characters (the Dog, its costume, mood, etc.) and the environment in Solidity language.

As you move on to the next chapters of Space Doggos’ adventure, the code gets more complex. The concept is almost the same with CryptoZombies. Take a look at the next section for places where you can learn to code a blockchain in detail.


Advanced Courses

You won’t become an adept blockchain developer by creating zombies and space doggies. These tutorials only help to clear the foggy coding path. You need advanced courses in whichever language you prefer to create a useful, secure, and faster blockchain. 

Developing a blockchain comes with a lot of challenges. Therefore, as a budding developer, you need to constantly mix with individuals of the same passion on platforms like GitHub, Reddit, Stack Exchange, and many others. Chat with participants, ask questions, and seek assistance from the mature members of the community in order to build a project with little to no errors.

The Bottom Line

Blockchain and cryptocurrencies, particularly bitcoin, are believed to have a huge role to play in asset and data transfer. As of late 2018, only a few blockchain platforms are up and running, while many others are still in the experimental stage. So, if you dream of becoming an accomplished developer in this space, then you have to start by mastering a few of the common blockchain programming languages.

While you can do it, it’s imperative to understand that this sphere already has millions of active developers, and all of them are eyeing the few blockchain gigs out there. However, only a few firmly believe in their skills, and this means the market still needs more people who know what they are doing.

So is it too late to learn blockchain programming? No, it’s not too late for those who wish to learn from scratch. But before you grab the tools for the job, what section of the blockchain do you want to master? What problem do you want to solve? If you can provide answers to those questions, then you are ready to roll.


How to Plot Cryptocurrency Price Charts with Python in 10 minutes

How to Plot Cryptocurrency Price Charts with Python in 10 minutes

Starting from complete scratch, you will plot your first Cryptocurrency candlestick data charts by the end of this article

Starting from complete scratch, you will plot your first cryptocurrency candlestick data chart by the end of this article - In less than 10 minutes.

Building tools which take advantage of exchange data is a nightmare in the cryptocurrency space. The limited number of available tools means you need to develop features from nothing.

Since every exchange provides different endpoints for collecting data, this quickly turns into a black hole which will consume your time.

Each exchange requires custom code and infrastructure to handle the intricacies of what they offer.

Thankfully, the Universal Crypto Exchange APIs normalize this data for us. An API which you can freely use to access historical and live data.

This article will describe how to set up your first script to access live market data from any exchange, normalize it into a cohesive format, and plot it. There is no complex configuration or development.

Let’s get started!

Install Libraries

Before we get started writing the script, we need to install a few libraries. If you use pip, this can be done simply by running the following commands.

pip install shrimpy-python
pip install pandas
pip install plotly==4.1.0

Generate API Keys

After installing the necessary libraries, sign up for a Shrimpy Developer API account. These are the APIs which provide the exchange data. It’s free and takes only a few seconds to sign up.

After signing up, generate your master key. These keys are used to sign requests to Shrimpy and access crypto market data.

Make sure to securely store your public and secret keys. They will be needed for later steps.

Writing Our First Script

We’re now ready to begin writing our first script. The script for this article will collect candlestick market data from the exchange we specify, organize it in a way that’s understandable for the plotting library, and display it.

Import Libraries

In this script, we will be using the Plotly Library. This will provide a convenient way for us to get up and running without much effort.

Import these libraries into your script so we can collect our data and graph it.

import shrimpy
import plotly.graph_objects as go

Assign Keys

Before we can access any data from Shrimpy, we need to make sure we correctly sign our requests. This requires us to pass in our public and private keys. For now, let’s just assign them for later use.

public_key = '8x71n32d8cfbnnn1xzimjustkeyboardmashing8xn1t8jyv5098'
secret_key = '771dc5nxct4709672v4n09xn0morekeyboardmashing9475c029374n0xx4n50'

Create Client

To create the client, pass in the public and secret keys which were assigned in the previous step. The client will then conveniently handle the signing of each request, so you can focus on accessing the data and building tools with the data.

client = shrimpy.ShrimpyApiClient(public_key, secret_key)

Get Candles

It’s time to get our candlestick data from Shrimpy. Use the client to call the endpoint for retrieving the candlesticks.

Just make sure to pass in the exchange, trading pair, and interval you wish to access.

Example 1:

candles = client.get_candles(
    'binance',  # exchange
    'XLM',      # base_trading_symbol
    'BTC',      # quote_trading_symbol
    '15m'       # interval
)

Example 2:

candles = client.get_candles(
    'bittrex',  # exchange
    'LTC',      # base_trading_symbol
    'BTC',      # quote_trading_symbol
    '1h'        # interval
)

Example 3:

candles = client.get_candles(
    'kucoin',   # exchange
    'ETH',      # base_trading_symbol
    'USDT',     # quote_trading_symbol
    '1d'        # interval
)

Observe how we are able to change each of these parameters to configure the data we want to access.

The supported time intervals for each candle include the following:

1m, 5m, 15m, 1h, 6h, or 1d

Convert Data

Once the data has been collected from Shrimpy, we want to convert the data to the format which is accepted by the plotting library Plotly. To do this, we will go through the candlesticks we collected from Shrimpy and assign each of the candlestick components to an element of the candle.

dates = []
open_data = []
high_data = []
low_data = []
close_data = []

for candle in candles:
    dates.append(candle['time'])
    open_data.append(candle['open'])
    high_data.append(candle['high'])
    low_data.append(candle['low'])
    close_data.append(candle['close'])

The result of this step is each individual candlestick will be broken out into a list which holds the individual component of every candlestick.

Generate Figure

Finally, it’s time to generate the figure. Use the Plotly library to create the chart that we will display, then display the chart.

fig = go.Figure(data=[go.Candlestick(x=dates,
                       open=open_data, high=high_data,
                       low=low_data, close=close_data)])

fig.show()

Calling fig.show() displays the graph. This will look something like the following chart.

This is image title

The end result of the script is a graph which displays the candlesticks for an individual asset on an individual exchange over time.

Putting It All Together

Now that we’ve walked through each element of the script step-by-step, it’s time to put everything together.

# import the libraries we need
import shrimpy
import plotly.graph_objects as go

# insert your public and secret keys here
public_key = '8x71n32d8cfbnnn1xzimjustkeyboardmashing8xn1t8jyv5098'
secret_key = '771dc5nxct4709672v4n09xn0morekeyboardmashing9475c029374n0xx4n50'

# create the client
client = shrimpy.ShrimpyApiClient(public_key, secret_key)

# get the candles
candles = client.get_candles(
    'binance',  # exchange
    'XLM',      # base_trading_symbol
    'BTC',      # quote_trading_symbol
    '15m'       # interval
)

# create lists to hold our different data elements
dates = []
open_data = []
high_data = []
low_data = []
close_data = []

# convert from the Shrimpy candlesticks to the plotly graph objects format
for candle in candles:
    dates.append(candle['time'])
    open_data.append(candle['open'])
    high_data.append(candle['high'])
    low_data.append(candle['low'])
    close_data.append(candle['close'])

# construct the figure
fig = go.Figure(data=[go.Candlestick(x=dates,
                       open=open_data, high=high_data,
                       low=low_data, close=close_data)])

# display our graph
fig.show()

The final script can be run, altered, and leveraged to generate graphs similar to the one depicted above. Just make sure to insert your own public and secret keys so your client can properly sign requests.

More Scripts

If you want more ideas for developing your own scripts, explore everything that’s offered by the Universal Crypto Exchange APIs. You can find the Node and Python libraries for these APIs here:

Node

Python

Thank for reading! Please share if you liked it!

Automating Crypto Portfolios Value with Trading Scripts using Python

Automating Crypto Portfolios Value with Trading Scripts using Python

A Python Script to Check Your Crypto Portfolio Value. Install Library. Import Library. API Keys. Create Client. Create User. Link Exchange Account. Get Asset Balances.

Instead of collecting more market data, let’s try something different. Most cryptocurrency users currently have funds located on an exchange. We can leverage the exchange’s APIs to access the asset balances and calculate their value without ever going to the exchange.

The following tutorial will take a step-by-step approach to detail how you can connect to an exchange account through APIs and access your balance data without ever logging into your exchanges.

Install Library

Before we can start writing our scripts and connecting to exchanges, let’s set up our development environment by first installing the libraries we need to complete our project.

pip install shrimpy-python

For this script, we will only need access to the Shrimpy Developer API Python library. This library makes it easy to connect to exchanges, manage assets, collect data, and build applications. The full APIs and their documentation can be found here.

Import Library

Once the library is installed, we can import it into our script to access all the features it provides.

import shrimpy

That’s it for libraries, so we’re ready to start constructing the meat of our script.

API Keys

There are 2 different sets of API keys we need in order to access our balance data on the exchange.

Exchange Account

The first set of API keys we need is the exchange API keys. These keys are found by going to your exchange of choice and creating a new set of API keys.

Our script will require the ability to access balance data, so make sure you have enabled the permissions on your exchange API keys for reading balance data from your exchange account. In this tutorial, you won’t need to enable the permissions for trading or withdrawals.

You can find a number of helpful tutorials on how to access exchange API keys here.

Once you’ve generated your API keys, save them as variables which we will use in the next steps to access your exchange account balances.

exchange_name = 'bittrex'
exchange_public_key = 'fbnnn1xzimjustkeyboardmashing8xn1t8'
exchange_secret_key = '09672v4n09xn0morekeyboardmashing947'

Note: Shrimpy supports 16 different exchanges. Use the following names when creating your exchange_name variable: binance, bittrex, bittrexinternational, kucoin, poloniex, bibox, huobi, hitbtc, bitstamp, bitfinex, coinbasepro, kraken, gemini, huobiglobal, bitmart, and okex.

Shrimpy Account

The second set of API keys we need to access our balance data on the exchange is the Shrimpy Developer API Master Keys.

To get your set of keys, sign up for your free Shrimpy account and select the option to “Create Api Master Key”.

When selecting the permissions for this key, ensure you have enabled the options for “User” and “Account”. These are required to link and access exchange accounts for users.

With your Shrimpy Developer API key in hand, assign it to variables which can be accessed in a future step.

shrimpy_public_key = '8x7138n1xzimjustkeyboardmashing8xn1t8jv5098'
shrimpy_secret_key = '771dc5n72v4n09xn0morekeyboardmashing9475c0294n50'
Create Client

Use the keys we generated in the previous step to create your Shrimpy client.

client = shrimpy.ShrimpyApiClient(shrimpy_public_key, shrimpy_secret_key)
Create User

The Shrimpy APIs require exchange accounts to be connected to users. That way we can generate any number of users who manage multiple individual exchange accounts. This provides a built-in way to determine who owns which exchange account.

Let’s create our user who will be the one which gets linked to our exchange accounts.

create_user_response = client.create_user('Satoshi Nakamoto')
user_id = create_user_response['id']
Link Exchange Account

Once the user is created, linking an exchange to the user is straight forward. Simply specify the user, exchange name, and the API keys for that exchange.

link_account_response = client.link_account(
    user_id,
    exchange_name,
    exchange_public_key,
    exchange_secret_key
)

account_id = link_account_response['id']

As soon as the exchange account is linked, Shrimpy will automatically begin collecting data from the exchange regarding the account’s balances. This process can take a moment, so let’s take 5 seconds before going on to the next step.

Note: You can link up to 20 exchange accounts to a single user. That means if you have accounts with Bittrex, Binance, KuCoin, BitStamp, Kraken, and Coinbase Pro (and more) you can link them all to a single user.

Get Asset Balances

We’re almost done. Let’s grab the exchange account balance from Shrimpy. Simply call the library and ask for the balance data for a specific user and account.

The response to this call will return every asset we own, the balances for these assets, and the dollar values.

balance = client.get_balance(user_id, account_id)
holdings = balance['balances']
Print Out Balances

The final step is to calculate the balances and display them. In this case, we will just print them out, but you can certainly do anything you wish with the balances.

We will iterate over each asset in the returned list and display the asset and the value of our asset holdings.

total = 0

for asset in holdings:
    print(asset['symbol'] + ' ' + str(asset['usdValue']))
    total += asset['usdValue']

print("Total" + ' $' + str(total))

That’s it! You have successfully connected to your exchange account and accessed your balances without logging into the exchange through the UI.

Whenever you wish to update your balances, you can simply request the latest balances from Shrimpy again by passing in your user ID and account ID. Shrimpy will handle the rest by accessing your linked exchange account and collecting the balance data. You DO NOT need to re-link your keys every time or create a new user each time. Those steps are a one-time thing.

Putting it All Together

This is image title

The first time you want to connect to an exchange and access the balance data for the assets you hold on the exchange, you can run the entire script here. Each subsequent time, you only need to run the portion which collects the balance data

This script can also easily be modified to link multiple exchanges, so you can access your balances across every exchange for which you have an account.

First Run

Fill in the information for your Shrimpy Master API keys and Exchange Keys to run this script. I’ve used fake keys for this tutorial.

# import required libraries
import shrimpy
import time

# assign your Shrimpy Master API keys for later use
shrimpy_public_key = '8x7138n1xzimjustkeyboardmashing8xn1t8jv5098'
shrimpy_secret_key = '771dc5n72v4n09xn0morekeyboardmashing9475c0294n50'

# assign your exchange keys for which you wish to access the balance data
exchange_name = "bittrex"
exchange_public_key = 'fbnnn1xzimjustkeyboardmashing8xn1t8'
exchange_secret_key = '09672v4n09xn0morekeyboardmashing947'

# create the Shrimpy client
client = shrimpy.ShrimpyApiClient(shrimpy_public_key, shrimpy_secret_key)

# create a user which will be linked to our exchange
create_user_response = client.create_user('The Shrimp Master')
user_id = create_user_response['id']

# link our first exchange so we can access balance data
link_account_response = client.link_account(
    user_id,
    exchange_name,
    exchange_public_key,
    exchange_secret_key
)

account_id = link_account_response['id']

# wait while Shrimpy collects data for the exchange account
# only required the first time linking
time.sleep(5)

# collect asset balances on the exchange
balance = client.get_balance(user_id, account_id)
holdings = balance['balances']

total = 0

# calculate and print balances for each asset. 
for asset in holdings:
    print(asset['symbol'] + ' $' + str(round(asset['usdValue'], 2)))
    total += asset['usdValue']

print("Total" + ' $' + str(round(total, 2)))

Subsequent Runs

After running the initial script, you can simply access your balances at any time by running this second script.

Notice this script removed the steps to create a user, link an exchange account, and sleep for a few seconds.

Shrimpy will automatically remember this information for you, so all you need to do is connect to the Shrimpy APIs again, tell Shrimpy what account you want balance data for, and print out the balance data which is returned in the response.

# import required libraries
import shrimpy

# input your user and account IDs
user_id = 'dc12349b-1234-12k4-123n12n12nnf'
account_id = 12345

# assign your Shrimpy Master API keys for later use
shrimpy_public_key = '8x7138n1xzimjustkeyboardmashing8xn1t8jv5098'
shrimpy_secret_key = '771dc5n72v4n09xn0morekeyboardmashing9475c0294n50'

# create the Shrimpy client
client = shrimpy.ShrimpyApiClient(shrimpy_public_key, shrimpy_secret_key)

# collect asset balances on the exchange
balance = client.get_balance(user_id, account_id)
holdings = balance['balances']

total = 0

# calculate and print balances for each asset. 
for asset in holdings:
    print(asset['symbol'] + ' $' + str(asset['usdValue']))
    total += asset['usdValue']

print("Total" + ' $' + str(total))
Crypto Developers

The Shrimpy community is becoming the largest network of builders. People who are looking to push the bounds of what’s possible with crypto application development, trading, and market data analysis.

Find the full Python and Node libraries here:

Node

Python

We would love to hear more about what you’re building, so don’t hesitate to reach out and share your story!

Thank for reading! Please share if you liked it!

Script for Live Bitcoin Price Ticker using Websockets

Script for Live Bitcoin Price Ticker using Websockets

Websockets are just part of the equation. Executing real-time trades, collecting historical order book snapshots, and managing exchange accounts is all part of the API.

Websockets are just part of the equation. Executing real-time trades, collecting historical order book snapshots, and managing exchange accounts is all part of the API.

A 5-minute tutorial to connect to cryptocurrency exchange websockets.

Check the time - I have 5 minutes to get you connected to a cryptocurrency exchange’s websocket.

That’s a bold assertion, so let’s not waste any time.

Install Libraries

Before we can write our Python script to connect to exchange websockets, we need to install a library. Yes, exactly one library.

Run the following command to install Shrimpy:

pip install shrimpy-python

1 minute down - already 20% done.

Generate API Keys

After installing the Shrimpy Python Library, register for a Shrimpy Developer API account. This service will be used to access the exchange websockets.

Once you’ve signed up for an account, create a new master key. The master key is how you sign requests and access crypto market data. Save the public and private keys for later use. Make sure to enable “data” permissions on these keys. Some data which is available through the APIs includes candlestick (OHLCV) data, historical order book snapshots, and live trade data.

3 minutes passed - Uh oh, we haven’t even started coding yet.

The Code

Stretch those fingers because we’re about to set a new record for the fastest time anyone has ever connected to a crypto exchange websocket.

Library Import

The Shrimpy library has already been installed, so import it into your script.

import shrimpy

Define Handler

To receive data out of the websocket, we need to create a handler. This handler will simply print the price of each trade which is received through the trade websocket.

Since we can receive multiple trades per message, we will only consider the last trade in the message to be the current ticker price.

def error_handler(err):
    print(err)

def handler(msg):
    ticker = msg['content'][len(msg['content']) - 1]['price']
    print(ticker)

Client Creation

Create a client object by calling into the Shrimpy library. Don’t forget to first get the token which is required to create the client. You can get this client by creating an API client, which is created by passing in your public and private API keys. This will help you manage your websocket connection and subscriptions.

public_key = '6d73c2464a71b94a81aa7b13d...'
private_key = 'e6238b0de3cdf19c7861f8e8f5d137ce7113ac1e884b191a14bbb2...'

api_client = shrimpy.ShrimpyApiClient(public_key, private_key)
raw_token = api_client.get_token()
client = shrimpy.ShrimpyWsClient(error_handler, raw_token['token'])

4 minutes now - it’s going to be close.

Declare Subscribe Data

Before we can subscribe to a websocket stream, we must define the subscription for which we want to connect.

subscribe_data = {
    "type": "subscribe",
    "exchange": "binance",
    "pair": "btc-usdt",
    "channel": "trade"
}

Connect Websocket

Start processing the Shrimpy websocket stream by subscribing to the channel.

client.connect()
client.subscribe(subscribe_data, handler)

… and 5 minutes - game, set, match.

Note: You can subscribe to 100 different channels per client. Shrimpy allows each IP to manage up to 10 clients for a total of 1,000 channels per IP.

Just like that, you are now live streaming the latest trade data from Binance. In the handler we defined, that data is parsed to only extract the price at which each trade was executed. That allows us to print the tick-by-tick price of the cryptocurrency at this exact moment.

Disconnect Websocket

Once you’ve finished collecting data, disconnect the client.

client.disconnect()

This is image title

After connecting to the websocket, you will begin to see price data stream in real time.

Putting it all Together

That was quick, so let’s take a moment to regroup and get a full picture of what we just accomplished.

In the last 5 minutes, we leveraged the Shrimpy APIs and connected to the trade websocket for a crypto exchange. This allowed us to get the real-time ticker price for an asset.

# import the Shrimpy library for crypto exchange websockets
import shrimpy

# a sample error handler, it simply prints the incoming error
def error_handler(err):
    print(err)

# define the handler to manage the output stream
def handler(msg):
    # multiple trades can be returned in each message, so take the last one
    ticker = msg['content'][len(msg['content']) - 1]['price']
    print(ticker)

# input your Shrimpy public and private key
public_key = '6d73c2464a71b94a81aa7b13d...'
private_key = 'e6238b0de3cdf19c7861f8e8f5d137ce7113ac1e884b191a14bbb2...'

# create the Shrimpy websocket client
api_client = shrimpy.ShrimpyApiClient(public_key, private_key)
raw_token = api_client.get_token()
client = shrimpy.ShrimpyWsClient(error_handler, raw_token['token'])

# construct the subscription object
subscribe_data = {
    "type": "subscribe",
    "exchange": "binance",
    "pair": "btc-usdt",
    "channel": "trade"
}

# connect to the Shrimpy websocket and subscribe
client.connect()
client.subscribe(subscribe_data, handler)

# disconnect from the websocket once data collection is complete
client.disconnect()

Now, Binance isn’t the only exchange supported by Shrimpy and the btc-usdt pair isn’t the only trading pair.

The Shrimpy APIs support 17 different exchanges and over 1,300 markets. Each of the most prominent exchanges can be accessed through a simple consolidated websocket API.

Not only that, websockets are just part of the equation. Executing real-time trades, collecting historical order book snapshots, and managing exchange accounts is all part of the API. You can find the full documentation here.

End

Users are able to configure a custom cryptocurrency portfolio and implement a passive rebalancing strategy, removing the hassle of having to actively trade crypto. Shrimpy’s Developer Trading API is a unified way to integrating trading functionality across every major exchange. Collect historical market data, access real-time websockets, execute advanced trading strategies, and manage an unlimited number of users.

Thank for reading !

10 Strategic Technologies in 2020

10 Strategic Technologies in 2020

Here are 10 Strategic Technologies in 2020 that tech leaders should have on their radar in the coming years. Augmented and virtual reality might train employees in the future, voting might become based on a blockchain, and AI security might become the most important factor in risk management.

People-centric and smart space tech

Research and advisory company Gartner released a report on the top 10 strategic technology trends predicted for 2020 Using this predictive information, technology innovation leaders can plan strategies for the upcoming year and where to focus their efforts for technological and AI adoption.

The full report from Gartner weighs in at a hefty 52 pages with insights from analysts David Cearley, Brian Burke, David Smith, Nick Jones, Arun Chandrasekaran, and CK Lu. Interested individuals can download their free copy.

What are the 10 highlighted technologies? Let’s take a dive into each of them and how they can potentially change the enterprise landscape.

1. AI security

This is image title

AI and ML will continue to be applied to augment human decision making across a broad set of use cases. While AI is powerful and helpful for many businesses, it also opens up a large number of security holes. Security is evolving fast, and risk management experts have to keep up with new kinds of attacks, previously never seen before. AI and ML tools such as DeepExploit and identity deception tools pose a serious threat.

Gartner predicts that through 2022, 30% of all AI security attacks will use training-data poisoning, AI model theft, or adversarial samples to attack AI-powered systems.

2. Practical blockchain

This is image title

By now, most people are aware of the potential use cases for blockchain or are familiar with how its most successful endeavor, Bitcoin, works. Blockchain and the use of smart contracts distribute trust and allow for everyone with access to the blockchain to access the same information and trace assets back to their origin.

Just some of the future potentials for blockchain may include a blockchain-based voting system, a self-sovereign digital identity, or cryptocurrency payments and remittance services.

Blockchain remains immature for enterprise deployments due to a range of technical issues including poor scalability and interoperability. Despite these challenges, the significant potential for disruption and revenue generation means organizations should begin evaluating blockchain, even if they don’t anticipate aggressive adoption of the technologies in the near term. Blockchain has the potential to reshape industries by enabling trust, providing transparency and enabling value exchange across business ecosystems, potentially lowering costs, reducing transaction settlement times and improving cash flow.

Gartner predicts that blockchain will be scalable by the year 2023.

3. Hyper-automation

This is image title

Automation requires the use of tools each with their own narrowly defined specific purpose. By using these tools in combination technology can become nearly entire automatic and adaptive.

Hyperautomation is the combination of multiple machine-learning (ML), packaged-software and automation tools to deliver work. Hyperautomation refers not only to the breadth of tools available, but also to all the steps of automation itself (discover, analyze, design, automate, measure, monitor and reassess), Cearly said. Understanding the range of automation mechanisms, how they relate to one another and how they can be combined and coordinated is a major focus for hyperautomation. Hyperautomation requires a combination of tools to help support replicating pieces of where the human is involved in a task.

The two most important components are robotic process automation (RPA) and intelligent business management suites (iBPMSs). RPAs connect legacy systems with modern systems and iBPMSs manage long-running processes. These two technologies will be used and deployed together to create sophisticated, automatic models.

4. Multi-experience

This is image title

The way that users interact with the digital world is changing and opening up to a multisensory experience. Also referred to as ambient experience, Multiexperience refers to the future of multisensory and multitouchpoint technology.

Immerse experiences such as virtual reality and augmented reality are becoming more commonplace. According to Gartner, these have potential in the realm beyond entertaining apps like Pokémon GO. For instance, VR and MR can help improve product design and visualization, field service and operations, and training simulation.

Perhaps in a few years, you will encounter a job training program that is entirely virtual reality.

Through 2028, the user experience will undergo a significant shift in how users perceive the digital world and how they interact with it. Conversational platforms with improved voice-driven and dialogue-management capabilities are changing the way that people interact with the digital world. And virtual reality (VR), augmented reality (AR) and mixed reality (MR) are changing the way in which people perceive the digital world This shift in both interaction and perception models leads to a future multisensory and multimodal experience.

By 2021, at least one-third of enterprises will have deployed a multiexperience development platform to support mobile, web, conversational and augmented reality development, Gartner stated.

“The model will shift from one of technology-literate people to one of people-literate technology. The burden of translating intent will move from the user to the computer,” said Brian Burke, research vice president at Gartner. “This ability to communicate with users across many human senses will provide a richer environment for delivering nuanced information.”

5. Democratization of expertise

This is image title

Democratization and citizen access give all people the potential to access technical expertise. This levels the playing field and forgoes expensive training classes that many people, including non-experts, are unable to access.

The future of the citizen developer may include the ability to develop with zero code or code knowledge. Assisted development tools may become mainstream, enabling all people to potentially experiment with machine learning and AI.

As for AI specialists, Gartner predicts that by 2022, at least 40% of new application development projects will have AI co-developers on the team.

Through 2023, Gartner said it expects four key aspects of the democratization trend to accelerate, including democratization of data and analytics (tools targeting data scientists expanding to target the professional developer community), democratization of development (AI tools to leverage in custom-developed applications), democratization of design (expanding on the low-code, no-code phenomena with automation of additional application development functions to empower the citizen-developer) and democratization of knowledge (non-IT professionals gaining access to tools and expert systems that empower them to use and apply specialized skills.

6. Human augmentation

This is image title

Human enhancement is nothing new, as anyone with glasses, a prosthetic limb, a smart watch, a pacemaker, or orthodontic braces will tell you. However, the future opens up new speculative doors for cognitive and physical augmentation.

For instance, it may be possible in the future to detect your glucose levels via smart contact lenses. Wearables will also likely become more commonplace and extend their functionalities, perhaps by enhancing abilities like hearing or sense of smell.

The controversial and ethical side of this include gene and cell therapies and genetic engineering. Time will tell how human rights are potentially impacted by these loaded topics.

Over the next 10 years increasing levels of physical and cognitive human augmentation will become prevalent as individuals seek personal enhancements. By 2025, 40 percent of enterprises will shift from designing for humans to architecting humans themselves by adopting human augmentation technologies and methodologies, Gartner says.

7. Transparency and traceability

This is image title

Ethics in AI and information privacy are growing concerns for both individuals and businesses alike. People want more active control over their data and personal information.

The six key elements of trust are ethics, integrity, openness, accountability, competence, and consistency. Especially with the EU’s GDPR, businesses should be mindful regarding data transparency in the upcoming years.

By 2023, over 75 percent of large organizations will hire artificial intelligence specialists in behavior forensics, privacy and customer trust to reduce brand and reputation risk, the company said.

8. The Empowered edge

This is image title

The future of edge devices includes simple embedded devices, edge input/output devices, edge computing devices, and complex embedded edge devices. Edge devices will increase in sophistication.

Edge computing includes tech on the Internet of Things. According to a 2018 IoT Analytics report, there are currently seven billion IoT devices and the number is accelerating. Looking into the future, it is possible that by 2023, there will be over 20 times as many smart devices at the edge of the network.

By 2023, more than 50 percent of enterprise-generated data will be created and processed outside the data center or cloud, up from less than 10 percent in 2019.

9. Distributed cloud

This is image title

Cloud computing and hybrid scenarios aren’t going anywhere in 2020. From Gartner:

Distributed cloud allows data centers to be located anywhere. This solves both technical issues like latency and also regulatory challenges like data sovereignty. It also offers the benefits of a public cloud service alongside the benefits of a private, local cloud.

Gartner predicts distributed cloud computing will happen in three separate phases and that by 2024, “most cloud platforms will provide at least some services that execute at the point of need”.

10. Autonomous things

This is image title

Both semi and fully autonomous technologies such as drones will likely continue to grow in use in 2020 and beyond. While currently many autonomous devices are limited to private use, it is likely they will become more common in the public sphere.

What else may become autonomous in the future? Gartner predicts autonomous tech may impact agriculture, self-driving cars, shipping companies, and search and rescue.

Be the first to share this article with your network! Thank you ...