The problem of determining optimal retention levels for a non-life portfolio consisting of a number of independent sub-portfolios was first discussed by de Finetti (1940). He considered retention levels as optimal if they minimised the variance of the insurer's profit from the portfolio subject to the constraint of a fixed level of expected profit. In this paper we consider a similar problem, changing the criterion for optimality to minimising the probability of ruin, either in discrete or continuous time. We investigate this problem through a series of case studies based on a real portfolio.