Ruin probabilities and optimal investment: The case of dependence between financial and insurance risks