diff --git a/robot.py b/robot.py index 4a6b932..9e691eb 100644 --- a/robot.py +++ b/robot.py @@ -45,16 +45,26 @@ symbols = json.loads(s) f.close() if args.symbol is not None: - symbol, fullname, currency = args.symbol.split('|') + sfc = args.symbol.split('|') + symbol = sfc[0] show_symbols = [symbol] if symbol not in symbols: + try: + fullname = sfc[1] + except: + fullname = 'Enter full name here' + try: + currency = sfc[2] + except: + currency = 'USD' + symbols[symbol] = {'name' : fullname, 'currency' : currency} s = json.dumps(symbols, sort_keys=True, indent=4) f = open('stocks.json', 'w') f.write(s) f.close() else: - print ("{} is already in database".format(symbol)) + print ("{} is in database".format(symbol)) if args.analyze_range is not None: params['analyze_range_days'] = args.analyze_range