The problem of optimal portfolio of purchase of products (services) at the enterprises from many possible ones is considered. In this setting, the problem is explored and solved for the first time using a simulation tool. A mathematical model of the problem is built and an algorithm for its solution is developed. When building a mathematical model, the following parameters are taken into account: the number of types of products / services purchased; the number of enterprises that produce the required products; the need for products of a certain type; the cost of manufacturing a unit of production of each type at each enterprise; generalized indicator of quality of manufactured products of each type at each enterprise; index of identified comparative advantages in the manufacture of products j-th enterprise; the general budget of funds allocated for the purchase of products (financing the manufacture of products). The developed mathematical model makes it possible to find the optimal result of distribution of the required volume of orders (purchases) of each type of products at different enterprises (or at one enterprise), which provides the maximum offered level of product quality, and product purchase costs do not exceed the planned level. To illustrate the results of the developed algorithm, the example shows the search for the best option for purchasing products of four types (meeting a specific need) at each of the five companies offering these types of products. The proposed algorithm is of interest for practical application, makes it possible to determine the optimal portfolio of purchases of products (semi-finished products, parts), to solve the problem of optimal "package" purchases / orders. It is advisable to use it in private business, in enterprises of various spheres of activity and forms of ownership, as well as at the macro level of the economy, in particular, in the process of finding optimal options for government programs.