webread not reading the full query data from Yahoo Finance

9 views (last 30 days)
I have a query url from Yahoo Finance to read historical stock price data. The url is:
where, TITAN.NS is the name of the stock. Opeing this url in the browser shows data from time periods (in unix format) 1230661800 (1-1-2009) till 1596565800 (4-8-2020). However running the code:
url = 'https://query1.finance.yahoo.com/v8/finance/chart/TITAN.NS?symbol=TITAN.NS&period1=1230661800&period2=1596565800&interval=1d&includePrePost=true&events=div%2Csplit'
data = webread(url)
fetches only the last timestamp data. Replacing TITAN.NS with another stock ticker such as BAJFINANCE.NS (Bajaj Finance Ltd.), I am able to get all timesatmps and corresponding prices. Not sure why this is happening. Any help on this would be much appreciated.
  1 Comment
Image Analyst
Image Analyst on 8 Jun 2021
What I got was an error:
Error using matlab.internal.webservices.HTTPConnector/copyContentToByteArray (line 373)
The server returned the status 403 with message "Forbidden" in response to the request to URL
https://query1.finance.yahoo.com/v8/finance/chart/TITAN.NS?symbol=TITAN.NS&period1=1230661800&period2=1596565800&interval=1d&includePrePost=true&events=div%2Csplit.
Error in readContentFromWebService (line 46)
byteArray = copyContentToByteArray(connection);
Error in webread (line 125)
[varargout{1:nargout}] = readContentFromWebService(connection, options);
Error in test1 (line 2)
data = webread(url)

Sign in to comment.

Answers (0)

Categories

Find more on Financial Toolbox in Help Center and File Exchange

Products


Release

R2017b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!