Ex-dividend date available?


Hello! I’m wondering if there is a way to query the upcoming ex-dividend date for a given stock. I’ve looked through the docs for the sharadar and reuters feeds but didn’t see it as an available field. If it’s not available in the core data api, does anyone know of a reliable way to get this data? Perhaps a 3rd party library or place to scrape it? Thank you.


This is currently not available in the QuantRocket API but is available by querying the IB API directly. Docs for directly connecting to the IB API are here. Using ib_insync, you would want to use reqMarketData and ask for generic tick 456. The format of the returned data, which contains the upcoming ex date, is described in the IB API docs. The API for this data is a bit of a hassle because you have to subscribe to market data, wait for the dividend data to arrive, then unsubscribe, as opposed to a synchronous request and response.

A general word of advice with any forward-looking data is that it tends to change and I would only rely on it if it is talking about the immediate future, i.e. the next day. Don’t store dates which are several days or weeks in the future and rely on them. I would collect this data right before you need it for trading decisions.


Thank you for the extremely helpful answer!


Per the instructions for directly connecting to the IB api, I attempted to install the ib_insync package via command line with:

$ echo ‘ib_insync==0.9.37’ >> quantrocket.satellite.pip.txt
$ quantrocket satellite exec ‘/opt/quantrocket/bin/install-packages’
status: success

This appeared to work as it returned the “success” status message. However when I tried to import it with:

from quantrocket.launchpad import start_gateways
from ib_insync import *

I received this error:

ModuleNotFoundError Traceback (most recent call last)
in ()
1 from quantrocket.launchpad import start_gateways
----> 2 from ib_insync import *
3 #from ibapi import *
5 #ib = IB()

ModuleNotFoundError: No module named ‘ib_insync’

I checked the installed packages with pip freeze > packages.txt and did not see the ib_insync package in the list. I did see the ibapi was installed though.

Any ideas on why the quantrocket satellite exec ‘/opt/quantrocket/bin/install-packages’ did not work to install ib_insync?


Did you perhaps get the error inside Jupyter? The commands you ran would only install the package on the satellite container. To also use it in jupyter, you should also pip install it there.


Of course! Thank you.