From 29d82dab6962f114dafd54b4103e9deca91edd83 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Tue, 7 Jan 2020 22:24:07 +0000 Subject: [PATCH] - added convenient adding of symbols git-svn-id: http://moon:8086/svn/projects/Stock@359 fda53097-d464-4ada-af97-ba876c37ca34 --- robot.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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