Portfolio selection is a well-known intractable research problem in the area of economics and finance. There are many definitions of the problem that by introduction of additional constraints try to make it closer to the realword conditions. Firefly algorithm is one of the latest swarm intelligence metaheuristics that was very successfully applied to both, unconstrained and constrained hard optimization problems. In this paper we adjusted firefly algorithm to the portfolio optimization problem and since the results were not completely satisfactory, we modified it so that better exploitation/exploration balance was achieved. We tested our improved algorithm on unconstrained portfolio problem, as well as on the problem formulation with cardinality and bounding constraints. We used official benchmark data sets from the OR-Library, and included data from Hang Seng in Hong Kong, DAX 100 in Germany and FTSE 100 in UK with 31, 85 and 89 assets respectively. Our upgraded algorithm proved to be uniformly better than the original one. Additionally, we compared it on the same data set to five other optimization metaheuristics from the literature and our upgraded firefly algorithm was better in most cases measured by all performance indicators.