SF29丨Magic Adaptive Moving Average + Long-Short Asymmetric Combination

 Committed to sharing quantitative strategies, training videos, Python, algorithm research and other related content.

Big guy, I'm LE CHIFFRE

Today, I will give you a little bit of "hell" (it seems that this stalk is outdated~), wharever~~..., as a preacher to get rid of doubts (self-improvement force [doge]), naturally I have to show you some different points of view and perspective. From the long history, we can see that the changes of every dynasty and era, including industry and commerce, agriculture, and any innovation and development, there is no so-called certain, certain, and must be followed by the rules. Of course, only the constant Following the rules may be the cause of the demise of the dynasty.

Speaking of reality, in the industry of programming, a small branch industry in a large society, often in the subway after get off work, walking in the park, queuing up to pick up the express, every time I think about it, why do we have to do this strategy? Why can't it be that way? Is it really easy to step on overfitting and hard to avoid overfitting? Do you really want to test 10+ years of data? Do you really want one strategy or all strategies take one parameter? Is strategy magic really overfitting? Is exponential backtesting really a toy? Is the slippage of the intermediate frequency CTA product back-testing 1 jump back and forth, and the handling fee is 1.5 million? Is it really not rigorous? Does the strategy have parameters or more than 2 parameters is shit? ...

It's a pity that there are many questions, and I can't put everyone's questions in the article. Some questions have no answers themselves, and I don't think I have the ability to explain them to people at different levels in this industry so that everyone can be convinced. . However, in my opinion, the investment industry is an industry with multiple variables, and there is no need for it. Anyway, in the author's opinion, there is nothing so-called invariable in the world itself, and even the time of the sun's revolution is not constant. Is it really necessary, certain and only necessary to invest in strategies?

1. Does the strategy have to be designed symmetrically?

The so-called strategic symmetrical design is: the entry and exit of long and short are exactly the same logic, but the direction is opposite. I think this kind of thinking or thinking should be what 80%+ people think, expect, and think for a long time not only now but also for a long time. Because I used to think so too. Most of the colleagues and people in the circle who studied and grew up with me also told me the same way. . But until one time I wanted to do a performance attribution to see if the historical performance of the backtest was more contributed by longs or more by shorts? So I split the long and short positions into two workspaces for viewing, and found that in the past 3-4 years, the profit of many is far greater than that of the short. Some people will say, isn't this nonsense, these years have basically increased Yes, it must be more than empty performance, the key point is not here, OK. The core essence of the CTA quantitative strategy: one is risk control, the other is risk control, and the third is TMD risk control. In the past 5 years or 3 years, most of yours are 45 degrees or 30 degrees up, and the air is 30 degrees or 45 degrees down. What about risk control? Obviously, the bigger the problem is the strategy logic, the smaller the problem is the parameter or the time period. There is a very bottom-level soul problem that needs everyone to think about. Is the combination really ABC...Z strategy plus fund management? It is called a combination? Is there no combination of long and short strategy A itself?

Based on the above elaboration, I think everyone knows what I want to express, why not try to combine the strategy itself once by splitting the long and short positions?

2. Do long and short strategies have to be put together?

My personal advice is: it doesn't have to be together. In TBQ, they can be placed in different workspaces, and in VNPY, different processes can be calculated in parallel, all of which can be separated. As shown below:

Many and empty are not the same family, they can be put together or separated. Unless, of course, your strategy is of the all-or-nothing kind. The specific logic and ideas have been described above and will not be repeated here.

Next, we will officially introduce the strategy of the current magic reform adaptive moving average. According to the usual practice, this strategy is still the V1 version. Although it is the V1 version, it still has strong practical significance. In the future, I will provide VIP students with subsequent iterations from time to time according to the actual situation.

I won't introduce too much about the adaptive moving average here. There are all kinds of magic modified versions, and you can Baidu by yourself. But here I still use the well-known Kaufman's adaptive moving average, because I haven't figured out the algorithm for changing the moving average. As shown below:

The characteristics of the adaptive moving average are: slap~soon, one turn up, followed by another turn down. And this is also the reason why I originally chose the "wheel" I wrote to go to the magic modification. First, the magic modification algorithm may be used with a little modification while standing on the shoulders of giants. Second, since Mr. Mu completed the development of SF21, I have been addicted to short-term strategies. Unable to extricate themselves.

Here is the effect of the magic change:      

The red and green lines are modded, and the white line is the base line. The logic of the change is actually very simple. We practice a little logic of the SF26 pivot point, neither the percentage nor the range calculated by so-and-so, but the ATR adaptive volatility. The code is shown below:      

After we calculate the upper and lower tracks of ATR according to the adaptive moving average, we judge the adaptive moving average and the Tup value, and the Tup value comes from the upper track.      

But when we judge that trend=1, the lower rail of the ATR track is the red bullish trend line. Likewise, vice versa.

In terms of exit, we still use the VWAP volume-weighted average, which is more universal, in the SF20 strategy, as shown in the following figure:

Finally, let's first look at the performance mix, as shown in the following figure:      

2021 performance

2020-2021 Performance

Workspace Fee + Slippage

Exploding joke: I never thought someone told me last year: The base price of this corn and nickel is 100 times worse. You set a slippage for corn, and you have to set a 100 tick for nickel. Otherwise it is unreasonable [doge, manual funny]

Scientific, objective and reasonable slippage setting: the difference between the buy-one and sell-one data of each TICK, see the average value. For example, iron ore: if the buy-one is 1000 and the sell-one is 1000.5, then the slippage It is one jump. If it is 1001, it is 2 jumps. For each TICK handicap data, you can get an average value. If the average value is equal to 1 jump, it means that there is no slippage, or the slippage is a set value. Jump. If it is less than 2 jumps, it means that there is slippage in the intraday, then you can count the data for one year or more. See where the final mean and median are, then you can come up with a scientifically reasonable slippage setting for this breed.

Secondly, do you trade hundreds or dozens a day? The few slippages of more than 2 jumps that you can't encounter in a year will frighten you.

The strategy stress test should not come from slippage, this is just a non-core reference, but from the market.

Let's take a look at a few varieties:      

Iron Ore 2016-2021

Palm Oil 2017-2021

PTA 2017-2021

NI 2021-2021

Summary of the review

1. When the long and short entry is a consistent logic, the appearance of course does not have to be consistent, and even the long and short running cycle trajectory is not. Because of the many leeks (including me), everyone's views must be different. So you don't have to say who is right and who is wrong. The idea I insist on is that what you think is not necessarily eternal, and of course there are other people who think that what you think is right.

2. In view of the problem of asymmetric characterization of long and short positions, what I currently think of is that the basic characterization of long and short space and time factors, such as: the length of time for the XXX variety to fall and the length of time to rise. The downside and upside of previous market prices. Of course, if you are using the hourly line, you can also divide the space by the time to see if each unit of time falls and rises, and counts them out.

Secondly, you can also use the de-dimensioned ATR volatility characterization script by Mr. Mu to intuitively and qualitatively observe the fluctuation size and fluctuation cycle of the past two years and the previous two years.

What is a good way to describe the multi-space structure, you can also share and discuss in the group. In a word: if the parameters of 10 years ago are put today, there is a high probability of losing money. There is no Holy Grail. Those who say that there is a Holy Grail are definitely fooling you.

Finally, I put two sets of pictures. In order to make it clearer for everyone, I will take screenshots by month.

Do more in January

Do more in February

Do more in March

Short in January

short in February

short in March

Statistics: From January to April, there are 7 more transactions (the draft will be completed by April 7)

          3 trades right, 3 trades wrong, 1 trade open

         From January to April, open 4 short positions in July

         2 correct and 2 wrong

Long and short combination of 1-4.7 month transaction records (14 transactions)

Because the optimized parameter combination needs to be screened by Sharp, winning percentage, and other rules, the final selected Sharp, maximum drawdown and other performance and risk indicators are not as good as the combination of long and short. If it is not screened, the number of transactions will be twice as many as the separate combination, and the winning rate will be reduced to less than 30%. Overall, from the comprehensive evaluation, the performance of this strategy is much better than that of no separation, and this much better performance is attributed to the optimization of different parameters of long and short, which is equivalent to 3 parameters before and then multiplied by 2 times 6 parameters. As for people who have this kind of thinking, I can't say anything, after all, everyone has different ideas. And I think this is contributed by the separation of the long-short structure, thus achieving the combination upgrade of the strategy itself.

Ok, the strategy of this issue is to pave the way for the next issue. Saying this sentence is not to let yourself down, em....m, and strive to provide you with a more strategic idea of ​​"opening your eyes to see the world" next month.

If you have any questions, welcome to join our squirrel quant, we are waiting for you in the VIP group~     

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/123416310