The paper presents an N-country model with stock markets, in which a closed-form solution for the real exchange rate is derived. Risky asset prices and allocation of risky assets among countries are determined endogenously. Such a framework allows an analysis of how fundamental parameters, such as the variance and covariance of the risky assets or demographic variables, affect the real exchange rate. The predictions of the model are contrasted with the Balassa-Samuelson effect. A new transmission channel of the real exchange rate for parameters such as income on net foreign assets, risk aversion, and risk-hedging opportunities is also explored.