Trade, Finance, and Endogenous Firm Heterogeneity