Git Product home page Git Product logo

yahoofinance-api's People

Contributors

alexanderhagenhoff avatar apete avatar chenwoon avatar dependabot[bot] avatar hoffs avatar jaredsburrows avatar mwlazlo avatar randle2000 avatar sekodevlp avatar sfuhrm avatar shahmharsh avatar sstrickx avatar thomasquintana avatar vadimjoukrewe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yahoofinance-api's Issues

Price updates

Is there a way to listen to delayed price updates?

stats.getMarketCap() should be NaN instead of 0

When fetching a ticker that does not exist, I noticed that stats.getMarketCap() returns 0.
This should be NaN.
Probably this issue is more general. If something is not available, the value should be NaN instead of 0. For values like dividend, this distinction is important.

Coversion Error for Symbol=TFSCR

dividendRating=IGNORE
Exception in thread "Timer-0" java.lang.ArithmeticException: / by zero
at java.math.BigDecimal.divideAndRound(BigDecimal.java:4106)
at java.math.BigDecimal.divide(BigDecimal.java:5153)
at java.math.BigDecimal.divide(BigDecimal.java:1561)
at yahoofinance.Utils.getPercent(Utils.java:138)
at yahoofinance.quotes.stock.StockQuote.getChangeFromAvg200InPercent(StockQuote.java:118)
at com.jnd.analysis.StockAnalysisBatchClass.processMarginOfSafety(StockAnalysisBatchClass.java:64)
at com.jnd.analysis.StockAnalysisBatchClass.processStockFundamentals(StockAnalysisBatchClass.java:50)
at com.jnd.stocksparser.StockBatchProcess.startStockDetailsProcess(StockBatchProcess.java:41)
at com.jnd.stocksparser.StockBatchProcess.triggerStockBatchProcess(StockBatchProcess.java:61)
at com.jnd.stocksparser.Main.run(Main.java:68)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)

Add timezone for .VX

yahoofinance.exchanges.ExchangeTimeZone get: Cannot find time zone for exchange suffix: 'VX'.
Using default: America/New_York

Timezone for .VX (Switzerland) is Central European Time

Error while parsing double 77K

ANother error but I dont know where it is coming from . Hope this trace helps:-
INFO: Parsing CSV line: "Biocept, Inc.","BIOC","USD","NCM",2.90,2.90,"BIOC",10,"BIOC",N/A,0.00,"BIOC",N/A,"BIOC",2.4492,"BIOC",500,"BIOC","1/23/2015","3:59pm",2.59,2.50,2.34,2.59,23219,21897,10.02,2.27,2.7091,3.6116,"BIOC", 4,449,000,"BIOC","BIOC",-,"BIOC",10.9M,"BIOC", 2,406,000,"BIOC","N/A","N/A",0.00,N/A,-4.94,-3.99,-0.75,-2.08,N/A,N/A,3.32,145.21,0.752,77K,-12.0M,13.50
Jan 25, 2015 9:50:12 AM yahoofinance.Utils getDouble
INFO: Failed to parse: 77K
java.lang.NumberFormatException: For input string: "77K"
at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)
at java.lang.Double.parseDouble(Double.java:538)
at yahoofinance.Utils.getDouble(Utils.java:59)
at yahoofinance.quotes.stock.StockQuotesData.getStats(StockQuotesData.java:78)
at yahoofinance.quotes.stock.StockQuotesData.getStock(StockQuotesData.java:104)
at yahoofinance.YahooFinance.getQuotes(YahooFinance.java:336)
at yahoofinance.YahooFinance.get(YahooFinance.java:76)
at yahoofinance.YahooFinance.get(YahooFinance.java:61)

Maven repo

Great API you have made there ๐Ÿ‘

I think however this api should be made available from maven repository. It is kind a hard to include in a project today when you do not have your own local repository.

Utilsjava throws Unparseable date exception for the symbol -> JCP

IT looks like it is giving an Unparseable exception for JCP.

I am trying to fetch the DividendYield detaills and it seems to come when it tries to parse the dividend date. I tried to use the trim() but it still fails.
Jan 25, 2015 7:21:36 AM yahoofinance.quotes.QuotesRequest getResult
INFO: Sending request: http://finance.yahoo.com/d/quotes.csv?s=JCP&f=n0sc4x0a0b2sa5sb0b3sb6sl1sk3sd1t1o0p0g0h0v0a2k0j0m3m4sj2sss1sj1sf6sr1q0d0y0e0e7e9e8r0r5p6p5b4s6j4t8&e=.csv
Jan 25, 2015 7:21:37 AM yahoofinance.quotes.QuotesRequest getResult
INFO: Parsing CSV line: "J.C. Penney Compa","JCP","USD","NYSE",N/A,7.75,"JCP",N/A,"JCP",N/A,6.75,"JCP",N/A,"JCP",7.52,"JCP",N/A,"JCP","1/23/2015","4:01pm",7.50,7.49,7.38,7.58,6920662,16251600,11.30,4.90,6.9094,8.43,"JCP", 304,851,000,"JCP","JCP",-,"JCP",2.292B,"JCP", 290,676,000,"JCP"," 1-May-12"," 5-Apr-12",0.00,N/A,-2.219,-2.54,-0.72,-1.36,N/A,0.11,0.94,0.19,7.972,12.146B,30.0M,8.22
Jan 25, 2015 7:21:37 AM yahoofinance.Utils parseDividendDate
SEVERE: Unparseable date: "1-May-12"
java.text.ParseException: Unparseable date: "1-May-12"
at java.text.DateFormat.parse(DateFormat.java:366)
at yahoofinance.Utils.parseDividendDate(Utils.java:124)
at yahoofinance.quotes.stock.StockQuotesData.getDividend(StockQuotesData.java:87)
at yahoofinance.Stock.update(Stock.java:44)
at yahoofinance.Stock.getStats(Stock.java:126)
at yahoofinance.Stock.getStats(Stock.java:104)
at com.jnd.stocksparser.StockAnalysisBatchClass.processBuffetRating(StockAnalysisBatchClass.java:80)
at com.jnd.stocksparser.StockAnalysisBatchClass.main(StockAnalysisBatchClass.java:241)

Jan 25, 2015 7:21:37 AM yahoofinance.Utils parseDividendDate

Thanks,
JItesh

Returns NULL pointer instead of the looked up symbol on single-symbol get...

StockQuotesRequest.parseCSVLine() will scramble the stock symbol if the first token isn't (Stock name) isn't enclosed in quotes -- and it currently isn't.

A quick and dirty kludge was to do this:
int pos1 = 0;
int pos2 = 0;
if (line.startsWith("""))
{
pos1 = 1; // skip first "
pos2 = line.indexOf('"', 1);
}
else
{
pos1 = 0;
pos2 = line.indexOf(",", pos1);
}

and:
String symbol = fullSymbol.substring(1, fullSymbol.length() - 1);
becomes
String symbol = fullSymbol.substring(0, fullSymbol.length() - 1);

Support of Indice

Does this API support Index? If not is there any plan to support index in future releases?

Index data are available in Yahoo Finance.

unnecessary warning

Minor: Warning message: yahoofinance.Utils getBigDecimal: Failed to parse: nan

I think this warning is not really needed. If the csv service returns a NaN, the result should just be NaN

Yahoo finance doesn't always use the time zone "America/New_York"

SGX, (exchange code: SES) stock quote data is using the SGT (GMT +8) timezone. For example, the downloaded price for the "D05.SI" Last trade time is as the following. The time is SGT (GMT +8), not the "America/New_York".

So YahooFinance.TIMEZONE should be configurable for the different market.

image

Detecting failures

I find difficult to distinguish an empty result from a genuine failure, I think when the quote request fail there should be an indication, either an exception or something like a Try object like in Scala....

specifically the part:

 } catch (IOException ex) {
        YahooFinance.logger.log(Level.SEVERE, ex.toString(), ex);
    }

Null Values

Hi, thanks for this API been looking for something this simple.

It is not getting data however and when I run
Stock stock = new Stock("INTC");
stock.print();
All fields are left null (Except symbol = INTC)

Any idea why it isn't getting data?

java.lang.StringIndexOutOfBoundsException: String index out of range: -1

Source:

package asd.cc;

import java.io.IOException;
import java.math.BigDecimal;

import yahoofinance.Stock;
import yahoofinance.YahooFinance;

public class Sstocks {

public static void main (String[] args)
{

    try {
        Stock stock = YahooFinance.get("INTC");

        stock.print();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        System.out.println("error: "+e);
    }
}

}

Error ๐Ÿ‘
Apr 10, 2016 11:02:38 AM yahoofinance.quotes.QuotesRequest getResult
INFO: Sending request: http://finance.yahoo.com/d/quotes.csv?s=INTC&f=nsc4xab2sa5sbb3sb6sl1sk3sd1t1opghva2kjm3m4sj2sss1sj1sf6sr1qdyee7e9e8rr5p6p5b4s6j4t8s7&e=.csv
Apr 10, 2016 11:02:38 AM yahoofinance.quotes.QuotesRequest getResult
INFO: Parsing CSV line:
Exception in thread "main" java.lang.StringIndexOutOfBoundsException: String index out of range: -1
at java.lang.String.substring(Unknown Source)
at yahoofinance.quotes.stock.StockQuotesRequest.parseCSVLine(StockQuotesRequest.java:126)
at yahoofinance.quotes.stock.StockQuotesRequest.parseCSVLine(StockQuotesRequest.java:11)
at yahoofinance.quotes.QuotesRequest.getResult(QuotesRequest.java:95)
at yahoofinance.YahooFinance.getQuotes(YahooFinance.java:355)
at yahoofinance.YahooFinance.get(YahooFinance.java:85)
at yahoofinance.YahooFinance.get(YahooFinance.java:69)
at asd.cc.Sstocks.main(Sstocks.java:15)

I'm getting a lot of java.io.FileNotFoundException

http://ichart.yahoo.com/table.csv?s=STMP&a=7&b=18&c=2015&d=7&e=18&f=2015&g=m&ignore=.csv

21:41:53.583 [pool-2-thread-2] INFO com.oak.external.spring.config.ApplicationConfig - Sending request: http://ichart.yahoo.com/table.csv?s=STMP&a=7&b=18&c=2015&d=7&e=18&f=2015&g=m&ignore=.csv
21:42:00.827 [pool-2-thread-2] ERROR com.oak.external.spring.config.ApplicationConfig - error getting price from Yahoo for [Ljava.lang.String;@21ba09a3
java.io.FileNotFoundException: http://ichart.yahoo.com/table.csv?s=STMP&a=7&b=18&c=2015&d=7&e=18&f=2015&g=m&ignore=.csv
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source) ~[?:1.8.0_45]
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source) ~[?:1.8.0_45]
at yahoofinance.histquotes.HistQuotesRequest.getResult(HistQuotesRequest.java:107) ~[bin/:?]
at yahoofinance.Stock.getHistory(Stock.java:296) ~[bin/:?]
at yahoofinance.YahooFinance.fetchHistoricalQuotes(YahooFinance.java:382) ~[bin/:?]
at yahoofinance.YahooFinance.getQuotes(YahooFinance.java:376) ~[bin/:?]
at yahoofinance.YahooFinance.get(YahooFinance.java:247) ~[bin/:?]
at com.oak.external.finance.app.marketdata.api.impl.yahoo.YahooDataConnector.getEconomics(YahooDataConnector.java:49) [bin/:?]
at com.oak.external.finance.app.marketdata.api.impl.MarketDataPollingProviderImpl.startThread(MarketDataPollingProviderImpl.java:55) [bin/:?]
at com.oak.external.finance.app.marketdata.api.impl.MarketDataPollingProviderImpl$1.run(MarketDataPollingProviderImpl.java:45) [bin/:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [?:1.8.0_45]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:1.8.0_45]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_45]

I saw someone posting similar problem. is there a way around it?

Error while parsing dividend date

INFO: Sending request: http://finance.yahoo.com/d/quotes.csv?s=SHOO&f=n0sc4x0a0b2sa5sb0b3sb6sl1sk3sd1t1o0p0g0h0v0a2k0j0m3m4sj2sss1sj1sf6sr1q0d0y0e0e7e9e8r0r5p6p5b4s6j4t8&e=.csv
Jan 25, 2015 11:01:38 AM yahoofinance.quotes.QuotesRequest getResult
INFO: Parsing CSV line: "Steven Madden, Lt","SHOO","USD","NasdaqNM",43.48,43.48,"SHOO",100,"SHOO",N/A,0.00,"SHOO",N/A,"SHOO",33.62,"SHOO",33,630,"SHOO","1/23/2015","4:00pm",34.00,33.94,33.57,34.32,464720,589060,37.72,28.02,32.0067,32.6865,"SHOO", 64,227,000,"SHOO","SHOO",-,"SHOO",2.159B,"SHOO", 57,150,000,"SHOO","N/A"," 9-Nov-06",0.00,N/A,1.962,1.77,0.36,1.98,17.30,1.73,3.20,1.63,10.594,1.335B,202.5M,35.73
Jan 25, 2015 11:01:38 AM yahoofinance.Utils parseDividendDate
SEVERE: Unparseable date: "9-Nov-06"
java.text.ParseException: Unparseable date: "9-Nov-06"
at java.text.DateFormat.parse(DateFormat.java:366)
at yahoofinance.Utils.parseDividendDate(Utils.java:128)
at yahoofinance.quotes.stock.StockQuotesData.getDividend(StockQuotesData.java:88)
at yahoofinance.quotes.stock.StockQuotesData.getStock(StockQuotesData.java:105)
at yahoofinance.YahooFinance.getQuotes(YahooFinance.java:336)
at yahoofinance.YahooFinance.get(YahooFinance.java:76)
at yahoofinance.YahooFinance.get(YahooFinance.java:61)

IllegalStateException

I know this isn't a StackOverflow but I felt it might be a bit more helpful to ask the library dev.

I'm writing a quick stock app to help me learn Android. I have a basic understanding of Java and a moderate understanding of Android.

This method is being unable to be fully run and is exiting with an IllegalStateException - pointing to the Stock stock = YahooFinance.get(stockcodetext) line. I have properly imported the library and the app is actually calling the API properly but crashing very soon afterwards.

I suspect the issue is arising for some elementary misunderstanding but on the offchance that its an issue with your library I have posted it here.

Could you help (thanks by the way for the library, saves myself many lines of clunky code)? If not feel free to close the issue.

Thanks

public void getStockPrice(View v) throws IOException {
        EditText stockcode = (EditText) findViewById(R.id.user_entered_code); //This is what the user enters
        TextView finalstock = (TextView) findViewById(R.id.stockcode); //This is the big stock code displayed
        TextView stockprice = (TextView) findViewById(R.id.price);
        String stockcodetext = stockcode.getText().toString();
        Log.d("s", stockcodetext);

        Stock stock = YahooFinance.get(stockcodetext);
        BigDecimal price = stock.getQuote(true).getPrice();;


        stockprice.setText(String.valueOf(price));
        finalstock.setText(stockcode.toString());

    }

How to get the change in stock share

Sir, thank you for writing this library.
The problem that i am facing currently is how get the change in stock price and how to know whether it's in negative or positive?

Now it seems yahoo doesn't provide the quote downloading anymore

Today I get this following exception. When I manually visit the following URL, yahoo website complains the request format is invalid.

java.io.IOException: Server returned HTTP response code: 400 for URL: http://download.finance.yahoo.com/d/quotes.csv?s=D05.SI&f=nsc4xab2sa5sbb3sb6sl1sk3sd1t1opghva2kjm3m4sj2sss1sj1sf6sr1qdyee7e9e8rr5p6p5b4s6j4t8&e=.csv

Unable to parse date

Hi,

I am using your code:

Stock stock = YahooFinance.get("INTC");
BigDecimal price = stock.getQuote(true).getPrice();

And I have this erros, I think this probably is in your end..

Thanks!!

Mar 04, 2015 5:58:25 PM yahoofinance.quotes.QuotesRequest getResult
[java] INFO: Sending request: http://finance.yahoo.com/d/quotes.csv?s=INTC&f=n0sc4x0a0b2sa5sb0b3sb6sl1sk3sd1t1o0p0g0h0v0a2k0j0m3m4sj2sss1sj1sf6sr1q0d0y0e0e7e9e8r0r5p6p5b4s6j4t8&e=.csv
[java] Mar 04, 2015 5:58:25 PM yahoofinance.quotes.QuotesRequest getResult
[java] INFO: Parsing CSV line: "Intel Corporation","INTC","USD","NasdaqNM",34.23,34.23,"INTC",11,300,"INTC",34.22,34.22,"INTC",6,200,"INTC",34.23,"INTC",100,"INTC","3/4/2015","11:43am",33.86,34.095,33.72,34.24,9239085,28483100,37.90,24.38,34.5329,34.7955,"INTC", 4,736,000,000,"INTC","INTC",-,"INTC",162.1B,"INTC", 4,729,180,000,"INTC","Mar 1","Feb 4",0.915,2.68,2.31,2.38,0.55,2.60,14.76,1.59,2.90,2.89,11.766,55.870B,24.191B,37.27
[java] Mar 04, 2015 5:58:25 PM yahoofinance.Utils parseDividendDate
[java] SEVERE: Unparseable date: "Feb 4"
[java] java.text.ParseException: Unparseable date: "Feb 4"
[java] at java.text.DateFormat.parse(DateFormat.java:357)
[java] at yahoofinance.Utils.parseDividendDate(Utils.java:176)
[java] at yahoofinance.quotes.stock.StockQuotesData.getDividend(StockQuotesData.java:88)
[java] at yahoofinance.quotes.stock.StockQuotesData.getStock(StockQuotesData.java:105)
[java] at yahoofinance.YahooFinance.getQuotes(YahooFinance.java:336)
[java] at yahoofinance.YahooFinance.get(YahooFinance.java:76)
[java] at yahoofinance.YahooFinance.get(YahooFinance.java:61)
[java] at it.sqm.stockmarkets.StockMarkets.main(StockMarkets.java:20)
[java] Mar 04, 2015 5:58:25 PM yahoofinance.quotes.QuotesRequest getResult
[java] INFO: Sending request: http://finance.yahoo.com/d/quotes.csv?s=INTC&f=n0sc4x0a0b2sa5sb0b3sb6sl1sk3sd1t1o0p0g0h0v0a2k0j0m3m4sj2sss1sj1sf6sr1q0d0y0e0e7e9e8r0r5p6p5b4s6j4t8&e=.csv
[java] Mar 04, 2015 5:58:26 PM yahoofinance.quotes.QuotesRequest getResult
[java] INFO: Parsing CSV line: "Intel Corporation","INTC","USD","NasdaqNM",34.23,34.23,"INTC",11,300,"INTC",34.22,34.22,"INTC",6,200,"INTC",34.23,"INTC",100,"INTC","3/4/2015","11:43am",33.86,34.095,33.72,34.24,9239085,28483100,37.90,24.38,34.5329,34.7955,"INTC", 4,736,000,000,"INTC","INTC",-,"INTC",162.1B,"INTC", 4,729,180,000,"INTC","Mar 1","Feb 4",0.915,2.68,2.31,2.38,0.55,2.60,14.76,1.59,2.90,2.89,11.766,55.870B,24.191B,37.27
[java] Mar 04, 2015 5:58:26 PM yahoofinance.Utils parseDividendDate
[java] SEVERE: Unparseable date: "Feb 4"
[java] java.text.ParseException: Unparseable date: "Feb 4"
[java] at java.text.DateFormat.parse(DateFormat.java:357)
[java] at yahoofinance.Utils.parseDividendDate(Utils.java:176)
[java] at yahoofinance.quotes.stock.StockQuotesData.getDividend(StockQuotesData.java:88)
[java] at yahoofinance.Stock.update(Stock.java:44)
[java] at yahoofinance.Stock.getQuote(Stock.java:84)
[java] at it.sqm.stockmarkets.StockMarkets.main(StockMarkets.java:21)
[java] Mar 04, 2015 5:58:26 PM yahoofinance.Stock update
[java] INFO: Updated Stock with symbol: INTC

Another Dividend Parsing Error

Using 1.2.2. I know this issue has been logged a couple of times, but found another format that can't be parsed. Getting "MSFT". Something is strange with the response...
INFO: Sending request: http://finance.yahoo.com/d/quotes.csv?s=MSFT&f=n0sc4x0a0b2sa5sb0b3sb6sl1sk3sd1t1o0p0g0h0v0a2k0j0m3m4sj2sss1sj1sf6sr1q0d0y0e0e7e9e8r0r5p6p5b4s6j4t8&e=.csv

INFO: Parsing CSV line: N/A,"MSFT","USD",N/A,N/A,N/A,"MSFT",4000,"MSFT",N/A,N/A,"MSFT",5500,"MSFT",42.62,"MSFT",190,"MSFT","3/9/2015","12:31pm",N/A,N/A,N/A,N/A,N/A,36259900,N/A,N/A,43.54,45.86,"MSFT",8203785000,"MSFT","MSFT",N/A,"MSFT",349.65B,"MSFT",7564218000,"MSFT","3/12/2015",N/A,N/A,N/A,N/A,2.40,0.63,2.93,N/A,2.20,3.79,3.72,11.18,93.46B,33.61B,47.81
Mar 09, 2015 9:46:07 AM yahoofinance.Utils parseDividendDate
SEVERE: Unparseable date: "3/12/2015"

Also what is strange is that the company name is not be returned from the API...something appears to be broken on the Yahoo side. Thanks

Another error after 1.2 upgrade.Plz check

Feb 15, 2015 7:45:37 PM yahoofinance.quotes.QuotesRequest getResult
INFO: Sending request: http://finance.yahoo.com/d/quotes.csv?s=ZB%5EF&f=n0sc4x0a0b2sa5sb0b3sb6sl1sk3sd1t1o0p0g0h0v0a2k0j0m3m4sj2sss1sj1sf6sr1q0d0y0e0e7e9e8r0r5p6p5b4s6j4t8&e=.csv
Feb 15, 2015 7:45:38 PM yahoofinance.quotes.QuotesRequest getResult
INFO: Parsing CSV line: "ZB^F","ZB^F","|v
Exception in thread "Timer-0" java.lang.StringIndexOutOfBoundsException: String index out of range: -16
at java.lang.String.substring(String.java:1954)
at yahoofinance.quotes.stock.StockQuotesRequest.parseCSVLine(StockQuotesRequest.java:134)
at yahoofinance.quotes.stock.StockQuotesRequest.parseCSVLine(StockQuotesRequest.java:11)
at yahoofinance.quotes.QuotesRequest.getResult(QuotesRequest.java:93)
at yahoofinance.YahooFinance.getQuotes(YahooFinance.java:332)
at yahoofinance.YahooFinance.get(YahooFinance.java:76)
at yahoofinance.YahooFinance.get(YahooFinance.java:61)
at com.jnd.analysis.StockAnalysisBatchClass.processStockFundamentals(StockAnalysisBatchClass.java:43)
at com.jnd.stocksparser.StockBatchProcess.startStockDetailsProcess(StockBatchProcess.java:41)
at com.jnd.stocksparser.StockBatchProcess.triggerStockBatchProcess(StockBatchProcess.java:61)
at com.jnd.stocksparser.Main.run(Main.java:68)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)

Improve code to facilitate better testing

Provide an interface to allow mocking of the http request.
Otherwise the tests would depend on an external service and everyone running the tests would be constantly sending a bunch of requests to Yahoo Finance. Let's try to avoid that.
By mocking the HTTP request we can also provide a reproducible test environment.

getShortRatio()

Congratz for your great API !!

Minor remark: I noticed that you don't expose a getShortRatio(). Any reason for that?

Dividends always seems to be 0

I am looking for dividend information but annualYield and annualYieldPercent always seem to return 0.

Example:

"dividend": {
    "symbol": "BNDX",
    "annualYield": 0,
    "annualYieldPercent": 0
  }

After midnight: FileNotFoundException due to URL not working

The API doesn't work anymore after precisely midnight but works again in the morning (I don't have a more specific time). The links for downloading the CSVs do not work and give an Error 404.

I get the following Log messages and stack trace:
Sep 01, 2016 1:12:14 AM yahoofinance.histquotes.HistQuotesRequest getResult INFO: Sending request: http://ichart.yahoo.com/table.csv?s=MSFT&a=7&b=31&c=2016&d=8&e=1&f=2016&g=d&ignore=.csv Sep 01, 2016 1:12:14 AM yahoofinance.histquotes.HistQuotesRequest getResult INFO: Sending request: http://ichart.yahoo.com/table.csv?s=GOOG&a=7&b=31&c=2016&d=8&e=1&f=2016&g=d&ignore=.csv Sep 01, 2016 1:12:14 AM yahoofinance.histquotes.HistQuotesRequest getResult INFO: Sending request: http://ichart.yahoo.com/table.csv?s=AAPL&a=7&b=31&c=2016&d=8&e=1&f=2016&g=d&ignore=.csv Error: java.io.FileNotFoundException: http://ichart.yahoo.com/table.csv?s=AAPL&a=7&b=31&c=2016&d=8&e=1&f=2016&g=d&ignore=.csv sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1834) sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1439) yahoofinance.histquotes.HistQuotesRequest.getResult(HistQuotesRequest.java:117) yahoofinance.Stock.getHistory(Stock.java:290) yahoofinance.YahooFinance.fetchHistoricalQuotes(YahooFinance.java:380) yahoofinance.YahooFinance.getQuotes(YahooFinance.java:374) yahoofinance.YahooFinance.get(YahooFinance.java:166) data.YahooHistoricalDataFetcher$$anonfun$historicalPrices$1.apply(YahooHistoricalDataFetcher.scala:31) data.YahooHistoricalDataFetcher$$anonfun$historicalPrices$1.apply(YahooHistoricalDataFetcher.scala:32) scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24) scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24) scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121) scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260) scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1339) scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979) scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

Is there a way to retrieve http status codes and afterhours?

@sstrickx
Ty for answering my last question. I've got a couple more about things I couldn't find in the docs, so this might be a longshot.
So right now, if I query a invalid symbol it will throw FileNotFoundException. However, when a user enters the correct symbol and Yahoo service is down it will also throw the same exception. How can we distinguish between the two? Are there different errors codes we can retrieve?

Also is there after hours information we can look at or is this not available with Yahoo currently?

Parser should respect non-numeric values

INFO: Parsing CSV line: \"AlphaClone Alternative Alpha ET\",\"ALFA\",\"USD\",\"PCX\",35.62,N/A,\"ALFA\",3600,\"ALFA\",35.56,N/A,\"ALFA\",1400,\"ALFA\",35.56,\"ALFA\",100,\"ALFA\",\"1/27/2016\",\"11:35am\",35.83,35.83,35.56,35.83,1268,45842,47.66,33.00,36.69,40.25,\"ALFA\",N/A,\"ALFA\",\"ALFA\",N/A,\"ALFA\",N/A,\"ALFA\",N/A,\"ALFA\",N/A,N/A,0.00,0.00,N/A,nan,0.00,N/A,N/A,0.00,N/A,N/A,0.00,N/A,N/A,N/A
Jan 27, 2016 5:52:37 PM yahoofinance.Utils getBigDecimal
INFO: Failed to parse: nan
java.lang.NumberFormatException
    at java.math.BigDecimal.<init>(BigDecimal.java:494)
    at java.math.BigDecimal.<init>(BigDecimal.java:383)
    at java.math.BigDecimal.<init>(BigDecimal.java:806)
    at yahoofinance.Utils.getBigDecimal(Utils.java:70)
    at yahoofinance.quotes.stock.StockQuotesData.getStats(StockQuotesData.java:71)
    at yahoofinance.quotes.stock.StockQuotesData.getStock(StockQuotesData.java:107)
    at yahoofinance.YahooFinance.getQuotes(YahooFinance.java:353)
    at yahoofinance.YahooFinance.get(YahooFinance.java:79)
    at yahoofinance.YahooFinance.get(YahooFinance.java:63)

Missing Zurich time zone

I get a warning when loading the Euro Stoxx 50 TR (SX5T.Z) yahoofinance.exchanges.ExchangeTimeZone.get Cannot find time zone for exchange suffix: 'Z'. Using default: America/New_York

It outputs a wrong lastTradeTime in the quote, like 16h30 instead of 10h30.

Correct date not returned by stock.getHistory().getDate().getTime()

Say you ask data for 07-08-2016, then the response from the API is

Date,Open,High,Low,Close,Volume,Adj Close
2016-07-08,217.800003,219.809998,214.50,216.779999,4064300,216.779999

but when you call .getHistory().getDate().getTime() on the stock, the date that is returned is Thu Jul 07 21:00:00 PDT 2016

I have a PR addressing this issue #50

Yahoo Finance historical quote limits?

@sstrickx Hey, I've noticed that historical quotes make separate calls to ichart.yahoo.com. If I need historical data for 100 stocks, it would require 100 calls to yahoo. I'm worried this will be too much for yahoo servers to handle. Do you know the limits of this?

Foreign markets

Any chance of getting stock price infor for the following exchanges? .BO, .NS, .MC, .SS, .SZ, .BK

Is it possible to get the image of the token?

I'm wondering if it's possible to fetch the image of the token with this api.

checkds

I want to achieve something like this, so we basically get all the above the token symbol, exchange,... except the picture.
So what i want to know is, is it possible to retrieve the company logo with this api?

NumberFormatException in StockQuotesData.getStats() function

Currently I am using the 1.3.0 version of maven dependency in my sample java project.

I got this exception :
java.lang.NumberFormatException: null
at java.math.BigDecimal.(BigDecimal.java:494) ~[na:1.8.0_101]
at java.math.BigDecimal.(BigDecimal.java:383) ~[na:1.8.0_101]
at java.math.BigDecimal.(BigDecimal.java:806) ~[na:1.8.0_101]
at yahoofinance.Utils.getBigDecimal(Utils.java:70) ~[YahooFinanceAPI-1.3.0.jar:na]
at yahoofinance.quotes.stock.StockQuotesData.getStats(StockQuotesData.java:69) [YahooFinanceAPI-1.3.0.jar:na]
at yahoofinance.quotes.stock.StockQuotesData.getStock(StockQuotesData.java:105) [YahooFinanceAPI-1.3.0.jar:na]
at yahoofinance.YahooFinance.getQuotes(YahooFinance.java:336) [YahooFinanceAPI-1.3.0.jar:na]
at yahoofinance.YahooFinance.get(YahooFinance.java:191) [YahooFinanceAPI-1.3.0.jar:na]
at yahoofinance.YahooFinance.get(YahooFinance.java:171) [YahooFinanceAPI-1.3.0.jar:na]
at com.xxx.xxx.xxx.StockExchangeService.getInformation(StockExchangeService.java:34) [classes/:na]

Sample code of my application where i have used the YahooFinance methods :

Line 33: String[] symbols = new String[] {"INTC", "BABA", "TSLA", "AIR.PA", "YHOO"};
Line 34: Map<String, Stock> stocks = YahooFinance.get(newSymbols);

Please fix it or let me know if I am wrong somewhere.

name is N/A

It the stock name is not available, stock.getName() should return (null or) an empty string, so it's easier to test on this after the method call.

remark:

example NMKTF.

503 Errors

thanks for the library, it's very helpful and works great. I do get 503 errors from time to time, is that normal?

Is it possible to query yahoo for more information?

I am trying to write a sort of stock scanner, that would collect prices and economic data and statistics about a huge universe of stocks. I'm using your YahooFinance-API for this.

The additional things that I would like to be able to get are statistics about the debt and cashflows, and cash.
Is it possible to retrieve this?

Also, I would like to be able to get the sector classification, so that I can compare some of this data to the sector average.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.