Quiver Quantitative

US Congress Trading

Introduction

The US Congress Trading dataset by Quiver Quantitative tracks US Equity trades made by members of Congress in the Senate and the House of Representatives. The data covers 1,800 US Equities, starts in January 2016, and is delivered on a daily frequency. This dataset is created by scraping SEC reports.

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 US Congress 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 US Congress Trading dataset:

from QuantConnect.DataSource import *

self.aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
self.dataset_symbol = self.add_data(QuiverCongress, self.aapl).symbol

self._universe = self.add_universe(QuiverQuantCongressUniverse, self.universe_selection)
using QuantConnect.DataSource;

_symbol = AddEquity("AAPL", Resolution.Daily).Symbol;
_datasetSymbol = AddData<QuiverCongress>(_symbol).Symbol;

_universe = AddUniverse<QuiverQuantCongresssUniverse>(UniverseSelection);

Data Summary

The following table describes the dataset properties:

PropertyValue
Start DateJanuary 2016
Asset Coverage1,800 US Equities
Data DensitySparse
ResolutionDaily
TimezoneUTC

Example Applications

The US Congress Trading dataset enables you to take immediate action on trades made by informed Members of Congress. Examples include the following strategies:

  • Following the trades of specific representatives on the premise that the representatives are more informed
  • Assigning a long/short-bias to securities on a daily frequency based on how Members of Congress are trading them

Data Point Attributes

The US Congress Trading dataset provides QuiverCongressDataPoint, QuiverCongress, and QuiverQuantCongressUniverseobjects.

QuiverCongressDataPoint Attributes

QuiverCongressDataPoint object has the following attributes:

QuiverCongress Attributes

QuiverCongress object has the following attributes:

QuiverQuantCongressUniverse Attributes

QuiverQuantCongressUniverse object has the following attributes:

Requesting Data

To add US Congress Trading data to your algorithm, call the AddDataadd_data method. Save a reference to the dataset Symbol so you can access the data later in your algorithm.

class QuiverCongressDataAlgorithm(QCAlgorithm):
    def initialize(self) -> None:
        self.set_start_date(2019, 1, 1)
        self.set_end_date(2020, 6, 1)
        self.set_cash(100000)

        self.aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
        self.dataset_symbol = self.add_data(QuiverCongress, self.aapl).symbol
namespace QuantConnect
{
    public class QuiverCongressDataAlgorithm : 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<QuiverCongress>(_symbol).Symbol;
        }
    }
}

Accessing Data

To get the current US Congress 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 on_data(self, slice: Slice) -> None:
    if slice.contains_key(self.dataset_symbol):
        data_points = slice[self.dataset_symbol]
        for data_point in data_points:
            self.log(f"{self.dataset_symbol} transaction amount at {slice.time}: {data_point.amount}")
public override void OnData(Slice slice)
{
    if (slice.ContainsKey(_datasetSymbol))
    {
        var dataPoints = slice[_datasetSymbol];
        foreach (var dataPoint in dataPoints)
        {
            Log($"{_datasetSymbol} transaction amount at {slice.Time}: {dataPoint.Amount}");
        }
    }
}

To iterate through all of the dataset objects in the current Slice, call the Getget method.

def on_data(self, slice: Slice) -> None:
    for dataset_symbol, data_point in slice.get(QuiverCongress).items():
        self.log(f"{dataset_symbol} transaction amount at {slice.time}: {data_point.amount}")
public override void OnData(Slice slice)
{
    foreach (var kvp in slice.Get<QuiverCongress>())
    {
        var datasetSymbol = kvp.Key;
        var dataPoint = kvp.Value;
        Log($"{datasetSymbol} transaction amount at {slice.Time}: {dataPoint.Amount}");
    }
}

Historical Data

To get historical US Congress Trading data, call the Historyhistory 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[QuiverCongress](self.dataset_symbol, 100, Resolution.DAILY)
var history = History<QuiverCongress>(_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 US Congress Trading data, call the AddUniverseadd_universe method with the QuiverQuantCongressUniverse class and a selection function.

def initialize(self) -> None:
    self._universe = self.add_universe(QuiverQuantCongressUniverse, self.universe_selection)

def universe_selection(self, alt_coarse: List[QuiverQuantCongresssUniverse]) -> List[Symbol]:
    return [d.symbol for d in alt_coarse \
        if d.amount > 200000 and d.transaction == OrderDirection.BUY]
private Universe _universe;
public override void Initialize()
{
    _universe = AddUniverse<QuiverQuantCongresssUniverse>(altCoarse =>
    {
        return from d in altCoarse.OfType<QuiverCongressDataPoint>()
            where d.Amount > 200000 && d.Transaction == OrderDirection.Buy 
            select d.Symbol;
    })
};

For more information about dynamic universes, see Universes.

Universe History

You can get historical universe data in an algorithm and in the Research Environment.

Historical Universe Data in Algorithms

To get historical universe data in an algorithm, call the Historyhistory method with the Universe object and the lookback period. If there is no data in the period you request, the history result is empty.

var universeHistory = History(_universe, 30, Resolution.Daily);
foreach (var trade in universeHistory.SelectMany(x => x).OfType<QuiverCongressDataPoint>())
{
    Log($"{trade.Symbol} amount at {trade.EndTime}: {trade.Amount} {trade.Representative}");
}
history = self.history(self._universe, 30, Resolution.DAILY)
for (univere_symbol, time), trades in universe_history.items():
    for trade in trades:
        self.log(f"{trade.symbol} amount at {trade.end_time}: {trade.amount} {trade.representative}") {trade.Representative}")

Historical Universe Data in Research

To get historical universe data in research, call the UniverseHistoryuniverse_history method with the Universe object, a start date, and an end date. This method returns the filtered universe. If there is no data in the period you request, the history result is empty.

var universeHistory = qb.UniverseHistory(universe, qb.Time.AddDays(-30), qb.Time);
foreach (var trade in universeHistory.SelectMany(x => x).OfType<QuiverCongressDataPoint>())
{
    Console.WriteLine($"{trade.Symbol} amount at {trade.EndTime}: {trade.Amount} {trade.Representative}");
}
universe_history = qb.universe_history(universe, qb.time-timedelta(30), qb.time)
for (univere_symbol, time), trades in universe_history.items():
    for trade in trades:
        print(f"{trade.symbol} amount at {trade.end_time}: {trade.amount} {trade.representative}")

You can call the Historyhistory method in Research.

Remove Subscriptions

To remove a subscription, call the RemoveSecurityremove_security method.

self.remove_security(self.dataset_symbol)
RemoveSecurity(_datasetSymbol);

If you subscribe to US Congress 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 US Congress Trading dataset enables you to take immediate action on trades made by informed Members of Congress. Examples include the following strategies:

  • Following the trades of specific representatives on the premise that the representatives are more informed
  • Assigning a long/short-bias to securities on a daily frequency based on how Members of Congress are trading them

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: