On the one hand, the demand response management and dynamical pricing supported by the smart grid had started to lead to fundamentally different energy consumption behaviours; On the other hand, energy supply has gone through a dramatic new pattern due to the emergence and development of renewable energy resources. Facing these changes, this thesis investigates one of the resulting challenges, which is how to integrate the wholesale market and the retail market into one framework in order to achieve optimal balancing between demand and supply. Firstly, based on the existing mechanisms of the wholesale and retail electricity markets, a simulation tool is proposed and developed. This enables the ISO to find the best balance between supply and demand, by taking into account the different objectives of the generators, retailers and customers. Secondly, a new market mechanism based on the interval demand is proposed in order to address the challenges of the unpredictable demand due to the demand response management programs. Under the proposed new market mechanism, the corresponding approaches are investigated in order to support the retailers to find their profit-optimal pricing strategies, the generators to develop their best bidding strategies, and the ISO to identify the market clearing price function in order to best balance supply and demand. In particular: 1) For the ISO, our designed mechanism could effectively handle unpredictable demand under the dynamic retail pricing. It also enables the realisation of the goals of dynamic pricing by utilising smart meters; 2) In the retail market, we extend the smart pricing model in the current research in order to enable the retailers to find the most-profitable pricing scheme under the proposed new mechanism with the demand-based piecewise cost (i.e., market clearing price) function; 3) For the wholesale market, we developed a pricing forecasting model in order to forecast a market clearing price. Based on this model, we analysed the optimal bidding strategies for a generator under an interval demand from the ISO. Simulation results are provided in order to verify the effectiveness of the proposed approaches.