<commit_before>from plugin import plugin, require
import requests
import json

@plugin('stock')
class Stock():

    def __call__(self, jarvis, s):
        quote = input("Stock Symbol: ").replace(" ", "")
        self.getStockData(quote)


    def getStockData(self, quote):
        resp = requests.get('https://api.iextrading.com/1.0/stock/' + quote + '/quote').json()
        print("Price: " + str(resp['iexRealtimePrice']))
        print("Open: " + str(resp['open']))
        print("Close: " + str(resp['close']))
        print("Change: " + str(resp['changePercent']) + "%")
        print("MarketCap: " + str(resp['marketCap']))






# if __name__ == '__main__':
#     Stock.getStockData(Stock, 'aapl')<commit_msg>Added error handling for invalid stock symbol<commit_after>from plugin import plugin, require
import requests
import json

@plugin('stock')
class Stock():

    def __call__(self, jarvis, s):
        quote = input("Stock Symbol: ").replace(" ", "")
        self.getStockData(quote)


    def getStockData(self, quote):

        resp = requests.get('https://api.iextrading.com/1.0/stock/' + quote + '/quote')

        if (resp.status_code == 200):
            resp = resp.json()
            print("Price: " + str(resp['iexRealtimePrice']))
            print("Open: " + str(resp['open']))
            print("Close: " + str(resp['close']))
            print("Change: " + str(resp['changePercent']) + "%")
            print("MarketCap: " + str(resp['marketCap']))
        else:
            print("The given stock symbol could not be found!")








# if __name__ == '__main__':
#     Stock.getStockData(Stock, 'aapl')
{'fraction_non_alphanumeric': 0.17730061349693252, 'fraction_numerical': 0.004294478527607362, 'mean_word_length': 2.9396135265700485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5255675', 'n_tokens_mistral': 522, 'n_tokens_neox': 485, 'n_words': 105}