Price and Sentiment Analysis: Why is Bitcoin Going Down?

Bitcoin Price and Sentiment Analysis with variable Moving Average: click to open interactive Tableau dashboard with annotations
Bitcoin Price and Sentiment Analysis with variable Moving Average: click to open interactive Tableau dashboard with annotations

Bitcoin has become one of the trendy investment assets in the recent years. Whenever bitcoin prices approach historical highs, every investor should watch the currency closely. Bitcoin rallied by more than 20% in the first days of 2017, crossing the $1000 mark for the first time since November 2013.

As many experienced bitcoin traders will remember, the first $1000 peak was a case of obvious over exuberance. Bitcoin was hot, plenty of money was pouring into it. Bitcoin investors got too excited, causing a price surge. Prices then rebounded and suffered a long-term collapse shortly after.

Moving Average Convergence/Divergence Indicator

Many traders rely on a Moving Average Convergence/Divergence (MACD) indicator. The MACD is a measure of the convergence and divergence between two EMAs (usually 12 and 26 days) and is calculated by subtracting the two of them. The signal line is constructed by creating an EMA (usually 10 days) of the signal line.

The signal line crossing the MACD from above is a buy signal. The signal line crossing the MACD from below is a sell signal. Relying only on momentum-based indicators (such as the MACD) and optimization-based models, however, will most certainly fail to indicate heavy price drops, as the drop in late 2016.

Predicting Fear with Sentiment Analysis

In late 2016 a lot of people began to pour money into bitcoin again. This time because they were worried that stock markets and other assets were due for a drop. For investors, it is essential to figure out whether or not these fears are actually founded. However, such „safe assets“ are prone to suffering from bubbles. People get scared, get invested into gold, or bitcoin, then realize that their fears were unfounded. As a result bitcoin prices could plummet.

So how to catch emotions such as fear in advance? Twitter is a valuable source of information and emotion. It certainly influences the stock market and can help to predict the market. Sentiment analysis can lead price movements by up to two days. Negative sentiment, however, is reflected in the market much more than positive sentiment. This is probably because most people tweet positive things about bitcoins most of the time. Even more positive news occurred after breaking the $1000 barrier.

This content is part of the session “Price and Sentiment Analysis: Why is Bitcoin Going Down?” that I deliver at the Frankfurt Bitcoin Colloquium. Have a look on my upcoming sessions!

[Update 14 Jun 2017]: Axis for Moving Average adjusted. Relative Date selector added with last 6 month as default. Screenshot updated.

Feel free to share the Bitcoin Price and Sentiment Analysis dashboard, which is also featured as Viz of the Day on Tableau Public:

Monkey Business: Always be Ready to Demo

The famous Tableau Superstore demo data set
The famous Tableau Superstore demo data set

Usually, I really don’t like looking on the screens of other passengers. On this early morning train from Frankfurt to Cologne, however, the screen of my seatmate caught my attention. Where have I seen the logo on his slide deck before? Two coffee sips later, it came to me: it was the logo of Monkey 47, a very delicious gin, distilled in the heart of the Black Forest. So I asked my neighbor: “Is that the Monkey 47 logo?”

He was happy that I recognized his brand and we had a small chat about gin and the Black Forest. Turns out his name is Thomas, and he is the head of Sales and Marketing for Monkey 47. Thomas mentioned that his team is planning a tour to promote Monkey 47 in a number of cities. That sounds similar to what we are doing with the Tableau Cinema Tour, so I showed him our Cinema Tour landing page and explained briefly who we are and what our mission is.

I asked him how he is organizing his data. Thomas revealed that he lives in Excel hell: “spreadsheets with thousands of rows and way too many columns”. This also sounded familiar. I opened up our Superstore.xlsx in Excel and asked: “Do your Excel sheets look like this?” Thomas replied: “Yes!”

Here we go! I drag’n’dropped the file on my Tableau desktop icon and paced through a 7-minute-demo ending with an interactive dashboard. Thomas was flabbergasted. To polish things off, I showed him the interactive Twitter Sentiment Dashboard embedded in my blog. Thomas grabbed his jacket and gave me a business card, saying: “We need Tableau!”

Monkey 47 business card (back side)
Monkey 47 business card (back side)

This story was originally written for Tableau’s EMEA Sales Newsletter. I think it’s a good read for the holidays, and wish you all Merry Christmas!

TabPy Tutorial: How to Integrate Python with Tableau for Advanced Analytics

Python in Tableau: TabPy allows Tableau to execute Python code on the fly
Python in Tableau: TabPy allows Tableau to execute Python code on the fly

In 2013, Tableau introduced R Integration, the ability to call R scripts in calculated fields. This opened up possibilities such as K-means clustering, Random Forest models, and sentiment analysis. With the release of Tableau 10.2, we can enjoy a new, fancy addition to this feature: the Python Integration through TabPy, the Tableau Python Server.

Python in Tableau: The Perfect Blend

Python is a widely used general-purpose programming language, popular among academia and industry alike. It provides a wide variety of statistical and machine-learning techniques and is highly extensible. Together, Python and Tableau are the data science dream team to cover any organization’s data analysis needs.

In this tutorial, I’m going to walk you through the installation and connecting Tableau with TabPy. I will also give you an example of calling a Python function from Tableau to calculate correlation coefficients for a trellis chart.

Step by Step: Integrating Python in Tableau

1. Install and start Python and TabPy

Start by clicking on the Clone or download button in the upper right corner of the TabPy repository page, downloading the zip file, and extracting it.

TabPy download via GitHub web page

Protip: If you are familiar with Git, you can download TabPy directly from the repository:

> git clone git://github.com/tableau/TabPy

TabPy download via Git command line interface

Within the TabPy directory, execute setup.sh (or setup.bat if you are on Windows). This script downloads and installs Python, TabPy, and all necessary dependencies. After completion, TabPy is starting up and listens on port 9004.

2. Connecting Tableau to TabPy

In Tableau 10.2 (and later versions), a connection to TabPy can be added in Help > Settings and Performance > Manage External Service Connection:

Tableau main menu
Tableau main menu

Set port to 9004:

External Service Connection dialogue
External Service Connection dialogue

3. Adding Python code to a Calculated Field

You can invoke Calculated Field functions called SCRIPT_STR, SCRIPT_REAL, SCRIPT_BOOL, and SCRIPT_INT to embed your Python script in Tableau:

SCRIPT_REAL('
import numpy as np
return np.corrcoef(_arg1,_arg2)[0,1]
',
SUM([Sales]), SUM([Profit]))
Python script within Tableau
Python script within Tableau

4. Use Calculated Field in Tableau

Now you can use your Python calculation as Calculated Field in your Tableau worksheet:

Tableau workbook featuring a Python calculation
Tableau workbook featuring a Python calculation

Feel free to download the Tableau Packaged Workbook (twbx) here.

Further Reading: Visual Analytics with Tableau

Join the data science conversation and follow me on Twitter and LinkedIn for more tips, tricks, and tutorials on Python in Tableau and other data analytics topics. If you’re looking to master Tableau, don’t forget to preorder your copy of my upcoming book, Visual Analytics with Tableau (Amazon). It offers an in-depth exploration of data visualization techniques and best practices.

Also, feel free to comment and share my TabPy Tutorial tweet:

Blog post updates:

Tableau: How to find the most important variables for determining Sales

Random Forest Animation
Interactive dashboard displaying the most important variables for determining the Sales measure in Tableau 10.0 (click screenshot to enlarge)

During the Q&A session of a recent talk on Data Strategy, I was challenged with a rather technical question: I was asked how to identify the variables that are heavily influencing a certain measure – with an interactive solution that matches a modern data strategy as suggested in my presentation.

Of course, this could be done by executing a script. The result however would be static and it would be not convenient for a Business Analyst to run it over and over again. Instead of applying a script every time the data changes, it would be much more innovative to get the answer immediately with every data update or interactivity such as a changed filter.

So why not solve this with Tableau? The magic underneath this easy-to-use Tableau dashboard is a nifty R script, embedded in a calculated field. This script calls a statistical method known as Random Forest, a sophisticated machine learning technique used to rank the importance of variables as described in Leo Breiman’s original paper.

The Tableau Packaged Workbook (twbx) is available here. Do you have more ideas or use cases? Feel free to leave a comment or send me an email: aloth@tableau.com

3 Essential Components to building a Data Strategy

data-strategy-slide
Three core elements of a Data Strategy Plan for the telecommunications industry

Does your enterprise manage data as a corporate asset? Many companies don’t. Here’s how to get started with the three core elements for your Data Strategy Plan.

1. Data

The ongoing digital transformation of our environment has created an enormous amount of data about just every aspect of what we are doing. Every website we visit, every link we click, every search engine term, every purchase is recorded associated either with our online identity if we have logged in, or in a system that saves our session through cookies or digital fingerprinting.

Once gathered, data across the enterprise are typically stored in silos belonging to business functions (vertical silos), business units (horizontal silos), or even different projects within the same division (segmented silo). Making this data a valuable and useful asset will require to break down the silos. This may not be so easy to accomplish, due to ownership issues, regulatory concerns, and governance practices.

2. Analytics

Collecting data alone does not generate value. The completeness of your Advanced Analytics stack and the complexity of the applied models determine how „smart“ your insights will be and therefore how deep the level of business impact will get. Prescriptive and Semantic Analytics might be tough to implement, especially, if you need to find a way to classify semi-structured data, such as social media streams.

While you look to apply sophisticated models, you should not forget to collect the low-hanging fruits and see if you put in all your quantitative information, such as revenue data, to scale out your diagnostic capabilities.

3. Decision-support Tools

Now you need intuitive tools that integrate data into sustainable processes and apply your analytic models to generate information that can be used for your business decisions. Depending on the stakeholder, the outcome might be presented as a self-service web front end, such as a Network Performance Monitor that allows predictive maintenance, or an Executive dashboard that provides your CFO the latest numbers for upcoming M&A.

An important consideration for your decision-support tools is user acceptance. Decision-support tools should be easy to use and should not make processes more complicated. Instead, consider adding buttons that trigger actions directly from the user interface.

This content is part of the session „3 Essential Components to building a Data Strategy“ that I delivered at Telekom Big Data Days 2016. Have a look at my upcoming sessions!