<jupyter_start><jupyter_text>YFinance<jupyter_code>def get_info_on_stock(ticker):
    stock = yf.Ticker(ticker)

    # Get overview of company
    print(stock.info)

    # Get historical closing price data
    hist = stock.history(period="max")["Close"]
    print(hist.head())

    # Get financial data
    print(stock.financials)

    # Get major share holders
    print(stock.major_holders)

    # Get institutional holders
    print(stock.institutional_holders)

    # Get balance sheet
    print(stock.balance_sheet)

    # Show cashflow
    print(stock.cashflow)

    # Show earnings
    print(stock.earnings)

    # Show analysts recommendations
    print(stock.recommendations)
    
get_info_on_stock("14D.AX")<jupyter_output>{'zip': '5039', 'sector': 'Utilities', 'longBusinessSummary': '1414 Degrees Limited offers silicon-based thermal energy storage systems for networks and industries in Australia. It provides heat and electricity from renewable energy sources. The company was formerly known as Latent Heat Storage Pty Ltd and changed its name to 1414 Degrees Limited in December 2016. 1414 Degrees Limited was incorporated in 2009 and is based in Melrose Park, Australia.', 'city': 'Melrose Park', 'phone': '61 8 8357 8273', 'state': 'SA', 'country': 'Australia', 'companyOfficers': [], 'website': 'https://1414degrees.com.au', 'maxAge': 1, 'address1': '136 Daws Road', 'industry': 'Utilities—Independent Power Producers', 'ebitdaMargins': 0, 'profitMargins': 0, 'grossMargins': 1, 'operatingCashflow': -2393455, 'revenueGrowth': None, 'operatingMargins': -6.1708302, 'ebitda': -2969202, 'targetLowPrice': None, 'recommendationKey': 'none', 'grossProfits': None, 'freeCashflow': -1790165, 'targetMedianPrice': None, 'c[...]<jupyter_text>Holds Stocks Not Downloaded<jupyter_code>stocks_not_downloaded = []
missing_stocks = []<jupyter_output><empty_output><jupyter_text>Function that Returns a Stock Dataframe from a CSV<jupyter_code># Reads a dataframe from the CSV file, changes index to date and returns it
def get_stock_df_from_csv(folder, ticker):
    
    # Try to get the file and if it doesn't exist issue a warning
    try:
        df = pd.read_csv(folder + ticker + '.csv')
    except FileNotFoundError:
        print("File Doesn't Exist")
    else:
        return df<jupyter_output><empty_output><jupyter_text>Returns a Named Columns Data from a CSV<jupyter_code>def get_column_from_csv(file, col_name):
    # Try to get the file and if it doesn't exist issue a warning
    try:
        df = pd.read_csv(file)
    except FileNotFoundError:
        print("File Doesn't Exist")
    else:
        return df[col_name]<jupyter_output><empty_output><jupyter_text>Get Stock Tickers<jupyter_code># Total of 3898 tickers
# Windows version
# tickers = get_column_from_csv("D:/Python for Finance/Australia.csv", "Ticker")
# MacOS Version
#path = "/Users/derekbanas/Documents/Tutorials/Python for Finance/Australia.csv"
path = "../csv/Russell10.csv"
tickers = get_column_from_csv(path, "Ticker")
tickers

for x in tickers:
    print(x, end=", ")<jupyter_output>AMC, OVV, NTLA, LSCC, TTEK, ASAN, CROX, SGMS, BJ,<jupyter_text>Function that Saves Stock Data to CSV<jupyter_code># Function that gets a dataframe by providing a ticker and starting date
def save_to_csv_from_yahoo(folder, ticker):
    
    stock = yf.Ticker(ticker)
    
    try:
        print("Get Data for : ", ticker)
        # Get historical closing price data
        df = stock.history(period="max")["Close"]
    
        # Wait 2 seconds
        time.sleep(2)
        
        if df.empty:
            stocks_not_downloaded.append(ticker)
        
        # Remove the period for saving the file name
        # Save data to a CSV file
        # File to save to 
        the_file = folder + ticker.replace(".", "_") + '.csv'
        print(the_file, " Saved")
        df.to_csv(the_file)
    except Exception as ex:
        stocks_not_downloaded.append(ticker)
        print("Couldn't Get Data for :", ticker)<jupyter_output><empty_output><jupyter_text>Get 5 Years of Data for the 1st 20 Stocks<jupyter_code># mkdir -p '../stock_data'
# Folder used to store stock data
folder = "../stock_data/"

for x in range(9):
    save_to_csv_from_yahoo(folder, tickers[x])
print("Finished")<jupyter_output>Get Data for :  AMC
../stock_data/AMC.csv  Saved
Get Data for :  OVV
../stock_data/OVV.csv  Saved
Get Data for :  NTLA
../stock_data/NTLA.csv  Saved
Get Data for :  LSCC
../stock_data/LSCC.csv  Saved
Get Data for :  TTEK
../stock_data/TTEK.csv  Saved
Get Data for :  ASAN
../stock_data/ASAN.csv  Saved
Get Data for :  CROX
../stock_data/CROX.csv  Saved
Get Data for :  SGMS
../stock_data/SGMS.csv  Saved
Get Data for :  BJ
../stock_data/BJ.csv  Saved
Finished<jupyter_text>Get Next 80 Stocks<jupyter_code># for x in range(20, 100):
#   save_to_csv_from_yahoo(folder, tickers[x])
# print("Finished")
# for x in range(2000, 3898):
#   save_to_csv_from_yahoo(folder, tickers[x])
# print("Finished")
# stocks_not_downloaded<jupyter_output><empty_output><jupyter_text>Get Euronext Tickers<jupyter_code># # Total of 1648 tickers
# tickers = get_column_from_csv("D:/Python for Finance/Euronext.csv", "Ticker")
# tickers

# for x in tickers:
#     print(x, end=", ")
# folder = "D:/Python for Finance/Euronext_Stocks/"
# for x in range(0, 1648):
#   save_to_csv_from_yahoo(folder, tickers[x])
# print("Finished")
# stocks_not_downloaded<jupyter_output><empty_output><jupyter_text>Get Frankfurt Tickers<jupyter_code># # Total of 496 tickers
# tickers = get_column_from_csv("D:/Python for Finance/Frankfurt.csv", "Ticker")
# tickers

# for x in tickers:
#     print(x, end=", ")
# folder = "D:/Python for Finance/Frankfurt_Stocks/"
# for x in range(0, 495):
#   save_to_csv_from_yahoo(folder, tickers[x])
# print("Finished")
# stocks_not_downloaded<jupyter_output><empty_output><jupyter_text>Get FTSE Stocks<jupyter_code># # Total of 620 tickers
# tickers = get_column_from_csv("D:/Python for Finance/FTSE.csv", "Ticker")
# tickers

# for x in tickers:
#     print(x, end=", ")
# folder = "D:/Python for Finance/FTSE_Stocks/"
# for x in range(0, 619):
#   save_to_csv_from_yahoo(folder, tickers[x])
# print("Finished")
# stocks_not_downloaded<jupyter_output><empty_output><jupyter_text>Get Johannesburg Stocks<jupyter_code># # Total of 400 tickers
# tickers = get_column_from_csv("D:/Python for Finance/Johannesburg.csv", "Ticker")
# tickers

# for x in tickers:
#     print(x, end=", ")
# folder = "D:/Python for Finance/Johannesburg_Stocks/"
# for x in range(0, 399):
#   save_to_csv_from_yahoo(folder, tickers[x])
# print("Finished")
# stocks_not_downloaded<jupyter_output><empty_output><jupyter_text>Get NASDAQ<jupyter_code># # Total of 2968 tickers
# tickers = get_column_from_csv("D:/Python for Finance/Nasdaq.csv", "Ticker")
# tickers

# for x in tickers:
#     print(x, end=", ")
# folder = "D:/Python for Finance/Nasdaq_Stocks/"
# for x in range(0, 2967):
#   save_to_csv_from_yahoo(folder, tickers[x])
# print("Finished")
# stocks_not_downloaded<jupyter_output><empty_output><jupyter_text>Get NYSE<jupyter_code># # Total of 2626 tickers
# tickers = get_column_from_csv("D:/Python for Finance/NYSE.csv", "Ticker")
# tickers

# for x in tickers:
#     print(x, end=", ")
# folder = "D:/Python for Finance/NYSE_Stocks/"
# for x in range(0, 2625):
#   save_to_csv_from_yahoo(folder, tickers[x])
# print("Finished")
# stocks_not_downloaded<jupyter_output><empty_output><jupyter_text>Get Russell 2000<jupyter_code># Total of 2033 tickers
tickers = get_column_from_csv("D:/Python for Finance/Russell2000.csv", "Ticker")
tickers

for x in tickers:
    print(x, end=", ")
folder = "D:/Python for Finance/Russell2000_Stocks/"
for x in range(1761, 2032):
  save_to_csv_from_yahoo(folder, tickers[x])
print("Finished")
stocks_not_downloaded<jupyter_output>Get Data for :  DS
D:/Python for Finance/Russell2000_Stocks/DS.csv  Saved
Get Data for :  GLUE
D:/Python for Finance/Russell2000_Stocks/GLUE.csv  Saved
Get Data for :  INTA
D:/Python for Finance/Russell2000_Stocks/INTA.csv  Saved
Get Data for :  DAWN
D:/Python for Finance/Russell2000_Stocks/DAWN.csv  Saved
Get Data for :  SOLY
D:/Python for Finance/Russell2000_Stocks/SOLY.csv  Saved
Get Data for :  LCUT
D:/Python for Finance/Russell2000_Stocks/LCUT.csv  Saved
Get Data for :  USLM
D:/Python for Finance/Russell2000_Stocks/USLM.csv  Saved
Get Data for :  CDAK
D:/Python for Finance/Russell2000_Stocks/CDAK.csv  Saved
Get Data for :  ICAD
D:/Python for Finance/Russell2000_Stocks/ICAD.csv  Saved
Get Data for :  AWH
D:/Python for Finance/Russell2000_Stocks/AWH.csv  Saved
Get Data for :  FLMN
D:/Python for Finance/Russell2000_Stocks/FLMN.csv  Saved
Get Data for :  ATNX
D:/Python for Finance/Russell2000_Stocks/ATNX.csv  Saved
Get Data for :  NEXI
D:/Python for Finance/Russell2000_Stocks/NEXI.csv[...]
{'fraction_non_alphanumeric': 0.11856721831784175, 'fraction_numerical': 0.026071185672183177, 'mean_word_length': 4.51782363977486, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '15', 'dir': 'jupyter-structured-clean-dedup', 'id': '384393', 'license': 'CC0-1.0', 'n_tokens_mistral': 3463, 'n_tokens_neox': 3144, 'n_words': 783, 'path': '1_test_notebooks/Download Every Stock.ipynb', 'repo_name': 'tonybutzer/pf', 'size': '8822'}