Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
Fetch and Write 13F Filings
00:00
5 left

Fetch and Write 13F Filings

MediumPython

Problem

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.

Contract

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.

Constraints

  • 1 <= number of filings <= 100
  • Each XML document contains zero or more information-table entries
  • XML namespaces and namespace URIs may vary
  • Use only Python standard-library modules
  • Output columns must use the specified order

Function Signature

def write_13f_tsv(filings, output_path):
Interviewer

Your question is Fetch and Write 13F Filings. Start with the requirements in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePython 3
You need to log in / sign up to run or submit.Ln 2
Run your code to see test output here.