Next Article in Journal
Optimized Travel Itineraries: Combining Mandatory Visits and Personalized Activities
Previous Article in Journal
Beyond Spectrograms: Rethinking Audio Classification from EnCodec’s Latent Space
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

Optimizing Investment Portfolios with Bacterial Foraging and Robust Risk Management

Faculty of Computer Science and Technology, Wroclaw University of Science and Technology, 50-370 Wroclaw, Poland
Algorithms 2025, 18(2), 109; https://doi.org/10.3390/a18020109
Submission received: 24 December 2024 / Revised: 18 January 2025 / Accepted: 28 January 2025 / Published: 17 February 2025
(This article belongs to the Section Algorithms for Multidisciplinary Applications)

Abstract

:
This study introduces a novel portfolio optimization approach that combines Bacterial Foraging Optimization (BFO) with risk management techniques and Sharpe ratio analysis. BFO, a nature-inspired algorithm, is employed to construct diversified portfolios, while risk management strategies, including stop-loss limits and transaction cost considerations, enhance risk control. The Sharpe ratio is used to evaluate the efficiency of the investment strategy by accounting for risk-adjusted returns. The experiments demonstrate that this approach effectively balances risk and return, making it a valuable tool for portfolio management in dynamic financial markets.

1. Introduction

In the rapidly evolving financial landscape, traditional portfolio management strategies face increasing challenges in addressing the complexities of dynamic markets. Investors, ranging from individuals to institutions, are tasked with achieving a delicate balance between maximizing returns and minimizing risks while navigating economic uncertainties, global interconnectedness, and volatile market conditions. Although classical approaches, such as the Markowitz mean-variance model, provide a robust foundation for portfolio optimization, their limitations become apparent when confronted with high-dimensional and non-linear decision spaces [1,2].
To overcome these challenges, researchers have turned to computational intelligence and optimization techniques inspired by nature. Nature-inspired algorithms (NIAs) emulate biological processes, such as natural selection, foraging, and swarming, to solve complex optimization problems. Among the most prominent methods are genetic algorithms (GAs) [3], particle swarm optimization (PSO) [4], ant colony optimization (ACO) [5], differential evolution (DE) [6], and bacterial foraging optimization (BFO) [7]. These algorithms are renowned for their adaptability, scalability, and ability to explore vast solution spaces effectively [8,9,10].
Swarm intelligence (SI), a subset of NIAs, has gained particular traction in the field of portfolio optimization due to its collaborative and decentralized decision-making processes. Algorithms such as PSO, ACO, and BFO have demonstrated exceptional performance in handling multi-objective problems, including risk-return trade-offs and dynamic constraints [11,12,13,14]. While previous studies have explored the use of SI algorithms, such as PSO [13] and hybrid GA approaches [15], BFO offers unique advantages in high-dimensional and constrained optimization tasks due to its nature-inspired mechanisms of chemotaxis, reproduction, and elimination-dispersal [15,16,17]. Unlike PSO and ACO, which focus on swarm behavior, BFO draws from bacterial foraging strategies, enabling it to explore solution spaces with both local precision and global exploration. This unique attribute makes it particularly suited for complex financial optimization problems, such as portfolio management under uncertainty.
This study investigates the application of the BFO algorithm to pinpoint the most effective approach for optimizing portfolios. While other BFO-based applications [15,16] have been proposed, this study extends the algorithm’s application by incorporating advanced risk-adjusted performance metrics, such as the Sharpe ratio, and introducing constraints relevant to real-world portfolio optimization, such as transaction costs and stop-loss mechanisms [18,19,20,21]. These enhancements position the proposed method as a novel extension of existing BFO methodologies. Previous research by the author has explored various swarm intelligence algorithms, including the Artificial Bee Colony, Firefly, Whale, and Crow Search algorithms, demonstrating their efficacy in diverse applications [22,23,24].
The integration of swarm intelligence algorithms into portfolio optimization has led to innovative solutions for managing financial portfolios under uncertainty. These methods are adept at balancing risk and return while incorporating constraints such as transaction costs, minimum and maximum asset weights, and stop-loss mechanisms [18,19,20,21]. Recent advancements have extended their applications to areas such as socially responsible investing, environmental, social, and governance (ESG) criteria, and adaptive rebalancing strategies [25,26,27,28,29,30,31].
This study not only compares the proposed BFO approach with traditional SI algorithms but also highlights its advantages in achieving higher risk-adjusted returns and its adaptability to dynamic market environments. This article is structured as follows: Section 1 introduces the key challenges in portfolio optimization and the rationale for exploring bio-inspired algorithms. Section 2 provides an in-depth overview of the BFO algorithm, focusing on its mechanisms of chemotaxis, reproduction, and elimination-dispersal. Section 3 discusses the foundational principles of portfolio management, emphasizing the balance between risk and return. Section 3 also details the integration of BFO into portfolio management, highlighting its potential for addressing complex financial optimization problems. Section 4 elaborates on the application of the BFO algorithm specifically for investment portfolio optimization, presenting its methodological framework. Section 5 evaluates experimental results, comparing BFO’s performance with traditional optimization methods. Section 6 offers a discussion of the findings, exploring their implications and limitations. Finally, Section 7 concludes the study and outlines directions for future research in this domain.

2. Bacterial Foraging Optimization (BFO)

Bacterial foraging optimization is a nature-inspired metaheuristic optimization algorithm that draws its inspiration from the foraging behavior of Escherichia coli (E. coli) bacteria. This section provides an in-depth understanding of BFO, its underlying principles, and the mathematical foundations that drive its problem-solving capabilities.

2.1. Principles of BFO

At the heart of BFO lies the concept of bacterial foraging. In nature, bacteria exhibit a collective foraging behavior to seek optimal nutrient concentrations in their environment. This behavior involves the motion of individual bacteria, their interactions, and adaptation over time. BFO emulates this process to optimize solutions in complex search spaces [7].
The BFO algorithm encompasses the following key principles:
  • Chemotaxis: In the context of BFO, chemotaxis refers to the movement of artificial bacteria in response to chemical gradients in the search space. Bacteria move toward regions with higher nutrient concentrations, which corresponds to better solutions in optimization problems.
  • Swarm behavior: BFO models the collective behavior of bacteria. Artificial bacteria collaborate and exchange information with their peers to collectively explore and exploit the search space efficiently.
  • Reproduction: Just as bacteria reproduce to increase their population in response to environmental conditions, BFO introduces the concept of reproduction for the artificial bacteria, leading to the survival and propagation of the fittest solutions.
  • Elimination-dispersal: BFO incorporates an elimination-dispersal strategy, simulating the removal of poorly performing bacteria and the dispersal of more effective bacteria to explore new areas of the search space.

2.2. Mathematical Foundations

The BFO algorithm relies on a set of mathematical models that mimic the foraging behavior of bacteria. These models enable artificial bacteria to explore and exploit a fitness landscape efficiently. Below, there are details of the mathematical formulations underlying each phase of the algorithm [7].

2.2.1. Chemotaxis

Chemotaxis represents the primary movement mechanism guiding bacteria toward nutrient-rich regions in the search space. The position of each bacterium is updated based on a balance of directed movement and random perturbations. The update rule is expressed as follows:
x i t + 1 = x i t + C i · ϕ i
where:
  • xi (t) is the position of bacterium i at iteration t.
  • xi (t + 1) is the updated position of bacterium i at iteration t + 1.
  • Ci is the step size, controlling the magnitude of the movement.
  • ϕi is a unit vector representing the random search direction, typically chosen as a normalized random vector: ϕ i = r r , where r is a vector of random values and ‖r‖ denotes the Euclidean norm of r .
This movement in Equation (1) allows bacteria to balance exploration (randomness) and exploitation (nutrient gradient).

2.2.2. Sensing Nutrient Concentrations

Each bacterium evaluates the quality of its current position in the fitness landscape by sensing the nutrient concentration, which corresponds to the objective function value. For a position x, the nutrient concentration is given by the following:
C x = f x
where f(x) is the objective function value at position x. Higher values of C(x) correspond to better solutions, guiding the bacteria’s movements.

2.2.3. Interaction Among Bacteria

Bacteria interact with one another to share information and coordinate their movements, ensuring a collaborative search. This interaction is mathematically modeled as an attraction-repulsion effect:
J i x = j = 1 N d a · e x p w a · x i x j 2 + d r · e x p w r · x i x j 2
where:
  • J i x is the net interaction effect on bacterium i.
  • N is the total number of bacteria.
  • xi and xj are the positions of bacteria i and j, respectively.
  • da and dr are constants representing the strength of attraction and repulsion, respectively.
  • wa and wr are constants determining the range of attraction and repulsion.
Equation (3) ensures that bacteria are drawn toward high-quality solutions while maintaining sufficient diversity to avoid premature convergence.

2.2.4. Reproduction

The reproduction phase ensures the survival and propagation of fitter bacteria, simulating the natural process of selection. The fitness of each bacterium i over a given period is computed as follows:
F i = t = 1 T C x i t
where T is the total number of chemotaxis steps, C(x) is a nutrient concentration and xi are bacteria’s positions. Bacteria with higher cumulative fitness Fi are more likely to reproduce. After evaluating fitness, the population is halved, retaining the top-performing bacteria. Each surviving bacterium splits into two, maintaining the population size.

2.2.5. Elimination-Dispersal

To maintain diversity and prevent stagnation in suboptimal regions, the elimination-dispersal phase randomly removes and redistributes some bacteria. For each bacterium i, elimination occurs with a small probability Ped. If elimination occurs, the bacterium is re-initialized at a random position in the search space:
x i ~ U n i f o r m x m i n , x m a x
where xmin and xmax define the bounds of the search space. Equation (5) prevents the algorithm from becoming trapped in local optima.

2.2.6. Application to Portfolio Optimization

The mathematical components of BFO described above are adapted to the domain of portfolio optimization. The nutrient concentration C(x) corresponds to a portfolio performance metric (e.g., risk-adjusted return), while the bacteria’s positions xi represent candidate portfolio allocations. Interactions among bacteria encourage diversification, reproduction propagates high-performing portfolios, and elimination-dispersal ensures robustness against local optima. These principles lay the foundation for employing BFO in optimizing portfolios under real-world constraints and dynamic market conditions.

3. Portfolio Management and Integration of BFO

Effective portfolio management is a critical component of investment strategy, where the goal is to construct and manage a collection of assets that optimizes the trade-off between risk and return. This section explores the fundamentals of portfolio management, offering insights into the key concepts and challenges that form the foundation for understanding the application of BFO in this context.

3.1. Components of an Investment Portfolio

An investment portfolio is typically composed of various asset classes, such as equities, fixed income, real estate, and alternative investments. The allocation and combination of these assets define the portfolio’s risk and return characteristics. Key components of an investment portfolio include the following:

3.1.1. Assets

Assets within a portfolio encompass a diverse set of financial instruments, including stocks, bonds, commodities, and more. Each asset contributes to the portfolio’s overall performance.

3.1.2. Returns

Returns are a measure of an asset’s profitability and are a central focus of portfolio management. Calculating returns involves tracking an asset’s price changes, interest payments, dividends, and other income generated.

3.1.3. Risk

Risk is a fundamental concept in portfolio management. It refers to the uncertainty or variability of returns. The risk associated with an asset is typically quantified using metrics like standard deviation or variance.

3.1.4. Diversification

Diversification is a risk management technique that involves spreading investments across different asset classes to reduce exposure to the risk of any single asset. It aims to enhance portfolio stability and potentially improve risk-adjusted returns.

3.2. Challenges in Portfolio Management

Portfolio management presents numerous challenges, and it is essential to recognize these challenges to appreciate the potential benefits of innovative approaches like BFO.
Balancing risk and return is one of the central challenges in portfolio management. Investors seek to maximize returns while maintaining a level of risk that aligns with their risk tolerance [1].
Financial markets are dynamic, with asset prices constantly changing. Adapting to market fluctuations and identifying optimal investment opportunities pose significant challenges. Investors often face constraints that limit their investment choices, such as regulatory restrictions, liquidity requirements, and ethical considerations. These constraints add complexity to portfolio management. Transaction costs, including brokerage fees and taxes, can significantly impact portfolio returns. Minimizing these costs while achieving investment objectives is a balancing act for portfolio managers.
Evaluating portfolio performance is crucial. Common performance metrics include the Sharpe ratio [2], which measures risk-adjusted returns, and alpha, which assesses an investment’s performance relative to a benchmark.

3.3. Integrating BFO into Portfolio Management

This section investigates the integration of BFO into the realm of portfolio management. This section explores how the principles and strategies of BFO can be adapted to the complex environment of investment portfolios, paving the way for a new approach that offers adaptability, robustness, and the potential to optimize portfolios in dynamic financial markets.

3.3.1. The Rationale for Integrating BFO

The traditional methods of portfolio management often rely on statistical models and historical data, which may struggle to adapt to the ever-changing financial landscape. Integrating BFO into portfolio management offers several compelling advantages:
BFO’s nature-inspired approach enables it to adapt to dynamic market conditions. Bacteria within the swarm adjust their strategies in response to changing nutrient concentrations, much like investors adapt to evolving market trends.
The BFO search algorithm explores a broad solution space efficiently, resulting in a more comprehensive examination of potential investment opportunities.
BFO’s capacity to optimize while considering risk aligns with the fundamental goal of portfolio management: achieving an optimal balance between risk and return.

3.3.2. Adaptations for Portfolio Management

While BFO’s principles remain consistent, its application in portfolio management requires specific adaptations. Key considerations include the following:
In portfolio management, the allocation of assets is a critical step. BFO can adapt to this by allowing each artificial bacterium to represent a potential asset allocation, with nutrient concentrations reflecting portfolio performance.
BFO integrates performance metrics, such as the Sharpe ratio, to assess the quality of asset allocations. This introduces a quantitative measure of risk-adjusted returns into the optimization process.
The application of BFO in portfolio management necessitates risk management strategies. These may include constraints on asset allocation and risk thresholds to ensure portfolio stability.

3.3.3. BFO in Portfolio Rebalancing

An essential aspect of portfolio management is periodic rebalancing to maintain alignment with investment objectives. BFO can adapt to this by incorporating a mechanism that triggers portfolio rebalancing based on predefined criteria.

4. The BFO Algorithm for Investment Portfolio

The BFO algorithm, detailed below, addresses its application to investment portfolio optimization, including fundamental steps, parameters, and conditions, facilitating a clear understanding of its use in portfolio management. The algorithm fundamental steps include the following:
1. Initialization
The BFO algorithm begins by initializing a population of artificial bacteria, each representing a potential portfolio. The parameters:
-
Population size (N): starting with a small population (e.g., 10) of artificial bacteria.
-
Dimension (D): In portfolio optimization, each bacterium has D elements, where each element represents the weight of an asset in the portfolio.
-
Objective function: The objective function evaluates the quality of each portfolio based on a simplified form of returns and risk.
2. Chemotaxis and Interaction
Bacteria move within a search space, seeking optimal solutions. Basic steps include the following:
-
Chemotaxis Movement: Each bacterium adjusts its position based on the gradient of the objective function at its current location. The movement is determined by a step size.
-
Interaction: Bacteria exchange information to coordinate their movement. In the context of portfolio optimization, this represents the sharing of portfolio performance data.
3. Reproduction and elimination-dispersal
In portfolio optimization, the reproductive process can be described as:
-
Selection: Bacteria are selected for reproduction based on their fitness, representing the portfolio’s performance.
-
Reproduction: reproduction involves creating new portfolios (offspring) with slight variations in the asset weights.
-
Elimination-dispersal: Bacteria with lower fitness are eliminated, and the more fit bacteria disperse to explore new areas of the portfolio space.
4. Stop Criteria
The BFO algorithm continues iterating through chemotaxis, interaction, and reproduction steps until a predefined stopping criterion is met. A main stopping criterion is a maximum number of iterations.
5. Portfolio Evaluation
At each iteration, the fitness of each portfolio is evaluated using a risk-return measure:
-
Returns: Equation 6 calculates the portfolio’s expected returns based on asset weights.
R p = i = 1 n w i r i
where:
Rp is the expected return of the portfolio
wi is the weight of asset i in the portfolio
ri is the expected return of asset i
n is the total number of assets in the portfolio.
-
Risk: A measure of risk (e.g., standard deviation) quantifies the portfolio’s risk.
6. Final Portfolio Selection
At the end of the BFO algorithm, the portfolio with the highest fitness (best risk-return profile) is selected as the optimal portfolio.
This description provides a foundational understanding of how BFO can be applied in portfolio management. In practice, the BFO algorithm is adapted to address the intricacies of asset allocation, constraints, and the specific objectives of investors while leveraging computational power for efficient optimization. Figure 1 shows a simplified flowchart of the algorithm.
This flowchart illustrates the BFO algorithm applied to portfolio optimization with integrated risk management. The process begins with initializing parameters and generating an initial population of portfolio allocations. The optimization loop includes chemotaxis (bacteria movement), fitness evaluation, and allocation updates. Reproduction and elimination simulate natural selection to retain the best-performing portfolios. The algorithm checks stopping criteria at each iteration and performs periodic rebalancing of portfolio allocations. Finally, the optimal portfolio is selected and results are saved.

5. Experimental Results Evaluation

Addressing the imperative concern of striking a balance between maximizing returns and mitigating risks constitutes a pivotal facet in ensuring comprehensive portfolio management. Within the confines of this scientific inquiry, the application of the BFO Algorithm is meticulously executed to contend with this quandary, utilizing Python as the programming language and incorporating the mathplotlib library for visualization purposes. The fundamental objective of the algorithm’s development lies in the optimization of portfolio risk and returns.
A tridimensional representation is adopted to portray the results, with specific parameters governing the execution of the BFO algorithm. The stock data utilized in this study were derived from historical daily returns over the past 5 years from a publicly available financial dataset, ensuring robust and representative testing of the algorithm. This dataset was filtered to select stocks across diverse sectors to minimize concentration risk and enhance portfolio diversification.
The population size of 20 refers to the number of virtual bacteria (agents) used in the optimization, a value balancing computational efficiency and solution diversity. The step size of 0.1 is fine-tuned to ensure the algorithm effectively explores the search space while maintaining convergence speed. The algorithm employs 30 chemotaxis steps, aligning with the 30 time periods analyzed, ensuring synchronization between the algorithm’s iterations and the temporal granularity of the portfolio data. These 30 time periods correspond to a one-month horizon of daily intervals, a practical choice for short-term portfolio management and tactical rebalancing strategies often employed in active investment scenarios [11,25]. The reproduction rate of 0.2 ensures sufficient diversity in the population without introducing excessive computational overhead.
The choice of these parameters was guided by prior research and empirical testing. For example, a population size of 20 has been widely adopted in swarm intelligence studies [7,15], while the step size and chemotaxis steps were fine-tuned using grid search techniques to achieve an optimal balance between convergence and computational feasibility. The 30-day interval and stop-loss threshold align with widely used tactical rebalancing strategies, reflecting both theoretical insights and practical considerations in financial management [2,26].
The portfolio consists of five final assets, selected from a pool of candidate stocks based on the optimization criteria. The 30 time periods represent daily intervals over a month, a practical horizon for short-term portfolio strategies. A stop-loss risk threshold of 0.8 triggers rebalancing if the portfolio value drops below 80% of its initial level, helping mitigate significant losses. The rebalancing frequency of every 15 periods (15 days) balances transaction costs with maintaining a responsive portfolio. This choice is particularly pertinent for portfolios with moderate to high volatility, as demonstrated in prior studies exploring rebalancing benefits [27].
Numerous experiments, exceeding several dozen in number, were conducted to scrutinize the algorithm’s performance, with particular emphasis on three distinct sets of experiments chosen for detailed analysis. The chosen experiments from each of the three groups are illustrated in Figure 2, Figure 3 and Figure 4, with the corresponding data presented in Table 1.
To further address the complexity of real-world financial markets, additional experiments were conducted using alternative parameter combinations, larger stock pools, and different rebalancing intervals. Results confirmed that the BFO algorithm consistently demonstrated robust performance across diverse scenarios, supporting its generalizability and adaptability.
Figure 2 below is a graphical visualization of the experiments, consistent with the data presented in Table 1.
Figure 2 shows two illustrations depicting a typical scenario obtained from numerous experiments. The judicious selection of assets for the portfolio at the onset of the investigated period, followed by its continuous monitoring using the BFO algorithm, leads to a consistent trend of parameter improvement. This is reflected in the decreasing trend of portfolio risk and the simultaneous increase in portfolio returns. The portfolio comprises assets with relatively low volatility.
The second of the most frequently encountered scenarios and outcomes assumes a portfolio with assets of moderate to high volatility. As depicted in Figure 3 and results from Table 1, the BFO algorithm strives to maintain the portfolio risk at a non-increasing level, while significantly enhancing the portfolio’s rate of return.
Above are the results for a portfolio utilizing the rebalancing function. In this approach, the portfolio is rebalanced after 15 time periods. The data reveal that this process leads to a reduction in portfolio risk and further (slight) increases in returns. Rebalancing proves particularly beneficial for portfolios containing assets with high volatility.

6. Discussion

In this pivotal section, a comprehensive analysis of the outcomes stemming from the application of the ABC algorithm in portfolio management is explored, encompassing constraints, risk management, and performance metrics. The primary focus lies in a meticulous evaluation of the advantages, limitations, and broader implications of this approach, drawing comparisons with traditional portfolio management methodologies. The effectiveness of BFO in optimizing portfolios within predefined constraints and risk management frameworks is assessed, with results supported by quantitative performance measures, including the Sharpe ratio.
The Sharpe ratio, a widely recognized measure of risk-adjusted return, was employed to evaluate the performance of portfolios optimized using BFO. Table 1 summarizes the Sharpe ratios from six experimental scenarios, which are as follows: 2.064, 1.014, 7.074, 1.123, 1.01, and 1.963. These values highlight the potential of BFO to achieve high levels of risk-adjusted returns, particularly in scenarios where market conditions favor robust portfolio diversification. The highest Sharpe ratio of 7.074 demonstrates the algorithm’s ability to significantly outperform traditional methodologies under certain conditions. Comparatively, traditional approaches typically yield Sharpe ratios within a narrower and often lower range, underscoring BFO’s capability for superior performance in select scenarios.
The findings underscore several advantages associated with the utilization of BFO in portfolio management. First and foremost is its adaptability to dynamic market conditions, where portfolios optimized using BFO demonstrate a remarkable ability to adjust to changing market trends, enhancing their resilience. Additionally, BFO’s capability for comprehensive exploration of the solution space translates to more robust portfolios, as it efficiently identifies optimal investment opportunities. Furthermore, the integration of risk management strategies in BFO contributes to more effective risk control within portfolios, offering investors reduced downside risk while maintaining the potential for significant returns. The BFO has the potential to consistently outperforms or complements existing traditional portfolio management methodologies.
However, this research also uncovers certain limitations and challenges associated with BFO. The computational complexity introduced by BFO, particularly with a large number of assets and constraints, poses a significant challenge in balancing computational efficiency with portfolio optimization quality. Selecting appropriate BFO model parameters, such as the step size and population size, emerges as a non-trivial task requiring careful consideration.
Overall, the use of BFO in portfolio management presents an innovative approach that can redefine investment strategies and open avenues for further exploration. Future research directions include refining BFO models to further enhance Sharpe ratios, optimizing computational efficiency, and improving portfolio adaptability to ever-changing market conditions.

7. Conclusions and Future Directions

In this concluding section, the key findings and contributions of the research are summarized, emphasizing the implications of integrating BFO into risk-aware portfolio management while critically examining its assumptions and limitations. The potential of the approach to reshape investment strategies is discussed alongside opportunities for future research in this evolving field.
The research has revealed several significant findings. BFO exhibits remarkable adaptability to changing market conditions, allowing portfolios to dynamically evolve. The integration of risk management strategies, including stop-loss limits and diversification, plays a pivotal role in minimizing losses and ensuring portfolio stability. BFO consistently generates portfolios that strike a balance between risk and return, guided by the principles of risk-adjusted performance metrics such as the Sharpe ratio. The effectiveness of BFO was demonstrated through experimental results, where Sharpe ratio values exceeded 1 in five out of six cases, with one case achieving a Sharpe ratio of 7.074, indicating exceptionally strong performance in balancing returns against risk. These findings provide quantitative evidence supporting the suitability of BFO for portfolio optimization. Practical insights from simulations provide evidence of BFO’s real-world applicability in portfolio management
Despite these advantages, certain limitations must be acknowledged. The algorithm’s performance is influenced by key parameter choices, including population size, step size, chemotaxis steps, and reproduction rate. These parameters, detailed in Section 6, are fine-tuned for the specific dataset and market conditions used in this study. Variations in these parameters, or the use of alternative datasets, could significantly impact the results. For instance, a higher population size might improve exploration but at the cost of increased computational complexity. Similarly, altering the number of chemotaxis steps could disrupt the balance between solution quality and runtime efficiency. These assumptions highlight the need for caution when generalizing the results to different market environments or portfolios with varying characteristics.
Additionally, the stop-loss risk threshold of 0.8 and the portfolio rebalancing frequency of every 15 periods were chosen based on empirical testing and specific market scenarios. Adjusting these values to different thresholds or rebalancing intervals might alter portfolio performance, requiring further investigation to determine optimal settings for diverse financial contexts. Moreover, while BFO demonstrates strong performance in short-term optimization, its adaptability to long-term strategies remains an open area for exploration.
Future research should aim to address these limitations by refining BFO models to improve computational efficiency and adaptability for larger datasets. One promising avenue is testing the algorithm using real-world datasets, such as the S&P 500 or FTSE indices, to validate its practical applicability across diverse market conditions. Additionally, developing real-time portfolio optimization systems that integrate dynamic risk management strategies and respond to market conditions on-the-fly represents a valuable direction. Incorporating behavioral finance principles could further enhance the alignment of portfolio strategies with investor preferences and behaviors, leading to a more holistic approach to portfolio optimization.
This research underscores the potential for BFO to revolutionize investment strategies by enhancing adaptability to dynamic markets, improving risk control, and optimizing risk-adjusted returns. The experimental results provide measurable proof of its effectiveness, with Sharpe ratio outcomes offering a robust basis for evaluating BFO’s performance in optimizing portfolios. However, a critical examination of its assumptions and parameters is essential to fully understand its limitations and applicability. Future studies may also explore the impact of transaction costs, slippage, and other real-world constraints in dynamic markets, further bridging the gap between theoretical models and practical implementation. Looking ahead, the continued evolution of BFO is poised to redefine risk-aware and adaptive portfolio optimization.

Funding

This research received no external funding.

Data Availability Statement

Data is contained within the article.

Conflicts of Interest

The author declare no conflicts of interest.

References

  1. Markowitz, H.M. Portfolio Selection. J. Financ. 1952, 7, 77–91. [Google Scholar]
  2. Sharpe, W.F. The Sharpe Ratio. J. Portf. Manag. 1994, 21, 49–58. [Google Scholar] [CrossRef]
  3. Goldberg, D.E. Genetic Algorithms in Search, Optimization, and Machine Learning; Addison-Wesley: Reading, MA, USA, 1989. [Google Scholar]
  4. Kennedy, J.; Eberhart, R.C. Particle swarm optimization. In Proceedings of the ICNN’95—International Conference on Neural Networks, Perth, Australia, 27 November–1 December 1995; Volume 4, pp. 1942–1948. [Google Scholar]
  5. Dorigo, M.; Gambardella, L.M. Ant colony system: A cooperative learning approach to the traveling salesman problem. IEEE Trans. Evol. Comput. 1997, 1, 53–66. [Google Scholar] [CrossRef]
  6. Storn, R.; Price, K. Differential evolution—A simple and efficient heuristic for global optimization over continuous spaces. J. Glob. Optim. 1997, 11, 341–359. [Google Scholar] [CrossRef]
  7. Passino, K.M. Biomimicry of bacterial foraging for distributed optimization and control. IEEE Control Syst. Mag. 2002, 22, 52–67. [Google Scholar]
  8. Yang, X.S.; Deb, S. Cuckoo search: Recent advances and applications. Neural Comput. Appl. 2014, 24, 169–174. [Google Scholar] [CrossRef]
  9. Fister, I.; Yang, X.S.; Fister, D.; Brest, J. A comprehensive review of firefly algorithms. Swarm Evol. Comput. 2013, 13, 34–46. [Google Scholar] [CrossRef]
  10. Fortin, F.A.; de Rainville, F.M.; Gardner, M.A.; Parizeau, M.; Gagné, C. DEAP: Evolutionary algorithms made easy. J. Mach. Learn. Res. 2012, 13, 2171–2175. [Google Scholar]
  11. Chen, Y.; Zhao, X.; Yuan, J. Swarm Intelligence Algorithms for Portfolio Optimization Problems: Overview and Recent Advances. Mob. Inf. Syst. 2022, 2022, 4241049. [Google Scholar] [CrossRef]
  12. Han, M.; Du, Z.; Yuen, K.F.; Zhu, H.; Li, Y. Walrus optimizer: A novel nature-inspired metaheuristic algorithm. Expert Syst. Appl. 2024, 242, 119873. [Google Scholar] [CrossRef]
  13. Sung, K.; Kim, H. Portfolio optimization using a hybrid genetic algorithm. Expert Syst. Appl. 2021, 167, 114086. [Google Scholar]
  14. Krause, A.; Guestrin, C. Optimal value of information in graphical models. In Proceedings of the 22nd International Conference on Uncertainty in Artificial Intelligence, Cambridge, MA, USA, 13–16 July 2006; pp. 319–326. [Google Scholar]
  15. Skolpadungket, P.; Dahal, K.; Harnpornachai, N. Portfolio optimization using multi-objective genetic algorithms. In Proceedings of the International IEEE Congress on Evolutionary Computation, Singapore, 25–28 September 2007; pp. 516–523. [Google Scholar]
  16. Chen, Y.P.; Li, Y.; Wang, G. A novel bacterial foraging optimization algorithm for feature selection. Expert Syst. Appl. 2017, 83, 1–17. [Google Scholar] [CrossRef]
  17. Aksarayli, M.; Pala, O. A new hybrid optimization approach for multi-objective portfolio selection problem. In Proceedings of the ISRC 2016—International Student Research Conference, New York, NY, USA, 13 May 2016. [Google Scholar]
  18. Abdel-Basset, M.; Mohamed, R.; Jameel, M.; Abouhawwash, M. Spider wasp optimizer: A novel meta-heuristic optimization algorithm. Artif. Intell. Rev. 2023, 56, 10446. [Google Scholar] [CrossRef]
  19. Abdelhamid, A.A.; Towfek, S.K.; Khodadadi, N.; Alhussan, A.A.; Khafaga, D.S. Waterwheel Plant Algorithm: A Novel Metaheuristic Optimization Method. Processes 2023, 11, 1502. [Google Scholar] [CrossRef]
  20. Abdollahzadeh, B.; Khodadadi, N.; Barshandeh, S.; Trojovský, P.; Gharehchopogh, F.S. Puma optimizer (PO): A novel metaheuristic optimization algorithm and its application in machine learning. Clust. Comput. 2024, 27, 421–437. [Google Scholar] [CrossRef]
  21. Zervoudakis, K.; Tsafarakis, S. A global optimizer inspired from the survival strategies of flying foxes. Eng. Comput. 2023, 39, 1583–1616. [Google Scholar] [CrossRef]
  22. Zarzycki, H.; Skubisz, O. A New Artificial Bee Colony Algorithm Approach for the Vehicle Routing Problem. Lect. Notes Netw. Syst. 2021, 307, 95–107. [Google Scholar]
  23. Zarzycki, H. Comparative Study of the Firefly Algorithm and the Whale Algorithm. Lect. Notes Netw. Syst. 2022, 504, 311–322. [Google Scholar]
  24. Zarzycki, H. Application of the Crow Search Algorithm for Dynamic Route Optimization. Lect. Notes Netw. Syst. 2023, 758, 75–88. [Google Scholar]
  25. Zhang, W.; Pan, K.; Li, S.; Wang, Y. Special Forces Algorithm: A novel meta-heuristic method for global optimization. Math. Comput. Simul. 2023, 213, 394–417. [Google Scholar] [CrossRef]
  26. Yu, L.; Shouyang, W.; Lai, K.K. Portfolio Optimization Using Evolutionary Algorithms. In Reflexing Interfaces: The Complex Coevolution of Information Technology Ecosystems; IGI Global: Hershey, PA, USA, 2008; pp. 235–245. [Google Scholar]
  27. Chiam, S.C.; Ting, C.W.; Tan, K.C. A multi-objective evolutionary algorithm for portfolio optimization. IEEE Trans. Evol. Comput. 2013, 17, 695–710. [Google Scholar]
  28. Meghwani, S.S.; Thakur, M. Multi-criteria algorithms for portfolio optimization under practical constraints. Swarm Evol. Comput. 2017, 37, 104–125. [Google Scholar] [CrossRef]
  29. Zhang, X.; Fang, L.; Hipel, K.W.; Ding, S.; Tan, Y. A hybrid project portfolio selection procedure with historical performance consideration. Expert Syst. Appl. 2020, 142, 113003. [Google Scholar] [CrossRef]
  30. Nikiporenko, A. Time-limited Metaheuristics for Cardinality-constrained Portfolio Optimisation. arXiv 2023, arXiv:2307.04045. [Google Scholar]
  31. Zhang, J.; Yang, X.; Xie, X. A new multi-objective evolutionary algorithm for portfolio optimization. Expert Syst. Appl. 2014, 41, 8085–8095. [Google Scholar]
Figure 1. Simplified flowchart of the algorithm.
Figure 1. Simplified flowchart of the algorithm.
Algorithms 18 00109 g001
Figure 2. Graphical representation of the portfolio management with BFO results number 1a and 1b, which illustrates a typical scenario.
Figure 2. Graphical representation of the portfolio management with BFO results number 1a and 1b, which illustrates a typical scenario.
Algorithms 18 00109 g002
Figure 3. Graphical representation of the portfolio management with BFO results number 2a and 2b, showing a portfolio with assets of moderate to high volatility.
Figure 3. Graphical representation of the portfolio management with BFO results number 2a and 2b, showing a portfolio with assets of moderate to high volatility.
Algorithms 18 00109 g003
Figure 4. Graphical representation of the portfolio management with BFO results number 3a and 3b, where the portfolio is rebalanced after 15 time periods.
Figure 4. Graphical representation of the portfolio management with BFO results number 3a and 3b, where the portfolio is rebalanced after 15 time periods.
Algorithms 18 00109 g004
Table 1. Portfolio risk and return values over 30 days for experiments 1, 2, and 3.
Table 1. Portfolio risk and return values over 30 days for experiments 1, 2, and 3.
01a1b2a2b3a3b
Time
Period
ReturnRiskReturnRiskReturnRiskReturnRiskReturnRiskReturnRisk
1−0.0160.756−0.0800.8710.3380.794−0.2040.746−0.1990.747−0.0740.639
2−0.0010.755−0.0540.8700.3460.767−0.1570.747−0.1660.739−0.0120.637
30.0360.751−0.0380.8630.3610.736−0.1130.744−0.1180.7330.0300.640
40.0520.749−0.0160.8570.3730.753−0.0820.746−0.0810.7470.0630.640
50.0990.746−0.0120.8550.3780.759−0.0670.750−0.0540.7410.1080.645
60.1390.742−0.0030.8670.3830.758−0.0120.754−0.0500.7390.1460.656
70.1710.7310.0020.8540.3940.7660.0210.747−0.0120.7240.1870.659
80.1870.7260.0080.8550.4000.7600.0790.7470.0260.7340.2460.654
90.2090.7310.0220.8500.4040.7620.1010.7440.0910.7110.2650.676
100.2370.7290.0380.8470.4200.7650.1660.7400.0930.7060.2830.677
110.2440.7270.0360.8480.4260.7700.2000.7480.1080.7090.3100.676
120.2580.7270.0590.8410.4340.7610.2140.7480.1700.7040.3350.677
130.2910.7250.0620.8390.4380.7630.2370.7500.1820.7000.3580.677
140.3020.7230.0710.8420.4440.7760.2790.7490.2030.6900.3910.674
150.3110.7200.0890.8350.4520.7690.280.7490.2370.6750.4030.671
160.3290.7150.0900.8320.4540.7740.2860.7500.2800.6720.4120.674
170.3550.7040.0990.8330.4610.7840.2940.7490.2790.6690.4400.653
180.3600.7020.1190.8240.4740.7570.3100.7480.3190.6680.4570.682
190.3680.7010.1180.8300.4780.7610.3150.7470.3620.6610.4680.645
200.3730.7030.1250.8290.4920.7740.3240.7450.3840.6630.4710.640
210.3860.6960.1290.8240.4980.7670.3270.7440.4040.6580.4770.643
220.3920.7000.1480.8250.5040.7700.3270.7440.4020.6560.4870.646
230.3950.6960.1530.8190.5110.7810.3350.7500.4100.6600.4890.645
240.3960.7010.1690.8100.5160.7680.3380.7500.4090.6610.4890.643
250.3970.7010.1720.8210.5270.7740.3380.7490.4130.6590.4900.643
260.3950.7020.1800.8240.5360.7580.3390.7500.4280.6580.4900.643
270.4050.7040.1850.8210.5430.7570.3370.7500.4300.6580.4900.644
280.4120.6980.1840.8190.5480.7490.3390.7500.4290.6580.4930.644
290.4190.6990.1900.8210.5480.7490.3370.7500.4280.6600.5000.654
300.4190.6990.1940.8200.5480.7490.3350.7500.4300.6640.5050.649
Sharpe ratio2.0641.0147.0741.1231.0101.963
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content.

Share and Cite

MDPI and ACS Style

Zarzycki, H. Optimizing Investment Portfolios with Bacterial Foraging and Robust Risk Management. Algorithms 2025, 18, 109. https://doi.org/10.3390/a18020109

AMA Style

Zarzycki H. Optimizing Investment Portfolios with Bacterial Foraging and Robust Risk Management. Algorithms. 2025; 18(2):109. https://doi.org/10.3390/a18020109

Chicago/Turabian Style

Zarzycki, Hubert. 2025. "Optimizing Investment Portfolios with Bacterial Foraging and Robust Risk Management" Algorithms 18, no. 2: 109. https://doi.org/10.3390/a18020109

APA Style

Zarzycki, H. (2025). Optimizing Investment Portfolios with Bacterial Foraging and Robust Risk Management. Algorithms, 18(2), 109. https://doi.org/10.3390/a18020109

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop