We derive the optimal portfolio for an expected utility maximizer whose utility does not only depend on terminal wealth but also on some random benchmark (state-dependent utility). We then apply this result to obtain the optimal portfolio of a loss-averse investor with a random reference point...