In the aftermath of the 2007 global financial crisis, banks started reflecting into derivative pricing the cost of capital and collateral funding through XVA metrics. Here XVA is a catch-all acronym whereby X is replaced by a letter such as C for credit, D for debt, F for funding, K for capital and so on, and VA stands for valuation adjustment.This behaviour is at odds with economies where markets for contingent claims are complete, whereby trades clear at fair valuations and the costs for capital and collateral are both irrelevant to investment decisions.In this paper, we set forth a mathematical formalism for derivative portfolio management in incomplete markets for banks. A particular emphasis is given to the problem of finding optimal strategies for retained earnings which ensure a sustainable dividend policy.