Investigate the top 10 stocks raised at the time of the first state of emergency


Synopsis
The first state of emergency was issued on April 7, 2020 to the seven prefectures of Tokyo, Kanagawa, Saitama, Chiba, Osaka, Hyogo, and Fukuoka, and on April 16 the target was It was expanded nationwide. Furthermore, following the rapid spread of infection from around the end of 2020, a second state of emergency was issued on January 7, 2021, targeting the three prefectures of Tokyo, Saitama, Chiba, and Kanagawa.

We will examine the effect of this ** state of emergency on stock prices **. In addition, the period will be set by increasing or decreasing the number of newly infected coronaviruses, and the number of coronaviruses infected and the stock price will also be verified.

[Conclusion] ・ Investigate the top 10 stocks whose stock prices rise as the number of people infected with corona increases ・ The TOP10 stocks that went up at the time of the first state of emergency are rising ** out of 10 stocks from the day when the second state of emergency was requested **

Trigger

The new coronavirus was first confirmed in Wuhan, China on November 22, 2019, and as of January 9, 2021, a total of about 90 million people have been infected worldwide, and 270,000 people in Japan have been infected. The first state of emergency was issued on April 7, 2020 to the seven prefectures of Tokyo, Kanagawa, Saitama, Chiba, Osaka, Hyogo, and Fukuoka, and on April 16th. Has been expanded nationwide. After that, the target area was reduced due to the infection situation, etc., and it was lifted nationwide on May 25. However, due to the rapid spread of infection from around the end of 2020, the second state of emergency was issued on January 7, 2021, targeting the three prefectures of Tokyo, Saitama, Chiba, and Kanagawa.

I wanted to know the effect of this ** state of emergency on stock prices **, so I came to the verification.

In addition, we will set a period by increasing or decreasing the number of newly infected coronaviruses as follows, and verify the fluctuation of stock price during that period.

period_all.png [Period setting] Increase ①: 2020/1/16 ~ 2020/4/11 Decrease ①: 2020/4/15 ~ 2020/6/25 Increase ②: 2020/6/25 ~ 2020/8/9 Decrease ②: 2020/8/9 ~ 2020/10/27 Increase ③: 2020/10/27 ~ 2020/1/4

Verification content

Verification is easy because of stock screening (screening) during a specific period. For all 4088 stocks listed on the Tokyo Stock Exchange, the amount of change during that period is calculated and shown in a ranking format.

[Verification period] ① The first state of emergency (2020/4/7 ~ 2020/5/25) (2) Period during which the number of newly infected persons increased (increase in the above figure ① + increase ② + increase ③) ③ Period when the number of newly infected people decreased (decrease ① + decrease ② in the above figure)

[Target brand] All 4088 stocks listed on the Tokyo Stock Exchange

【Method of verification】 ① simply finds the rate of change during the period of the first state of emergency. For (2) and (3), calculate the rate of change in each period and add them together. The volatility is as follows.

Rate of change[\%]=\frac{Closing price for a period-Opening price for a certain period}{Opening price for a certain period}\times100

Furthermore, in order to find stocks that are susceptible to the new coronavirus, all the rates of change in (1), (2), and (3) are added together to calculate "** susceptibility **".

Susceptibility=(Rate of change in period ①)+(Rate of change in period ②)-(Rate of change in period ③)

The higher the value of "susceptibility", the higher the stock price as the number of people infected with corona increases. Conversely, the smaller the stock, the higher the stock price when the number of people infected with corona decreases.

Python validation program listed at the end of the article

inspection result

Below are the top 10 rising stocks at the time of the state of emergency in period (1) and the top 10 stocks whose stock prices rise as the number of corona-infected persons determined from "susceptibility" increases. Other results will be given at the end of the article.

▼ ① Top 10 stocks raised at the time of the state of emergency roc_s_e_10_False.jpg ▼ TOP 10 stocks whose stock price rises as the number of people infected with corona increases total_10_False.jpg

[The following results are summarized at the end] ・ ① Top 10 stocks that went down when an emergency was declared ・ ② Top 10 brands that went up during the period when the number of newly infected people increased ・ ② Top 10 brands that fell during the period when the number of newly infected people increased ・ ③ Top 10 brands that went up during the period when the number of newly infected people decreased ・ ③ TOP10 brands that fell during the period when the number of newly infected people decreased ・ Top 10 stocks whose stock price rises as the number of people infected with corona decreases

Additional verification

Check if the above 20 stocks have risen since January 2, 2021, when Governor Koike of Tokyo requested a second state of emergency. Since the exchange is closed on the 1st to 3rd, the rate of change in the stock price was calculated using the data for 5 days from January 4th to 8th, 2021.

【result】 ・ The TOP10 stocks that went up at the time of the first state of emergency were ** 9 out of 10 stocks went up ** ・ The top 10 stocks whose stock prices rise as the number of people infected with corona increased, 6 out of 10 stocks rose. ⇒ The number of stocks that go up as the number of people infected with corona increases does not mean that the number of stocks that go up will rise just because an emergency declaration is issued. ⇒The stocks that went up at the time of the first state of emergency are going up again this time when the state of emergency is declared.

▼ Rate of change due to the 2nd State of Emergency add_result.png

Summary

In order to know the effect of the state of emergency on stock prices, we screened all 4088 stocks listed on the Tokyo Stock Exchange. ・ Top 10 stocks raised at the time of the 1st state of emergency ・ Top 10 stocks whose stock price rises as the number of people infected with corona increases We also calculated the rate of change from the date when the second state of emergency was requested to the present (January 8, 2021). Then, it was found that 9 of the TOP10 stocks that were raised at the time of the first state of emergency are still rising. On the contrary, it was confirmed that the top 10 stocks that rise as the number of people infected with corona increases are 6 stocks, and that the declaration of an emergency does not mean that the stocks will rise.

Currently, the number of people infected with corona is increasing rapidly. ・ Top 10 stocks whose stock price rises as the number of people infected with corona decreases By checking the trends of the stocks ranked in, I think it can be used for selecting investment destinations in the future.

next

I would like to examine something about the soaring virtual currency. Since it is clear that Bitcoin is the leading index of Altcoin for virtual currencies, I would like to take a closer look using data. We also verified how much technical analysis such as Golden Cross can actually be relied on.

Future plans ・ Investigate the relationship between Bitcoin and Altcoin ・ How much will it actually go up after the Golden Cross?

Verification program

Finds the rate of change for the specified period.

python


import pandas as pd
import datetime
#I have put together my own functions for stock price analysis (I will introduce them all together)
from trade_module import trade_module as tm

#Obtained the code and name of a stock listed on the Tokyo Stock Exchange
list_tokyo = tm.get_tokyo()

#Setting the verification period
date1 = datetime.datetime(2020, 1, 16, 0, 0, 0, 0)
date2 = datetime.datetime(2020, 4, 11, 0, 0, 0, 0)
date3 = datetime.datetime(2020, 6, 25, 0, 0, 0, 0)
date4 = datetime.datetime(2020, 8, 9, 0, 0, 0, 0)
date5 = datetime.datetime(2020, 10, 27, 0, 0, 0, 0)
date6 = datetime.datetime(2021, 1, 4, 0, 0, 0, 0)
date = [date1,date2,date3,date4,date5,date6]

#Create a data frame to put the result
col = ["code","name","up1","down1","up2","down2","up3"]
result = pd.DataFrame(columns=col)
result.code = list_tokyo.code
result.name = list_tokyo.name

#Calculate the rate of change for the specified period
for i in range(len(result.code)):
    #Read the prepared data
    data = pd.read_csv("data/"+str(result.code[i])+".T.csv",index_col=0,usecols=[0,4],parse_dates=True)
    #Calculate the rate of change for stocks with data for the specified period
    if(data.index[0] <= date1 and data.index[-1] == date6):
        for j in range(len(date)-1):
            price_s = data.Close[date[j]:date[j+1]][0]
            price_e = data.Close[date[j]:date[j+1]][-1]
            result.at[i,col[j+2]] = (price_e-price_s)/price_s*100

#Output csv file
result.to_csv("result.csv", encoding="utf_8_sig")

List of verification results

▼ ① Top 10 brands that went down when an emergency was declared roc_s_e_10_True.jpg

▼ ② Top 10 brands that went up during the period when the number of newly infected people increased sum_up_10_False.jpg

▼ ② Top 10 brands that fell during the period when the number of newly infected people increased sum_up_10_True.jpg

▼ ③ Top 10 brands that went up during the period when the number of newly infected people decreased sum_down_10_False.jpg

▼ ③ Top 10 brands that fell during the period when the number of newly infected people decreased sum_down_10_True.jpg

▼ Top 10 stocks whose stock price rises as the number of people infected with corona decreases total_10_True.jpg

Recommended Posts

Investigate the top 10 stocks raised at the time of the first state of emergency
At the time of python update on ubuntu
Grep so that grep does not appear at the time of grep
Summary of stumbling blocks in Django for the first time
Introducing yourself at Qiita for the first time (test post)
Kaggle for the first time (kaggle ①)
Kaguru for the first time
Verification of the spread of hoaxes in the "State of Emergency Declaration on April 1"
First Python 3 ~ The beginning of repetition ~
Get the first element of queryset
[For self-learning] Go2 for the first time
Process the result of% time,% timeit
See python for the first time
Start Django for the first time
Get a datetime instance at any time of the day in Python