Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
how to get previous accouting data

PG =(OPi,q-OPi,q–4)/book equity
OP=REVTQ–COGSQ–XSGAQ–XINTQ
book equity =TXDITCQ-PSTKQ or SEQQ or CEQQ+PSTKQ or ATQ–LTQ
all data comes from wrds
follow the rule of calculation, how can i get OP lagged four quarters, thanks a lot if you can show me the codes!

1 response

Take a look at the posts below for some ideas. You will need to create a custom factor and use pipeline. The most reliable way to get fundamental data for a specific quarter is to check the 'asof_date' and not simply rely on looking back a fixed number of trading days.

Doug Baldwin has a nice custom factor for this ( see https://www.quantopian.com/posts/trailing-twelve-months-ttm-with-as-of-date ).
A discussion of some of the issues (https://www.quantopian.com/posts/eps-ttm)

Good luck.