We build a parsimonious agent-based model under the adaptive market hypothesis (AMH), which can explain the formation of equilibrium prices and market efficiency dynamics. Our model combines heterogeneous interacting agents, switching behavior, and investor feedback on past realized returns, with realistic assumptions on the market microstructure. Numerical simulations show that our model is empirically robust to the facts observed in returns of developed and emerging financial markets (leptokurtic distribution, excess volatility, time-varying linear and nonlinear autocorrelations in returns, and time-varying degree of market efficiency). These results reveal that the elements in the model are necessary for generating these empirical facts. They also confirm the AMH. The model can be used as an artificial laboratory to assess the effectiveness of regulatory policies and the profitability of trading strategies.