We propose a macroprudential theory of foreign reserve accumulation that can rationalize the secular trends in public and private international capital flows. In middle-income countries, the increase in international reserves has been associated with elevated private capital inflows, both in the aggregate and in the cross-section, and economies with a more open capital account have accumulated more reserves. We present an open economy model of financial crises that is consistent with these features. We show that optimal reserve management policy leans against the wind, raising gross private borrowing while improving the net foreign asset position and reducing exposure to crises.