-1

As the question suggest can you please tell me how i can fetch details regarding stocks (current price,Market Cap,open price, bid price etc) and key statistical information such as Trailing P/E, Forward P/E,Profit Margin (ttm),Revenue Per Share (ttm),Book Value Per Share (mrq) etc. Can you also give a simple example/script (parsing Json/xml) for fetching these details. I want to fetch the details of this stock. Most of the tutorial for yahoo finance api in web is for C# and also vague regarding details. Ca

Eka
  • 14,170
  • 38
  • 128
  • 212

2 Answers2

1

I would suggest the following posts and code sample on how to fetch stock prices from Yahoo! using PHP and json. This is by no means a complete solution just a baseline on how to go about it. It is important that you at least try something and post you code because it makes it easier for the community to catch-on what you attempting.

PHP: How to get stock quote data from Yahoo! Finance? (Complete Code and Tutorial)

Now you have to take the result dataset from the PHP and encode it into json format which you can use on your front-end. For this part you might want to look at this link instead:

JSON Example to html table

There might be examples that explain or even provide a full solution to your problem but I that would require more research on your part. This is just to get you going!

Best of luck!

Conrad Lotz
  • 8,200
  • 3
  • 23
  • 27
0

If you don't mind using the key statistics from BarChart.com, here is a simple function script:

library(XML)
getKeyStats <- function(symbol) {
  barchart.URL <- "http://www.barchart.com/profile.php?sym="
  barchart.URL.Suffix <- "&view=key_statistics"
  html_table <- readHTMLTable(paste(barchart.URL, symbol, barchart.URL.Suffix, sep = ""))
  df_keystats = html_table[[5]]
  print(df_keystats)
 }
Victor Burnett
  • 588
  • 6
  • 10