---
title: "Insider Trading"
description: "Insider Trading dataset from Quiver Quantitative."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quiver-quantitative/insider-trading
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quiver-quantitative/insider-trading.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/23%20Quiver%20Quantitative/03%20Insider%20Trading
modified: 2026-10-30
index: https://www.quantconnect.com/llms.txt
---

# Insider Trading

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [Quiver Quantitative](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/quiver-quantitative.md) > Insider Trading

> Code examples are shown in Python. Append `?lang=csharp` to this URL for the C# version of this page.

## 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](https://www.quantconnect.com/datasets/quantconnect-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](https://www.quantconnect.com/datasets/quiver-quantitative-insider-trading).

## About the Provider

[Quiver Quantitative](https://www.quiverquant.com/) 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:

```python
self.aapl = self.add_equity("AAPL", Resolution.DAILY).symbol
self.dataset_symbol = self.add_data(QuiverInsiderTrading, aapl).symbol
self._universe = self.add_universe(QuiverInsiderTradingUniverse, self.universe_selection)
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | April 25 2014* |
| Asset Coverage | 4994 US Equities |
| Data Density | Sparse |
| Resolution | Daily |
| Timezone | UTC |

Before May 14 2021, this dataset included legacy data without all the information. Only the following are valid: price_per_share, shares, and shares_owned_following.

## Requesting Data

To add Insider Trading data to your algorithm, call the `add_data` method. Save a reference to the dataset `Symbol` so you can access the data later in your algorithm.

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

        symbol = self.add_equity("AAPL", Resolution.DAILY).symbol
        self.dataset_symbol = self.add_data(QuiverInsiderTrading, symbol).symbol
```

## Accessing Data

To get the current Insider Trading data, index the current [`Slice`](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md) 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.

```python
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} shares at {slice.time}: {data_point.shares}")
```

Note that `data_points` is a list of `QuiverInsiderTrading` object since we can have several trades per symbol in a day. You need to iterate `data_points` to access the data.

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

```python
def on_data(self, slice: Slice) -> None:
    for dataset_symbol, data_points in slice.get(QuiverInsiderTrading).items():
        for data_point in data_points:
            self.log(f"{dataset_symbol} shares at {slice.time}: {data_point.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.

```python
# DataFrame
history_df = self.history(self.dataset_symbol, 100, Resolution.DAILY)

# Dataset objects
self.history[QuiverInsiderTrading](self.dataset_symbol, 100, Resolution.DAILY)
```

For more information about historical data, see [History Requests](https://www.quantconnect.com/docs/v2/writing-algorithms/historical-data/history-requests.md).

## Universe Selection

To select a dynamic universe of US Equities based on Insider Trading data, call the `add_universe` method with the `QuiverInsiderTradingUniverse` class and a selection function.

```python
class InsiderTradingUniverseAlgorithm(QCAlgorithm):

    def initialize(self):
        self.set_start_date(2023, 1, 1)
        self._universe = self.add_universe(QuiverInsiderTradingUniverse, self._select_assets)

    def _select_assets(self, alt_coarse: List[QuiverInsiderTradingUniverse]) -> List[Symbol]:
        dollar_volume_by_symbol = {}
        for data in alt_coarse:
            symbol = data.symbol
            if not data.price_per_share:
                continue
            if symbol not in dollar_volume_by_symbol:
                dollar_volume_by_symbol[symbol] = 0
            dollar_volume_by_symbol[symbol] += (data.shares or 0) * data.price_per_share
        return [
            symbol for symbol, _ in sorted(dollar_volume_by_symbol.items(), key=lambda kvp: kvp[1])[-10:]
        ]
```

## 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 `history` method with the `Universe` object and the lookback period. If there is no data in the period you request, the history result is empty.

```python
# DataFrame example where the columns are the QuiverInsiderTradingUniverse attributes:
history_df = self.history(self._universe, 30, Resolution.DAILY, flatten=True)

# Series example where the values are lists of QuiverInsiderTradingUniverse objects:
universe_history = self.history(self._universe, 30, Resolution.DAILY)
for (_, time), insiders in universe_history.items():
    for insider in insiders:
        if insider.price_per_share:
            self.log(f"{insider.symbol} volume at {insider.end_time}: {insider.shares * insider.price_per_share}")
```

### Historical Universe Data in Research

To get historical universe data in research, call the `universe_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.

```python
# DataFrame example where the columns are the QuiverInsiderTradingUniverse attributes:
history_df = qb.universe_history(universe, qb.time-timedelta(30), qb.time, flatten=True)

# Series example where the values are lists of QuiverInsiderTradingUniverse objects:
universe_history = qb.universe_history(universe, qb.time-timedelta(30), qb.time)
for (_, time), insiders in universe_history.items():
    for insider in insiders:
        if insider.price_per_share:
            print(f"{insider.symbol} volume at {insider.end_time}: {insider.shares * insider.price_per_share}")
```

You can call the `history` method in Research.

## Remove Subscriptions

To remove a subscription, call the `remove_security` method.

```python
self.remove_security(self.dataset_symbol)
```

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](https://www.quantconnect.com/docs/v2/writing-algorithms/algorithm-framework/alpha/key-concepts.md#05-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

### Classic Algorithm Example

In this example, we would 100% long AAPL if there was any insider buying event. Otherwise, we liquidate it.

```python
from AlgorithmImports import *

class QuiverInsiderTradingAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self._equity = self.add_equity("AAPL", Resolution.DAILY)
        # Subscribe to insider trade data for AAPL to generate trade signals.
        self._dataset_symbol = self.add_data(QuiverInsiderTrading, self._equity).symbol
        # Warm up the custom data subscription with recent history.
        history = self.history(self._dataset_symbol, 10, Resolution.DAILY)
        self.debug(f"We got {len(history)} items from historical data request of {self._dataset_symbol}.")

    def on_data(self, data: Slice) -> None:
        # Trade only from insider trade data.
        for insider_trades in data.get(QuiverInsiderTrading).values():
            for insider_trade in insider_trades:
                # Buy when insiders purchase shares because it may signal confidence in future prices.
                if insider_trade.shares > 0:
                    self.set_holdings(self._equity, 1)
                # Liquidate when insiders sell shares because it may signal weaker future confidence.
                else:
                    self.liquidate(self._equity)
```

### Framework Algorithm Example

In this example, we long a equal-sized portfolio with equities that having insider trading for over $100000 USD in the previous day.

```python
from AlgorithmImports import *

class QuiverInsiderTradingDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)
        # To hold the insider trade dataset symbol for managing subscription
        self.data_symbols = {}

        # Filter universe using insider trade data
        self.add_universe(QuiverInsiderTradingUniverse, self.universe_selection)

        self.add_alpha(ConstantAlphaModel(InsightType.PRICE, InsightDirection.UP, timedelta(1)))

        # Invest equally to evenly dissipate the capital concentration risk
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())

    def universe_selection(self, data: List[QuiverInsiderTradingUniverse]) -> List[Symbol]:
        symbol_data = {}

        for datum in data:
            symbol = datum.symbol

            if symbol not in symbol_data:
                symbol_data[symbol] = []
            symbol_data[symbol].append(datum)

        # Select the ones with insider trading dollar amount above 100k, assuming insider have confidence in stock price with more informed information and projection
        return [symbol for symbol, d in symbol_data.items()
                if sum([x.shares * x.price_per_share for x in d if x.shares and x.price_per_share]) >= 100000]

    def on_securities_changed(self, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            # Requesting insider trade data for trading
            symbol = security.symbol
            dataset_symbol = self.add_data(QuiverInsiderTrading, symbol).symbol
            self.data_symbols[symbol] = dataset_symbol
            # Historical Data
            history = self.history(dataset_symbol, 10, Resolution.DAILY)

        for security in changes.removed_securities:
            dataset_symbol = self.data_symbols.pop(security.symbol, None)
            if dataset_symbol:
                # Remove insider trade data subscription to release computation resources
                self.remove_security(dataset_symbol)
```

### Research Example

The following example lists US Equities having insider trading for over $10,000,000.

```python
qb = QuantBook()

# Requesting Data
aapl = qb.add_equity("AAPL", Resolution.DAILY).symbol
symbol = qb.add_data(QuiverInsiderTrading, aapl).symbol

# Historical data
history = qb.history(QuiverInsiderTrading, symbol, 60, Resolution.DAILY)
for (symbol, time), insiders in history.items():
    for insider in insiders:
        print(f"{insider.symbol} shares at {insider.end_time}: {insider.shares}")

# Add Universe Selection
def universe_selection(alt_coarse: List[QuiverInsiderTradingUniverse]) -> List[Symbol]:
    return [d.symbol for d in alt_coarse if d.price_per_share and d.shares * d.price_per_share >= 10000000]

universe = qb.add_universe(QuiverInsiderTradingUniverse, universe_selection)

# Historical Universe data
universe_history = qb.universe_history(universe, qb.time-timedelta(5), qb.time)
for (_, time), insiders in universe_history.items():
    for insider in insiders:
        if insider.price_per_share:
            print(f"{insider.symbol} volume at {insider.end_time}: {insider.shares * insider.price_per_share}")
```

## Data Point Attributes

The Insider Trading dataset provides `QuiverInsiderTrading` and `QuiverInsiderTradingUniverse` object.

### QuiverInsiderTrading

`QuiverInsiderTrading` objects have the following attributes:

*Members of `QuantConnect.DataSource.QuiverInsiderTrading` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.DataSource.QuiverInsiderTrading&language=python*

### QuiverInsiderTradingUniverse

`QuiverInsiderTradingUniverse` objects have the following attributes:

*Members of `QuantConnect.DataSource.QuiverInsiderTradingUniverse` (JSON): https://www.quantconnect.com/services/inspector?type=T:QuantConnect.DataSource.QuiverInsiderTradingUniverse&language=python*
