The invention discloses an overall planning optimization algorithm for a monthly power market and a day-ahead market, and the algorithm comprises the steps: carrying out the risk analysis of the uncertainty of load prediction, introducing the risk cost into an economic optimal optimization function, carrying out the linear transformation of a nonlinear constraint condition, and achieving the optimization solution. The algorithm is used for overall planning and arranging electricity purchasing strategies of the monthly electricity market and the day-ahead market, the solving efficiency is improved, in the monthly electricity market, the electricity price is the electricity price of bilateral transaction, in the day-ahead market, the electricity price is changed per hour, the price is determined by the market clearing price of each transaction time period, and the price of each transaction time period is determined by the market clearing price. If the electricity purchasing quantity of the day-ahead market and the monthly electricity market exceeds the actual electricity quantity, the unexecuted electricity contract is punished. According to the overall planning optimization algorithm, the problems of large prediction error and unbalanced supply and demand of the two markets are solved through calculation, the transaction strategy of overall arrangement of the monthly electricitymarket and the day-ahead market is realized, and reference is provided for organizers of the electricity market.