[PYTHON] Invest in stocks with large price fluctuations of 1,000 yen or less per share to improve performance


Last year, due to the spread of the new coronavirus, the market price (stock price) went up and down sharply.

Starting with Pfizer's successful vaccine development on November 18, last year, the Nikkei Stock Average continued to hit a high for the first time in about 30 years by the end of 2020.


At present, expectations for business expansion are ahead, and stock prices and current profits are diverging.

In the United Kingdom, a corona mutant spread and the third city blockade was carried out in London. Furthermore, the state of emergency is being reconsidered in Japan, and the spread of infection is still spreading in Japan and around the world.

Therefore, due to the influence of the new coronavirus, it is expected that the stock price will continue to rise and fall sharply.

In this article, based on the fact that stock prices are expected to rise and fall sharply in the future. ** We investigated which stocks can make short-term profits by taking advantage of severe price fluctuations **.

Indicator of the magnitude of stock price movements

There is ** volatility ** as an index showing the range of daily price movements of stock prices. This index is mainly used for short-term trading of individual stocks.

Volatility $ (%) $ is

\frac{True range of the day{\rm TR}}{Typical price of the day{\rm TP}} \times 100 \ (\%)

It can be calculated with.

The typical price TP in the denominator is the average of the high, low, and close prices.

The true range TR of the numerator uses the one with the largest value among the following three ($ {\ rm TR} = \ max (t_1, t_2, t_3) $).

t_1 =High price of the day-Low price of the day
t_2 =High price of the day-The closing price of the previous day
t_3 =The closing price of the previous day-Low price of the day

If the volatility is 5% or more, it can be said that the volatility is relatively high. For stocks with low stock prices, volatility may be high even if the price range is small. It also shows the fluctuation range of the stock price and at the same time shows the risk. Since you can only know the fluctuation range of price movements, you need to look at other indicators at the same time when you actually buy or sell.

result of analysis

We will select stocks with large price fluctuations of 1,000 yen or less per share.

To that end, we first select stocks that meet the following conditions. At the time of selection, the time series data and volume data of stock prices used for the past 90 days from January 5, 2020.

[Brand selection criteria] ・ Listed on the Tokyo Stock Exchange ・ Average daily trading volume of 500,000 shares or more ・ Average daily closing price of 50 yen or more and 1,000 yen or less

The condition of "average daily trading volume of 500,000 shares or more" is to select stocks with a certain amount of trading volume because it is difficult to close a transaction with a stock with a small trading volume. "50 yen or more" of "average closing price of 50 yen or more and 1,000 yen or less per day" is set to "50 yen or more" because the volatility may be high even if the price range is small for stocks with low stock prices. Did.

As a result of selecting stocks under these conditions, there were 242 applicable stocks. Among them, 10 stocks with high volatility are summarized in the table below.

Ranking Securities code trading name Average volatility (%) Average closing price (yen) Average volume Co., Ltd.
1 9878 Sekido 10.8 700.6 573921
2 5337 DANTO HOLDINGS 9.9 502.7 2699480
3 6400 Fuji Seiki 9.2 529.5 2886709
4 1757 Claire Holdings 8.9 70.6 5968157
5 5952 Amatei 8.7 172.6 3114188
6 6659 Media Links 8.3 487.0 1453528
7 3645 Medical net 8.2 747.3 798739
8 2586 Fruta Fruta 7.9 191.5 1508418
9 2191 Terra 7.6 769.2 2084927
10 3071 stream 7.6 140.0 1470286

Since the development of the vaccine, the stock price has gradually risen, and it has more than doubled at one point compared to before the development of the vaccine.

Features: Withdrawal from the home appliance store of the original business and fashion is the pillar. Affiliated with Aucfan, focusing on EC, special events, and wholesale training Yahoo! JAPAN Finance

――Second place. DANTO HOLDINGS (5337) 4-month chart

It seems that active trading is not taking place recently because the trading volume is small. .. ..

Features: A long-established interior and exterior tile. In 2016, sales, manufacturing, investment 3 business integration, main business rebuilding. Real estate management business Yahoo! JAPAN Finance

The stock price has more than quadrupled since the trading became active.

Features: Starting from precision molds, mainly contracted molded products. Widely deployed mainly for 2-wheel and 4-wheel vehicle parts. Factory in Southeast Asia, China Yahoo! JAPAN Finance

in conclusion

Due to the influence of the new coronavirus, it is expected that stock prices will continue to rise and fall sharply in the future.

At this time, it is possible to improve investment performance by investing a part of the investment funds in stocks with high volatility in the short term.

Based on that, I investigated which stocks can be earned in the short term among the stocks that can be bought for less than 1,000 yen per share, that is, less than 100,000 yen.

I have summarized the 1st to 10th places in the above list, but there may be more than double the number of stocks in the above list.

Good use of volatility can help you achieve better investment performance. However, there is a possibility of losing that amount, so let's use other indicators to identify the brand.

The following is a list of articles that have verified stocks and crypto assets so far. If you are interested, I would be grateful if you could take a look.

Past articles
・ [Verify the investment efficiency of all Nikkei 225 stocks](https://qiita.com/MandT500/items/f4aaafa0de824dab92c2) ・ [Can we make use of the fact that 30% of the Nikkei Stock Average is determined by 5 stocks when selecting investment destinations? ](https://qiita.com/MandT500/items/2a1ae0d62118250ed01e) ・ [I want to find a stock that will rise the day after the Nikkei Stock Average rises](https://qiita.com/MandT500/items/55c73b9d46aa39083d1c) ・ [How to avoid risk with scattered investment [2 issues]](https://qiita.com/MandT500/items/594d5a860d21acdd3cf3) ・ [[Time Anomaly] Time zone when stock price rises/falls most in a day](https://qiita.com/MandT500/items/fa906acc11b405e53c52) ・ [Disperse investment products and minimize risk [3 issues]](https://qiita.com/MandT500/items/292d6f5482fe0209cf3f) ・ [I want to find a stock that will rise 5 minutes after the Nikkei Stock Average rises](https://qiita.com/MandT500/items/7c76030c9a67d1172608) ・ [Which crypto assets can be earned efficiently](https://qiita.com/MandT500/items/53c2ff8f48592429effc)

Appendix (Analysis method: Python program)

--Create a stock list

First, create a list of stocks by referring to the "List of stocks listed on the Tokyo Stock Exchange".

Download the Excel file of "List of listed stocks on the Tokyo Stock Exchange (end of November 2020)" from List of stocks listed on the Tokyo Stock Exchange-Tokyo Stock Exchange (as of January 05, 2021).

I think the downloaded file name is data_j.xls.

Open this in Excel and save it in CSV format with "Save As". At this time, the file name should be data_j.csv. Put the file in the folder where you plan to save the program.


date,code,trading name,Market / product classification,33業種code,33 industry categories,17業種code,17 industry categories,規模code,Scale classification
20201130,1301,Polar Ocean,First part of the market (domestic stocks),50,Fisheries / Agriculture and Forestry,1,Food,7,TOPIX Small 2
20201130,1305,Daiwa Exchange Traded Fund-Topics,ETF / ETN,-,-,-,-,-,-
20201130,1306,NEXT FUNDS TOPIX-linked exchange-traded fund,ETF / ETN,-,-,-,-,-,-
20201130,9996,Satoh & Co.,JASDAQ(Standard / domestic stocks),6050,Wholesale business,13,Trading company / wholesale,-,-
20201130,9997,Belluna,First part of the market (domestic stocks),6100,Retail business,14,retail,6,TOPIX Small 1

This operation is because the Python program introduced below reads the file in CSV format.

Even the pandas module of Python can read the Excel file `` .xls```, so if this operation is troublesome, please change the program so that the Excel file can be read directly.

--Create a folder

Create a folder named "data" in the folder where you plan to save the program. We will save the stock price data of each stock in this folder.

--Get stock price data

We will acquire stock price data from Yahoo! Finance based on the stock list data_j.csv. Stock price data is saved in the "data" folder.

You can get the stock price of each stock by executing the following program. There are more than 4,000 stocks in total, and it will take a considerable amount of time to acquire stock prices from 2015 to the present. If it takes a long time to acquire, you may try changing the acquisition period.

Data acquisition of some brands may fail due to a time error, so please try it several times. Brands for which data has already been acquired are skipped and executed.


import glob
import pandas_datareader.data as web
import pandas as pd

#Acquired all TSE stocks
def get_tokyo():
    tokyo = pd.read_csv("data_j.csv", engine="python", names=("date","code", "name","market", "CodeIndustry33", "ClassificationIndustry33", "CodeIndustry17", "ClassificationIndustry17", "CodeScale", "ClassificationScale"), skiprows=1, usecols=[1,2], encoding="utf-8")
    return tokyo
#Stock price acquisition
def get_price_csv(stock_name,start=None,end=None):
    data = web.DataReader(stock_name,"yahoo",start,end)

list_tokyo = get_tokyo()
list_file_exist = glob.glob("./data/*")

for code in list_tokyo.code:
    filename = './data\\'+str(code)+'.T.csv'
    if filename in list_file_exist:
        print(code, 'GET... ', end='')
            get_price_csv(str(code)+'.T', start='2015-1-1')
        except Exception as e:
            print('FAIL:', e)

Execution result

1432 GET... FAIL: No data fetched for symbol 1432.T using YahooDailyReader
1440 GET... FAIL: No data fetched for symbol 1440.T using YahooDailyReader
25935 GET... FAIL: No data fetched for symbol 25935.T using YahooDailyReader
3456 GET... FAIL: No data fetched for symbol 3456.T using YahooDailyReader
3483 GET... FAIL: No data fetched for symbol 3483.T using YahooDailyReader
6695 GET... FAIL: No data fetched for symbol 6695.T using YahooDailyReader
6945 GET... FAIL: No data fetched for symbol 6945.T using YahooDailyReader
7693 GET... FAIL: No data fetched for symbol 7693.T using YahooDailyReader
7790 GET... FAIL: No data fetched for symbol 7790.T using YahooDailyReader
9388 GET... FAIL: No data fetched for symbol 9388.T using YahooDailyReader
9437 GET... FAIL: No data fetched for symbol 9437.T using YahooDailyReader

If the above display appears, all the time series data that can be obtained from Yahoo! Finance can be obtained.

data_j.No data fetched for symbol 9437 because csv contains delisted stocks etc..I get the error T using Yahoo Daily Reader. 9437 is NTT DoCoMo's securities code, but since it was delisted on December 25, 2020, Yahoo!!It can no longer be obtained from finance. data_j.This is happening because csv used the list as of the end of November 2020.

 --Calculate the volatility of each stock
 Calculate the average volatility and volume of all stocks.

 After that, select a brand that meets the [Brand Selection Criteria].

 [Brand selection criteria]
 ・ Listed on the Tokyo Stock Exchange
 ・ Average daily trading volume of 500,000 shares or more
 ・ Average daily closing price of 50 yen or more and 1,000 yen or less

 Finally, the stocks that meet the [Brand Selection Criteria] are sorted in descending order of volatility, and the results are saved in a CSV file called `` `result.csv```.

#### **`analysis_volatility.py`**

import pandas as pd
import glob

def get_tokyo():
    tokyo = pd.read_csv("data_j.csv", engine="python", names=("date","code", "name","market", "CodeIndustry33", "ClassificationIndustry33", "CodeIndustry17", "ClassificationIndustry17", "CodeScale", "ClassificationScale"), skiprows=1, usecols=[1,2], encoding="utf-8")
    return tokyo

#Save the file name of each brand in the list
list_file_exist = glob.glob("./data/*.csv")
#Data frame creation
df_result = pd.DataFrame(columns=['Name','AveVolatility','StdVolatility','AveClose','AveVol'])
#TSE-listed company code, brand name
list_tokyo = get_tokyo()
#Calculate the volatility of each stock
for filename in list_file_exist:
    #Read csv file, latest 90 days
    df = pd.read_csv(filename, usecols=[0,1,2,3,4,5])[-91:-1]
    #True Range, Typical Price
    df_TR = pd.concat([df['High']-df['Low'],df['High']-df['Close'],df['Close']-df['Low']], axis=1).max(axis=1)
    df_TP = pd.concat([df['High'],df['Low'],df['Close']], axis=1).mean(axis=1)
    #Calculate volatility
    df_volatility = df_TR/df_TP*100
    #View results
    #print(pd.concat([df,df_TR,df_TP,df_volatility], axis=1))
    #Volatility mean, standard deviation, closing price mean, volume mean
    df_var_volatility = df_volatility.describe()['std']
    df_ave_volatility = df_volatility.describe()['mean']
    df_ave_close = df['Close'].describe()['mean']
    df_ave_vol   = df['Volume'].describe()['mean']
    #Add results to dataframe
    df_result.loc[filename[7:-6]] \
        = [list(list_tokyo[list_tokyo.code==int(filename[7:-6])].name)[0].replace('\uff0d', '-'),df_ave_volatility, df_var_volatility, df_ave_close, df_ave_vol]

#Limited to stocks with an average trading volume of 100,000 shares or more
df_result_vol100000 = df_result[(df_result['AveVol']>=500000)&(df_result['AveClose']<=1000)&(df_result['AveClose']>=50)]
print(df_result_vol100000.sort_values('AveVolatility', ascending=False))

#Output result,Shift to open in Excel etc._jis save
df_result_vol100000.sort_values('AveVolatility', ascending=False).to_csv('result.csv', encoding="shift-jis")

The following is the result file that is output when `` `analysis_volatility.py``` is executed.


5337,DANTO HOLDINGS,9.92851091994063,5.829129218840265,502.6666666666667,2699480.0
6400,Fuji Seiki,9.232563647851181,7.672251177037584,529.4888888888889,2886708.888888889
1757,Claire Holdings,8.889975863776952,7.016323356057786,70.56666666666666,5968156.666666667
6659,Media Links,8.254688076596251,5.6874328079605885,486.9555555555556,1453527.7777777778
3645,Medical net,8.223274540256988,4.850665328679253,747.3,798738.8888888889
2586,Fruta Fruta,7.912068446987964,7.29850462904478,191.46666666666667,1508417.7777777778
5950,Japan Power Fastening,7.446253747895412,7.0779071007236425,130.16666666666666,1637843.3333333333
4772,Stream Media Corporation,7.40040609365142,4.485065376345073,319.1,869971.1111111111
7625,Global dining,7.314423734014114,7.072805004359223,190.6888888888889,1005386.6666666666
2459,AUN CONSULTING,7.278918564082975,6.233558919862727,233.4111111111111,652956.6666666666
7608,SK Japan,6.917702918007265,6.282340278985323,418.74444444444447,666320.0
3776,BroadBand Tower,6.822772043330271,4.151829727326367,383.7111111111111,6908035.555555556
7448,Jeans mate,6.599137804949079,6.763328689586605,274.74444444444447,780083.3333333334
3556,Renet Japan Group,6.574738312165315,4.017277288743839,576.7111111111111,550920.0
6779,Nihon Dempa Kogyo,6.535959574856966,4.692920736222049,457.7888888888889,655442.2222222222
9508,Kyushu Electric Power,1.7224171026624042,0.6751134425152434,922.9555555555555,1161698.888888889
8601,Daiwa Securities Group Inc.,1.6910960304616955,0.8788866774373107,462.2066667344835,4492950.0
6178,Japan Post,1.6550971289374474,0.6455812899662257,766.626666937934,5703288.888888889
8355,Shizuoka Bank,1.6505290019625318,0.792098756434268,746.7666666666667,1464793.3333333333
7182,Japan Post Bank,1.612183745456123,0.6859743481317608,848.5888888888888,2572678.888888889
5020,ENEOS Holdings,1.5173205855293537,0.6202105245263454,379.30999959309895,16662358.888888888
8628,Matsui Securities,1.5071163588276981,0.6693067820926953,890.8111111111111,673733.3333333334
8306,Mitsubishi UFJ Financial Group,1.499832308077275,0.6679667878012966,440.46333279079863,55239340.0
1671,WTI Crude Oil Price Linked Exchange Traded Fund,1.1440880131986952,0.7287071846639852,864.4333333333333,2514501.388888889

Recommended Posts

Invest in stocks with large price fluctuations of 1,000 yen or less per share to improve performance