02-26-2016 07:14 PM
I want to use labview to download option data from Yahoo finance or Google finance and build my own tools for stock trading. I can use this example to get the html code from Yahoo and Google and extract the information I need. There are drop down menus on the webpage to select options of different dates, however, the returned html only contains the latest option without showing those from other dates. Even Yahoo has different web addresses for different option dates, e.g. http://finance.yahoo.com/q/op?s=MSFT&date=1466121600 , the last number indicates specific date. But still, it will return the data of the latest option data that has a different web address.
Any thoughts?
Many thanks!
Best,
Spiral
Solved! Go to Solution.
02-28-2016 07:45 AM - edited 02-28-2016 07:45 AM
You don't really ask a question (except "Any Thoughts?"), so it's hard to guess what you need.
the returned html only contains the latest option without showing those from other dates.
That's the way it works - it's not like the one web page delivered has all the data on it, and the selector just chooses a set to show.
When you switch the DATE selector, it will make a new HTTP request to the server, and the data returned from that is shown.
IOW, if you want to ask for a specific date, you have to format the HTTP request, the way the web pages do it, and send it off and wait for the answer. Then parse out what you need.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
02-28-2016 07:50 AM
Consider looking for specific tools, from Yahoo or Google, to access what you want.
You're trying to scrape the info off the web page, but they might just offer an API to directly get what you want:
'Get daily stock price of {"AAPL","INTL","IBM" } from 2015/06/01 to 2015/12/31'
There are APIs to obtain weather data like that, I would imagine that financial data might be available the same way.
(That's just a guess though - I don't know for sure).
Blog for (mostly LabVIEW) programmers: Tips And Tricks
02-28-2016 10:51 AM
Hi Steve,
Thanks a lot for your reply.
Sorry for not being clear. My problem is exactly what you have suggested - I do not know how to format the specific HTTP request to the web pages. Looks like Yahoo has a master URL. Whenever I input my URL which works in chrome browser, my VI returns the content from the master URL that is different from chrome results.
When you mentioned "switch the DATE selector", how to implement this in datasocket?
Labview is the only program tool I am familiar with, but I do not know how to associate with an API. Anyway, I think Yahoo and google do not have stock trading APIs.
Thanks.
Spiral
02-28-2016 11:29 AM
Do a search for JSON Financial Data
Both Google and Yahoo have it, apparently.
Don't know if you can execute trades, but you can obtain historical data.
Here's one example: http://www.financialcontent.com/support/documentation/json_quote_api.php
Unless you just want to learn scraping data from web pages in LabVIEW, that sounds like a better solution for your task.
There might be some JSON examples in LV2015. Check around.
Blog for (mostly LabVIEW) programmers: Tips And Tricks
02-28-2016 09:10 PM
Thanks!!
The API indeed saved my world!
Best,
Spiral