i am using Java Yahoo finance api for getting the stock historical data and stats. from past 1 week its not returning the historical data. is there any modification. I am using the following java code to get the historical data
Map<String, Stock> stocks = YahooFinance.get(symbols_array, from, to, Interval.DAILY);
for (int i = 0; i <= index; i++) {
try {
Stock element = stocks.get(symbols_array[i]);
StockQuote element_quote = element.getQuote();
StockStats element_stats = element.getStats();
List<HistoricalQuote> hist_list = element.getHistory();
}
catch(Exception e){}
}
As an alternate, you can use this url -
https://query2.finance.yahoo.com/v8/finance/chart/NHPC.NS?formatted=true&crumb=6iPfwrHM.4i&lang=en-IN®ion=IN&period1=1501563799&period2=1502254999&interval=1d&events=div|split&corsDomain=in.finance.yahoo.com
This is the URL requested by your browser to https://in.finance.yahoo.com/ when you make a historical search of a stock in the Yahoo Finance Site.
Check the screenshot -

The parameters that one have to change in the Script name, and the duration. I was looking for the historical stock price of NHPC in NSE, that's why the script name is NHPC.NS
For setting the duration, you need to change the value of the parameters period1 and period2, period1 is start date and period2 is end date. The value of both the date parameters is in Unix epoch time. For converting Human Date to Unix epoch time check the tool: https://www.epochconverter.com/
In the URL that I have posted above, I am looking for the duration from 1st Aug to 9th Aug.
1-Aug-2017 (IST) - 1501563799
9-Aug-2017 (IST) - 1502254999
After you modify the above URL according to your criteria, make a Get request and you will get a Json Response which would something like this -

Now you can just write a Json parser for the response in your favorite language and use the historical data in your project accordingly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With