Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

StringIndexOutOfBoundsException -> when retrieving stocks #202

Open
milpatel11 opened this issue Feb 12, 2023 · 0 comments
Open

StringIndexOutOfBoundsException -> when retrieving stocks #202

milpatel11 opened this issue Feb 12, 2023 · 0 comments

Comments

@milpatel11
Copy link

milpatel11 commented Feb 12, 2023

Hi Team,

I just installed

<dependency>
            <groupId>com.yahoofinance-api</groupId>
            <artifactId>YahooFinanceAPI</artifactId>
            <version>3.5.0</version>
  </dependency>

and I am trying to play around for fun, I found YahooFinance.get("STOCK_NAME") is throwing an exception.

Here is the log from console for stacktrace

2023-02-11T20:48:45.600-05:00  INFO 16736 --- [           main] yahoofinance.YahooFinance                : Sending request: http://finance.yahoo.com/d/quotes.csv?s=APPL&f=nsc4xab2sa5sbb3sb6sl1sk3sd1t1opghva2kjm3m4sj2sss1sj1sf6sr1qdyee7e9e8rr5p6p5b4s6j4t8s7&e=.csv
2023-02-11T20:48:45.703-05:00  INFO 16736 --- [           main] yahoofinance.YahooFinance                : Parsing CSV line: redirect
2023-02-11T20:48:45.703-05:00 ERROR 16736 --- [           main] c.sm.stockanalyzer.service.DataManager   : java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 8
java.lang.StringIndexOutOfBoundsException: begin 0, end -1, length 8
  at java.base/java.lang.String.checkBoundsBeginEnd(String.java:4604)
  at java.base/java.lang.String.substring(String.java:2707)
  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 com.sm.stockanalyzer.service.DataManager.<init>(DataManager.java:18)
  at com.sm.stockanalyzer.StockAnalyzerApplication.main(StockAnalyzerApplication.java:23)

Here is the code that has been giving me issue -

try {
            Stock stock = YahooFinance.get("APPL");
            logger.info("History - ", stock.getHistory());

        } catch (Exception ex) {
            logger.error(ex);
            ex.printStackTrace();
        }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant