You can get information on domestic stocks from Yahoo! Finance by using the remote data access function of japandas, but there were various points I wanted to improve, so I made the one I made before during fin-py Mokumokukai # 2. I completed it with.
--Extra records are acquired during the stock split --I also want company information ――I also want financial information
In the japandas implementation, HTML is scraped with ``` pd.read_html ()` ``, but since it simply picks up the table on the screen as it is, it picks up the split event depending on the acquisition period. ..
Example of getting with japandas
import japandas as jpd
jpd.DataReader('8411', 'yahoojp', '2008-12-15', '2009-01-15')
Execution result
Open price | High price | Low price | closing price | Volume | Adjusted closing price* | |
---|---|---|---|---|---|---|
date | ||||||
2008/12/19 | 259400 | 270600 | 253200 | 259900 | 281076 | 259.9 |
2008/12/22 | 266400 | 276000 | 265800 | 270200 | 164024 | 270.2 |
2008/12/24 | 262200 | 268100 | 254400 | 257700 | 96027 | 257.7 |
2009/1/5 | Split:1 share->1000 shares | NaN | NaN | NaN | NaN | NaN |
2009/1/5 | 283 | 294 | 279 | 292 | 91382100 | 292 |
2009/1/6 | 297 | 299 | 287 | 289 | 112779100 | 289 |
2009/1/7 | 293 | 298 | 289 | 296 | 79444700 | 296 |
Not good ... If you want to display the four prices on the chart, you have to modify other than the closing price.
That's why I made it here. It inherits pandas_datareader like japandas, so it can be used in almost the same way. sawadyrr5/YahooJapanDataReader
It seems that it is about 20% faster even if measured with% timeit of Jupyter. Is it because the internal processing is parsed by XPath?
Recommended Posts