import json import time from copy import deepcopy as cp from __init__ import chk_arg fname = None if chk_arg("json") is not None: fname = chk_arg("json") with open(fname, 'r') as f: data = json.load(f) top = {} loops = 0 for symbol, profit_avg_list in sorted(data.iteritems()): avg = int(profit_avg_list[0]) profit = float(profit_avg_list[1]) if profit < 1: continue if len(top) < 30: top[symbol] = profit_avg_list continue for tmp_symbol, tmp_profit_avg_list in sorted(top.iteritems()): tmp_avg = int(tmp_profit_avg_list[0]) tmp_profit = float(tmp_profit_avg_list[1]) if profit > tmp_profit: del top[tmp_symbol] top[symbol] = profit_avg_list break print json.dumps(top, indent=4, sort_keys=True)
#!/usr/bin/env python import mvg import datetime import sys import json from __init__ import START_DATE, END_DATE, chk_arg import os fprint = False if 'debug' in sys.argv: fprint = True fjson=None if chk_arg("json") is not None: fjson = chk_arg("json") SELL_THRESHOLD = 6 if chk_arg("sell_thresh") is not None: SELL_THRESHOLD = int(chk_arg("sell_thresh")) if chk_arg("days") is not None: days = int(chk_arg("days")) if chk_arg("ticker") is not None: stocks = [chk_arg("ticker")] elif any("links" in s for s in sys.argv): with open("../links.json", 'r') as g: links = json.load(g) stocks = [] for a, b in links.iteritems(): tmp = a.lower()
INITIAL_CAPITAL) return capital if __name__ == '__main__': fprint = False _ticker = sys.argv[1] if 'debug' in sys.argv: fprint = True if any("short" in s for s in sys.argv): index = [i for i, s in enumerate(sys.argv) if 'short' in s][0] sshort = sys.argv[index].split('=')[1] sshort = int(sshort) short_window = sshort long_window = sshort elif chk_arg("json") is not None: fjson = chk_arg("json") with open(fjson, 'r') as fx: data = json.load(fx) if _ticker in data: sshort = int(data[_ticker][0]) else: with open('json/best_avg.json', 'r') as fx: data = json.load(fx) if _ticker in data: sshort = int(data[_ticker][0]) if any("long" in s for s in sys.argv): index = [i for i, s in enumerate(sys.argv) if 'long' in s][0] llong = sys.argv[index].split('=')[1] long_window = int(llong)
#!/usr/bin/env python import mvg2 import datetime import sys import json from __init__ import START_DATE, END_DATE, chk_arg fprint = False if 'debug' in sys.argv: fprint = True fjson=None if chk_arg("json") is not None: fjson = chk_arg("json") SELL_THRESHOLD = 6 if chk_arg("sell_thresh") is not None: SELL_THRESHOLD = int(chk_arg("sell_thresh")) if chk_arg("days") is not None: days = int(chk_arg("days")) if chk_arg("ticker") is not None: stocks = [chk_arg("ticker")] elif any("links" in s for s in sys.argv): with open("../links.json", 'r') as g: links = json.load(g) stocks = [] for a, b in links.iteritems(): tmp = a.lower() if "." in a: