
Parsing Form 4: How to Extract Signal from SEC Insider Trading Data
What Is Form 4? Form 4 is filed with the SEC within 2 business days whenever a corporate insider buys or sells their company's stock. It's one of the most actionable free datasets in finance. Transaction Codes Code Type Signal P Open market purchase High — insider buying with own money S Open market sale Context-dependent M Option exercise Low — usually compensation A Award/grant Ignore for signals Python Parsing import xml.etree.ElementTree as ET def parse_form4 ( xml_content ): root = ET . fromstring ( xml_content ) transactions = [] for txn in root . findall ( ' .//nonDerivativeTransaction ' ): code = txn . find ( ' .//transactionCode ' ). text shares = float ( txn . find ( ' .//transactionShares/value ' ). text ) price = float ( txn . find ( ' .//transactionPricePerShare/value ' ). text or 0 ) transactions . append ({ ' code ' : code , ' shares ' : shares , ' price ' : price }) return transactions High-Signal Patterns Cluster buying — 3+ insiders buy in same 30-day window → strong
Continue reading on Dev.to Python
Opens in a new tab


