*Medium-term tactical planning
*Modeling, simulation and optimization
This paper proposes a methodology for determining the optimal bidding strategy of a retailer who supplies electricity to end-users in the short-term electricity market. The aim is to minimize the cost of purchasing energy in the sequence of trading opportunities that provide the day-ahead and intraday markets. A genetic algorithm has been designed to optimize the parameters that define the best purchasing strategy. The proposed methodology has been tested using real data from the Spanish day-ahead and intraday markets over a period of two years with a significant cost reduction with respect to trading solely in the day-ahead market.