In Active Distribution Networks (ADNs), Distribution Company (Disco) follows two main strategies of dispatching of Distributed Energy Resources (DERs) and trading energy with wholesale energy markets, including Day-Ahead (DA) and Real-Time (RT) markets, to meet the demand. An attempt is made in this paper to model the strategic behavior of the Disco, in the wholesale DA and RT energy markets, through a bi-level optimization approach While the objective of the upper-level problem is to minimize the expected cost of the Disco, the lower-level problem (with two optimization problems) formulates to simultaneously maximize the social-welfare of the DA market and minimize the cost of the RT market. Furthermore, uncertain behavior of renewable energy sources as well as demand is tackled into the problem formulation. To this end, Disco decision-making represents as a risk-based two-stage stochastic problem where the Disco’s risk aversion is modeled using conditional value at risk (CVaR) method. Generally stated, the proposed model is a non-linear bi-level problem which may be transformed into a non-linear but single-level problem through Karush–Kuhn–Tucker (KKT) conditions and dual theory. Detailed numerical results on a 6-bus and RTS 24-bus power systems are used to demonstrate efficiency of the proposed model. Moreover, sensitivity analysis is carried out to investigate the effect of risk-aversion parameter on the decision making of the Disco and the offers/bids in both the DA and RT markets.