This paper analyzes the optimal planning and operation of aggregated distributed energy resources (DER) with participation in the electricity market. Aggregators manage their portfolio of resources in order to obtain the maximum benefit from the grid, while participating in the day-ahead wholesale electricity market. The goal of this paper is to propose a model for aggregated DER systems planning, considering its participation in the electricity market and its impact on the market price. The results are the optimal planning and management of DER systems, and the appropriate energy transactions for the aggregator in the wholesale day-ahead market according to the size of its aggregated resources. A price-maker approach based on representing the market competitors with residual demand curves is followed, and the impact on the price is assessed to help in the decision of using price-maker or price-taker approaches depending on the size of the aggregated resources. A deterministic programming problem with two case studies (the average scenario and the most likely scenario from the stochastic ones), and a stochastic one with a case study to account for the market uncertainty are described. For both models, market scenarios have been built from historical data of the Spanish system. The results suggest that when the aggregated resources have enough size to follow a price-maker approach and the uncertainty of the markets is considered in the planning process, the DER systems can achieve up to 50% extra economic benefits, depending on the market share, compared with a non-aggregated business-as-usual approach (not implementing DER systems).