A model of the balance of payments