In this paper we describe how to include funding and margining costs into a
risk-neutral pricing framework for counterparty credit risk. We consider
realistic settings and we include in our models the common market practices
suggested by the ISDA documentation without assuming restrictive constraints on
margining procedures and close-out netting rules. In particular, we allow for
asymmetric collateral and funding rates, and exogenous liquidity policies and
hedging strategies. Re-hypothecation liquidity risk and close-out amount
evaluation issues are also covered.