I would like to gather stock data from Yahoo Finance using Python 3.x.
Currently I use the following data strings:
import requests
url = "https://query1.finance.yahoo.com/v7/finance/download/AAC?period1=1514761200&period2=1517439600&interval=1d&events=history&crumb=Nr.jC4aJCc7"
s = "AAC,"
response = requests.post(url)
print ((s),(response.text))
This code gives me the following return:
AAC, Date,Open,High,Low,Close,Adj Close,Volume 2018-01-16,9.370000,9.410000,9.000000,9.060000,9.060000,69400 2018-01-17,9.120000,9.170000,9.000000,9.030000,9.030000,104500 2018-01-18,9.050000,9.135000,8.980000,8.990000,8.990000,166600 2018-01-19,9.000000,9.270000,9.000000,9.200000,9.200000,110600 2018-01-22,9.200000,9.200000,8.940000,9.080000,9.080000,139200 2018-01-23,9.050000,9.110000,9.000000,9.020000,9.020000,54700 2018-01-24,9.070000,9.070000,8.910000,8.950000,8.950000,117500 2018-01-25,9.000000,9.060000,8.900000,9.050000,9.050000,204300 2018-01-26,9.110000,9.240000,9.090000,9.170000,9.170000,62000 2018-01-29,9.170000,9.780000,9.170000,9.500000,9.500000,173300 2018-01-30,9.400000,9.480000,9.000000,9.080000,9.080000,82800 2018-01-31,9.080000,9.250000,8.820000,8.950000,8.950000,122000
I would like to receive the following return:
Ticker,Date,Open,High,Low,Close,Adj Close,Volume, AAC,2018-01-16,9.370000,9.410000,9.000000,9.060000,9.060000,69400 AAC,2018-01-17,9.120000,9.170000,9.000000,9.030000,9.030000,104500 AAC,2018-01-18,9.050000,9.135000,8.980000,8.990000,8.990000,166600 AAC,2018-01-19,9.000000,9.270000,9.000000,9.200000,9.200000,110600 AAC,2018-01-22,9.200000,9.200000,8.940000,9.080000,9.080000,139200 AAC,2018-01-23,9.050000,9.110000,9.000000,9.020000,9.020000,54700 AAC,2018-01-24,9.070000,9.070000,8.910000,8.950000,8.950000,117500 AAC,2018-01-25,9.000000,9.060000,8.900000,9.050000,9.050000,204300 AAC,2018-01-26,9.110000,9.240000,9.090000,9.170000,9.170000,62000 AAC,2018-01-29,9.170000,9.780000,9.170000,9.500000,9.500000,173300 AAC,2018-01-30,9.400000,9.480000,9.000000,9.080000,9.080000,82800 AAC,2018-01-31,9.080000,9.250000,8.820000,8.950000,8.950000,122000
Is there anyone who could help me with this issue?