Back to Community
Dividend Announcements, Ex-dates, and Payment Dates now available in Pipeline

We've had a number of folks asking for ways to know about dividend related dates in their research.

I'm happy to say that dividend announcements, ex-dates, and payment dates (along with amounts, quarter-over-quarter changes, and more) from EventVestor are now available in Pipeline.

Attached to this post is an interactive tutorial that will show you how to get started using dividends in your work. All available fields from the dataset can be found there as well.

Also attached to this thread is:

Feel free to post questions here.

Loading notebook preview...
Notebook previews are currently unavailable.
Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

8 responses

A simple, but informative tool to visualize share prices on the dividend ex-date

Loading notebook preview...
Notebook previews are currently unavailable.

Code snippet that you can modify to avoid trading securities 1 business day before/after a dividend ex-date

Clone Algorithm
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
import pandas as pd
import numpy as np

from quantopian.algorithm import attach_pipeline, pipeline_output
from quantopian.pipeline import Pipeline

# Sample data available 01 Jan 2007 - 03 Jun 2014
from quantopian.pipeline.factors.eventvestor import (
    BusinessDaysUntilNextExDate,
    BusinessDaysSincePreviousExDate,
)

def make_pipeline():
    # Create our pipeline
    pipe = Pipeline()
    pipe.add(BusinessDaysUntilNextExDate(), "next_exdate")
    pipe.add(BusinessDaysSincePreviousExDate(), 'prev_exdate')
    pipe.set_screen(BusinessDaysSincePreviousExDate().notnan())
    return pipe

# Put any initialization logic here. The context object will be passed to
# the other methods in your algorithm.
def initialize(context):
    # List of securities to trade
    context.stocks = [symbol('AAPL'), symbol('BID')]
    
    schedule_function(rebalance,
                      date_rules.every_day())
    
    # Making our pipeline
    attach_pipeline(make_pipeline(), name='factors')

def before_trading_start(context, data):
    context.results = pipeline_output('factors')

def rebalance(context, data):
    for stock in context.stocks:
        # |--------Trade--------| |--Ex-date--| |--------Trade--------|
        if stock in context.results.index:
            prev_exdate = context.results.ix[stock]['prev_exdate']
            next_exdate = context.results.ix[stock]['next_exdate']
            if prev_exdate >= 1:
                order_target_percent(stock, 1.0/len(context.stocks))
            elif next_exdate == 1:
                order_target_percent(stock, 0)
        else:
            # If no dividends, then just buy.
            order_target_percent(stock, 1.0/len(context.stocks))
            
    
def record_positions(context, data):
    # Record our leverage, exposure, positions, and number of open
    # orders
    record(lever=context.account.leverage,
           exposure=context.account.net_leverage,
           num_pos=len(context.portfolio.positions))
    
There was a runtime error.

Hi Seong,

Looking to use the Dividend functions, but the above is currently generating a compile time error. Any ideas what might have broken?

Thanks

Steve

Hi Steve,

I cloned all of Seong's content here and ran it all.

Generally the data is working -- it looks like the only problem here is the cell in the first notebook that has the line dataset[:3] which is throwing some kind of error and might be a bug. But you can work around that by simply running dataset which will give you the top 10 rows by default. The purpose of that cell in the notebook is to simply show you the data in interactive mode. All of the critical pieces are working and you should be able to use the dividends data in a pipeline.

Thanks
Josh

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Thanks Josh,

It wasn't the notebook as such, it was the code snippet below. If I just clone it and run, it gives:

ValueError: Bad response: Computation failed with message: AssertionError: File "/home/databazaar/.venv/lib/python3.4/site-packages/blaze/server/server.py", line 643, in compserver  

I've tried to use BusinessDaysUntilNextExDate in my own algo's as well, and it produces the same compile error.

Can you confirm that cloning and running the code snippet rather than the notebook runs as expected?

Thanks

Steve

Hi Steve,

Thanks for reporting the issue. It looks like we have a bug with the EventVestor Dividend dataset preventing it from being loaded in your algorithm. I've notified our engineers. We'll have to get that fixed. Sorry for the trouble.

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

@Steve,

The issue has been fixed. you should now be able to run the notebook + algo. Sorry for the trouble.

Jamie

Can you confirm that the amounts quoted (next_amount / prev_amount) are the actual quarterly dividend paid and not the annualized yearly payments?

For rows without the next_ex_date field, is there a way to verify those dividends are paid quarterly as is standard? I do not want to incorrectly assume that all these dividends are paid quarterly to calculate the annualized dividend return.

If there's another variable that gives annualized dividend return please let me know!

Thanks,

Jeff