Objectives To identify factors associated with COVID-19 test positivity and assess viral and antibody test concordance. Design Observational retrospective cohort study. Setting Optum de-identified electronic health records including over 700 hospitals and 7000 clinics in the USA. Participants There were 891 754 patients who had a COVID-19 test identified in their electronic health record between 20 February 2020 and 10 July 2020. Primary and secondary outcome measures Per cent of viral and antibody tests positive for COVID-19 (‘positivity rate’); adjusted ORs for factors associated with COVID-19 viral and antibody test positivity; and per cent concordance between positive viral and subsequent antibody test results. Results Overall positivity rate was 9% (70 472 of 771 278) and 12% (11 094 of 91 741) for viral and antibody tests, respectively. Positivity rate was inversely associated with the number of individuals tested and decreased over time across regions and race/ethnicities. Antibody test concordance among patients with an initial positive viral test was 91% (71%–95% depending on time between tests). Among tests separated by at least 2 weeks, discordant results occurred in 7% of patients and 9% of immunocompromised patients. Factors associated with increased odds of viral and antibody positivity in multivariable models included: male sex, Hispanic or non-Hispanic black or Asian race/ethnicity, uninsured or Medicaid insurance and Northeast residence. We identified a negative dose effect between the number of comorbidities and viral and antibody test positivity. Paediatric patients had reduced odds (OR=0.60, 95% CI 0.57 to 0.64) of a positive viral test but increased odds (OR=1.90, 95% CI 1.62 to 2.23) of a positive antibody test compared with those aged 18–34 years old. Conclusions This study identified sociodemographic and clinical factors associated with COVID-19 test positivity and provided real-world evidence demonstrating high antibody test concordance among viral-positive patients.