Link to the original text:http://tecdat.cn/?p=6811
My research topic this year is to use particle swarm optimization (PSO) for currency trading portfolio optimization. In this article, I will introduce portfolio optimization and explain its importance. Secondly, I will demonstrate how particle swarm optimization can be applied to portfolio optimization. Third, I will explain the arbitrage portfolio and then summarize my findings.
The investment portfolio includes assets and investment capital. Portfolio optimization involves determining how much money should be invested in each asset. With the introduction of constraints such as diversification requirements, minimum and maximum asset exposure, transaction costs and foreign exchange costs, I use particle swarm optimization (PSO) algorithm.
The working principle of portfolio optimization is to predict the expected risk and return of each asset in the portfolio. The algorithm takes these forecasts as inputs and determines how much capital should be invested in each asset to maximize the risk adjusted return of the portfolio and meet the constraints. The prediction of the expected risk and return of each asset needs to be as accurate as possible to make the algorithm perform well. There are various methods, in this study, I studied three commonly used methods.
- Normal distributed revenue – in this method, a distribution of historical asset values is created and randomly sampled to obtain the future value of each asset. The method assumes that the historical and future values are normally distributed.
- Returns follow Brownian motion – in this approach, random walks of each asset are generated over time, representing daily returns. The total return of the portfolio is calculated. This method assumes that future returns follow random walk.
- Returns follow geometric Brownian motion – in this approach, random walks are generated again, but are normalized according to daily variance and long-term market drift. This method assumes that future earnings follow a standardized random walk.
In my research, I found that the third method is the most accurate
Particle swarm optimization (PSO)
In PSO, each particle in a group is represented as a vector. In the context of portfolio optimization, this is a weight vector that represents the allocated capital of each asset. The vector is converted to the position in the multidimensional search space. Each particle will also remember its best historical position. For each iteration of PSO, the global optimal location is found. This is the best position in the group. Once the global optimal position is found, each particle will be closer to its local optimal position and global optimal position. When executed in multiple iterations, the process produces a good solution to the problem because the particles converge on the approximate optimal solution.
#This class contains the particle code in the swarm class Particle: velocity =  pos =  pBest =  def __init__(self): for i in range(dimension): self.pos.append(random.random()) self.velocity.append(0.01 * random.random()) self.pBest.append(self.pos[i]) return
The graph depicts how the particle swarm optimization algorithm updates the position of each particle in the population relative to the global optimal (blue) and local optimal (red).
#This class includes particle swarm optimization algorithm and particle parameter optimizer class ParticleSwarmOptimizer: solution =  swarm =  def __init__(self): for h in range(swarmSize): particle = Particle() self.swarm.append(particle)
The performance of PSO is influenced by weight. Exploration describes the ability of PSO to explore different areas of the search space. Exploration describes PSO’s ability to focus search on promising areas of the search space. In order to enhance the exploration and development ability of PSO, the following algorithm enhancement functions are applied
- Random reinitialization of aggregate particles – improves exploration by restarting particles when they gather on globally optimal particles. The convergence is measured by using the similarity function between two particles (carriers).
If the particles converge in the global optimal space, they will not converge in the global optimal space. This improves the exploration ability of PSO.
- The selective mutation of the optimal particle is improved by initializing the neighbor of the global optimal particle. If the neighbor is better than the global optimal particle, the global optimal particle is replaced by the neighbor.
For each iteration of the algorithm, neighbors are created near the global optimal particles. If any of these neighbors is better than the global optimal particle, the global optimal particle is replaced.
Portfolio optimization using particle swarm optimization
PSO algorithm can be used to optimize the portfolio. In the context of portfolio optimization, each particle in the group represents the potential capital allocation among the assets in the portfolio. The relative suitability of these portfolios can be determined by one of many financial utility functions that balance risk and expected return. I use the sharp ratio because it has become the industry accepted benchmark for portfolio performance. Consider the following PSO diagram for a portfolio of three assets,
An example of portfolio optimization using particle swarm optimization (PSO). Gray particles are updating. The red particle is the local optimal location of the gray particle, and the blue particle is the global optimal location.
Grey particles are transformed into vectors (0.5, 0.2, 0.3), which means that 50% of portfolio capital is allocated to asset 1, 20% to asset 2, and 30% to asset 3. The expected Sharpe ratio of the allocation is 0.38, which is smaller than the local optimal position (red particles) and the global optimal position (blue particles). In this way, the position of the gray particle is updated to make it closer to the global optimal particle and the local optimal particle.
An example of portfolio optimization using particle swarm optimization (PSO). The grey particle is updated to make it closer to the global optimum and local optimum. The resulting vector is better than before.
The gray particles have moved and are now converted to vectors (0.3, 0.3, 0.4) with an expected Sharpe ratio of 0.48. This value is higher than the previous local optimum position, so the local optimum position (red particle) is updated to the current position.
An example of portfolio optimization using particle swarm optimization (PSO). The local best position (red particle) is now updated to the current position of the particle.
The real challenge of using particle swarm optimization is to ensure that the constraints of portfolio optimization are met. As mentioned earlier, there are many limitations. The most common constraints are, first of all, that assets are no longer allocated to each other and that no less than 100% of available capital is available (i.e. the weight vector must add up to 1.0). Secondly, negative distribution of assets is not allowed. Finally, capital should be allocated to at least so many assets in the portfolio. The latter is cardinality constraint. Two common techniques are used to ensure that particles satisfy constraints,
- Fix particles that do not meet the constraint – for each particle that does not meet the constraint, apply a set of rules to change the position of the particles.
- Adaptability to penalize particles that do not meet the constraint – the Sharpe ratio to penalize each particle that does not meet the constraint.
For my research, I apply this technology to arbitrage portfolio. Arbitrage portfolio includes multiple arbitrage transactions. Arbitrage is a trading strategy in which traders sell currencies with relatively low interest rates and use these funds to buy different currencies, resulting in higher interest rates. Traders using this strategy try to find the difference between interest rates called interest rate difference.
The risk of foreign exchange loss can be reduced by diversifying the investment in various currencies, but it cannot be eliminated. Therefore, the risk of arbitrage portfolio itself is lower than that of individual arbitrage. Under the background of arbitrage trading portfolio, the goal of portfolio optimization is to further reduce the risk of foreign exchange loss and improve the investment return of portfolio.
The objective of portfolio optimization is to determine how much money should be allocated to each transaction to optimize the risk adjusted return.
In my research, I use particle swarm optimization algorithm to determine the optimal allocation of investment capital between a group of arbitrage transactions. The arbitrage portfolio in my study consists of 22 different currencies. Currencies include Australian dollar, Canadian dollar, Swiss franc, RMB, etc.
Thank you very much for reading this article. If you have any questions, please leave a message below!
Most popular insights