diff --git a/src/historicaldata.py b/src/historicaldata.py index a297a7b..975c15e 100644 --- a/src/historicaldata.py +++ b/src/historicaldata.py @@ -20,7 +20,7 @@ def summary(step, company_details): if len(hist_data) < 1: print ("Sorry! No results found for the given date range.\n") else: - print("="*20+"History"+"="*20+"\n\n"+str(hist_data)+"\n\n"+"="*48) + print("\n"+"="*21+"History"+"="*21+"\n\n"+str(hist_data)+"\n\n"+"="*49) # This function displays the historical on monthly frequency basis within the date range given by the user def summary_monthly(company_details): @@ -44,7 +44,7 @@ def summary_monthly(company_details): if len(month_summary) < 1: print ("Sorry! No results found for the given date range.\n") else: - print("="*16+"Monthly history"+"="*16+"\n\n"+str(month_summary)+"\n\n"+"="*47) + print("\n"+"="*18+"Monthly history"+"="*18+"\n\n"+str(month_summary)+"\n\n"+"="*51) # This function is used for printing the menu for frequency of data retreival def historicaldata(company_details): diff --git a/src/main.py b/src/main.py index c9fee98..a3d359f 100644 --- a/src/main.py +++ b/src/main.py @@ -10,11 +10,8 @@ from prediction import prediction import utils -companylist = pd.read_csv("http://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchan0ge=nasdaq&render=download") - -def menu2(companydata,companylist,comindex): - utils.cls() - +def menu2(companylist,comindex): + utils.cls() print("="*26, "You selected", "="*26) print((companylist.iloc[int(comindex)])) loop = True @@ -29,13 +26,13 @@ def menu2(companydata,companylist,comindex): print("6. Exit") option = input("\nYour option: ").lstrip() if option == '1': - summary(companydata) + summary(companylist,comindex) elif option == '2': graph(companylist,comindex), elif option == '3': - historicaldata(companydata), + historicaldata(companylist,comindex), elif option == '4': - prediction(companydata), + prediction(companylist,comindex), elif option == '5': menu() elif option == '6': @@ -48,6 +45,7 @@ def menu2(companydata,companylist,comindex): def name(): utils.cls() + companylist = pd.read_csv("http://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchan0ge=nasdaq&render=download") companyName = input("\nEnter the company name you want to search : ").lstrip() outlen = len(companylist[companylist['Name'].str.contains(companyName,case = False)]) @@ -62,7 +60,7 @@ def name(): outlen = len(companylist[companylist['Name'].str.contains(companyName,case = False)]) temp_match = companylist[companylist['Name'].str.contains(companyName,case = False)] - print(temp_match.loc[:,'Symbol':'Name']) + print("\n"+str(temp_match.loc[:,'Symbol':'Name'])) loop = True while loop: @@ -70,9 +68,7 @@ def name(): comindex = int(input("\nEnter the index number of the company you want: ").lstrip()) if temp_match.index.contains(comindex): loop = False - tickerName = companylist.iloc[int(comindex)].Symbol - companydata = pd.read_csv("https://www.google.com/finance/historical?output=csv&q=" + str(tickerName)) - menu2(companydata,companylist,comindex) + menu2(companylist,comindex) else: print("\nThe name you have entered is not found. Please try again...") @@ -81,6 +77,7 @@ def name(): def ticker(): utils.cls() + companylist = pd.read_csv("http://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchan0ge=nasdaq&render=download") companyTicker = input("\nEnter the company ticker you want to search: ").lstrip() matchTicker = companylist[companylist['Symbol'].str.contains(companyTicker,case = False)] outlen = len(matchTicker) @@ -98,7 +95,7 @@ def ticker(): outlen = len(matchTicker) temp_match = companylist[companylist['Symbol'].str.contains(companyTicker,case = False)] - print(temp_match.loc[:,'Symbol':'Name']) + print("\n"+str(temp_match.loc[:,'Symbol':'Name'])) loop = True while loop: @@ -106,15 +103,15 @@ def ticker(): comindex = int(input("\nEnter the index number of the company you want: ").lstrip()) if temp_match.index.contains(comindex): loop = False - tickerName = companylist.iloc[int(comindex)].Symbol - companydata = pd.read_csv("https://www.google.com/finance/historical?output=csv&q=" + str(tickerName)) - menu2(companydata,companylist,comindex) + menu2(companylist,comindex) else: print("\nThe ticker you have entered is not found. Please try again...") except ValueError: print("\nIncorrect Index Value! Please try again ... ") + + def menu(): utils.cls() loop = True diff --git a/src/utils.py b/src/utils.py index 9b5f35c..41d2e65 100644 --- a/src/utils.py +++ b/src/utils.py @@ -25,7 +25,6 @@ def get_date(): while True: try: to_date = datetime.strptime(input("\nPlease enter the To date in format dd-mon-yy. ie 20-Feb-17 : "),'%d-%b-%y') - print("\n") cur_date = datetime.strptime(str(date.today()),'%Y-%m-%d') if to_date > cur_date: print("\nTo date cannot be greater than today's date.") @@ -43,7 +42,7 @@ def get_date(): def check_date_after(): while True: try: - pred_date = datetime.strptime(input("Please enter the prediction date in format dd-mon-yy. ie 20-Feb-18: "),'%d-%b-%y') + pred_date = datetime.strptime(input("\nPlease enter the prediction date in format dd-mon-yy. ie 20-Feb-18: "),'%d-%b-%y') cur_date = datetime.strptime(str(date.today()),'%Y-%m-%d') if pred_date < cur_date: print("\nPrediction date cannot be before today's date.")