The invention relates to a compound shown as formula (I), a pharmaceutically acceptable salt, ester or stereoisomer thereof. R1, R2, R3, R4, m, n, W, A, Z, E, F, X and Y are defined as the specification. The invention also relates to a preparation method of the compounds, pharmaceutical preparations and application in drugs for treatment and/or prevention of FXR (farnesoid X receptor) mediated nonalcoholic fatty liver diseases, primary biliary cirrhosis, lipid metabolism disorders, diabetic complications, malignant tumors and other related diseases. (formula (I)).