In the last few years, the value at risk (VaR), known as a risk-based optimization, has been proposed in the literature [38]. On the other hand, VaR is known for being a noncoherent risk measure which shows a few limitations, for instance, the absence of coherency and convexity. A fact that deems it quite unattractive for such types of optimization problems [39]. The risk measure known as the conditional value at risk (_CVaR_) is, on the other hand, a much more coherent one which was recently applied to a certain power grid associated problem, in this case, an optimized energy control model [40]. In ref. [41] an optimum trading of wind power in day-ahead (DA) electricity markets is proposed under uncertainty while taking into consideration the wind power generation and prices. Kernel density estimation is used to create a probabilistic wind power prediction, while the Gaussian distribution is considered for uncertainties in DA and real-time (RT) prices. An optimized risk-constrained offering strategy, which takes into account the _CVaR_, is proposed in ref. [42] for the electricity market in the case of a hybrid electricity power grid which includes certain elements such as demand response and a wind farm. It is concluded that cooperative operation of demand response users and wind power producers can decrease the possible risks and raise the anticipated revenue. A model which combines large-scale penetration of wind and solar electricity generation with \(\sim\)50% of annual demand with a baseload coal and nuclear generation is proposed in ref. [43] where _CVaR_ is used in the objective function with the aim of optimizing the residual load and then tailoring it in order to fit the baseload generation. In ref. [44] an optimization model of an electric vehicle aggregator is proposed in order to obtain the real-time flexible bidding and day-ahead inflexible bidding under several market uncertainties. In ref. [34] an optimization model of the day ahead planning and management is presented which takes into account the risk measurement. In this study, a stochastic optimization model is applied under two scenarios including a risk averse and a risk neutral decision. It is demonstrated that the day-ahead scheduling can be changed considerably with risk-based decision-making in microgrids. Moreover, it is shown that determining factors for the savings and risks of the microgrid are the capacity configuration and the variability measures. A _CVaR_ risk aversion model is proposed in ref. [45] with the aim of dynamically schedule a virtual power plant connected with a combined PV, wind, and ESS system and which also takes into consideration the DR and uncertainty. The results showed that the model successfully described the virtual power plant (VPP) risk and provided the decision support means for the decision maker. In ref. [46] a energy trading model is proposed, which happens to be decentralized, in a day-ahead electricity market with renewable energy generation and load aggregators' active participation in DR programs. In this study, in order to reduce uncertainty, _CVaR_ is applied with the aim to limit the possibility of an elevated renewable generation shortage with a well definite level of confidence. Finally, a stochastic two-stage unit commitment for Crete and Lanzarote-Fuerteventura islands with high renewable penetration is proposed in ref. [47] by using _CVaR_ for an effective management of the uncertainty. This paper presents an online optimal management for a finite time horizon of a grid connected microgrid comprising an intermittent renewable energy source, an energy storage device, and a power demand. The key contribution of this work is the risk consideration of the electricity price which is incorporated into the optimization problem. The goal is to minimize the cost of the electricity while supplying the demand as well as ensuring the operation constraints of the energy storage device.