import sys
sys.path.append('../group-1')
import pandas as pd 
from scraper.top100_extractor import programming_crime_list

def stock_price_time_series(ticker: str):
  # Read market price csv
    market_prices = pd.read_csv(f'Companies_Data/{ticker}_Data/{ticker}_price_history.csv')

    return market_prices

def eps_bar_chart(ticker: str):
    # Read earnings csv
    earnings = pd.read_csv(f'Companies_Data/{ticker}_Data/{ticker}earnings.csv')
    
    earnings = earnings[['symbol', 'epsActual', 'quarter']]

    return earnings

def concatenate_price_history():
    # Declare empty dataframe 
    unified_price_history = pd.DataFrame()

    for ticker in programming_crime_list:
        prices = stock_price_time_series(ticker)
        unified_price_history = pd.concat([prices, unified_price_history], ignore_index=True, axis=0)
    
    unified_price_history.to_csv('Elaborated_Data/price_history_data.csv')

def concatenate_eps():
    # Declare  empty dataframe
    eps_df = pd.DataFrame()

    for ticker in programming_crime_list:
        eps = eps_bar_chart(ticker)
        eps_df = pd.concat([eps, eps_df], ignore_index=True, axis=0)
    
    eps_df.to_csv('Elaborated_Data/eps_quarterly_bar_chart.csv')

if __name__ == '__main__':
    concatenate_price_history()
    concatenate_eps()