In this paper, we propose a distributed control strategy for the design of an energy market. The method relies on a hierarchical structure of aggregators for the coordination of prosumers (agents which can produce and consume energy). The hierarchy reflects the voltage level separations of the electrical grid and allows aggregating prosumers in pools, while taking into account the grid operational constraints. To reach optimal coordination, the prosumers communicate their forecasted power profile to the upper level of the hierarchy. Each time the information crosses upwards a level of the hierarchy, it is first aggregated, both to strongly reduce the data flow and to preserve the privacy. In the first part of the paper, the decomposition algorithm, which is based on the alternating direction method of multipliers (ADMM), is presented. In the second part, we explore how the proposed algorithm scales with increasing number of prosumers and hierarchical levels, through extensive simulations based on randomly generated scenarios.