Quiver Quantitative
Insider Trading
Introduction
Corporate insiders are required to disclose purchases or sales of their own stock within two business days of when they occur. Using these disclosures, we collect data on insider trading activity, which can give hints on whether executives are bullish or bearish on their own companies. Here is a blog that we did on this dataset: https://www.quiverquant.com/blog/081121
This dataset depends on the US Equity Security Master dataset because the US Equity Security Master dataset contains information on splits, dividends, and symbol changes.
For more information about the Insider Trading dataset, including CLI commands and pricing, see the dataset listing.
About the Provider
Quiver Quantitative was founded by two college students in February 2020 with the goal of bridging the information gap between Wall Street and non-professional investors. Quiver allows retail investors to tap into the power of big data and have access to actionable, easy to interpret data that hasn’t already been dissected by Wall Street.
Getting Started
The following snippet demonstrates how to request data from the Insider Trading dataset:
from QuantConnect.DataSource import * aapl = self.AddEquity("AAPL", Resolution.Daily).Symbol self.quiver_insider_trading_symbol = self.AddData(QuiverInsiderTradings, aapl).Symbol self.AddUniverse(QuiverInsiderTradingUniverse, "QuiverInsiderTradingUniverse", Resolution.Daily, self.UniverseSelection)
using QuantConnect.DataSource; var aapl = AddEquity("AAPL", Resolution.Daily).Symbol; var quiverInsiderTradingSymbol = AddData<QuiverInsiderTradings>(aapl).Symbol; AddUniverse<QuiverInsiderTradingUniverse>("QuiverInsiderTradingUniverse", Resolution.Daily, UniverseSelectionFilter);
Data Point Attributes
The Insider Trading dataset provides QuiverInsiderTrading objects encapsulated in a QuiverInsiderTradings object, and QuiverInsiderTradingUniverse object.
QuiverInsiderTradings
QuiverInsiderTradings objects have the following attributes:
QuiverInsiderTrading
QuiverInsiderTrading objects have the following attributes:
QuiverInsiderTradingUniverse
QuiverInsiderTradingUniverse objects have the following attributes:
Requesting Data
To add Insider Trading data to your algorithm, call the AddData method. Save a reference to the dataset Symbol so you can access the data later in your algorithm.
class QuiverInsiderTradingDataAlgorithm(QCAlgorithm): def Initialize(self) -> None: self.SetStartDate(2019, 1, 1) self.SetEndDate(2020, 6, 1) self.SetCash(100000) self.symbol = self.AddEquity("AAPL", Resolution.Daily).Symbol self.dataset_symbol = self.AddData(QuiverInsiderTradings, self.symbol).Symbol
namespace QuantConnect.Algorithm.CSharp.AltData { public class QuiverInsiderTradingDataAlgorithm: QCAlgorithm { private Symbol _symbol, _datasetSymbol; public override void Initialize() { SetStartDate(2019, 1, 1); SetEndDate(2020, 6, 1); SetCash(100000); _symbol = AddEquity("AAPL", Resolution.Daily).Symbol; _datasetSymbol= AddData<QuiverInsiderTradings>(_symbol).Symbol; } } }
Accessing Data
To get the current Insider Trading data, index the current Slice with the dataset Symbol. Slice objects deliver unique events to your algorithm as they happen, but the Slice may not contain data for your dataset at every time step. To avoid issues, check if the Slice contains the data you want before you index it.
def OnData(self, slice: Slice) -> None: if slice.ContainsKey(self.dataset_symbol): data_points = slice[self.dataset_symbol] for data_point in data_points: self.Log(f"{self.dataset_symbol} shares at {slice.Time}: {data_point.Shares}")
public override void OnData(Slice slice) { if (slice.ContainsKey(_datasetSymbol)) { var dataPoints = slice[_datasetSymbol]; foreach (QuiverInsiderTrading dataPoint in dataPoints) { Log($"{_datasetSymbol} shares at {slice.Time}: {dataPoint.Shares}"); } } }
To iterate through all of the dataset objects in the current Slice, call the Get method.
def OnData(self, slice: Slice) -> None: for dataset_symbol, data_points in slice.Get(QuiverInsiderTradings).items(): for data_point in data_points: self.Log(f"{dataset_symbol} shares at {slice.Time}: {data_point.Shares}")
public override void OnData(Slice slice) { foreach (var kvp in slice.Get<QuiverInsiderTradings>()) { var datasetSymbol = kvp.Key; var dataPoints = kvp.Value; foreach(QuiverInsiderTrading dataPoint in dataPoints) { Log($"{datasetSymbol} shares at {slice.Time}: {dataPoint.Shares}"); } } }
Historical Data
To get historical Insider Trading data, call the History method with the dataset Symbol. If there is no data in the period you request, the history result is empty.
# DataFrame history_df = self.History(self.dataset_symbol, 100, Resolution.Daily) # Dataset objects self.History[QuiverInsiderTradings](self.dataset_symbol, 100, Resolution.Daily)
var history = History<QuiverInsiderTradings>(_datasetSymbol, 100, Resolution.Daily);
For more information about historical data, see History Requests.
Universe Selection
To select a dynamic universe of US Equities based on Insider Trading data, call the AddUniverse method with the QuiverInsiderTradingUniverse class and a selection function.
self.AddUniverse(QuiverInsiderTradingUniverse, "QuiverInsiderTradingUniverse", Resolution.Daily, self.UniverseSelection) def UniverseSelection(self, alt_coarse: List[QuiverInsiderTradingUniverse]) -> List[Symbol]: insider_trading_data_by_symbol = {} for datum in alt_coarse: symbol = datum.Symbol if symbol not in insider_trading_data_by_symbol: insider_trading_data_by_symbol[symbol] = [] insider_trading_data_by_symbol[symbol].append(datum) return [symbol for symbol, d in insider_trading_data_by_symbol.items() if len([x for x in d if x.Direction == OrderDirection.Buy]) >= 3]
AddUniverse<QuiverInsiderTradingUniverse>("QuiverInsiderTradingUniverse", Resolution.Daily, altCoarse => { var insiderTradingDataBySymbol = new Dictionary<Symbol, List<QuiverInsiderTradingUniverse>>(); foreach (var datum in altCoarse) { var symbol = datum.Symbol; if (!insiderTradingDataBySymbol.ContainsKey(symbol)) { insiderTradingDataBySymbol.Add(symbol, new List<QuiverInsiderTradingUniverse>()); } insiderTradingDataBySymbol[symbol].Add(datum); } return from kvp in insiderTradingDataBySymbol where kvp.Value.Where(x => x.Direction == OrderDirection.Buy) >= 3 select kvp.Key; });
Remove Subscriptions
To remove a subscription, call the RemoveSecurity method.
self.RemoveSecurity(self.dataset_symbol)
RemoveSecurity(_datasetSymbol);
If you subscribe to Insider Trading data for assets in a dynamic universe, remove the dataset subscription when the asset leaves your universe. To view a common design pattern, see Track Security Changes.
Example Applications
The Quiver Quantitative Insider Trading dataset enables researchers to create strategies using the latest information on insider trading activity. Examples include:
- Taking a short position in securities that have had the most insider selling over the last 5 days
- Buying any security that has had over $100,000 worth of shares purchased by insiders in the last month