Search code examples
pythonyfinance

yfinance how to get data if the ticker is same for different exchanges


I want to get historical price data using python and yfinance for Indonesian stocks. I see that there are many stocks that have the same name across different countries, for example AUTO (can be Indonesian company Astra Otoparts Tbk PT or NASDAQ's Autoweb Inc)

When I do yf.download('AUTO'), it's returning me a price data of Autoweb Inc, instead of Indonesian stock Astra Otoparts Tbk PT.

How can we select which exchange we want the ticker from?

Thanks.

enter image description here


Solution

  • I've only looked up the brand name in your question, AUTO.JK is the brand name. I have not checked if it is a rule to add abbreviated names.

    import yfinance as yf
    data = yf.download("AUTO.JK", start="2021-01-01", end="2021-03-01")
    
    data.head()
        Open    High    Low     Close   Adj Close   Volume
    Date                        
    2021-01-04  1115.0  1140.0  1100.0  1120.0  1093.855225     1639000
    2021-01-05  1120.0  1150.0  1120.0  1130.0  1103.621826     1337200
    2021-01-06  1140.0  1150.0  1090.0  1135.0  1108.505127     1507500
    2021-01-07  1135.0  1145.0  1110.0  1115.0  1088.971924     2225300
    2021-01-08  1115.0  1145.0  1115.0  1135.0  1108.505127     2546400