Python Forum
Read csv file from Yahoo Finance
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Read csv file from Yahoo Finance
#1
I am trying use of url as below with error. But I tried url manually ok. Please advise. Thanks

import pandas as pd
import numpy as np
url = f'https://query1.finance.yahoo.com/v7/finance/download/X.TO?period1=1410148800&period2=1567915200&interval=1d&events=history&crumb=.ZKRNIaomp4'
a = np.array(pd.read_csv(url,skiprows=7,header=None))
Reply
#2
I got unauthorized error when tried to copy-and-paste the url provided. You probably being logged-in to your yahoo account, when tried to get the data manually?!
Reply
#3
You are absolutely right! I got the error after logging out Yahoo. It says "Unauthorized", "Invalid cookie".
Is there a way to work around this or any other python modules can do it? I would like to retrieve historical market data like below from the csv file and put them in a dataframe. Thanks.

Date Open High Low Close Adj Close Volume
9/10/2018 16121 16147.09961 16057.09961 16057.09961 16057.09961 200681100
9/11/2018 16042.29981 16111.7002 15975.79981 16094.29981 16094.29981 215647000
9/12/2018 16093.29981 16096.09961 15993.59961 16049 16049 266571000
9/13/2018 16059.2002 16071.2002 15987.2002 16001.7002 16001.7002 221711900
9/14/2018 15990.29981 16032.5 15981 16013.5 16013.5 194435900
9/17/2018 16046.5 16118 16045.29981 16082.29981 16082.29981 222709300
9/18/2018 16120.79981 16198.7002 16091.5 16196 16196 228914700
Reply
#4
Find out whether Yahoo offers an HTTP API to access the data.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Pandas read csv file in 'date/time' chunks MorganSamage 4 1,628 Feb-13-2023, 11:24 AM
Last Post: MorganSamage
  Yahoo Premium pogere 1 1,238 Jun-01-2022, 11:42 AM
Last Post: pogere
  Can't read text file with pandas zinho 6 11,935 May-24-2020, 06:13 AM
Last Post: azajali43
  Finance projet - Any Volunteers?? Houssam 2 2,655 Apr-13-2020, 07:14 PM
Last Post: Houssam
  Read file Into array with just $0d as Newline lastyle 5 3,275 Feb-03-2020, 11:58 PM
Last Post: lastyle
  IDE for Finance TIME SERIES Data Trader2013 2 61,358 Jan-19-2020, 04:44 PM
Last Post: danielgoldfarb
  read complex file with both pandas and not Diedro 1 2,850 Jan-29-2019, 05:26 PM
Last Post: Larz60+
  read from txt. file in certain manner SchroedingersLion 13 7,320 Aug-07-2018, 04:14 PM
Last Post: SchroedingersLion
  1 I cant read many stocks(list) with pandas-datareader from yahoo Davidii111 1 4,887 Dec-27-2017, 04:47 PM
Last Post: nilamo
  Downloading data from Yahoo finance Alberto 2 15,244 Jun-26-2017, 04:50 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020