The purpose of the study is to optimize power price in smart homes that connect to share energy. A Demand Side Management (DSM) system is used to coordinate P2P energy trading between smart homes using the improved eagle perching optimizer (IEPO). The IEPO algorithm produces optimum solutions for 99% of actual datasets, according to the outcomes. It is possible that consumer price distribution in the microgrid (MG) could be unequal as a result of P2P energy trading. The Pareto optimality principle addresses the issue of unequal price distribution, preventing households from being harmed by improving the costs of others. A final evaluation is performed on the effect of renewable energy and the penetration of storage within the MG. As the renewable energy and the penetration of storage increases, savings cannot necessarily be linear. As the saturation point approaches, they slowly begin to decline.