Adapting Quotes.py for worldwide stocks & funds


Now that we have several great methods of importing quotes for USA stocks and funds using Yahoo! Finance, I’ve gotten inquiries regarding quotes from other exchanges and countries around the world.  It appears to be as easy as locating the Yahoo! Finance compatible symbols from the appropriate Yahoo! Finance websites and plugging them in as you would for the USA quotes.

Hera are the YAHOO! FINANCE WORLDWIDE sites:

I’ve just tried this out for a Canadian mutual fund and a Toronto Exchange stock with successful results…

FICDX FIDELITY CANADA FUND 47.29 2/12/2010 6:25pm
YLO-UN.TO YELLOW PAGES INCOME TRUST 5.67 2/12/2010 4:15pm

 


The quotes do seem to be in US Dollars though.   The section of Python script that gathers the quote is…

url = “http://finance.yahoo.com/d/quotes.csv?s=%s&f=nl1d1t1” % self.ticker
        try:
            csv = urllib2.urlopen(url).read()

and could be easily changed, if someone found a similar function at one of the other websites.

-ameridan

Advertisements

8 Comments »

  1. Michael said

    While one can get stock price updates for most foreign stock exchanges on YAHOO Finance – the problem is that Yahoo appends a stock exchange identifier tag to each stock.
    For example for your example of Yahoo Canada you show 2 investments
    1 Fidelity has not identifier as it is a US registered mutual fund – FICDX
    2 Yellow Pages Income Trust is a TSX listed stock with the Yahoo identifier appended (*.TO) and is YLO-UN.TO. The same stock in MS Money will be designated as CD:YLO-UN
    Your script works well with pure US stocks and funds as there are no identifier tags and thus NYSE and Yahoo both have the same Ticker
    Can anyone help for Foreign stocks

  2. ameridan said

    Hi Michael,

    I think you also posted a comment on TFB’s Blog about foreign stocks and I replied:

    The symbols are all relative to MSN, so when gathering the quotes from Yahoo!, they’ll need to be changed. When matching the investments up after the first download using quotes.py, I think Money will store the new symbol internally, even if you don’t see it changed in the Portfolio screen.

    You can download quotes for foreign stocks using the OFX scripts, but I think the quotes will always be in US dollars.

    Even though the exchange rate can also be downloaded with the same script, it won’t work in the same manner as the MSN update.

    I know the foreign stock quotes work, but I think they will always be in US dollars and you would probably have to use the exchange rate as a multiplier.

    Let us know what your analysis comes up with as you experiment some more… 🙂

    • Denis said

      I have been playing around with this, and far as I can see, the only way to relaibly specify non-US funds is by the ISIN code. I have ‘almost’ got it working from Yahoo.co.uk site, but a) the fund prices and often 3 days old, and b) it is a bit hit or miss if Yahoo actually recognises the ISIN code.

      Google seems more reliable in indentifying the correct stock via ISIN, but does not provide a csv format download facility (that I can find anyway).

  3. John Hennessey said

    Denis,
    In all my browsing, you appear to be closest to the prize for us UK stock (and more challengingly) Mutual Fund holders.
    I wondered if you had had any further thoughts / made further progress.
    As threads to date indicate, the challenge is to source a csv from a UK site…but does not appear easy…
    Thanks so much for your work on this.

  4. Chris said

    Hi Ameridan,

    Many thanks for providing this script.

    I’m able to get it working in Australia by using the ticker symbol and appending ‘.ax’ for my stocks. The quotes are accurate and download really quickly.

    I have to edit the OFX file to insert the number of equities I hold for each company otherwise my portfolio gets set to zero. Is there any way the script could be updated to hold these values and just update the prices?

    Many thanks anyway.

    Chris

    • Chris,
      Are you able to download quotes for Australia with the number of equities now? If so, could I have a copy please?
      Neil

    • Chris. Edgeworth said

      Hi Neil,

      I’ve played around with the OFX file without much success I’m afraid.

      What I do now is create the OFX file with the Java script and edit it using Notepad++. There I have created a macro to strip of the ‘*.ax’ appendage from the ticker symbols and update the number of equities for the stocks I hold. It only takes a second to run and I run it via a keyboard shortcut.

      Its a pain and an extra step, but gives me the results I want.

      I’ve also found where the account details are held in the ‘quotes.ofx’ file so my macro even updates that.

      It lessens the key strokes when you import it into Money as it dumps it directly into the correct Portfolio account.

      I sometimes use the ‘MSN Money Excel Add On’ in a spreadsheet and update the prices manually. I’m not sure exactly where they come from but they are correct. I think its from Microsoft as there are heaps of their cookies left on my PC after I have updated the prices. Its still working even though they say they are not supporting this facility anymore.

      I’m sorry I cannot be of much help. I’m not a programmer, so hacking / writing a Java script is beyond me at my time of life. None the less I’m very grateful to the guy(s) who wrote the script I’m now using.

      Cheers

      Chris.

RSS feed for comments on this post

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: