[Quantitative] Verify the cyclical theory of "Stock Market Trading Guide"

origin

Insert image description here

When the market plummeted on July 26 this year, a big guy in the Hulu Group came up with a picture. I was very shocked when I read it because the author predicted this decline:

Insert image description here

Although it is not always correct, the big guys in the group said it was a magical book. Out of curiosity, I opened it and read it, and found that the author concluded that "A-shares have a 10-year cycle." Even though they did not understand the author's argument, But at a glance it seems to make sense, so let’s verify it!

Author’s opinion and verification

Author's point of view

The author's point of view: China's stock market follows a 10-year cycle. A bull market begins in Year C of the lunar calendar . Year D continues to Year Xin after adjustment. Year Rengui is a bear market, and Year B breeds a bull market.

Since the author's calculation method is based on the Heavenly Stems calendar, and there are 10 Heavenly Stems, each year can correspond to the mantissa of the AD calendar year, which can be organized into this table:

Time flies The last digit of AD market conditions
Geng 0 structure bear
Spicy 1 bear market
the ninth of the ten Heavenly Stems 2 bear market
Gui 3 bear market
First 4 Bear to Bull conversion
Second 5 Bear to Bull conversion
C 6 ox
Man 7 Bull+Bear conversion
E 8 big bear
Has 9 ox

verify

The content of the preliminary verification is the ten-year cycle proposed by the author . It is not the previous content that is accurate to the month and day. The main reason is that the first impression given by those things cannot be 100% correct, and if this cycle has a certain general If there are rules to follow, it will be of great help to the timing of our strategies.

My verification idea is:

  1. Download the data of the Shanghai Composite Index and the CSI 300 Index (this is covered in the course, if you are too lazy to crawl, you can go to the website) and convert it into the chronology of the zodiac signs and branches;
  2. Calculate the rise and fall, amplitude, number of rising days, number of falling days and other indicators for each year (classified by year of stems and branches, the same below), and make a preliminary judgment based on the author's conclusion;
  3. Draw annual charts and make subjective judgments (didn’t we agree that we are doing quantification);
Preparation
  • Crawl index data

At present, the earliest data we can obtain for the Shanghai Composite Index is December 1990 (from Sina Finance), and the earliest data for the CSI 300 Index is April 2005.

  • Download a library that can convert to lunar time

I use this library

The converted CSI 300 Index looks like this:

Insert image description here

process

First, let’s make descriptive statistics based on the chronology of the stems and branches:

df_all = pd.DataFrame()
df_all['year'] = list(set(df001['year']))
for i in list(set(df001['year'])):
    df_all.loc[df_all['year'] == i, 'candle_begin_time'] = df001.loc[df001['year'] == i, 'candle_end_time'].iloc[0]
    df_all.loc[df_all['year'] == i, 'candle_end_time'] = df001.loc[df001['year'] == i, 'candle_end_time'].iloc[-1]
    df_all.loc[df_all['year'] == i, '涨跌幅'] = round(df001.loc[df001['year'] == i, 'close'].iloc[-1] / df001.loc[df001['year'] == i, 'close'].iloc[0] - 1, 2)
    df_all.loc[df_all['year'] == i, '振幅'] = round(df001.loc[df001['year'] == i, 'close'].max() / df001.loc[df001['year'] == i, 'close'].min(), 2)
    df_all.loc[df_all['year'] == i, '上涨天数'] = len(df001.loc[(df001['year'] == i) & (df001['close_change'] >= 0), 'close_change'] )
    df_all.loc[df_all['year'] == i, '下跌天数'] = len(df001.loc[(df001['year'] == i) & (df001['close_change'] < 0), 'close_change'] )
df_all['上涨天数-下跌天数'] = df_all['上涨天数'] - df_all['下跌天数']
df_all.sort_values(['candle_begin_time'])

The result is as follows:

year candle_begin_time candle_end_time Quote change amplitude rising days Down days Number of rising days - number of falling days
Gengwu 1990/12/19 1991/2/14 0.07 1.07 39 1 38
Xin Wei 1991/2/19 1992/1/31 0.12 1.12 180 57 123
Renshen 1992/2/7 1993/1/22 7.09 10.43 69 14 55
Guiyou 1993/1/27 1994/2/4 -0.31 2.04 129 138 -9
Jiaxu 1994/2/14 1995/1/27 -0.28 3.09 100 146 -46
Yi Hai 1995/2/6 1996/2/16 0.04 1.74 128 138 -10
Bingzi 1996/3/4 1997/1/31 0.6 2.25 129 106 23
Ding Chou 1997/2/17 1998/1/23 0.24 1.68 137 99 38
Wuyin 1998/2/9 1999/2/9 -0.13 1.33 118 140 -22
Ji Mao 1999/3/1 2000/1/28 0.4 1.64 120 111 9
Gengchen 2000/2/14 2001/1/19 0.23 1.33 136 98 38
Xin Si 2001/2/5 2002/2/8 -0.25 1.65 123 129 -6
Renwu 2002/2/25 2003/1/29 -0.02 1.31 116 115 1
Guiwei 2003/2/10 2004/1/16 0.08 1.24 114 118 -4
Jiashen 2004/1/29 2005/2/4 -0.22 1.5 113 143 -30
Yiyou 2005/2/16 2006/1/25 -0.02 1.3 118 116 2
Bingxu 2006/2/6 2007/2/16 1.33 2.41 166 91 75
Dinghai 2007/2/26 2008/2/5 0.51 2.2 150 85 65
Wuzi 2008/2/13 2009/1/23 -0.56 2.73 101 135 -34
Ji Chou 2009/2/2 2010/2/12 0.5 1.73 157 102 55
Gengyin 2010/2/22 2011/2/1 -0.07 1.34 119 114 5
Xin Mao 2011/2/9 2012/1/20 -0.16 1.42 112 124 -12
Renchen 2012/1/30 2013/2/8 0.06 1.26 133 123 10
Guisi 2013/2/18 2014/1/30 -0.16 1.24 110 123 -13
Jiawu 2014/2/7 2015/2/17 0.59 1.7 148 108 40
Yiwei 2015/2/25 2016/2/5 -0.14 1.95 133 104 29
Bingshen 2016/2/15 2017/1/26 0.15 1.22 130 107 23
Ding You 2017/2/3 2018/2/14 0.02 1.17 154 104 50
Wuxu 2018/2/22 2019/2/1 -0.2 1.35 105 129 -24
Jihai 2019/2/11 2020/1/23 0.12 1.23 125 112 13
Gengzi 2020/2/3 2021/2/10 0.33 1.37 140 115 25
Xin Chou 2021/2/18 2021/7/30 -0.08 1.1 54 58 -4

The following is the situation of CSI 300:

year candle_begin_time candle_end_time CSI 300 rise and fall CSI 300 Amplitude CSI 300 rising days CSI 300 falling days CSI 300 rising days - falling days
Yiyou 2005/2/16 2006/1/25 0.01 1.23 103 93 10
Bingxu 2006/2/6 2007/2/16 1.59 2.67 166 91 75
Dinghai 2007/2/26 2008/2/5 0.82 2.39 151 84 67
Wuzi 2008/2/13 2009/1/23 -0.58 3.08 104 132 -28
Ji Chou 2009/2/2 2010/2/12 0.58 1.84 164 95 69
Gengyin 2010/2/22 2011/2/1 -0.05 1.41 119 114 5
Xin Mao 2011/2/9 2012/1/20 -0.18 1.48 109 127 -18
Renchen 2012/1/30 2013/2/8 0.13 1.32 130 126 4
Guisi 2013/2/18 2014/1/30 -0.2 1.27 105 128 -23
Jiawu 2014/2/7 2015/2/17 0.59 1.75 140 116 24
Yiwei 2015/2/25 2016/2/5 -0.15 1.88 132 105 27
Bingshen 2016/2/15 2017/1/26 0.15 1.24 126 111 15
Ding You 2017/2/3 2018/2/14 0.18 1.32 148 110 38
Wuxu 2018/2/22 2019/2/1 -0.2 1.39 105 129 -24
Jihai 2019/2/11 2020/1/23 0.21 1.27 121 116 5
Gengzi 2020/2/3 2021/2/10 0.57 1.65 147 108 39
Xin Chou 2021/2/18 2021/7/30 -0.17 1.22 59 53 6

Then we took a rough look at it based on the table above. I browsed it again and found that it was basically the same.

For example, the author emphasized that the year of Bing and Ding was the starting point of a bull market. In 1996 and 2006, there was an increase of more than 50%. In 1997 and 2007, the index also increased by more than 20%. Only in 2016 and 2017, the increase was smaller. But they are all positive; then look at the correction growth rates after the bull market in Year 5 are all negative; and in Year 9, the bull market specified by the author, there are also relatively large increases, but relatively speaking, the increase in 2019 is smaller; Then look at the Geng Year, it is said that there was a market, and only one of the four times was negative; only the Renshen Year of 1992 was originally a bear market, but the market performed very well, and the final increase was 7 times (but this year is quite special, specifically I don’t know why).

Ok, after the first round of judgment, we tentatively think that the author's conclusion is reasonable to a certain extent. Next, we will further understand it in the form of charts.

plt.figure(figsize=(15, 38))
var1 = ['丙', '丁', '戊', '己', '庚', '辛', '壬', '癸', '甲', '乙']
var_temp = 0
for o in var1:
    ax = plt.subplot(10, 1, var_temp+1)
    for i in list(filter(lambda x: x.startswith(o), set(df001['year']))):
        temp = df001.loc[df001['year']==i, 'close'].reset_index(drop=True)
        temp['curve'] = (1+temp.pct_change()).cumprod()
        ax.plot(temp['curve'], label=i)
        plt.legend()
    var_temp += 1
    
plt.savefig('picture.png')
plt.show()

Get a picture like this:

Insert image description here

This is the CSI 300:

Insert image description here

At this point, I found that if I want to affirm the author's conclusion, some years obviously do not support it. For example, the Renshen year soared in 1992, and the author proposed that the Renshen year was a bear market. If I want to deny the author's conclusion, there is insufficient evidence. , the author’s conclusion that years Bing and D were all bull markets, Years Wu was a bear market, and Year Ji was a bull market are indeed the same. It’s just that the so-called bull markets in recent years have seen relatively small increases and decreases, so there are also explanations for the different geological zones. The combinations come in different strengths and weaknesses. For example, the author mentioned that the year 26 is the Bingwu year, the noon fire is the purest fire, and the heavenly stems and earthly branches are all wealth, so it is a very strong bull market.

in conclusion

As for what it does for our strategy? I personally haven’t found a particularly good auxiliary method. The only useful method is to avoid the big drop after the big rise in Ding year, that is, Wu year. But in the bear market in the third year of Xin Rengui mentioned by the author, I think many strategies can make money. , and the big bull market in years B and D was not the time when each strategy performed best. The author said that the year A and B during the bear-bull transition were the years when many strategies made the most money.

In addition, not every year B and D is a bull market. For example, the recent one is not. It is a bull market composed of years A and B in 14 and 15. 16 and 17 are just small bulls that went from 2,600 to 3,500.

In short, the current sample data is too small, only three cycles, and the author's description of the cycle is not very quantitative. Our verification cannot 100% confirm or deny his conclusion. There is uncertainty in using his policy completely. Of course, everyone has different opinions on benevolence and wisdom.

Guess you like

Origin blog.csdn.net/food_for_thought/article/details/121190655