Accessing a Dividend DataSeries
Author: johnwlab
Creation Date: 4/23/2009 12:37 PM
profile picture

johnwlab

#1
Is it possible to access a Dividend DataSeries for
and individual Stock/ETF? I tried running the example
code from the programming manual below, but no dividend
data was plotted in the paneRatio pane that was created.
The symbol I used was QQQQ and a dividend was shown on
in the Price pane on 3/20/09. Is there a Preference setting
that needs to be set to access the Dividend data?


CODE:
Please log in to see this code.
profile picture

Cone

#2
The code is fine and works - try it on Dow 30 symbol, for exmaple.

The dividends displayed on the chart are per share dividends, Item = "dividend". "cash dividends" is the total cash dividends paid out. It doesn't work on QQQQ because apparently the data for "cash divideds" doesn't exist. Not sure why, but you can direct problems with Fidelity price and fundamental data to Fidelity phone support.
profile picture

johnwlab

#3
Still having problems accessing Dividend Data from the
DataSeries divYield. Tried Dow 30 symbols and
dividend data is still not displayed when divYield is
plotted. For example, AA has a dividend on 2/4/2009,
but the dividend does not show up when plotted in paneRatio
or in the debug log.

Added debug logging shown below. Is it possible
to access the dividend data into a variable as shown
below? My interest in the dividend data is to use it with
the price data to create and plot a Total Return line
for a symbol that accounts for dividends.

CODE:
Please log in to see this code.
profile picture

Eugene

#4
John, you're pasting the code outside of the CODE tags when pasting, so it's still not formatted.

Have you updated your fundamental data? The script works OK for me using Fidelity data.
profile picture

johnwlab

#5
How do you update Fundamental data? Did not see a separate
option for that in the Data Manager. I can see dividend
data in the Price Pane when I select the chart option
to show dividends, but its still does not show up in
divYield when plotted or logged. -
profile picture

Eugene

#6
QUOTE:
How do you update Fundamental data?

By checking the "Fidelity Fundamental Data for Securities" checkbox among "Fundamental Data Providers".
profile picture

johnwlab

#7
Eugene, thanks for the reply. Did get access to the
Fidelity Fundemental and was able to get the dividend yield
data. However, I then realized that what I was really
needed was not the "dividend yield", but the "per share Dividend".
The "per share Dividend" amount is displayed on a chart
(with a light blue icon with the letter D) when you select
the button to "Show Selected Fundemental Data Items". Is it
possible to access a data series with this "per share
Dividend" data?
profile picture

johnwlab

#8
Problem solved. Objective was to create a DataSeries (CDPS)
with the Per Share Dividend data included just on the Dividend
Dates. Thanks for your help. Very nice to have access to
this fundemental data.

CODE:
Please log in to see this code.
profile picture

Cone

#9
Just a note -

CODE:
Please log in to see this code.
profile picture

johnwlab

#10
Thanks for code comments. Very helpful.

There may be a runtime issue with this code, because
sometimes (not always) when I select another symbol
in a Dataset I get the message:
"Runtime error: Object reference not set to an instance of an object
at WealthLab.Strategies.MyStrategy.Execute() "
If I select the symbol a second or third time it will
then usually run correctly generating a Chart. Is there
some additional code that can be added to prevent this
type of runtime error? I did update the data using
the Data Manager prior to running the program.
profile picture

Cone

#11
The only statement that would return that error is FundamentalItem CD = GetFund.... so you wrap it in a try/catch block.

CODE:
Please log in to see this code.
profile picture

johnwlab

#12
That solved the runtime problem. Very nice solution.
Thanks again for comments on code. Would like to try
and use best/preferred methods when writing code in
the future.
profile picture

johnwlab

#13
There is one remaining problem with the above code that gets the
Dividend Per Share data. If the Start Date specified is before
the first Dividend Date in the DataSeries, then when the program
is executed an Exception error (System.NullReference) is generated
which prevents collection of the Dividend Data. When the Start Date
is set after the first Dividend date the problem goes away.

Would appreciate any suggestions on how the code could be modified
to avoid this problem when the Start Date specified is before the
first dividend date.
profile picture

Eugene

#14
CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).