Original link:tecdat.cn/?p=6811

 

My research topic this year isThe currency of particle swarm optimization (PSO) is used for trade portfolio optimization. In this article, I’ll introduce portfolio optimization and explain its importance. Second, I will demonstrate how particle swarm optimization can be applied to portfolio optimization. Third, I will explain the carry trade portfolio and then summarize my findings.


Combinatorial optimization

A portfolio consists of assets and investment capital. Portfolio optimization involves deciding how much money to invest 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) algorithms.

Portfolio optimization works by predicting the expected risks and returns of each asset in a portfolio. The algorithm takes these forecasts as input and determines how much capital should be invested in each asset to maximize the portfolio’s risk-adjusted returns and meet constraints. The forecast of the expected risk and return of each asset needs to be as accurate as possible for the algorithm to perform well. There are various methods, and in this study, I studied three commonly used methods.

  1. Normally distributed returns – In this approach, a distribution of historical assets is created and randomly sampled to obtain the future value of each asset. The method assumes that historical and future values are normally distributed.
  2. Returns follow Brownian motion – in this method, a random walk for each asset is generated over time, representing daily returns. From this, the total return on the portfolio is calculated. This approach assumes that future returns follow a random walk.
  3. Returns follow geometric Brownian motion – in this approach, a random walk is generated again, but normalized in terms of daily variance and long-term market drift. The method assumes that future returns follow a standardized random walk.

In my research, I found the third method to be the most accurate

 


Particle swarm Optimization (PSO)

 

In PSO, each particle in the group is represented as a vector. In the context of portfolio optimization, this is a weight vector representing the allocated capital for each asset. Vectors are transformed into positions in a multidimensional search space. Each particle also remembers its best historical location. For each iteration of the PSO, the global optimal position is found. This is the best optimal 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 performed over multiple iterations, the process produces a good solution to the problem because the particles converge on the approximate optimal solution.

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]) returnCopy the code

 

The figure depicts how the particle swarm optimization algorithm updates the position of each particle in the population relative to the global (blue) and local (red) best positions.

Class ParticleSwarmOptimizer: solution = [] swarm = [] def init__(self): for h in range(swarmSize): particle = Particle() self.swarm.append(particle)Copy the code

The performance of PSO is affected by weights. Exploration describes the PSO’s ability to explore different areas of the search space. Exploitation describes the PSO’s ability to focus the search on promising areas of the search space. In order to enhance the exploration and development capabilities of PSO, the following algorithm enhancements are applied:

  • Random reinitialization of aggregate particles – Improves exploration by restarting particles when they converge on globally optimal particles. Convergence is measured using the similarity function between two particles (carriers).

 

If the particles converge near the global optimal particle, but are not as suitable as the global optimal particle, they are randomly reinitialized somewhere in the search space. This improves the EXPLORATION capabilities of the PSO.

  • Selective mutation of the optimal particle – improved by initializing neighbors adjacent to the globally optimal particle. If the neighbor is better than the globally optimal particle, the globally optimal particle is replaced by the neighbor.

 

For each iteration of the algorithm, neighbors are created near the globally optimal particle. 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 cluster represents the potential capital allocation between assets in the portfolio. The relative fitness of these portfolios can be determined using one of many financial utility functions that balance risk and expected return. I use the Sharpe ratio because it has become the industry’s accepted benchmark for portfolio performance. Consider the following PSO diagram for a portfolio of three assets,

 

 

Example of portfolio optimization using particle swarm optimization (PSO). Grey particles are being updated. The red particle is the local optimal position of the gray particle, and the blue particle is the global optimal position.

The gray particle is converted into a vector (0.5,0.2,0.3), which means that 50% of the portfolio capital is allocated to asset 1, 20% to asset 2, and 30% to asset 3. The expected Sharpe ratio of this assignment is 0.38, which is smaller than the local optimal position (red particle) and the global optimal position (blue particle). 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.

  

 

Example of portfolio optimization using particle swarm optimization (PSO). Grey particles are updated to be closer to global and locally optimal. You get a better vector than you did before.

The grey particle has moved and is now converted into a vector (0.3,0.3,0.4) with an expected Sharpe ratio of 0.48. This value is higher than the previous local optimal position, so the local optimal position (red particle) will be updated to the current position.

 

Example of portfolio optimization using particle swarm optimization (PSO). The local optimal position (red particle) is now updated to the current position of the particle.

The real challenge with 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 no longer allocated between assets and no less than 100% of available capital (i.e. the weight vector must add up to 1.0). Second, negative allocation of assets is not allowed. Finally, capital should be allocated to at least this many assets in the portfolio. The latter is the cardinality constraint. Two common techniques are used to ensure that particles meet constraints,

  1. 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 particle.
  2. Adaptability to penalize particles that do not meet the constraint – for each particle that does not meet the constraint, penalize the Sharpe ratio of that particle.

 

Carry trade portfolio portfolio

For my research, I applied this technique to carry trade portfolios. The arbitrage trade portfolio includes several arbitrage trades. Carry trading is a trading strategy in which traders sell currencies with relatively low interest rates and use those funds to buy different currencies, generating higher interest rates. Traders using this strategy try to find differences between interest rates called interest-rate differentials.

 


By diversifying investments in multiple currencies, the risk of foreign exchange losses can be mitigated, but not eliminated. Therefore, the portfolio risk of carry trades is lower than that of individual carry trades. Under the background of arbitrage trade portfolio, the objective of portfolio optimization is to further reduce the risk of foreign exchange loss and improve the investment income realized by the portfolio.

The goal of portfolio optimization is to determine how much capital should be allocated to each trade to optimize risk-adjusted returns.

In my research, I use particle swarm optimization algorithm to determine the optimal allocation of investment capital between a set of arbitrage trades. The carry trade portfolio in my study consists of 22 different currencies. Currencies include Australian dollar, Canadian dollar, Swiss franc, RMB and so on.

 

Thank you very much for reading this article, please leave a comment below if you have any questions!


Most welcome insight

1. Machine learning to identify changing stock market conditions — the application of hidden Markov model (HMM)

2. Garch-dcc model and DCC (MVT) modeling estimation in R language

3.R language implementation Copula algorithm modeling dependency case analysis report

4.R language COPULAS and VaR analysis of financial time series data

5.R language multivariate COPULA GARCH model time series prediction

6. Use R language to realize neural network to predict stock cases

7. Realization of R language volatility prediction: ARCH model and HAR-RV model

8.R language how to do Markov switching model

9. Matlab uses Copula simulation to optimize market risks