Traffic operation has a significant impact on energy consumption in metro lines and thus it is important to analyze strategies to minimize it. In lines equipped with Automatic Train Operation systems (ATO), traffic regulation system selects one ATO speed profile on line among a preprogrammed set of optimized speed profiles. Previous works only minimize the energy demanded by the train in pantograph without considering energy savings measured at substations due to regenerative energy in detail. The main objective of this work is to design optimal ATO speed profiles of metro trains taking into account the energy recovered from regenerative brake in order to minimize the net energy at substations. A model of a train with an on-board energy storage device as well as a network model for estimating the energy recovered by the train is presented. Different scenarios are analyzed to assess the achievable energy savings due to possible investments such as installing power inverters or storage devices and energy savings due to the optimal design of ATO speed profiles are estimated. A real line of the Madrid Underground has been considered obtaining comparative results to facilitate an evaluation of the most advantageous scenario and possible investment. A future application would be the optimal design of driving for the newest train signaling system communications-based train control (CBTC). The CBTC improves train operation and control, due to continuous communication with each train. However, its features have not been taken full advantage yet to reduce the energy consumption. The proposed method could be applied to design and execute in real time the most energy-efficient driving according to the traffic and electrical situation of the line.