How to calculate the P/E ratio in Python from SEC filings
Calculate Alphabet’s trailing P/E ratio in Python from diluted EPS in its 10-K and 10-Q XBRL data and a dated Market Data close, then see how much of the E came from gains on equity securities.