- Advertisement -Newspaper WordPress Theme
Algorithm tradingTableau Tutorial - Understanding the Basics - AlgoTrading101 Blog

Tableau Tutorial – Understanding the Basics – AlgoTrading101 Blog


Is Tableau Free?

Yes and no. Tableau comes equipped with both premium and free versions. The premium version is known as Tableau Desktop and the free version is called Tableau Public.

Let’s explore the main difference between the two. When you hear that people use Tableau for building dashboards and making business data-driven decisions they are often referring to the premium version.

The premium version comes with more data connections, with the ability to save your data locally and upload it to a Tableau Server or Tableau Online (cloud version of Tableau). Tableau Desktop costs $70 a month.

On the other hand, with the free version, you must save your work files and data online. You also have limited data connections and no ability to access the Tableau Server.

But which one should you choose? The answer to this question depends on the type of work you do. The free version isn’t bad at all and is a great learning and starting point.

But if you’re working with sensitive data and would like to step up your Tableau game and have access to the cloud, then the premium version of Tableau is right up your alley. For this tutorial, we will use the free version.

How to get started with Tableau?

In order to start exploring our data and building those pretty visualizations, we will need to download the Tableau Public software. In order to do this visit the following link, enter your email and click “DOWNLOAD THE APP”.

https://public.tableau.com/en-us/s/download

After you go through the installation steps a Tableau icon will appear on your desktop and/or in the path where you saved the installation. Let’s open it up and start exploring Tableau!

The first things that we can see on the left side are our available connections like Excel, JSON, Statistical, and other files. On the right side, we can see some in-built tutorial features, viz of the day, and resources.

Have in mind that we’re only going to explore the minimum basics of Tableau. At the end of the article, I’ll add useful resources where you can learn much more about Tableau and become a professional user.

Before we obtain some data related to finance, let’s ease in with a sample data set that can be accessed by clicking the “Sample Data Sets’ string on the right side. I’ll choose the Netflix Movies and TV Shows dataset.

When you download the dataset pick the Microsoft Excel connection on the left side and navigate to the obtained dataset. You should see something like this:

In order to explore the tables of the dataset click on one on the left side and drag it to the upper middle half of the screen. I’ll pick the first one (netflix_titles).

Here you can play with the data by changing its order, adding filters, adding multiple tables and connecting them and etc. Let’s move on to the Sheets where the real action takes place (don’t quote me on that one).

What charts does Tableau have?

Tableau comes equipped with many chart types that will suit your needs. The main chart categories would be area, boxplot, scatter, map, bar, line, and other charts.

Let’s go back to the Data Source (lower toolbar) and add two new sources which are the directors and countries. Then we will go back to our sheet and click on the world map chart that will appear on the right side.

In order to visualize the world map add the Country feature to the columns and then click on the map.

And you will get an ugly chart that shows a world map for each of the titles. In order to combat this on the left side, you will see green features of longitude and latitude. Let’s just leave them on the shelves:

You might notice that some variables are colored green and some blue. The logic behind this is that the green color represents continuous values while the blue ones represent discrete values.

Now let’s scratch all that by dragging the measures of the shelves and adding ratings and the total count of our titles. A packed bubble chart will become available, let’s see it.

Another way to clean your sheet is to use the following shortcut Alt + Shift + Backspace. Be sure to play around a bit with all the variable combinations and try to create other informative charts.

What is the Tableau dashboard?

A Tableau dashboard is a collection of visualizations that were created in the Tableau Sheets. To create a dashboard all that you need to do is to drag your sheets onto the dashboard.

On the left side, you can see all the modifications that you can make to your existing dashboard. You can add different objects like web pages, sliders, images, extensions, and more.

If you right-click on your sheet graph you can filter, annotate, duplicate, toggle its features, and more. Be sure to play around and see what you can come up with.

I’ll play with another dataset of S&P 500 stock data that was obtained with the Yahoo Finance API, create some quick random sheets, extend our dashboard and add a web page object to it.

This is a perfect opportunity to practice what you’ve learned. I’ll share the code that will obtain the data and you can then import it into Tableau, create some sheets and add some objects to the dashboard.

Then come back and compare your sheet to mine.

#pip install yahoo_fin
import pandas as pd
import yahoo_fin.stock_info as si

sp500_list = si.tickers_sp500()
sp500_historical = {}

for ticker in sp500_list:
    sp500_historical[ticker] = si.get_data(ticker, start_date="01/01/2019", index_as_date = False, interval="1d")
sp500_historical

data = pd.concat(sp500_historical)
data.reset_index(drop=True, inplace=True)
data.to_csv('S&P_500_data')

Let’s check it out:

How to create an OHLC chart in Tableau?

Creating an OHLC chart in Tableau requires several things. Firstly, we need to have the data for the specified timeframe, then we need to transform the features and tweak some parameters like the sizing, color, and charting.

Let’s go over the chart creation in a step-by-step way as you’ll learn some advanced features of Tableau. Firstly, we’ll obtain monthly data for the BTC-USD ticker via the Kraken API.

import pandas as pd
import krakenex
from pykrakenapi import KrakenAPI
api = krakenex.API()
k = KrakenAPI(api)

# Get data starting from 1st April 2021
ohlc = k.get_ohlc_data('BTCUSD', interval=1440, since=1617228000, ascending=True)

# Delete unix time column as our index column is set to y/m/d format
ohlc = ohlc[0].drop(['time'], axis=1)

# Download the data
ohlc.to_csv('BTC-USD')

Now locate the data and connect to it via Tableau. It should look something like this:

The next step is to go over to “Sheet 1” where we will do all of our work. Firstly, we will calculate the open/close and high/low spreads by creating new variables.

In order to do this, on the left side of the screen where all variables are listed right-click and press “Create Calculated Field”. A new pop-up will appear where we will calculate the spread.

Now, rename the field to “Spread_Open/Close” and insert the following calculation: sum([Close]) - sum([Open])

Click ok and do the same for the High/Low spread by dividing the low sum by the high sum like this: sum([Low]) - sum([High])

Now that we have our variables ready, let us add the time to the Columns shelf and change it to Daily values and Continuous.

Now we add the High and Open variables to the Rows shelf. As you can see, Tableau assumes that this is a line chart. We will change it in the Marks section to a Gnatt Bar type.

Now click on the Open variable and select Dual Axis.

To synchronize the data right-click on the y label of the Open variable and click “Synchronize Axis”. Then right-click again and toggle off the header.

Now we need to create our candlestick with the measures we calculated at the very beginning. On the left side of your screen, you will see the “Marks” section and your added variables.

Click on each spread and drag it to the Size Mark for the complementing variable i.e. High/Low spread onto the Size mark of High. Be sure to click on the Measure Names mark on the High variable and remove it.

Now click on the Size mark of the High variable and drag the slider to the utmost left. The next step is to click on the Open/Close spread and add it right onto the color mark of the Open variable.

Then click on the color and change it to the usual red and green combination. Be sure to change the step size to two. If you did everything properly you should have a chart similar to this one:

Now right click on the chart and go to format as we want to make it prettier. There you can edit your chart by removing the gridlines and tweaking some of the features. Be sure to play with them.

Let’s add a trend line. Right-click on the chart -> Trend Lines -> Show Trend Lines -> SUM(Open). A new trendline will appear, click on it and then go to edit and play with its features. Check out the format too!

Hint: make it thinner, change the color and convert it into a third-degree polynomial.

Now that you know the basics of Tableau, homework would be to create a daily price chart, daily volume chart, and a daily spread chart. Then make a Tableau dashboard out of them.

That’s it! I hope your dashboard looks prettier than my quick and dirty one.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Subscribe Today

GET EXCLUSIVE FULL ACCESS TO PREMIUM CONTENT

SUPPORT NONPROFIT JOURNALISM

EXPERT ANALYSIS OF AND EMERGING TRENDS IN CHILD WELFARE AND JUVENILE JUSTICE

TOPICAL VIDEO WEBINARS

Get unlimited access to our EXCLUSIVE Content and our archive of subscriber stories.

Exclusive content

- Advertisement -Newspaper WordPress Theme

Latest article

More article

- Advertisement -Newspaper WordPress Theme