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.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
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. -
Size:
Color:
QUOTE:
How do you update Fundamental data?
By checking the "Fidelity Fundamental Data for Securities" checkbox among "Fundamental Data Providers".
Size:
Color:
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?
Size:
Color:
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.
Size:
Color:
Just a note -
CODE:
Please log in to see this code.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
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.
Size:
Color:
CODE:
Please log in to see this code.
Size:
Color: