Recently, coinciding with and perhaps driving the increased popularity of prediction markets, several novel pari-mutuel mechanisms have been developed such as the logarithmic market scoring rule (LMSR), the cost-function formulation of market makers, and the sequential convex parimutuel mechanism (SCPM). In this work, we present a unified convex optimization framework which connects these seemingly unrelated models for centrally organizing contingent claims markets. The existing mechanisms can be expressed in our unified framework using classic utility functions. We also show that this framework is equivalent to a convex risk minimization model for the market maker. This facilitates a better understanding of the risk attitudes adopted by various mechanisms. The utility framework also leads to easy implementation since we can now find the useful cost function of a market maker in polynomial time through the solution of a simple convex optimization problem. In addition to unifying and explaining the existing mechanisms, we use the generalized framework to derive necessary and sufficient conditions for many desirable properties of a prediction market mechanism such as proper scoring, truthful bidding (in a myopic sense), efficient computation, controllable risk-measure, and guarantees on the worst-case loss. As a result, we develop the first proper, truthful, risk controlled, loss-bounded (in number of states) mechanism; none of the previously proposed mechanisms possessed all these properties simultaneously. Thus, our work could provide an effective tool for designing new market mechanisms.