The paper analyses the possibilities to form a coalition of several heat energy providers in order to participate in the district heating market considering the open electricity market. Cooperation would allow the participants to better dispatch the existing energy sources and would ensure higher total profit for the participants. The objective function for such a cooperation is provided. To optimise the operation of the coalition, mixed integer linear programming is used, considering constraints of different heating energy market participants and the need to fulfil heating energy balance. If any additional profit is made, it is shared between coalition participants according to the Shapley value, which grants interest for market participants to form the coalition. Case study based on historical hourly data is provided and numerical results are presented in the paper.