Example #1
0
    def get_stock_data(self, stock):
        print(f"Getting Stock Data for {stock}")
        stock_json_file = API.API_Class().call_quotes_api(stock)
        if stock_json_file != 'False':
            self.reg_change_percent = stock_json_file['quoteResponse'][
                'result'][0]['regularMarketChangePercent']
            self.reg_change_dollars = stock_json_file['quoteResponse'][
                'result'][0]['regularMarketPreviousClose']
            pre_results = self.validation('Pre', stock_json_file)
            post_results = self.validation('Post', stock_json_file)

            if pre_results == True:
                self.pre_change_percent = stock_json_file['quoteResponse'][
                    'result'][0]['preMarketChangePercent']
                self.pre_change_dollars = stock_json_file['quoteResponse'][
                    'result'][0]['preMarketChange']

            if post_results == True:
                self.post_change_percent = stock_json_file['quoteResponse'][
                    'result'][0]['postMarketChangePercent']
                self.post_change_dollars = stock_json_file['quoteResponse'][
                    'result'][0]['postMarketChange']
            return True
        else:
            return False
Example #2
0
def main():
	'''
		Calls the Movers API and uses that file to retrieve the top movers
		and top losers of the day.
		The data is then stored in DynamoDB and generates a CSV based on
		those results. Those results are then sent to end users via text.
	'''
	print("Main Function Triggered")
	Database = Database_Class()
	S3 = S3_Class()
	Messenger = SNS_Class()
	movers_json = API.API_Class().call_movers_api()
	top_winners = Stock.Stock_Class().get_top_winners(movers_json)
	top_losers = Stock.Stock_Class().get_top_losers(movers_json)
	# Sample Values
	# top_winners = {'STNE': {'RPC': 20.49491, 'RP': 34.35, 'PRPC': 24.1, 'PRP': 2.1000023, 'PPC': 24, 'PP': 0.060001373}}
	Database.put_series(top_winners, 'Winners')
	Database.put_series(top_losers, 'Losers')
	file_name = Database.create_file()
	Database.export_data(f'Results/{file_name}')
	object_url = S3.upload_file(f'{file_name}')
	Messenger.send_text(object_url)