How to get a quote for a specific date using Yahoo Finance - yahoo-finance

Seems like it should be a simple problem. I'm using Matlab to build a stock database and analyses toolkit.
I'm using Matlab functions to get a table of data, using a URL like the following:
http://ichart.finance.yahoo.com/table.csv?s=aapl&a=00&b=01&c=2011&d=03&e=04&f=&ignore=.csv
That works just fine to get standard stats (open, close, volume, ect). I can't figure out how to add other yahoo finance stats though like moving averages. Can I modify the above URL to add other stats to the download? Or is there a way to modify a single quote query to include a date? I'm trying to modify the url below to no avail.
http://finance.yahoo.com/d/quotes.csv?s=aapl&f=m4m3
Thanks for the help!

The scripts at http://luminouslogic.com/matlab-stock-market-scripts are pretty helpful for working with Yahoo Finance in Matlab. Download the dates and prices you need and then use http://www.mathworks.com/help/toolbox/finance/tsmovavg.html to calculate a moving average.
UPDATE
It looks like you can use m4 to get the moving average. Check out the documentation at http://www.gummy-stuff.org/Yahoo-data.htm . Your url above is correct--you might need to comma separate the parameters.
UPDATE 2
Check out this question: source of historical stock data

Related

Get historical stock price from investing.com to google sheets [duplicate]

This question already has answers here:
Scraping data to Google Sheets from a website that uses JavaScript
(2 answers)
Closed last month.
Looking for a way to get the stock price for a specific date (eg. 31.1.2020).
I know I can use IMPORTHTML or IMPORTXML together with INDEX to get the table. However, when I use the browser to search for a specific date on investing.com, there's no direct URL for the date, and it rather presents me with the latest stock prices instead. This is the stock I'm looking for
I'm afraid that investing.com do not provide an API
https://www.investing-support.com/hc/en-us/articles/115005473825-Do-you-provide-an-API-
So you won't be able to do this very easily (if at all) with Google Sheets or Apps Script. The reason is that it looks like most of the content on the site is generated with JavaScript, and so it is not part of the original HTML that is shown when you first enter the site. The HTML is what IMPORTHTML gets.
To get the information you are looking for without using and API, would involve browser automation. That is, simulate the clicks that a user might make and then get the data. This can be very finicky and is prone to break whenever the website changes its layout or HTML for whatever reason (something that tends to happen quite often for busy websites).
I would recommend using a different service that has a Sheets friendly HTML format. Better than that, I would look into a service that has an API and interact with it with Apps Script. Finally, if you need it to be investing.com you could look into something like Puppeteer which can automate a browser (though its a fair bit more complex than a formula or an API).
You can import using importhtml the historical data for the last 30 days, and then use a lookup for that data.
To get historical data I use:
query(IMPORTHTML("https://investing.com/equities/STOCK-historical-data"; "table"; 2);"SELECT Col1, Col2")
I don't know if you can import more than 30, I'm searching for that answer myself.

yahoo finance stock price NSE,BSE rest-api

Am trying to create a program that fetches data from yahoo finance all stock data.
I found one rest API that gives me a stock price but I have to pass two parameters ex. if I have to get Apple stock price I have to pass Apple and stock name but I want all stock data so how do I get ??
can anyone help me thanks in advance
Unfortunately there isn't any official source of tickers or method of getting them.
You can use this script link to download tickers but as creator mentioned:
it is not possible to get all the symbols due to limitations set by
Yahoo. About 75%-90% of all symbols are gathered using this script
depending on type.
And it also downloads some no longer existing or inaccessible tickers.
From this site link you can download list of almost all tickers but about 30% of tickers are either in wrong category or aren't working. Checking whether ticker exists is easy because when API returns no data then we can deduce that ticker is incorrect. But checking if category is appropriate is a bit more complicated.
I've filtered tickers from the second site but only ETFs and Mutual Funds, you can find them on my GitHub. Those files contain about 99% of ETFs and Mututal Funds avaiable on Yahoo. I might consider filtering stocks later and then I'll upload them with script too. Be aware that filtering tickers is impossible on one run without for example VPN because Yahoo limits request to about 10k-20k per day and there are about 20k tickers per category and checking each ticker requires 2 requests.
Try with IEX api, it's free, and it provides very complete data, a very simple implementation and a very neat documentation
if yu want AAPL real-time price you just have to request
https://api.iextrading.com/1.0/stock/aapl/price
Here's complete documentation
https://iextrading.com/developer/docs
I was searching for a solution to a similar question for a long time. and at last, I got a solution to my problem.
there's a library in python that does this for you!
All you have to is pass the right symbol for the stock (for ex: the symbol of Infosys is INFY)
Here's the link to the documentation of the library
Dynamic Stock prices :
https://nsetools.readthedocs.io/en/latest/
Historical Stock Data :
https://nsepy.readthedocs.io/en/latest/
I hope this helps! All the best

Performing Google Search In Spreadsheet And Scraping The SERP Data

I hope that you guys are fine. I want to build a simple spreadsheet and I thought I could be able to make one but blank sheet looks horrible to me. I am sure that you guys are kind enough to help me out.
I want to perform multiple Google search queries in Google spreadsheet and want to parse results of each search (top 10 results of each search)
Something like this: https://www.youtube.com/watch?v=tBwEbuMRFlI
But when I tried his given formula in description to play test, Google returned #Error to me, I don't know why.
Can you guys please help me out in making a simple spreadsheet compatible for multiple queries at once? Like one column for keywords (where I could paste my list of keywords) and then 10 columns of search results. All results for one keyword should come in one row
Something like this:
My 1st Example Query = 1st search result, 2nd search result, 3rd result and so on.
My 2nd Example Query = 1st search result, 2nd search result, 3rd result and so on.
It must be easy to code but yeah, it might be time-consuming and I would be very grateful if anyone of you could help me about it.
Looking forward to your help guys.
The problem is that you want to scrape out of Spreadsheets, that's a bad approach and is almost certainly not going to work. Even if you manage to write a scraper inside that limited environment it will easily be spotted by Google.
As you said time is not a problem, I would suggest another route.
Use a backend tool/script that scrapes the data
Use a backend tool/script that creates/modifies the Google spreadsheet
You can run such a script(s) manually on your PC or from a server full automated using a scheduler/cron job.
To create/modify spreadsheets look here: How do I access the Google Spreadsheets API in PHP?
To scrape Google look here: Is it ok to scrape data from Google results?
So this is PHP as language of choice but you can do the exactly same in Java or Python or C#
There is a third party solution like SerpApi you could use for this. It's a paid API with a free trial.
Google Sheets Add-on: SerpApi - Search Engine Results and Ranks
Example code to extract title from the first result:
=SERPAPI_RESULT("engine=google&q=coffee&location=Austin, Texas, United States&google_domain=google.com&gl=us&hl=en", "organic_results.0.title")

get spreadsheet URL

I have a problem in my reporting, i create every day a google doc tracker where all the stack holders in my department update their work progress in it, so i have plenty of spreadsheets to monitor which is a hassle, here is what im trying to do, I'm trying to create a big google doc tracker where i can have an access over date applied in the normal spreadsheets, all what i need is the spreadsheet's URLs that exist in my google drive to be retrieved in this big tracker, with this i'll be able to drive all the needed data from the normal trackers.
PS: I'm not good with google scripts.
You can use the Drive Service to get a list of files with MIME type "application/vnd.google-apps.spreadsheet" using getFilesByType. This returns a FileIterator, which you can use to individually get each Spreadsheet file. From there, just use getUrl() to find the URL's. The FileIterator link has examples of how to loop through all the matching files.

Labview to google spreadsheet information transfer

I have been using LabVIEW to collect measurement data, and I would like to know if it is possible for LabVIEW to communicate the results to a Google Spreadsheet. If so, where could I find resources to learn how to make LabVIEW transmit information to the Google Spreadsheet ?
Thanks!
EDIT AND FOLLOW-UP- I used Jonathan's suggestion below and experimented with the LabVIEW http Post.vi. It's very simple, all you need to do is enter the URL of the Google form (replacing the final "viewform" with "formResponse") and a string with the data you want to enter (with rough syntax = ). A big thanks for that answer, it was really helpful !
However, when I try to use this method for a Google form with more than one page, the data isn't read properly... The form is still sent but every field not present on the first page of the form remains blank on the Spreadsheet. I feel that this is somehow linked to the fact that in the Google form, the URL of all the pages after page 1 are the URL of page 1 with the final "viewform" replaced with "formResponse". Is this what is causing the error or is it something else altogether, and how can I fix it ?
I can think of two ways to do this:
You can create a form in google spreadsheets. The form appears as an html document with standard tags. From here, I would use labview's http functionality to submit data to that form using a POST request. This would be the easiest way to get data in there.
Using the Google Apps API, you can manipulate google spreadsheets and dump data in there directly. This is going to be more complicated in terms of development time, but more configurable in the long run. https://developers.google.com/google-apps/spreadsheets/#what_can_this_api_do There are .net and java code examples throughout the documentation, so it would take some work to port this to LabVIEW, but it could be done.

Resources