Perovskites based on CsPbX 3 (X = Cl, Br, I) have promising applications in solar cells, light-emitting diodes, and photodetectors. In this paper, the phase stability of inorganic metal halide perovskite CsPbCl 3 under hydrostatic pressure and anion substitution is studied using density functional theory (DFT), and this modification is explained by the interaction of the octahedrons and transformation of the bond-orbital coupling. In addition, two space groups, P 4/ mbm and Amm 2, which are stable under stress, are subjected to anion substitution; then, the structural stability and band gap change of CsPbCl 3- y X y (X = Br, I; y = 0, 1, 2, 3) are analyzed after applying stress; finally, the electronic structures and optical properties of the six most stable components are presented. The effect of stress and anions on the components' optoelectronic properties is closely linked with the crystal's structural alteration mechanism. These results show that stress and anion modulation can significantly change the optoelectronic properties of materials, which make these materials have broad application prospects. Furthermore, stress can be used as an effective tool for screening the most stable material structure.