File size: 544 Bytes
2aaf2a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
import yfinance as yf
import pandas as pd

def fetch_yfinance_daily(ticker, start_date, end_date):
    try:
        data = yf.download(ticker, start=start_date, end=end_date)
        if data.empty:
            print(f"No data found for {ticker} between {start_date} and {end_date}")
            return None
        print("data type returned:", type(data['Close']))
        return data['Close'][ticker]
    except Exception:
        return None 
    
if __name__ == "__main__":
    print(fetch_yfinance_daily("MSFT", "2020-01-01", "2020-01-10"))