Foreign Capital Flows, Real Exchange and Interest Rates: An Analytical Framework