In this work we analyse the profitability of the agents participating in a Local Energy Community (LEC); the agents in these communities can be either passive or active. The main difference is that active agents own generating units that they need
to dispatch, whereas passive agents do not own any generating units. The LEC is operated and managed by a coordinating agent
that is in charge of all energy exchanges between the agents in the LEC and the external Public Electricity Network (PEN).
We propose a general optimization-based mathematical model to study the interactions among all the participants and to foresee
strategies and optimal behaviour within the rules of the LEC. With this model we can compute optimal costs, profits, energy
purchases and energy sales, assessing the best configuration for the LEC as a whole and for each individual participant.