Hi All-
I found this great discussion around short interest data. I am also in need of this data. However, it appears with the Quandl merger into NASDAQ (now apart of or renamed to the Data Link dataset??) that data has disappeared. When I run a backtest from this discussion it errors out, presumably because it can't find the Quandl dataset anymore.
Can anyone advise me on how I can get short interest data?
Below is the backtest which will display an error saying it can't find the Quandl dataset.
#region imports
from AlgorithmImports import *
#endregion
class NadionParticleThrustAssembly(QCAlgorithm):
def Initialize(self):
self.SetStartDate(2022, 8, 1) # Set Start Date
self.SetCash(100000) # Set Strategy Cash
self.AddUniverse(self.MyCoarseFilterFunction)
self.quandl_symbol_by_symbol = {}
def MyCoarseFilterFunction(self, coarse):
# Sort by dollar volume
top_dollar_volume = sorted(coarse, key=lambda x: x.DollarVolume, reverse=True)[:50]
top_dollar_volume = [x.Symbol for x in top_dollar_volume]
# Subscribe to Quandl datafeed for most liquid symbols
for symbol in top_dollar_volume:
if symbol in self.quandl_symbol_by_symbol:
continue
self.quandl_symbol_by_symbol[symbol] = self.AddData(QuandlFINRAData, f'FINRA/FNSQ_{symbol.Value}', Resolution.Daily).Symbol
# Gather short volume of the most liquid symbols
short_volume_by_symbol = {}
symbols_to_remove = []
for symbol, quandl_symbol in self.quandl_symbol_by_symbol.items():
if symbol in top_dollar_volume:
history = self.History(quandl_symbol, 1)
if history.empty or 'shortvolume' not in history.columns:
continue
short_volume_by_symbol[symbol] = history.loc[quandl_symbol].iloc[0]['shortvolume']
else:
# Remove Quandl data feed
symbols_to_remove.append(symbol)
self.RemoveSecurity(quandl_symbol)
# Remove symbols from the dictionary that don't have an active quandl subscription
for symbol in symbols_to_remove:
self.quandl_symbol_by_symbol.pop(symbol, None)
# Return symbols with highest short volume
sorted_by_short_volume = sorted(short_volume_by_symbol.items(), key=lambda x: x[1], reverse=True)
self.symbols = [symbol for symbol, _ in sorted_by_short_volume[:5]]
return self.symbols
def OnData(self, data):
## Access the value of the Quandl data using the standard accessor
for symbol in self.symbols:
quandl_symbol = self.quandl_symbol_by_symbol[symbol]
if data.ContainsKey(quandl_symbol) and data[quandl_symbol] is not None:
self.Log(f"Short interest of {str(symbol)}: {data[quandl_symbol].Value}")
class QuandlFINRAData(PythonQuandl):
def __init__(self):
## Rename the Quandl object column to the data we want, which is the 'ShortVolume' column
## of the CSV that our API call returns
self.ValueColumnName = 'ShortVolume'
Justin E
Or if there's a proxy measure for short interest data, that works too. Any idea if/when the Quandl dataset is coming back?
Nico Xenox
Hey Justin E,
the problem is that “BRK.A and BRK.B” should be BRK/A and BRK/B and they do not have the same providers as FNSQ. So putting them into a list that shouldn't be included works fine.
Hope it helps ;)
Justin E
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!