The book's content is focused on rigorous and advanced quantitative methods for the pricing and hedging of counterparty credit and funding risk. The new general theory that is required for this methodology is developed from scratch, leading to a consistent and comprehensive framework for counterparty credit and funding risk, inclusive of collateral, netting rules, possible debit valuation adjustments, re-hypothecation and closeout rules. The book however also looks at quite practical problems, linking particular models to particular 'concrete' financial situations across asset classes, including interest rates, FX, commodities, equity, credit itself, and the emerging asset class of longevity. The authors also aim to help quantitative analysts, traders, and anyone else needing to frame and price counterparty credit and funding risk, to develop a 'feel' for applying sophisticated mathematics and stochastic calculus to solve practical problems. The main models are illustrated from theoretical formulation to final implementation with calibration to market data, always keeping in mind the concrete questions being dealt with. The authors stress that each model is suited to different situations and products, pointing out that there does not exist a single model which is uniformly better than all the others, although the problems originated by counterparty credit and funding risk point in the direction of global valuation. Finally, proposals for restructuring counterparty credit risk, ranging from contingent credit default swaps to margin lending, are considered.