Click here to Login

How to Display the Year-to-Date Excess Return in a Pivot Table

Updated on 2015-12-15

In this blog post, we will show you how to create a table that displays year-to-date excess return of several assets versus a specific benchmark. For this, we are going to use a powerful tool in QuantShare called pivot tables.

First we need to create a dashboard then add a pivot table in it.

To do this, select "Tools -> Dashboard -> New Dashboard"
Give a name to your dashboard then click on "Save"

A dashboard is a panel where you can add shortcuts (of your trading items), widgets and pivot tables.

Right click on the dashboard then select "Create Pivot Table".

A new black rectangle should be added to your dashboard. That rectangle is the container of the table we are going to create.
At the top, you can see few icons. The first can be used to delete the pivot table while the second one is used to move the pivot table.
At the bottom (right corner), you can resize the pivot table container.

This tool is not very different from the Excel pivot table.

Pivot Table Settings

The next step would be to specify the row, column and value to display in the pivot table.

Right click on the black rectangle then select "update Rows/Columns/Values".

We want the table to look like this:

Notice in the above picture that each row contains a different asset symbol.

Click on the "+" icon next to "Rows" to create a "Symbols" row. Under the "Symbols" tab type in the ticker symbols that will be displayed as rows.
As an example, you can type the following ETFs:

Now, click on "+" next to "Columns". We must have the benchmark symbol as column here. So, type one or several benchmark symbols here.

Click on "+" next to values and input the following values:

Name: YTD
Dates: "Last Historical Quotes Date" (We will use the last bar's date for the calculation)
Time frame: Daily
Summarize: Last Value (We want to get only the last value)
((close / (valuewhen(year() != ref(year(), 1), ref(close, 1)))) - 1)*100

The above formula calculates the year to date return. You can plot it on a chart to see the corresponding time-series.

Click again on "+" next to values to create the excess column:

Name: YTD Excess
Dates: "Last Historical Quotes Date"
Time frame: Daily
Summarize: Last Value
((close / (valuewhen(year() != ref(year(), 1), ref(close, 1)))) - 1)*100-((SYMBOL / (valuewhen(year() != ref(year(), 1), ref(SYMBOL, 1)))) - 1)*100

The above formula calculates the year to date return of an asset specified in "Rows" then subtract the year to date return of the benchmark asset specified in "Columns".
Note how we reference the column's asset using the "SYMBOL" keyword. QuantShare will replace "SYMBOL" by the close price of the column's asset.

NB: The pivot table we just created here can be downloaded directly from the sharing server: Year to Date Excess Return

Using pivot tables, you can create so many things. Here are some examples:
Create a Pivot Table that displays the Relative Strength Index - RSI
How to display the number of stocks per day for different RSI groups
How to create a correlation matrix of several securities
Pivot Tables in QuantShare Trading Software

3 comments (Log in)

QuantShare Blog
Search Posts

Recent Posts

Create Graphs using the Grid Tool
Posted 1328 days ago

Profile Graphs
Posted 1433 days ago

Previous Posts

More Posts


Create an account
Affiliate Program
Contact Us
Trading Forum
How-to Lessons
About Us
Terms of Use

Copyright 2024
Social Media
Follow us on Facebook
Twitter Follow us on Twitter
Follow us on Google+
RSS Trading Items

Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.