Given an ISIN, e.g. FI0009800643, how can I query the history of this stock? I tried using yfinance as follows:

msft = yfinance.Ticker(FI0009800643"")
hist = msft.history(period="1d")

but this just returns an error No data found, symbol may be delisted.

But when I enter the same ISIN on the yahoo finance page https://fr.finance.yahoo.com/ I get to the correct result (in this case a company named YIT Oyj in Finland.

So how to query data with the Yahoo Finance API given the ISIN?

  • Does this violate Yahoo Finance's terms of service?
    – Flux
    May 31, 2021 at 12:05

1 Answer 1


You can query Yahoo finance to get the Yahoo ticker symbol using elemental (which is basically selenium). Here is the code:

import json
import elemental
import yfinance
import urllib.parse as urlparse
from urllib.parse import parse_qs

def get_quote(symbol):
    msft = yfinance.Ticker(symbol)
        hist = msft.history(period="2d")
    except json.decoder.JSONDecodeError:
        return None
        jsdata = json.loads(hist.to_json())
        return jsdata["Close"]["0"]
    except (ValueError, KeyError) as e:
       return None

def web_lookup(browser, isin):
    # Search PyPI for Elemental.
    browser = elemental.Browser()


    parsed = urlparse.urlparse(browser.url)
        ticker = parse_qs(parsed.query)['p'][0]
    except KeyError:
        ticker = "n/a"
    return ticker

When you call the function web_lookup essentially the lookup page will, be opened, the ISIN will be entered into the search box, and the browser eventually navigates to the Yahoo page with the Yahoo ticker symbol, which will be extracted from the URL the browser navigates to. The code then tries to use this ticker symbol to get the quotes from the last two days using the yahoo finance API. If that all works fine, the function returns a working Yahoo ticker symbol, or n/a in case something did not work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .