---
title: "Upcoming Dividends"
description: "Upcoming Dividends dataset from EOD Historical Data."
canonical: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/eod-historical-data/upcoming-dividends
markdown: https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/eod-historical-data/upcoming-dividends.md
language: python
source: https://github.com/QuantConnect/Documentation/tree/master/03%20Writing%20Algorithms/14%20Datasets/12%20EOD%20Historical%20Data/03%20Upcoming%20Dividends
modified: 2026-11-01
index: https://www.quantconnect.com/llms.txt
---

# Upcoming Dividends

[Documentation](https://www.quantconnect.com/docs/v2.md) > [Writing Algorithms](https://www.quantconnect.com/docs/v2/writing-algorithms.md) > Datasets > [EOD Historical Data](https://www.quantconnect.com/docs/v2/writing-algorithms/datasets/eod-historical-data.md) > Upcoming Dividends

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

## Introduction

The Upcoming Dividends dataset, provided by EODHD, offers daily alerts for US Equities that will have a dividend event within the upcoming 7 days. The data starts in January 2015 and is delivered on a daily frequency.

Compared to [US Equity Security Master](https://www.quantconnect.com/datasets/quantconnect-us-equity-security-master) as a benchmark, the Upcoming Dividends dataset has a 98.56% coverage of all dividend events, while having a 99.71% precision on the exact dividend dates of the covered ones and a 99.90% precision within +/- 3 days.

For more information about the Upcoming Dividends dataset, including CLI commands and pricing, see the [dataset listing](https://www.quantconnect.com/datasets/eodhd-upcoming-dividends).

## About the Provider

EOD Historical Data (EODHD) is a financial data provider based in France, and founded in April 2015. They focus on providing clean financial data, including stock prices, splits, dividends, fundamentals, macroeconomic indicators, technical indicators, and alternative data sources, through 24/7 API seamlessly. For more information about EODHD, visit [https://eodhd.com/](https://eodhd.com/).

## Getting Started

The following snippet demonstrates how to request data from the Upcoming Dividends dataset:

```python
self.add_data(EODHDUpcomingDividends, "dividends")
self.add_universe(EODHDUpcomingDividends, self.selection_function)
```

## Data Summary

The following table describes the dataset properties:

| Property | Value |
| --- | --- |
| Start Date | January 2015 |
| Data Density | Sparse |
| Resolution | Daily |
| Timezone | New York |

## Requesting Data

To add Upcoming Dividends data to your algorithm, call the `add_data` method.

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

        self._symbol = self.add_equity("AAPL", Resolution.DAILY).symbol
        self.dataset_symbol = self.add_data(EODHDUpcomingDividends, "dividends").symbol
```

## Accessing Data

To get the current Upcoming Dividends data, call the `get(EODHDUpcomingDividends)` method from the current [`Slice`](https://www.quantconnect.com/docs/v2/writing-algorithms/key-concepts/time-modeling/timeslices.md) and index the result with the security `Symbol`. `Slice` objects deliver unique events to your algorithm as they happen, but the `Slice` may not contain data for your security 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:
    upcomings_dividends = slice.get(EODHDUpcomingDividends)
    if upcomings_dividends and self._symbol in upcomings_dividends:
        upcomings_dividends_data_point = upcomings_dividends[self._symbol]
        self.log(f"{self._symbol} will pay dividend at {upcomings_dividends_data_point.dividend_date} with dividend per share of ${upcomings_dividends_data_point.dividend}")
```

You can also iterate through all of the dataset objects in the current `Slice`

```python
def on_data(self, slice: Slice) -> None:
    for equity_symbol, upcomings_dividends_data_point in slice.get(EODHDUpcomingDividends).items():
        self.log(f"{equity_symbol} will pay dividend at {upcomings_dividends_data_point.dividend_date} with dividend per share of ${upcomings_dividends_data_point.dividend}")
```

## Historical Data

To get historical Upcoming Dividends data, call the `history` method with the type `EODHDUpcomingDividends` cast and the period of request. If there is no data in the period you request, the history result is empty.

```python
history = self.history[EODHDUpcomingDividends](timedelta(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 the Upcoming Dividends dataset, call the `add_universe` method with a `EODHDUpcomingDividends` cast.

```python
def initialize(self) -> None:
    self._universe = self.add_universe(EODHDUpcomingDividends, self.universe_selection_filter)

def universe_selection_filter(self, dividends: List[EODHDUpcomingDividends]) -> List[Symbol]:
    return [d.symbol for d in dividends if d.dividend_date <= self.time + timedelta(1) and d.dividend > 0.05]
```

For more information about universe settings, see [Settings](https://www.quantconnect.com/docs/v2/writing-algorithms/universes/settings.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 EODHDUpcomingDividends attributes:
history_df = self.history(self._universe, 30, Resolution.DAILY, flatten=True)

# Series example where the values are lists of EODHDUpcomingDividends objects:
universe_history = self.history(self._universe, 30, Resolution.DAILY)
for (_, time), dividends in universe_history.items():
    for dividend in dividends:
        self.log(f"{dividend.symbol} dividend on {dividend.dividend_date}: {dividend.dividend}")
```

### Historical Universe Data in Research

To get historical universe data in research, call the `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 EODHDUpcomingDividends attributes:
history = qb.history(universe, qb.time-timedelta(30), qb.time, flatten=True)
```

## Remove Subscriptions

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

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

## Example Applications

The Upcoming Dividends dataset allows traders to trade the price change due to dividends. Examples include the following strategies:

- Short the stocks on dividend report day to earn the dividend discount on pricing.
- Avoid volatility on securities with upcoming dividends

### Classic Algorithm Example

The following example algorithm shorts each equity in equal size with an upcoming dividend by the next day. It selects stocks with dividend recording over $0.5 per share to capitalize on the price shock momentum due to dividend payment.

```python
from AlgorithmImports import *

class UpcomingDividendsExampleAlgorithm(QCAlgorithm):

    def initialize(self) -> None:
        self.set_start_date(2024, 9, 1)
        self.set_end_date(2024, 12, 31)
        self.set_cash(100000)
        # Seed the price of each asset with its last known price to avoid trading errors.
        self.settings.seed_initial_prices = True
        # Universe consists of equities with upcoming dividend events.
        self._universe = self.add_universe(EODHDUpcomingDividends, self.selection)
        # Add a Scheduled Event to rebalance the portfolio every morning based on upcoming dividend signals.
        spy = Symbol.create('SPY', SecurityType.EQUITY, Market.USA)
        self.schedule.on(
            self.date_rules.every_day(spy),
            self.time_rules.after_market_open(spy, 1),
            self._rebalance
        )

    def selection(self, dividends: List[EODHDUpcomingDividends]) -> List[Symbol]:
        # Select the stocks with upcoming dividend record date, with a sufficient dividend size.
        return [x.symbol for x in dividends if x.dividend_date < self.time + timedelta(1) and x.dividend > 0.5]

    def _rebalance(self) -> None:
        # Equally invest in each member of the universe.
        symbols = [s for s in self._universe.selected if self.securities[s].price]
        total_count = len(symbols)
        targets = [PortfolioTarget(symbol, -1 / total_count) for symbol in symbols]
        self.set_holdings(targets, True)
```

### Framework Algorithm Example

The following example implements a strategy of shorting each equity in equal size with an upcoming dividend by the next day using the framework. It selects stocks with dividend recording over $0.5 per share to capitalize on the price shock momentum due to dividend payment.

```python
from AlgorithmImports import *

class UpcomingDividendsExampleAlgorithm(QCAlgorithm):

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

        # Trade on a daily basis based on upcoming dividend signals daily.
        self.universe_settings.resolution = Resolution.DAILY
        # Universe consists of equities with upcoming dividend events.
        self._universe = self.add_universe(EODHDUpcomingDividends, self.selection)

        # A constant alpha model will emit insights for the stocks with dividend events in the upcoming day.
        # It is expecting a price shock due to pricing after the dividend, which might affect some momentum traders.
        self.add_alpha(ConstantAlphaModel(InsightType.PRICE, InsightDirection.DOWN, timedelta(1)))

        # Equal weighting for each signal to dissipate the capital risk evenly.
        self.set_portfolio_construction(EqualWeightingPortfolioConstructionModel(Expiry.END_OF_DAY))

    def selection(self, dividends: List[EODHDUpcomingDividends]) -> List[Symbol]:
        # Select the stocks with upcoming dividend record dates with a sufficient dividend size.
        return [x.symbol for x in dividends if x.dividend_date < self.time + timedelta(1) and x.dividend > 0.5]
```

## Data Point Attributes

The EODHD Upcoming Dividends dataset provides `EODHDUpcomingDividends` objects, which have the following attributes:

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