Python Get Historical Stock Prices With Yfinance

import yfinance as yfyticker = yf.Ticker("MSFT")df = yticker.history(period="3y") # max, 3mo, etc# print(df.columns)# ['Open', 'High', 'Low', 'Close', 'Volume', 'Dividends', 'Stock Splits'print(df)'''                  Open        High  ...  Dividends  Stock SplitsDate                                ...                         2017-10-31   80.666197   80.666197  ...        0.0             02017-11-01   80.015972   80.092470  ...        0.0             02017-11-02   79.700420   80.761818  ...        0.0             02017-11-03   80.398455   80.838313  ...        0.0             02017-11-06   80.513203   80.991310  ...        0.0             0...                ...         ...  ...        ...           ...2020-10-26  213.850006  216.339996  ...        0.0             02020-10-27  211.589996  214.669998  ...        0.0             02020-10-28  207.669998  208.839996  ...        0.0             02020-10-29  204.070007  207.360001  ...        0.0             02020-10-30  203.500000  204.289993  ...        0.0             0'''for index, row in df.iterrows():    # 2017-10-31 00:00:00 80.6661972680961 80.6661972680961 79.47093001044333 79.5378646850586 27086600.0    print(index, row['Open'], row['High'], row['Low'], row['Close'], row['Volume'])

NOTE: Plot yfinance Historical Candle Chart With mplfinance

❤️ Is this article helpful?

Buy me a coffee ☕ or support my work via PayPal to keep this space 🖖 and ad-free.

Do send some 💖 to @d_luaz or share this article.

✨ By Desmond Lua

A dream boy who enjoys making apps, travelling and making youtube videos. Follow me on @d_luaz

👶 Apps I built

Travelopy - discover travel places in Malaysia, Singapore, Taiwan, Japan.