Take-home: write a Python program that retrieves certain companies' 13F filings from SEC EDGAR (XML) and writes them to a tab-separated file; include a thorough README.
Asked in the take-home stage. Web scraping team; filings are in an XML file.
Implement write_13f_tsv(filings, output_path). filings is a list of objects containing company, cik, and either an EDGAR url or test-only XML text in xml. Fetch URLs with a descriptive User-Agent, parse each information table, and write one row per holding. Return the output path.
Use this column order: company, cik, issuer, class, cusip, value, shares, share_type, put_call, investment_discretion. Missing XML fields must be empty. Preserve source values, sort rows by CIK and CUSIP, and document setup, assumptions, errors, and usage in the README.
def write_13f_tsv(filings, output_path):