+ Reply to Thread
Results 1 to 42 of 42

Import historical quotes with specific dates

Hybrid View

  1. #1
    Registered User
    Join Date
    12-28-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2010
    Posts
    21

    Import historical quotes with specific dates

    Hello,

    I first must say that i know nothing about programming and therefore i really need some help.

    I am trying to do a research about historical stock quotes, however, instead of importing complete tables that have date intervals, i wish to importa dpecif historical quotes on specificic dates (ex: 05/01/1981).

    The problem is that my spreadsheet will consist of more than 600 companies and 62 different historical quote dates for each. You can see the amount of work and time that this will consume if i do it all by hand.

    I will attach a file and i hope that someone can help me with this.

    Thank you so much in advance.

    Best regards,
    Paulo Ferreira

    Consumer Discretionary.xls

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Import historical quotes with specific dates

    Hello Paffius,

    Welcome to the Forum!

    To help you with this, I need you to provide a list of stock symbols for the companies you want the historical quotes for. Is there a particular site you wanted to query for these quotes? If yes then please provide the site's web address.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-28-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Import historical quotes with specific dates

    Discretionary.xls

    Hi Leith,

    I posted a new file, with the symbols. Some stocks dont have symbols, so, forget those.
    Usually i use the Yahoo Finance website.
    For the FORD company, for example, the historical quotes link is: http://finance.yahoo.com/q/hp?s=F+Historical+Prices

    One more time, thanks so much for helping. Besides filling the data, i am also very interested in learning how to do it, for the others spreadsheets i will have to make in the near future.

    Best regards,
    Paulo Ferreira

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Import historical quotes with specific dates

    Hello Paffius,

    I downloaded the workbook again but I did not see the ticker symbols, only the company names. I can not use the names for the ticker symbol. For example Ford Motor Company's symbol is "F". Using "Ford" for the ticker symbol will return results for Forward Industries.

    Which values do you want for the dates: Open, High, Low, Close, Volume, or Adj Close? Or will high and low be copied to different sheets?

  5. #5
    Registered User
    Join Date
    12-28-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Import historical quotes with specific dates

    Hello Leith,

    The symbols are in column B in the last file i sent you.
    All i want is the CLOSE quotes, nothing else.

    Regards,
    Paulo

  6. #6
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Import historical quotes with specific dates

    Hello Paffius,

    I finished the testing the code and it appears to returning the correct data for the historical dates. The attached workbook currently fills in only the first worksheet. I can change this to handle whichever sheets you want. Have a look and let know what you think. There is a new worksheet "Sheet1". I added this to check that the proper URLs were being accessed. I can remove this for the final version.
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    12-28-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Import historical quotes with specific dates

    Hi Leith,

    You say it takes a little of time, i guess thats why whe i pressed the Get Historical quotes button, my excel started thinking and thinking...

    About the companies, i will have to do some research still, because i thought more companies existed in the 80's, and obviously only 2 appeared.
    So i will need some days to research a little, probably next week, because of this short holidays.

    Thanks for the huge help.
    Paulo

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Import historical quotes with specific dates

    Hello Paulo,

    You're welcome. I will change the macro to run on both sheets and add something to inform you of the progress.

  9. #9
    Registered User
    Join Date
    12-28-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Import historical quotes with specific dates

    Thanks once more.

    By the way, is it normal for excel to be much slower or even unresponsive while it gets the data?

    Paulo

  10. #10
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Import historical quotes with specific dates

    Hello Paulo,

    In this case, yes. The data is being retrieved synchronously. That is Excel requests the data and waits for the server to return the data before continuing on with the code.

  11. #11
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Import historical quotes with specific dates

    Hello Paulo,

    In this case, yes. The data is being retrieved synchronously. That is Excel requests the data and waits for the server to return the data before continuing on with the code.

  12. #12
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Import historical quotes with specific dates

    Hello Paulo,

    The button will now run the macro on all worksheets except "Copy". The symbol and the current historical prices URL are displayed in Excel Status bar below the worksheet tabs. There is also a button to clear the prices on each sheet. Also, only rows that do not have closing prices in them will be updated. This will allow you to add new companies and not have to wait for the whole page to update.
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    12-28-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Import historical quotes with specific dates

    Hi Leith,

    I am currently using IE9 and Windows 7 Ultimate.

    Regards,
    Paulo

  14. #14
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Import historical quotes with specific dates

    Hello Paulo,

    Try this update. The macro changes the user agent string to be compatible with Internet Explorer 9. This should solve the problems you are having.
    Attached Files Attached Files

  15. #15
    Registered User
    Join Date
    12-28-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Import historical quotes with specific dates

    Hi Leith,

    Now it doesnt even accept any symbol on column B.
    It gives an "Run time error 13 - Type mismatch".

    Regards,
    Paulo

  16. #16
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,259

    Re: Import historical quotes with specific dates

    Hello Paulo,

    Your new and old results seem to point to the user agent string not being correct. Since you Windows 7 Ultimate, do you ever run it in Windows 2003 compatibility mode? I would try running the previous workbook in this mode and see if it works.

  17. #17
    Registered User
    Join Date
    12-28-2011
    Location
    Portugal
    MS-Off Ver
    Excel 2010
    Posts
    21

    Re: Import historical quotes with specific dates

    Hi Leith,

    How do i do that, "run in Windows 2003 compatibility mode"?

    Regards,
    Paulo

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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