@Andrey I
The way your custom factor computes 'delta', while it seems correct, will never return anything but 0. This stems from the way fundamentals are tracked and updated in the Quantopian database.
Here's an example using data from the attached notebook.
The data is from Facebook (FB) Fundamentals.normalized_diluted_eps_earnings_reports
with a pipeline run from 2015-01-29 thru 2015-02-03.
pipeline date 01/29/15
01/28/15 eps 0.303328 as of 09/30/14
01/27/15 eps 0.303328 as of 09/30/14
pipeline date 01/30/15
01/29/15 eps 0.303328 as of 09/30/14
01/28/15 eps 0.303328 as of 09/30/14
pipeline date 02/02/15
01/30/15 eps 0.247863 as of 12/31/14
01/29/15 eps 0.247863 as of 12/31/14
pipeline date 02/03/15
02/02/15 eps 0.247863 as of 12/31/14
01/30/15 eps 0.247863 as of 12/31/14
First, it looks like FB had quarterly earnings reports dated 09/30/14 and 12/31/14. Since the data changes after 01/30/2015 it appears the 12/31/14 earnings were reported after that day (typically after market close).
When the pipeline is run on Friday 01/30/2015 it fetches data for the previous two days ( Wednesday and Thursday 1/29 and 1/28). The latest eps data for those days, as far as the market knows at the beginning of the day 01/30/2015, is .303328 from 09/30/14. Then earnings are reported. Now, the market knows differently. At the beginning of the day 02/02/2015, the latest earnings per share for those days is 0.247863 as of 12/31/14.
On 02/02/2015 all the eps data after 12/31/2014 is updated to reflect this new information. All the eps data changes from 0.303328 to 0.247863. Notice too that the as_of dates all change from 09/30/14 to 12/31/14.
This is why the simple delta factor always returns 0. On 01/30/2015 the delta is 0 (0.303328 -0.303328 ). On 02/02/15 the delta is 0 (0.247863 - 0.247863).
Take a look at the attached notebook. I added a few cells at the bottom for logging. Also take a look at this post for more info on this same issue https://www.quantopian.com/posts/change-in-fundamental-data-in-research.
Hope that helps.