The invention relates to a user side light storage integrated system demand charge capacity configuration software algorithm. The algorithm comprises the following steps that software inputting is performed, and a user annual time-sharing curve is obtained as computing input; 2, according to a user annual time-sharing load curve, the best photovoltaic configuration capacity and the investment cost are calculated according to the photovoltaic capacity optimized configuration under local consumption, and the best capacity configuration and the investment cost of a storage battery are calculated according to the battery type of an arranged energy storage system, the DOD discharging depth, the battery efficiency and other information and the requirement for charging and discharging time of peak shaving; if a user pays the capacity fee according to the needed electric charge, the electricity consumption in daytime is larger than that at night, the maximum demand occurrence time is short and shorter than 1 h, the maximum demand can be lowered through stored energy, and the demand electric charge can be lowered. According to energy storage, the charging valley time at night is 0 a.m. to 8 a.m., and discharging is performed during maximum demand occurrence. According to discharging power, discharging can be performed is performed when the electric supply P is larger than target power P, and discharging is stopped when electric supply P is equal to Ptn*40%. According to the monthly income, Cin=(P set power-Ptn*40%)*40 yuan per month, and electric supply P=P load-P photovoltaic.