This paper develops an adaptive learning scheme for an asset market with heterogeneous traders. We introduce the concept of a perfect forecasting rule for fundamentalists which generates rational expectations in the presence of chartists whose expectations are not necessarily rational. In the case when traders have linear mean-variance preferences and chartists base their decisions on simple technical trading rules, perfect forecasting rules are approximated by successively estimating the excess supply function from historical data. Conditions are given under which trajectories generated by this adaptive learning scheme converge to trajectories with rational expectations for fundamentalists.