Due to increasingly prominent climate change and environmental pollution problems caused by carbon emission, the carbon emission from some enterprises has been concerned and restricted within a certain range. As one of the enterprises with high carbon emission, the generation companies with thermal power units are faced with the increased cost, since they will be charged with extra fees or required to purchase carbon emission allowance if their carbon emission exceeds certain upper limit, which is unfavorable to generation companies aiming at profitability. On the other hand, the fluctuating electricity price in the wholesale market makes the profit of generation company instable, which may bring bankruptcy risk. In this sense, how to stabilize and increase the profitability has become an urgent problem for the generation company with thermal power units. In this paper, an optimal power generation strategy considering the trading of carbon emission allowance and generation right is proposed. Firstly, the profit function of generation company is modeled. Secondly, the risk is measured using conditional value at risk (CVaR), and the generation portfolio model aiming at maximizing the profit and minimizing the risk is constructed. Then, the desired optimal generation strategy is obtained via existing solver OPTI. Finally, the feasibility of the proposed portfolio is demonstrated in simulation.