Quantitative Research | Differentiation Analysis of Strategy in Index and Main Link Recovery (Final)

 Quantitative strategy development, high-quality community, trading ideas sharing and other related content

About the Author

Lu Yangyang 

In-service quantitative strategy researcher of a large asset management company, familiar with data cleaning, good at using macro factors, industry factors, etc. to model the impact of futures prices and correlation analysis, understand machine learning multiple regression methods, SVM, XGboost, financial time The underlying algorithm logic such as sequence, and some algorithms can be encapsulated by custom functions. Master the application of various machine learning packages and data calculation and analysis packages. Including but not limited to: Alphalens, pandas, crawler technology, sklearn, statsmodels, etc.

"text"

ˇ

This article is the final article of the differential analysis of the index and the main link re-weight. In the first two articles, we put forward the necessity and background of the analysis of this article, published on some quantitative public accounts and forums, and received many people's ideas, suggestions and questions. Thank you in advance for your attention and reading.

This article will sort out all the remaining problems in the first two articles; secondly, the author will write out the principle and algorithm of the main link restoration right for your reference and discussion; thirdly, I will return the main link restoration right after the completion of the review. The measurement details are being further improved. Finally, let our backtest truly achieve the goal of what is measured, and truly rise to the illusoryness of index backtesting and real market.

In the previous two articles, everyone's questions were mainly focused on "how to reinstate the rights and what is the most reasonable way to reinstate the rights", "the performance of the main consecutive reinstatement rights is more volatile than the index, and even better than the index performance", "the main consecutive reinstatement rights are more volatile than the index performance." Is the backtest the same as the real market?”, “Is it all over after the real price is mapped?” and other questions that are close to the real market. Below I will answer these questions one by one.

Q: Is the backtest of the main link and the right to be the same as the real market?

A: No, please refer to the next question for details.

Q: The performance of the main link and recovery rights is more volatile than the index, and it is even better than the index performance.

Answer: Because of the reason of reinstatement after the main connection, in addition to the varieties with the premium structure, basically all varieties have a large base until now after reinstatement, which leads to the return of the backtest performance curve is also large, and the drawdown is also large, because the price inside Including rollover multiples. I didn't say it here because I wanted to reveal the answer after I introduced the principle of post-rights restoration in this issue. I didn't expect that someone who had studied it would see it. In addition, this kind of profit and retracement theory is a multiple relationship, but it is not necessarily clear which is bigger or smaller with the market and take profit and stop loss conditions.

Therefore, we use the real price mapping in the backtest and the real market, that is, the function rolloverRealPrice. The order price is re-calculated according to the formula of "re-weighting price" = real price * re-weighting factor. Performance of opening and closing positions. In this way, we calculate the real performance (without considering the slippage) and not passively calculate the post-weighted price. At present, the preliminary test shows that the real price mapping calculation is better than the direct use of the main link recovery right.

Q: Is it finished after the real price is mapped?

Answer: No , because the price of opening and closing positions is through the inverse calculation of the re-weighting price during initialization. That is to say, the calculation of our signal is the weighted price, but the price of opening and closing positions is the real contract price. Let’s make up our minds, if your strategy is used to assign the entry price to a variable, and then calculate the value of variables such as take profit and stop loss, then there must be something wrong.

Q: How to restore rights, and what is the most reasonable way to restore rights

A: Here I will write more cause and effect, please read with patience

As we all know, we basically used the index price of 000 for the development of "rule-based" strategies before the return of the main link. Add, then divide by the total number of all contracts of this variety, and finally get a weighted average price, which is the 000 commodity index.

for example:

contract

price

open interest

Market capitalization (price * open interest)

XX01

200

1000

200000

XX05

220

7000

1540000

XX10

240

2000

480000

total

10000

2220000

000 index = ∑ (contract price * contract open interest)/∑ contract open interest

In other words, 000 index = 2220000 / 10000 = 222, in fact, everyone can see that this is a weighted average. This example is just to explain the origin and algorithm of the index contract. Of course, some market software is not exactly the same as this, but it is similar.

Below I give an example of exponential distortion:

Assume that the status of all contracts of a certain variety at time T is as follows

contract

price

open interest

Market capitalization (price * open interest)

XX01

200

2000

400000

XX05

220

10000

2200000

XX10

240

8000

1920000

total

20000

4520000

Index Price = 4520000/20000 = 226

Assume that the status of all contracts of a certain variety at time T+1 is as follows

contract

price

open interest

Market capitalization (price * open interest)

XX01

240

2000

480000

XX05

260

10000

2600000

XX10

180

8000

1440000

total

20000

4520000

Index Price = 4520000/20000 = 226

Obviously we can see that the price of the index is the same at both time points, both at 226. But when we pay attention to the main contract, we will find that the price of the 05 contract has risen from 220 to 260, and the increase has reached 260/220-1=0.18 (18%). In addition, the sub-main contract 10, the decline reached 180/240-1 = -0.25. With such strong fluctuations in the contract, why does the index remain unmoved?

There are two main reasons, which are actually the two points I have always summarized in my previous two articles.

First , the open interest of the main contract and the sub-main contract is very close. The 05 contract has 10,000, accounting for 50% of the total position, while the 10 contract has 8,000, accounting for 40% of the total position. The difference in proportion is not huge.

Second , the prices of the main contract and the sub-main contract have moved in opposite directions. Under normal circumstances, this kind of change rarely occurs, but if there is a major change in the market that affects the short-term supply and demand of the market, but basically does not affect the long-term supply and demand, then there will be a reverse price change. For example, our epidemic this year has caused many institutions to short the near month and long the far month in February and March. And egg market structure and so on. It shows that this situation is relatively common in the process of real disk.

Let's take 10,000 steps back and say, even if the market structure is no problem, it belongs to the same rise and fall, then when the monthly change occurs, the weight ratio of the primary and secondary contracts is close, and there is a premium and a discount between the two. Therefore, It also directly leads to the weighted average of premiums and discounts.

In our example above, the weight ratio of the primary and secondary contracts is close, and the impact on the index is just offset, resulting in basically no change in the index.

Since the index has not changed, it is obviously impossible to trigger any trading signals, but the actual market is likely to have turned upside down. If the missed signal is to open a position, the risk is still controllable. If you miss a closing signal, or even a stop-loss signal, this risk is uncontrollable.

Of course, the above examples are for the convenience of explanation, and the conditions are relatively exaggerated, but we talk about the source of art and life, and the author himself can be 100% responsible for telling everyone about this example, but it must have happened. This is also the reason why the author himself has been frightened all the time, and quickly switched to the main and reinstatement rights.

Therefore, based on the above real scenarios, we found the fatal core point of the index contract. So the next thing we consider is the type and method of reinstatement. The type of weighting refers to the former and the latter, and the method refers to: the difference weighting and the proportional weighting.

As shown in the figure below, the front-recovery right is to move all the data before the red box down to the red box behind the benchmark, and the post-recovery right is vice versa.

Since the operation mechanism of the programmed model is to run from left to right, the previous weighting will cause the historical data to be modified, and the signal records left by the previous model must be recalculated. Re-weight the data and run the calculation again. Let's not talk about the complexity and efficiency of system design, let's talk about the continuous iterative changes of historical data, which in itself is a thing that goes against the logic of normal people, how can new contracts enter, and then the historical data will continue Has it changed?

Secondly, if it is a post-recovery right, you only need a new main contract price after the post-recovery, but the former is all contracts and data. Imagine: 100 years later, will you also be willing to face the history when you switch to a new contract? What about recomputing iterations of centuries or even decades of data?

Therefore, we use the post-recovery right in the type of recovery.

Next, it is the difference re-weighting and proportional re-weighting. The logic of this is also very simple. If the primary and secondary contracts of a certain product always belong to the holy water structure, then the premium will be subtracted after each re-weighting, and the final price will definitely be negative. Therefore, the post-weighted difference weighting cannot be used.

Therefore, we can only use proportional restoration on the basis of post restoration.

In summary of the three articles, the author shares all the problems and solutions, such as the background of the series of articles, the basic path and steps of the research, the problems found, the experience, the details of the real market, etc. , but I believe that the IQ of futures people is supreme, and it is difficult for the big ones, so I will guard against them with wisdom and courage.

The article with this background has come to an end. In the follow-up, the author plans to study the risk parity portfolio of CTA, starting from the logic of risk parity portfolio, rather than the capital management perspective of the reciprocal volatility, to study this long-term investment in the investment community. "Free Lunch".

 

This strategy is only used for learning and communication, and investors are personally responsible for the profit and loss of real trading.

Guess you like

Origin blog.csdn.net/m0_56236921/article/details/123838888