Notebook
In [1]:
from quantopian.pipeline import Pipeline
from quantopian.pipeline.data.factset.estimates import (
    PeriodicConsensus,
    Actuals,
)

from quantopian.research import run_pipeline

# Create a dataset of EPS estimates for the upcoming fiscal quarter (fq1).
fq1_eps_cons = PeriodicConsensus.slice('EPS', 'qf', 1)

# Define a pipeline factor that gets the latest mean estimate EPS for fq1.
fq1_eps_cons_mean = fq1_eps_cons.mean.latest
In [2]:
pipe = Pipeline(
    columns={
        'fq1_eps_cons_mean': fq1_eps_cons_mean,
    },
)

df = run_pipeline(pipe, '2016-01-01', '2016-02-01')
df.dropna().head()
Out[2]:
fq1_eps_cons_mean
2016-01-04 00:00:00+00:00 Equity(2 [ARNC]) 0.838947
Equity(24 [AAPL]) 3.178544
Equity(31 [ABAX]) 0.328750
Equity(39 [DDC]) 0.175000
Equity(41 [ARCB]) 0.621499
In [3]:
# Index into the dataframe to look at the estimates for AAPL. Recall that AAPL has sid=24.
df.xs(24, level=1).head(10)
Out[3]:
fq1_eps_cons_mean
2016-01-04 00:00:00+00:00 3.178544
2016-01-05 00:00:00+00:00 3.255739
2016-01-06 00:00:00+00:00 3.255739
2016-01-07 00:00:00+00:00 3.250215
2016-01-08 00:00:00+00:00 3.246643
2016-01-11 00:00:00+00:00 3.239349
2016-01-12 00:00:00+00:00 3.239349
2016-01-13 00:00:00+00:00 3.236968
2016-01-14 00:00:00+00:00 3.236968
2016-01-15 00:00:00+00:00 3.236730
In [ ]: