You may have seen the Quandl tab when searching in Tradingviews’ instrument search panel and wondered just how some of the available exotic data sources could be of any use. I know I for one was taken back when I saw child mortality rates on a trading platform! If that last sentence didn’t make it obvious, Quandl has a massive selection of datasets that can be used creatively to try and find an edge.
This post aims to influence people to look beyond the price charts and find an edge with alternative data sources. So without further ado, lets get started with Quandl data sources.
What is Quandl?
Launced in 2013 and based in Toronto, Quandl is a marketplace for financial, economic and other wonderful datasets. They have a ton of both free and premium data sources. The free data is not low quality either! There is a plethora of excellent databases containing free fundamental and exotic data such as official government statistics from the ONS in the UK or FRED in the US, the Commitment of Traders report, end of day financial data and much, much more. If you have deep pockets, you can also take a look at the premium datasets. The sky is the limit.
For more information visit: https://www.quandl.com/
How to find data
If I have piqued your interest and you want to get your hands on some of this data, there are a few ways to go about it. If you know what you are looking for, you can use the normal search box and hit the Quandl tab.
Note: Do not open the search and just start typing. By default, Quandl results are NOT returned unless you hit the Quandl tab.
Having said this, at the time of writing I find the search often does not return the results I am looking for. Take this for an example, if you are looking to get open interest data from the COT report on the British Pound and simply search for “Pound”, “British Pound” or “BP”, you will not find what you are looking for!
To find it you need will likely need to filter the list and select the CFTC first:
A word of warning though, the list is not in alphabetical order. It took me a quite some time to fish out the CFTC from the huge list.
Once filtered, a general search can often find what you are looking for. In the image below, the correct COT data is found by searching for “Pound” only.
If you really know what you are looking for, you can also enter the ticker id directly (for this example the ticker id is is TIFF_CME_BP_ALL) and there is no need to filter the list. However, each data set in Quandl can, and often will have its own format so there is little chance of you guessing unless you already are familiar with the data providers general format.
Finally, the last option is to browse the Quandl site! Each data set has its own documentation giving you the exact ticker id required. Also by browsing, you will uncover some great datasets that you had not considered before. We don’t know to use what we don’t know exists.
To make this article have a little more value than just telling you how to do a basic search, lets design and code an indicator that uses data supplied from Quandl. To round it off, we will then put it to the test in a strategy to see how useful it is.
Disclaimer: As I write this I have no idea whether the my idea for an indicator will produce good results. I will present the results to you whether they are good or bad. The aim of this post is to inspire you to be creative, obtain data that is not on your chart and see if you can generate some edge!.
After browsing the Quandl website, I spotted something that grabbed my attention. The London Metals exchange provides daily stock (inventory) data for Aluminum, Copper and Zinc, all free of charge. This gave me the thought to develop an indicator that will track global inventories and measure the daily change in supply. In economics 101 we learn that price is determined by 2 factors, supply and demand so wouldn’t it be helpful to have a good gauge on one side of the equation? Let’s build the indicator and test it to find out!
//@version=3 study("LME Inventories Indicator", overlay=false) //Add an input for Metal Selection metal = input(defval='CU', title='Metal', options=['AL','CU','ZI']) // Create sym stBase = 'QUANDL:LME/ST_' stSym = stBase + metal + '_ALL' //Get the data st = security(stSym,'D', close) //Calc the percentage change stChange = ((st - st) / st) * 100 //Setup Colors stCol = if stChange > 0 red else green plot(stChange, title='Inventory Level Changes (In %)', color=stCol,linewidth=3,style=columns)
The code above is fairly straightforward. We are simply creating one input to select the metal of choice, getting the data and calculating the change in inventory levels from the day before.
If you are just getting started with Tradingview and Pinescript, I have some beginner tutorials here:
Details of the ticker structure for the London Metals Exchange can be found on the Quandl website in the link below along details of the other data available from the LME. :
On the chart
After adding the code below to a chart you should get some output that looks similar to below.
Those regular spikes in supply look interesting!
For our strategy rules, lets go back to economics 101. A decrease in supply should cause the price to increase (assuming demand stays the same). Conversely an increase in supply should cause a drop in price. With this in mind, and given those spikes look extreme, I think we have the basis of our strategy!
As we noted above, there seems to be regular periods of massive resupply followed by gradual daily drawdowns until another resupply of global inventories. Therefore, the strategy will look to short Copper every time the cooper supply increases by 10% or more. We will close the strategy when the amount of daily increases of supply is equal or drops below 0%. For safety, will will put a stop at the high of the days closing price.
//@version=3 strategy(title="Global Metal Inventories Strategy", overlay=true, default_qty_type=strategy.percent_of_equity,default_qty_value=10) //Add an input for Metal Selection metal = input(defval='CU', title='Metal', options=['AL','CU','ZI']) // Create syms stBase = 'QUANDL:LME/ST_' stSym = stBase + metal + '_ALL' //Get data st = security(stSym,'D', close) //Get data for current Chart stHigh = security(ticker,'D', high) stChange = ((st - st) / st) * 100 shortConditionOne = stChange > 10 if (shortConditionOne) strategy.entry("Oversupply", strategy.short, stop=stHigh) closeConditionOne = stChange <=0 if (closeConditionOne) strategy.close("Oversupply")
To turn the indicator into a strategy, we have to sacrifice the plotting of the indicator. This is because the indicator runs on a subplot (below the main chart) but the strategy needs to write on the main chart for entries and exits. Anyhow, this doesn’t matter too much as we can always load a version of the indicator on the chart as well.
Note: We can also remove the IF statement for setting the colors since there will be no plotting.
Apart from those two items, we can just copy and paste the rest of the indicator code into a new strategy script and extend it to include entry and exit conditions. The conditions are defined in the same way we did in: Tradingview: First Script
In the code above I am only taking the short side so I created a close condition rather than an opposite long condition.
On first inspection the results are incredible! A 100% win rate. However before I pat myself on the back it is worth noting that only 8 trades have been made. The data available does not go back far enough to test more. 8 trades is not enough data to build confidence in a strategy but as I mentioned before that is not the point of this post. I will be keeping an eye on this moving forward though.
And that is all there is too it. Go ahead and browse the Quandl site to see if you can find any interesting data that can give you an edge in the markets.
Find This Post Useful?
If this post saved you time and effort, please consider support the site! There are many ways to support us and some won’t even cost you a penny.