HB(Herd behavior) is a widespread phenomenon in the financial market, which means that investors adopt the same investment strategy because of the influence of some investment strategies adopted by other investors, that is, investors' choice depends entirely on public opinion, rather than on their own information. This paper introduces the mechanism of biological foraging behavior into PSO (Particle Swarm Optimization). Aiming at the "imitation" characteristics of investors' investment behavior under the network system, an improved PSO simulation model for HB is constructed from two dimensions of investors' self-psychological preference and neighborhood behavior effect. Random initialization is carried out in a certain neighborhood of the local optimal position, and the optimal value is further searched. The results show that with the increase of HB traders to a certain extent, the frequency and range of price fluctuations have declined. Compared with the improved PSO, PSO takes much longer to calculate. No matter in unimodal function or multimodal function, the improved PSO algorithm shows good convergence and search accuracy, and the optimization performance is significantly improved.