Essays on Margin Requirements, Endogenous Illiquidity, and Portfolio Choice