1.8 Code Examples
This book is supplemented with a large number of code examples in R and Python that can reproduce all the figures in the book. These supplementary resources are available on the companion website for the book.
Generally speaking, the resolution of all the portfolio optimization formulations covered in the book can be approached in a variety of ways, namely:
Use a software package or library specifically designed to optimize portfolios under a wide variety of formulations and constraints. Examples include the popular R package
fPortfolio
(Wuertz et al., 2023) and the Python packagesRiskfolio-Lib
(D. Cajas, 2023) andPyPortfolioOpt
(Martin, 2021).Utilize a modeling framework like CVX, which automatically calls upon a solver behind the scenes, available for programming languages including Python, R, and Julia (Fu et al., 2022, 2020; Grant and Boyd, 2008, 2014).
Directly invoke an appropriate solver.
Develop ad hoc efficient algorithms for specific formulations, as done in the packages developed by the ConvexFi group.3
References
Convex Optimization in Finance group: https://github.com/convexfi↩︎