Homoclinic bifurcations in heterogeneous market models