Getting Stock Prices from the Web

As the final step to complete our net asset application, we have to get the stock price from the web. We have the list of ticker symbols and the units in the file stocks.xml we saw earlier. For each of these symbols, we need to fetch the closing price. Thankfully, Yahoo provides a web service that we can use to get stock data. To find the latest closing price for Google stocks, for example, we can visit the following URL:

 
http://ichart.finance.yahoo.com/table.csv?s=GOOG&a=00&b=01&c=2015

The parameters s, a, b, and c represent the ticker symbol, start month (January is 0), start day, and start year, respectively. If you don’t specify the end dates using the parameters d, e, and f, the service returns all prices ...

Get Pragmatic Scala now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.