locked
What is the best way of importing historical prices ? RRS feed

  • Question

  • I am trying to prepare as best as I can for Black Monday (Jan 31st 2011).

    One of the things I would like to do is to have a complete a set of historical price data for my stocks and funds.  Other than the manual price entry facility is there a clever way of importing historical price data ? 

    I need to do this particularly for certain funds, that seem never to auto-update, despite a correct ISIN code.  It seems that when I add a new stock, then a bunch of historical price data is downloaded as part of the update process, although it is not a complete set. The data appears to be weekly only with some dates missing, so being able to import for stocks as well would be useful, though not as necessary as for funds.

    I am using the last UK version (2005 ?)

    Thanks, Angus

    Thursday, November 25, 2010 8:31 AM

All replies

  • Hi MasterBoy

    You could also theoretically create OFX file(s) to do it, with different dates. However, the only templates we have that are widely available are the pocketsense scripts - but the OFX outputted is one price per share/fund per day. I'm not sure if based on the OFX format (available for download via google) you could create a list.

    Money seems quite resilient wrt OFX import and I'm playing with dates now just for correct UK stock/fund update - see cross post at http://pocketsense.blogspot.com/2010/11/replacing-microsoft-money-continued-nov.html?showComment=1289842269724

    I haven't quite got to updating my funds (aside from Yahoo will not download them) but I would also like the ability to generate some more history in the future.  

    Thursday, November 25, 2010 12:45 PM
  • Hi Ouroboros

     

    Thanks for the reply.  I have had a look at the pocketsense stuff and I can see how it will work with daily downloads of stock prices post 1/31/2011.  Just while we are on that I had a little play and got it downloading UK stock prices OK, even some quite obscure ones.  However it didnt want to know with funds.  Admittedly I only tried a few, eg GB00B0XWNF82 (Aberdeen Asia Pac) and GB0000764447 (Rensburg UK Mid Cap Growth), but I got an error message.  Any ideas ?  I thought it might be it didnt like the code (ISIN), but I tried the ISIN code for some stocks and that worked fine, so I am assuming it is because they are funds.  The codes work fine directly on the yahoo! site.  Perhaps Yahoo doesnt provide UK fund prices in downloadable format ?  Looks like the problem you are having ?

    Does Yahoo! have a 'reference' guide somewhere that explains its download formats ?  Can someone post a link on here please.

    On the historical prices front (my original question) perhaps I am being thick but I dont see how the pocketsense will provide a one-time import of a historical price file.  Would one need to create lots of ofx transactions each containing one date and one price and then import one at a time ?  It would be quicker to just manually key the data through the manual price entry.  Or am I missing something ?  I dont know anything about OFX formats.  Anyone got any ideas ?

    Angus

     

    Friday, November 26, 2010 11:37 PM
  • Hi Masterboy,

    The problem seems to be Yahoo on their web pages will display the prices for some obscure funds (in the format you state) but will not  let you download it. I think they do this on purpose - try click the 'download' link in the bottom right of the web page and you will see what I mean when it serves the empty csv. I've escalated to customer support with no response

    Wrt OFX. So long as the investement has no price on that date, you seem to be able to update it with an OFX with the date you put in <DTASOF>. Empty the prices of an investment and give it a try then check the manual price update form and you should see an entry from that date in the file.

    The problem is you are gonna need loads of imports.........

    Saturday, November 27, 2010 3:20 PM
  • I wonder if you could just put a bunch of quotes for the same investment, with different dates, into the same OFX file.

    I would not have trouble extracting the numbers from the HTML from saving the http://uk.finance.yahoo.com/q/hp?s=BARC.L page using Perl. It has a powerful string matching ability. I read there is a way to invoke Perl functions from Python.

    Sunday, November 28, 2010 6:10 AM
    Moderator
  • Hi Cal,

    Would be most grateful if you could suggest some code that could be called from a python function that reads from another part of the sites.dat file.

    Note the funds we are after are the html page uk yahoo finance shows for GB00B0XWNF82.L

    I the Pocketsense scripts were extended in this way I think it would open alot of new possibilities!

    Sunday, November 28, 2010 2:30 PM
  • Hello,

    A rudimentary way to load quotes or indeed account book entries is to use Dataload (search for that name on the Web), which simply plays keystrokes on any application. I used it in the past with Money as I had missed quite some history, it's clumsy to set up but fine for a one off load of a large amount of data, which may be what you're looking for.

    Good luck.


    allp
    Monday, February 14, 2011 9:36 PM