Macroeconomic regime switches and speculative attacks