import yahoo_fin.stock_info as si
import csv
from time import sleep



tickers = [
"AAU"
]

counter = 0

for ticker in tickers:

    print(ticker)
    try:
        earnings_hist = si.get_earnings_history(ticker)
        print(earnings_hist)
    except IndexError:
        continue

    if(len(earnings_hist) > 0):

        with open(ticker+'.csv', 'w', newline='') as file:
            writer = csv.writer(file)
            for hist in earnings_hist:
                writer.writerow([hist["startdatetime"]])

    print(counter)
    counter+= 1
    if(counter == 15):
        print("sleep 10 seconds")
        #sleep(10)
        counter = 0
        
    
    
