We study a real small open economy with two key ingredients: (i) partial segmentation of home and foreign bond markets and (ii) a pecuniary externality that makes the real exchange rate excessively volatile in response to capital flows. Partial segmentation implies that, by intervening in the bond markets, the central bank can affect the exchange rate and the spread between home- and foreign-bond yields. Such interventions allow the central bank to address the pecuniary externality, but they are also costly, as foreigners make carry-trade profits. We analytically characterize the optimal intervention policy that solves this trade-off: (a) the optimal policy leans against the wind, stabilizing the exchange rate; (b) it involves smooth spreads but allows exchange rates to jump; (c) it partly relies on “forward guidance”, with non-zero interventions even after the shock has subsided; (d) it requires credibility, in that central banks do not intervene without commitment. Finally, we shed light on the global consequences of widespread interventions, using a multi-country extension of our model. We find that, left to themselves, countries over-accumulate reserves, reducing welfare and leading to inefficiently low world interest rates.