The paper is aimed at finding solutions for the optimization of operating modes of a small-scale power system, which consists of Renewable and Distributed Energy Resources, electricity consumers and prosumers (consumers with own generation), micro-grids with smart metering and technologies. Consideration of market volatility and variance of forecast parameters (ambient temperature, energy consumption and price, water inflow) make the solution of the problem much more complicated and require implementation of new technologies, algorithms and software tools. A brief review of smart grid technologies in Latvia is provided in this paper. The algorithm of profit maximization for prosumers is described, taking into account the random nature of the state variables. Mathematical description is given in a stochastic manner. When the energy resources are limited, their optimum distribution for the considered time period becomes especially important. A case study is provided for the existing micro-scale combined heat and power plant and demonstrates the operability and feasibility of the proposed stochastic optimization algorithm. It is concluded that the algorithm could increase the effectiveness of the operation of prosumers at the conditions of limited resources.