Statistical and algorithm aspects of optimal portfolios