[PYTHON] Stock price plummeted with "new corona"? I tried to get the Nikkei Stock Average by web scraping

Original article: https://www.octoparse.jp/blog/scraping-stock-prices/

The new coronavirus (COVID-19), which was reported to be infected in China in January 2020, has spread worldwide, and in mid-March, the number of infected people in other countries overtook the number of infected people in China. Due to restrictions on going out in each country, financial markets have moved significantly, and the real economy has also fallen sharply in many countries. The pandemic of the new coronavirus has also caused a significant decline in the stock market.

In this article, I will scrape the Nikkei Stock Average from January to April. This time, we will use the data published on the Yahoo! Finance website. You can refer to the Nikkei Stock Average data for the past 4 months at the following URL.

https://info.finance.yahoo.co.jp/history/?code=998407.O&sy=2020&sm=1&sd=1&ey=2020&em=4&ed=30&tm=d

Let's get started!

Data collection

I often scrape stock price data with Python or API, but Python makes the work complicated and I do not have free API information, so this time it is a scraping tool [Octoparse](https: // www. Use octoparse.jp/).

The latest Version 8.1 has an automatic recognition function for web pages, and the important data can be detected just by entering the above URL. When executed, it can be extracted quickly. 7.gif

Python etc. are relatively fast, but it still takes time to scrape time series data for the past year or more. If you want to analyze a large amount of data when you want to analyze stock prices, use Scraping Tool such as Octoparse. I think it's most efficient to collect. Moreover, it is easy for amateurs to be able to scrape data hands-free.

The following is the acquired data. It's a perfect data format without any organization.

sample data.png

Data analysis

This time I also got the data, so it's not as perfect as the official one, but I made a stock price graph in Excel. 日経平均株価.png

Looking at the graph, the Nikkei Stock Average continued to plunge from 23,386.74 yen on February 21, and hit a short-term bottom of 16,552.83 yen on March 19. With the support of the BOJ's buying, it was on a recovery trend, and returned to a high of 19,546.63 yen on March 25th. It dropped to 18,065.41 yen on April 1, but now the crash has stopped falling and is gradually rising.

Due to the turmoil caused by the spread of the new coronavirus infection, stock markets not only in Japan but also around the world continue to decline. In the US stock market as well, the S & P 500 Index fell by more than 7% shortly after approaching on March 9, 12 and 16, and a circuit breaker was activated to suspend trading for 15 minutes. This measure has been in effect since 1997.

img_f340657b5c7a14f030b33b232a9949bf73254.jpg

Source: Picte Investment Trust Investment Advisory Co., Ltd.

Summary

In the past, the stock market has plunged many times for various reasons, but regarding the spread of the new coronavirus worldwide, the production capacity of factories has declined, the supply chain and transportation network have been blocked, etc. Concerns about the impact on the supply side (supply shock) led to a decline in stock prices. As globalization progresses, if the effects of the new coronavirus continue in some countries, it will affect the economic activities of other countries, and I think that the severe situation will continue.

In any case, I hope that the situation will be resolved as soon as possible and that the crisis of the new coronavirus will be overcome.

Recommended Posts

Stock price plummeted with "new corona"? I tried to get the Nikkei Stock Average by web scraping
I tried to get an image by scraping
I tried to get and analyze the statistical data of the new corona with Python: Data of Johns Hopkins University
I tried to find the average of the sequence with TensorFlow
I tried web scraping with python.
I tried to get started with Bitcoin Systre on the weekend
I tried to predict the number of domestically infected people of the new corona with a mathematical model
Plot the Nikkei Stock Average with pandas
I tried to get started with Hy
765 I tried to identify the three professional families by CNN (with Chainer 2.0.0)
I tried to get the authentication code of Qiita API with Python.
I tried to streamline the standard role of new employees with Python
I tried to get the movie information of TMDb API with Python
I tried to predict the behavior of the new coronavirus with the SEIR model.
I tried to analyze the New Year's card by myself using python
I tried to save the data with discord
I tried to get CloudWatch data with Python
Let's do web scraping with Python (stock price)
I tried to predict the price of ETF
I tried to automatically send the literature of the new coronavirus to LINE with Python
I tried to learn the sin function with chainer
I tried to get started with blender python script_Part 01
I tried to touch the CSV file with Python
I tried to solve the soma cube with python
I tried to get started with blender python script_Part 02
I tried to visualize the characteristics of new coronavirus infected person information with wordcloud
[For beginners] Web scraping with Python "Access the URL in the page to get the contents"
[New Corona] Is the next peak in December? I tried trend analysis with Python!
I tried to solve the problem with Python Vol.1
I tried to aggregate & compare unit price data by language with Real Gachi by Python
Since the stock market crashed due to the influence of the new coronavirus, I tried to visualize the performance of my investment trust with Python.
I tried to rewrite the WEB server of the normal Linux programming 1st edition with C ++ 14
I tried to tabulate the number of deaths per capita of COVID-19 (new coronavirus) by country
I made a class to get the analysis result by MeCab in ndarray with python
I tried to get the number of days of the month holidays (Saturdays, Sundays, and holidays) with python
I want to find a stock that will rise 5 minutes after the Nikkei Stock Average rises
I tried to predict the sales of game software with VARISTA by referring to the article of Codexa
I tried to find the entropy of the image with python
I tried to simulate how the infection spreads with Python
I tried to analyze the whole novel "Weathering with You" ☔️
I tried to get the location information of Odakyu Bus
I tried to notify the train delay information with LINE Notify
I tried to get Web information using "Requests" and "lxml"
[Introduction to simulation] I tried playing by simulating corona infection ♬
I tried to get started with Hy ・ Define a class
[Python] I tried to visualize tweets about Corona with WordCloud
I tried to classify MNIST by GNN (with PyTorch geometric)
I tried to divide the file into folders with Python
I tried to get various information from the codeforces API
I tried scraping with Python
scraping the Nikkei 225 with playwright-python
I tried scraping with python
Get stock price with Python
[Stock price analysis] Learning pandas on the Nikkei average (005: Grouping by year / month-confirmation of statistical information)
I tried to verify the speaker identification by the Speaker Recognition API of Azure Cognitive Services with Python. # 1
I tried to verify the speaker identification by the Speaker Recognition API of Azure Cognitive Services with Python. # 2
I tried to predict the up and down of the closing price of Gurunavi's stock price using TensorFlow (progress)
I tried scraping the ranking of Qiita Advent Calendar with Python
I tried to describe the traffic in real time with WebSocket
I tried to solve the ant book beginner's edition with python
I tried to automate the watering of the planter with Raspberry Pi