We consider the risk sharing problem for capital requirements induced by capital adequacy tests and security markets. The agents involved in the sharing procedure may be heterogeneous in that they apply varying capital adequacy tests and have access to different security markets. We discuss conditions under which there exists a representative agent. Thereafter, we study two frameworks of capital adequacy more closely, polyhedral constraints and distribution based constraints. We prove existence of optimal risk allocations and equilibria within these frameworks and elaborate on their robustness.