---
title: "Corporate Buybacks"
description: "Corporate Buybacks dataset from Smart Insider."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/smart-insider/corporate-buybacks
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/smart-insider/corporate-buybacks.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/26%20Smart%20Insider/01%20Corporate%20Buybacks
modified: 2026-11-01
index: https://www.quantconnect.com/llms.txt
---

# Corporate Buybacks

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [Smart Insider](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/smart-insider.md) > Corporate Buybacks

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

## Introduction

The Corporate Buybacks dataset by Smart Insider tracks US Equities share buyback programs. The data covers 3,000 US Equities, starts in May 2015, and is delivered on a second frequency. This dataset is created by analyzing daily buyback announcements and by using secondary data sources to ensure records are accurate and complete.

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 Corporate Buybacks dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/smart-insider-corporate-buybacks).

## About the Provider

[Smart Insider](https://www.smartinsider.com/) was founded by Michael Tindale in 2016 with the goal of forming the most progressive insider data vendor in the field. Smart Insider provides access to buyback intention and transactions for quantitative researchers. In addition to their Corporate Buybacks dataset, Smart Insider provides data on stock trades made by US politicians and thousands of high net worth individuals around the globe.

## Getting Started

The following snippet demonstrates how to request data from the Corporate Buybacks dataset:

```python
self.aapl = self.add_equity("AAPL", Resolution.MINUTE).symbol
self.intention_symbol = self.add_data(SmartInsiderIntention, self.aapl).symbol
self.transaction_symbol = self.add_data(SmartInsiderTransaction, self.aapl).symbol

self.intention_universe = self.add_universe(SmartInsiderIntentionUniverse, self.intention_selection)
self.transaction_universe = self.add_universe(SmartInsiderTransactionUniverse, self.transaction_selection)
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | May 2015 |
| Asset Coverage | 3,000 US Equities |
| Data Density | Sparse |
| Resolution | Second |
| Timezone | New York |

## Requesting Data

To add Corporate Buybacks 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 CorporateBuybacksDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2016, 1, 1)
        self.set_end_date(2021, 1, 1)
        self.set_cash(100000)

        self.aapl = self.add_equity("AAPL", Resolution.MINUTE).symbol
        self.intention_symbol = self.add_data(SmartInsiderIntention, self.aapl).symbol
        self.transaction_symbol = self.add_data(SmartInsiderTransaction, self.aapl).symbol
```

## Accessing Data

To get the current Corporate Buybacks 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.intention_symbol):
        data_point = slice[self.intention_symbol]
        self.log(f"{self.intention_symbol} intention amount at {slice.time}: {data_point.amount}")

    if slice.contains_key(self.transaction_symbol):
        data_point = slice[self.transaction_symbol]
        self.log(f"{self.transaction_symbol} transaction amount at {slice.time}: {data_point.amount}")
```

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_point in slice.get(SmartInsiderIntention).items():
        self.log(f"{dataset_symbol} intention amount at {slice.time}: {data_point.amount}")

    for dataset_symbol, data_point in slice.get(SmartInsiderTransaction).items():
        self.log(f"{dataset_symbol} transaction amount at {slice.time}: {data_point.amount}")
```

## Historical Data

To get historical Corporate Buybacks 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
# DataFrames
intention_history_df = self.history(self.intention_symbol, 100, Resolution.DAILY)
transaction_history_df = self.history(self.transaction_symbol, 100, Resolution.DAILY)
history_df = self.history([self.intention_symbol, self.transaction_symbol], 100, Resolution.DAILY)

# Dataset objects
intention_history_bars = self.history[SmartInsiderIntention](self.intention_symbol, 100, Resolution.DAILY)
transaction_history_bars = self.history[SmartInsiderTransaction](self.transaction_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 Corporate Buybacks data, call the `add_universe` method with the `SmartInsiderIntentionUniverse` class or the `SmartInsiderTransactionUniverse` and a selection function.

```python
def initialize(self) -> None:
    self.intention_universe = self.add_universe(SmartInsiderIntentionUniverse, self.intention_selection)
    self.transaction_universe = self.add_universe(SmartInsiderTransactionUniverse, self.transaction_selection)

def intention_selection(self, alt_coarse: List[SmartInsiderIntentionUniverse]) -> List[Symbol]:
    return [d.symbol for d in alt_coarse \
                if d.percentage > 0.005 \
                and d.usd_market_cap > 100000000]

def transaction_selection(self, alt_coarse: List[SmartInsiderTransactionUniverse]) -> List[Symbol]:
    return [d.symbol for d in alt_coarse \
                if d.buyback_percentage > 0.005 \
                and d.usd_market_cap > 100000000]
```

For more information about dynamic universes, see [Universes](https://www.quantconnect.com/docs/v2/writing-algorithms/universes/key-concepts.md).

## 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 SmartInsiderIntentionUniverse attributes:
intention_history_df = self.history(self._universe, 30, Resolution.DAILY, flatten=True)

# Series example where the values are lists of SmartInsiderIntentionUniverse objects:
intention_universe_history = self.history(self.intention_universe, 30, Resolution.DAILY)
for (_, time), intentions in intention_universe_history.items():
    for intention in intentions:
        self.log(f"{intention.symbol.value} amount value at {intention.end_time}: {intention.amount_value}")

# DataFrame example where the columns are the SmartInsiderTransactionUniverse attributes:
transaction_history_df = self.history(self._universe, 30, Resolution.DAILY, flatten=True)

# Series example where the values are lists of SmartInsiderTransactionUniverse objects:
transaction_universe_history = self.history(self.transaction_universe, 30, Resolution.DAILY)
for (_, time), transactions in transaction_universe_history.items():
    for transaction in transactions:
        self.log(f"{transaction.symbol.value} amount at {intention.end_time}: {intention.amount}")
```

### 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 SmartInsiderIntentionUniverse attributes:
intention_history_df = qb.universe_history(universe, qb.time-timedelta(30), qb.time, flatten=True)

# Series example where the values are lists of SmartInsiderIntentionUniverse objects:
intention_universe_history = qb.universe_history(intention_universe, qb.time-timedelta(30), qb.time)
for (_, time), intentions in intention_universe_history.items():
    for intention in intentions:
        print(f"{intention.symbol.value} amount value at {intention.end_time}: {intention.amount_value}")

# DataFrame example where the columns are the SmartInsiderTransactionUniverse attributes:
transaction_history_df = qb.universe_history(universe, qb.time-timedelta(30), qb.time, flatten=True)

# Series example where the values are lists of SmartInsiderTransactionUniverse objects:
transaction_universe_history = qb.universe_history(transaction_universe, qb.time-timedelta(30), qb.time)
for (_, time), transactions in transaction_universe_history.items():
    for transaction in transactions:
        print(f"{transaction.symbol.value} amount at {transaction.end_time}: {transaction.amount}")
```

You can call the `history` method in Research.

## Remove Subscriptions

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

```python
self.remove_security(self.intention_symbol)
self.remove_security(self.transaction_symbol)
```

If you subscribe to Corporate Buybacks 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 Corporate Buybacks dataset enables you to design strategies using information on company buyback programs. Examples include the following strategies:

- Buying securities when the company announces an upcoming share buyback on the premise that the reduction in supply (shares outstanding) will drive up the remaining shares' price
- Buying securities when the company executes an upcoming share buyback on the premise that the reduction in supply (shares outstanding) will drive up the remaining shares' price

### Classic Algorithm Example

The following example algorithm buys Apple stock when there is a buyback intention or transaction and then it sells the stock 3 days later:

```python
from AlgorithmImports import *

class CorporateBuybacksDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)
        self._equity = self.add_equity("AAPL", Resolution.DAILY)
        # Request insider trade intention news and actual trades because insiders may have better information about future prospects.
        self._smart_insider_intention_data = self.add_data(SmartInsiderIntention, self._equity).symbol
        self._smart_insider_transaction_data = self.add_data(SmartInsiderTransaction, self._equity).symbol
        # Warm up custom data subscriptions with historical data.
        history = self.history(self._smart_insider_intention_data, 252, Resolution.DAILY)
        self.debug(f"We got {len(history)} items from our history request for intentions")
        history = self.history(self._smart_insider_transaction_data, 252, Resolution.DAILY)
        self.debug(f"We got {len(history)} items from our history request for transactions")

    def on_data(self, data: Slice) -> None:
        # Buy Apple when insider buyback events suggest stronger sentiment and potential market attention.
        if self._smart_insider_intention_data in data or self._smart_insider_transaction_data in data:
            self.set_holdings(self._equity, 1)
            self._entry_time = self.time
        # Liquidate after three days so the position exits once the event reaction has cooled.
        if self.portfolio.invested and self.time >= self._entry_time + timedelta(days=3):
            self.liquidate()
```

### Framework Algorithm Example

The following example algorithm buys Apple stock when there is a buyback intention or transaction and then it sells the stock 3 days later:

```python
from AlgorithmImports import *

class CorporateBuybacksDataAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)

        # Only interest in AAPL's insider trades information
        symbols = [Symbol.create("AAPL", SecurityType.EQUITY, Market.USA)]
        self.add_universe_selection(ManualUniverseSelectionModel(symbols))
        self.add_alpha(CorporateBuybacksAlphaModel())
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel())

class CorporateBuybacksAlphaModel(AlphaModel):

    def update(self, algorithm: QCAlgorithm, slice: Slice) -> List[Insight]:
        # Buy Apple whenever we receive a buyback intention or transaction notification, given the insiders may have confidence in the future to buy more
        # This news may stimulate market popularity, so we hold for 3 days
        if slice.contains_key(self.smart_insider_intention) or slice.contains_key(self.smart_insider_transaction):
            return [Insight.price(self.aapl, timedelta(days=3), InsightDirection.UP)]
        return []

    def on_securities_changed(self, algorithm: QCAlgorithm, changes: SecurityChanges) -> None:
        for security in changes.added_securities:
            self.aapl = security.symbol

            # Requesting insider trade intention news and actual trades to estimate the return, since insiders may have better information of the future confidence
            self.smart_insider_intention = algorithm.add_data(SmartInsiderIntention, self.aapl).symbol
            self.smart_insider_transaction = algorithm.add_data(SmartInsiderTransaction, self.aapl).symbol

            # Historical data
            history = algorithm.history(self.smart_insider_intention, 252, Resolution.DAILY)
            algorithm.debug(f"We got {len(history)} items from our history request for intentions")

            history = algorithm.history(self.smart_insider_transaction, 252, Resolution.DAILY)
            algorithm.debug(f"We got {len(history)} items from our history request for transactions")
```

### Research Example

The following example lists US Equities with the highest buyback amount.

```python
from math import isnan
qb = QuantBook()

# Requesting Data
symbol = qb.add_equity("AAPL").symbol
intention_symbol = qb.add_data(SmartInsiderIntention, symbol).symbol
transaction_symbol = qb.add_data(SmartInsiderTransaction, symbol).symbol

# Historical data
intention_history = qb.history(SmartInsiderIntention, intention_symbol, 300, Resolution.DAILY)
for (symbol, time), row in intention_history.iterrows():
    if isnan(row['amountvalue']): continue
    print(f"{symbol} amount value at {time}: {row['amountvalue']}")

transaction_history = qb.history(SmartInsiderTransaction, transaction_symbol, 300, Resolution.DAILY)
for (symbol, time), row in transaction_history.iterrows():
    if isnan(row['amount']): continue
    print(f"{symbol} amount at {time}: {row['amount']}")

# Add Universe Selection for SmartInsiderIntention
def intention_selection(alt_coarse: List[SmartInsiderIntentionUniverse]) -> List[Symbol]:
    return [d.symbol for d in sorted([x for x in alt_coarse if x.amount_value],
        key=lambda x: x.amount_value, reverse=True)[:10]]

intention_universe  = qb.add_universe(SmartInsiderIntentionUniverse, intention_selection)

# Historical Universe data
intention_universe_history = qb.universe_history(intention_universe, qb.time-timedelta(10), qb.time)
for (_, time), intentions in intention_universe_history.items():
    for intention in intentions:
        print(f"{intention.symbol.value} amount value at {intention.end_time}: {intention.amount_value}")

# Add Universe Selection for SmartInsiderTransaction
def intention_selection(alt_coarse: List[SmartInsiderTransactionUniverse]) -> List[Symbol]:
    return [d.symbol for d in sorted([x for x in alt_coarse if x.amount],
        key=lambda x: x.amount, reverse=True)[:10]]

transaction_universe  = qb.add_universe(SmartInsiderTransactionUniverse, intention_selection)

# Historical Universe data
transaction_universe_history = qb.universe_history(transaction_universe, qb.time-timedelta(10), qb.time)
for (_, time), transactions in transaction_universe_history.items():
    for transaction in transactions:
        print(f"{transaction.symbol.value} amount at {transaction.end_time}: {transaction.amount}")
```

## Data Point Attributes

The Corporate Buybacks dataset provides `SmartInsiderIntention`, `SmartInsiderIntentionUniverse`, `SmartInsiderTransaction`, and `SmartInsiderTransactionUniverse` objects.

### SmartInsiderIntention Attributes

`SmartInsiderIntention` objects have the following attributes:

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

### SmartInsiderIntentionUniverse Attributes

`SmartInsiderIntentionUniverse` objects have the following attributes:

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

### SmartInsiderTransaction Attributes

`SmartInsiderTransaction` objects have the following attributes:

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

### SmartInsiderTransactionUniverse Attributes

`SmartInsiderTransactionUniverse` objects have the following attributes:

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