The advent of competitive markets confronts each producer with the problem of optimally allocating his energy/capacity so as to maximize his profits. The multiplicity of auctions in electricity markets and the nontrivial constraints imposed by technical and bidding rules make the problem of crucial importance and difficult to model and solve. Further difficulties are represented by the dynamic and stochastic natures that characterize the decision process. We formulate the problem as a multi-stage mixed-integer stochastic optimization model under the assumption that the seller is a price taker. We validate the effectiveness of the proposed model on a representative test problem.