+ Reply to Thread
Results 1 to 15 of 15

Real Time Stock Price from Google Finance in Excel

  1. #1
    Registered User
    Join Date
    04-07-2014
    Location
    India
    MS-Off Ver
    Excel 2019
    Posts
    21

    Real Time Stock Price from Google Finance in Excel

    Hi All;

    I want to download google finance data from this url :-
    http://www.google.com/finance/getpri...=1266701290218
    where
    q= stock symbol on Google finance
    x= exchange symbol
    i= interval (here 60 means 60 sec (1 minute interval))
    p= no of period(here 5d denotes 5 days of data)
    f= parameters (day, close, open, high and low)
    df= difference (cpct is may be in % change )
    auto =1,

    and than want to save that in .txt file formate with that stock symbol.

    Here I am attaching one excel file which is downloading the data, but i want to save that data in .txt formate as well.
    here is the link of that excel file as well :- http://investexcel.net/google-financ...uotes-in-excel

    tnx in advance
    Attached Files Attached Files
    Last edited by chirag_patel5141; 06-09-2016 at 12:44 PM.

  2. #2
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Real Time Stock Price from Google Finance in Excel

    To add saving data as text file feature, add these lines to existing code :

    Please Login or Register  to view this content.
    1. I care dog
    2. I am a loop maniac
    3. Forum rules link : Click here
    3.33. Don't forget to mark the thread as solved, this is important

  3. #3
    Registered User
    Join Date
    04-07-2014
    Location
    India
    MS-Off Ver
    Excel 2019
    Posts
    21

    Re: Real Time Stock Price from Google Finance in Excel

    Hi karedog ,

    Sorry for not saying my problem in proper way ....I want to save that file in .txt format in this file format which I have attached.

    Where First is SYMBOL,than DATE in YYYYMMDD Format ,time stamp,Open,High,Low,Close,Volume
    Attached Files Attached Files

  4. #4
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Real Time Stock Price from Google Finance in Excel

    Maybe this :

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-07-2014
    Location
    India
    MS-Off Ver
    Excel 2019
    Posts
    21

    Re: Real Time Stock Price from Google Finance in Excel

    Hi karedog,

    You rock man ...that code done the job...!!
    One more query here ...some data/lines are giving error in this txt file..is it possible to solve it ???

    below is the example ...



    GAIL,20160523,11:02:00,373.2,373.3,373,373.15,3536
    GAIL,20160523,11:03:00,373.45,373.5,373.2,373.5,1155
    GAIL,20160523,11:04:00,373.5,373.6,373.15,373.6,728
    GAIL,20160523,11:05:00,373.2,373.55,373.2,373.55,20
    GAIL,20160523,11:06:00,373.45,373.45,372.8,372.8,176
    GAIL,20160523,11:07:00,373.15,373.15,372.8,372.8,720
    GAIL,#VALUE!,#VALUE!,0,0,0,0,0 <---- this is ERROR line
    GAIL,20160523,11:10:00,372.95,372.95,372.1,372.25,2956
    GAIL,20160523,11:11:00,372.6,372.75,372.55,372.55,24
    GAIL,20160523,11:12:00,372.5,372.9,372.5,372.9,23
    GAIL,20160523,11:13:00,372.9,372.9,372.9,372.9,295

  6. #6
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Real Time Stock Price from Google Finance in Excel

    You just found a bug in the macro (from investexcel.net isn't it), you can contact the author to tell him about this.

    His method is using QueryTable to fetch the data from GoogleFinance, the result of this fetch is one column of data (at column A), he then use TextToColumn to split the data to multiple columns. Under normal circumstances, the content of each cell should be in string datatype (so the TextToColumn using comma as delimited character can be used), but this GAIL symbol is something unexpected. For the row(s) where the error occurred, the cell is in numeric datatype.

    You can examine this by adding "Exit Sub" statement before the code reach TextToColumn job :
    Please Login or Register  to view this content.
    Now if you look at sheet "Data", for cell A150, A151, A215, A250, the datatype for these cells is numeric (they are right aligned), and if you change the number format to General for example, the format is ruined. This is not happened with other "normal" cells, because on these normal cells, there is mixed of commas and dots, so Excel automatically treats them as string (so can be splitted using TextToColumn using comma as delimiter), but for the failed cells, Excel assumes the comma(s) is just a thousand separator symbol (no comma at all), so the TextToColumn is failed.

    And since it is not always the data is grouped in 3 digits format (for example the cell A250, there is one extra digit compared to other failed cells), we cannot manually fix the error.

    -----------------------------------

    Here I use another method to fetch the data using WinHTTPRequest object, the return is in string datatype (so no automatic data Conversion as occurred using QueryTable), and then split manually (not using TextToColumn feature). It seemed that the result is correct :

    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    04-07-2014
    Location
    India
    MS-Off Ver
    Excel 2019
    Posts
    21

    Re: Real Time Stock Price from Google Finance in Excel

    Hi ..

    the reply is only in single word "AMAZING' ...really dear ur code is amazing ....!!!
    I actually try to understand ur code but I am not able to undestand it(bcoz of my limited knowledge of excel/vba)

    I want one more change if possible -- How can I skip first row of "SYMBOL,DATE,TIME,OPEN,HIGH,LOW,CLOSE,VOLUME' line in txt file ??

  8. #8
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Real Time Stock Price from Google Finance in Excel

    Thank you.

    To remove the header, change this line :
    Please Login or Register  to view this content.
    To :
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    04-07-2014
    Location
    India
    MS-Off Ver
    Excel 2019
    Posts
    21

    Re: Real Time Stock Price from Google Finance in Excel

    hi karedog...
    sorry for late reply and big tnx for ur code dear ...!!!

  10. #10
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Real Time Stock Price from Google Finance in Excel

    You are welcome, glad to help.


    Regards

  11. #11
    Registered User
    Join Date
    04-07-2014
    Location
    India
    MS-Off Ver
    Excel 2019
    Posts
    21

    Re: Real Time Stock Price from Google Finance in Excel

    Hi karedog,

    I am downloading data from this link http://www.nseindia.com/content/hist...14bhav.csv.zip from VBA like below method


    Please Login or Register  to view this content.
    But from today I got "Access Denied" msg ...I tried to find the solution on the net but I didn't get success...what I get is this link which I am not
    able to understand bcoz its for R ...
    http://stackoverflow.com/questions/2...-with-get-in-r

    here they said "You need to set a browser-like user agent string so the site thinks you're a browser vs an automated scraper/downloader robot:"

    SO HOW CAN I DO THIS IN EXCEL VBA ?? Any Help please dear ....

    Here I have also attach the screen shot of Error which I got from server
    Attached Images Attached Images
    Last edited by chirag_patel5141; 06-22-2016 at 01:39 AM.

  12. #12
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,882

    Re: Real Time Stock Price from Google Finance in Excel

    @chirag_patel5141

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here



    (This thread should receive no further responses until this moderation request is fulfilled, as per Forum Rule 7)
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  13. #13
    Registered User
    Join Date
    04-07-2014
    Location
    India
    MS-Off Ver
    Excel 2019
    Posts
    21

    Re: Real Time Stock Price from Google Finance in Excel

    Hi alansidman,

    sorry for my mistake ...i correct the post.In between my code is running well and other URL is also downloading files from the net/server...but only this url is not working. http://www.nseindia.com/content/hist...14bhav.csv.zip

    I haven't post the whole code here only post the code that do the downloading work bcoz I think the Problem is not in the code but the method I use to download the file bcoz the site's server thinks that I am a downloader robot or something (this is bcoz I have download the more than 2 years data from that site-thats why the site's server blocked me).

    By browsing the url I am able to download the file but only one at a time

  14. #14
    Forum Guru karedog's Avatar
    Join Date
    10-03-2014
    Location
    Indonesia
    MS-Off Ver
    2003
    Posts
    2,971

    Re: Real Time Stock Price from Google Finance in Excel

    I can't open that page with my browser either, which means it is not user agent related problem.

    But if try to open other page from the same website, for example : https://www.nseindia.com/archives/eq...r/PR210616.zip
    this page can be opened without a problem, so it seemed that this is a temporary server side problem.

    You can see the same thing from this webpage :
    http://answers.microsoft.com/en-us/w...8a0d67e?auth=1

    The asker said :
    "Well, today it works just fine without me having to do anything."

    so you may want to wait 1 or 2 days to see if the problem is gone by itself (fixed from serverside).

  15. #15
    Registered User
    Join Date
    04-07-2014
    Location
    India
    MS-Off Ver
    Excel 2019
    Posts
    21

    Re: Real Time Stock Price from Google Finance in Excel

    oh ok..so looks like wait and watch is the best salutation in this situation ...

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Download Google Finance Live Stock Rates To Excel
    By NeedForExcel in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-28-2016, 08:34 AM
  2. [SOLVED] Extracting Real Time Quote from Google Finance
    By cpfrona in forum Excel Programming / VBA / Macros
    Replies: 17
    Last Post: 05-05-2015, 12:29 AM
  3. How to insert real time GOLD price in excel cell?
    By bamboo84 in forum Excel General
    Replies: 2
    Last Post: 01-24-2015, 06:46 PM
  4. Getting live stock quotes from Google Finance from Indian stock exchanges like NSE and BSE
    By nischalshetye in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2014, 06:21 AM
  5. Realtime Stock quote from Google Finance and charting
    By kaleem1919 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 08-21-2014, 06:11 AM
  6. Getting real time stock quotes from google finance / yahoo finance in excel
    By Navin Agrawal in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-21-2012, 12:41 PM
  7. Replies: 1
    Last Post: 01-07-2005, 08:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1