I tried this and it worked very well.
WebElement stockpriceText = driver.findElement(By.cssSelector("span[id=\"yfs_l84_ctsh\"]"));
String price = stockpriceText.getText();
Output: 51.59
I believe your locating strategy is a bit wrong. You are trying to first find a span in:
WebElement price = driver.findElement(By.tagName("span"));
which could be the problem. WebDriver will find the very first <span>
element on the page. It could be some other span in the DOM.
Plus when you are executing this:
price.findElement(By.id("yfs_184_" + s.toLowerCase())).getText();
That time you are trying to find another element inside the span element which will not work.