Quiver Quantitative
CNBC Trading
Introduction
The CNBC Trading dataset by Quiver Quantitative tracks the recommendations made by media personalities on CNBC and their historical performance. The data covers over 1,500 US Equities, starts in December 2020, and is delivered on a daily frequency. This dataset covers recommendations made on Mad Money, Halftime Report, and Fast Money.
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 CNBC 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 CNBC Trading dataset:
from QuantConnect.DataSource import * self.symbol = self.AddEquity("AAPL", Resolution.Daily).Symbol self.dataset_symbol = self.AddData(QuiverCNBCs, self.symbol).Symbol self.AddUniverse(QuiverCNBCsUniverse, "QuiverCNBCsUniverse", Resolution.Daily, self.UniverseSelectionFilter)
using QuantConnect.DataSource; _symbol = AddEquity("AAPL", Resolution.Daily).Symbol; _datasetSymbol = AddData<QuiverCNBCs>(_symbol).Symbol; AddUniverse<QuiverCNBCsUniverse>("QuiverCNBCsUniverse", Resolution.Daily, UniverseSelectionFilter);
Data Point Attributes
The Quiver Quantitative CNBC Trading dataset provides QuiverCNBCs, QuiverCNBC, and QuiverCNBCsUniverse objects.
QuiverCNBCs
QuiverCNBCs objects have the following attributes:
QuiverCNBC
QuiverCNBC objects have the following attributes:
QuiverCNBCsUniverse
QuiverCNBCsUniverse objects have the following attributes:
Requesting Data
To add CNBC 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 QuiverCNBCDataAlgorithm(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(QuiverCNBCs, self.symbol).Symbol
namespace QuantConnect.Algorithm.CSharp.AltData { public class QuiverCNBCDataAlgorithm: 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<QuiverCNBCs>(_symbol).Symbol; } } }
Accessing Data
To get the current CNBC 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} direction at {slice.Time}: {data_point.Direction}")
public override void OnData(Slice slice) { if (slice.ContainsKey(_datasetSymbol)) { var dataPoints = slice[_datasetSymbol]; foreach (var dataPoint in dataPoints) { Log($"{_datasetSymbol} direction at {slice.Time}: {dataPoint.Direction}"); } } }
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(QuiverCNBCs).items(): for data_point in data_points: self.Log(f"{dataset_symbol} direction at {slice.Time}: {data_point.Direction}")
public override void OnData(Slice slice) { foreach (var kvp in slice.Get<QuiverCNBCs>()) { var datasetSymbol = kvp.Key; var dataPoints = kvp.Value; foreach(var dataPoint in dataPoints) { Log($"{datasetSymbol} direction at {slice.Time}: {dataPoint.Direction}"); } } }
Historical Data
To get historical CNBC 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 history_bars = self.History[QuiverCNBCs](self.dataset_symbol, 100, Resolution.Daily)
var history = History<QuiverCNBCs>(_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 CNBC Trading data, call the AddUniverse method with the QuiverCNBCsUniverse class and a selection function.
self.AddUniverse(QuiverCNBCsUniverse, "QuiverCNBCsUniverse", Resolution.Daily, self.UniverseSelection) def UniverseSelection(self, alt_coarse: List[QuiverCNBCsUniverse]) -> List[Symbol]: cnbc_data_by_symbol = {} for datum in alt_coarse: symbol = datum.Symbol if symbol not in cnbc_data_by_symbol: cnbc_data_by_symbol[symbol] = [] cnbc_data_by_symbol[symbol].append(datum) # define our selection criteria return [symbol for symbol, d in cnbc_data_by_symbol.items() if len([x for x in d if x.Direction == OrderDirection.Buy]) >= 3]
AddUniverse<QuiverCNBCsUniverse>("QuiverCNBCsUniverse", Resolution.Daily, altCoarse => { var cnbcDataBySymbol = new Dictionary<Symbol, List<QuiverCNBCsUniverse>>(); foreach (var datum in altCoarse) { var symbol = datum.Symbol; if (!cnbcDataBySymbol.ContainsKey(symbol)) { cnbcDataBySymbol.Add(symbol, new List<QuiverCNBCsUniverse>()); } cnbcDataBySymbol[symbol].Add(datum); } // define our selection criteria return from kvp in cnbcDataBySymbol 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 CNBC 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 CNBC Trading dataset enables you to create strategies using the latest recommendations made by media personalities on CNBC. Examples include the following strategies:
- Taking short positions in securities that were mentioned by Jim Cramer (CNBC commentator) in the last week
- Trading securities that were most/least discussed across CNBC programs over the last year