Using a continuous-time, stochastic, and dynamic framework, this study derives a closed-form solution for the optimal investment problem for an agent with hyperbolic absolute risk aversion preferences for maximising the expected utility of his or her final wealth. The agent invests in a frictionless, complete market in which a riskless asset, a (defaultable) bond, and a credit default swap written on the bond are listed. The model is calibrated to market data of six European countries and assesses the behaviour of an investor exposed to different levels of sovereign risk. A numerical analysis shows that it is optimal to issue credit default swaps in a larger quantity than that of bonds, which are optimally purchased. This speculative strategy is more aggressive in countries characterised by higher sovereign risk. This result is confirmed when the investor is endowed with a different level of risk aversion. Finally, we solve a static version of the optimisation problem and show that the speculative/hedging strategy is definitely different with respect to the dynamic one.