EOD Historical Data
Upcoming Dividends
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 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.
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/.
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.
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.
Requesting Data
To add Upcoming Dividends data to your algorithm, call the add_data
method.
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
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.
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
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.
history = self.history[EODHDUpcomingDividends](timedelta(100), Resolution.DAILY)
For more information about historical data, see History Requests.
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.
class UpcomingDividendsExampleAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2020, 1, 1) self.set_end_date(2024, 10, 1) self.set_cash(100000) # Trade on a daily basis based on daily upcoming dividend signals. self.universe_settings.resolution = Resolution.DAILY # Universe consists of equities with upcoming dividend events. self._universe = self.add_universe(EODHDUpcomingDividends, self.selection) 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 on_data(self, slice: Slice) -> None: # Equally invest in each member of the universe to evenly dissipate the capital risk. total_count = len(self._universe.selected) targets = [PortfolioTarget.percent(self, symbol, -1. / total_count) for symbol in self._universe.selected] self.set_holdings(targets, liquidate_existing_holdings=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.
class UpcomingDividendsExampleAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2020, 1, 1) self.set_end_date(2024, 10, 1) 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, splits: 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]