I tried to get stock price data using Quandl API, which provides various financial data of the world by API. I would like to share with you how to use the Quandl API service and your personal impressions of the service. (Because I am stingy, I will introduce the features within the range that can be used for free.)
Quandl API Quandl official website: https://www.quandl.com/
$ pip install Quandl
Tokens can be obtained by registering an account with Quandl.
In the sample code, the stock price of Coca-Cola Company is acquired.
Of course, you can also get data on Japanese stocks.
For example, if you want to get the stock price of Toyota, you can get it by changing `'WIKI / KO'``` to
`'TSE / 7203'```.
sample_quandl.py
import quandl
quandl.ApiConfig.api_key="MY_TOKEN"
data=quandl.get('WIKI/KO')
print(data)
I was able to acquire the stock price from 1962 to 2018. However, as a result of executing it in 2020, it seems that the latest stock price cannot be obtained because only the data up to 2018 can be obtained. (It seems that the latest data cannot be obtained if Japanese stocks are also free versions.)
Open High Low Close Volume ... Adj. Open Adj. High Adj. Low Adj. Close Adj. Volume
Date ...
1962-01-02 101.00 103.7500 101.000 101.00 16800.0 ... 0.262323 0.269465 0.262323 0.262323 1612800.0
1962-01-03 99.50 99.5000 97.250 98.75 32800.0 ... 0.258427 0.258427 0.252583 0.256479 3148800.0
1962-01-04 99.00 100.2500 99.000 99.50 17600.0 ... 0.257128 0.260375 0.257128 0.258427 1689600.0
1962-01-05 99.50 100.7500 97.000 97.25 29600.0 ... 0.258427 0.261673 0.251934 0.252583 2841600.0
1962-01-08 96.50 96.5000 94.380 96.25 42400.0 ... 0.250635 0.250635 0.245129 0.249986 4070400.0
... ... ... ... ... ... ... ... ... ... ... ...
2018-03-21 43.13 43.4500 42.790 43.00 13029766.0 ... 43.130000 43.450000 42.790000 43.000000 13029766.0
2018-03-22 42.88 43.3650 42.700 42.76 12134714.0 ... 42.880000 43.365000 42.700000 42.760000 12134714.0
2018-03-23 42.82 43.1556 42.290 42.33 13190877.0 ... 42.820000 43.155600 42.290000 42.330000 13190877.0
2018-03-26 42.61 42.8099 42.250 42.69 10939927.0 ... 42.610000 42.809900 42.250000 42.690000 10939927.0
2018-03-27 42.70 43.3100 42.525 42.89 11595357.0 ... 42.700000 43.310000 42.525000 42.890000 11595357.0
[14155 rows x 12 columns]
It seems that the latest stock price data cannot be obtained if the Quandl API is the free version. I wanted to create a service that uses the latest stock price data, so I would like to find another API service that can get the latest version of the stock price.
Recommended Posts