Пример #1
0
def create_graph(stock_list,
                 template_file,
                 conf_dir,
                 stock_region='US',
                 signal_file="signal_file",
                 endday='today'):
    """
    根据股票代码生成图片
    """
    out_dir = img_out_dir
    graph_conf = "%s/graph_day.conf" % (conf_dir)
    template_graph_conf = "/tmp/graph_%s.conf" % (signal_file)
    graph_week_conf = "%s/graph_week.conf" % (conf_dir)
    graph_month_conf = "%s/graph_month.conf" % (conf_dir)
    stock_count = len(stock_list)
    template = TemplateManager().prepare(template_file)
    tproc = TemplateProcessor(html_escape=0)
    stock = []
    for symbol in stock_list:
        img_file = "%s/%s.png" % (out_dir, symbol)
        img_week_file = "%s/%s_WEEK.png" % (out_dir, symbol)
        img_month_file = "%s/%s_MONTH.png" % (out_dir, symbol)
        stock_dict = {}
        stock_dict['symbol'] = symbol
        stock_dict['img'] = img_file
        stock_dict['img_week'] = img_week_file
        stock_dict['img_month'] = img_month_file
        stock.append(stock_dict)
    #pprint.pprint(stock)
    tproc.set("market_name", "%s Market" % stock_region)
    tproc.set("stock_count", stock_count)
    tproc.set("Stock", stock)
    # save to file
    filename = "%s/%s_%s_STOCK.html" % (out_dir, stock_region, signal_file)
    FILE = open(filename, "w")
    FILE.writelines(tproc.process(template))
    FILE.close()

    # 多线程运行
    global clientpool
    #globals()['clentpool'] = Queue.Queue(0)
    clientpool = Queue.Queue(0)
    ts = []
    for a in stock_list:
        a = a.strip()
        clientpool.put(a)

    for b in xrange(20):
        t = graph_runs(stock, endday, conf_dir)
        t.start()
        ts.append(t)
    for t in ts:
        if t: t.join()
Пример #2
0
def create_graph(stock_list,template_file,conf_dir,stock_region='US',signal_file="signal_file",endday='today'):
    """
    根据股票代码生成图片
    """
    out_dir = img_out_dir
    graph_conf = "%s/graph_day.conf" % (conf_dir)
    template_graph_conf = "/tmp/graph_%s.conf" % (signal_file)
    graph_week_conf = "%s/graph_week.conf" % (conf_dir)
    graph_month_conf = "%s/graph_month.conf" % (conf_dir)
    stock_count = len(stock_list)
    template = TemplateManager(precompile=0).prepare(template_file)
    tproc = TemplateProcessor(html_escape=0)
    stock = []
    for symbol in stock_list:
        symbol = symbol.strip()
        img_file = "%s/%s.png" % (out_dir,symbol)
        img_week_file = "%s/%s_WEEK.png" % (out_dir,symbol)
        img_month_file = "%s/%s_MONTH.png" % (out_dir,symbol)
        #if not os.path.isfile(img_file):
        #if calc_support_resistance(symbol,'day',template_graph_conf):
        #    graph_conf = template_graph_conf
        os.chdir('%s' % script_dir)
        #cmd = "cd %s;perl ./graphic.pl --file %s %s>%s" % (script_dir,graph_conf,symbol,img_file)
        cmd = "perl graphic.pl --file %s %s > %s" % (graph_conf,symbol,img_file)
        #print cmd
        (status,output) = commands.getstatusoutput(cmd)
        #print "DEBUG graph_cmd = %s" % cmd
        #res = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
        #print "DEBUG : stderr = %s " % res.stderr.readlines()
        #stock_line = res.stdout.readlines()
        #print stock_line
        (status,output) = commands.getstatusoutput(cmd)
        #sys.exit()
        cmd = "perl  graphic.pl --file %s %s > %s" % (graph_week_conf,symbol,img_week_file)
        #print "DEBUG graph_cmd = %s" % cmd
        (status,output) = commands.getstatusoutput(cmd)
        #res = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)

        cmd = "perl  graphic.pl --file %s %s > %s" % (graph_month_conf,symbol,img_month_file)
        #print "DEBUG graph_cmd = %s" % cmd
        #res = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
        (status,output) = commands.getstatusoutput(cmd)
        stock_dict= {}
        stock_dict['symbol'] = symbol
        stock_dict['img'] = img_file
        stock_dict['img_week'] = img_week_file
        stock_dict['img_month'] = img_month_file
        stock.append(stock_dict)

    #pprint.pprint(stock)
    tproc.set("market_name","%s Market" % stock_region)
    tproc.set("stock_count",stock_count)
    tproc.set("Stock",stock)
    # save to file
    filename = "%s/%s_%s_STOCK.html" % (out_dir,stock_region,signal_file)
    FILE = open(filename,"w")
    FILE.writelines(tproc.process(template))
    FILE.close()
Пример #3
0
def create_graph(stock_list,template_file,conf_dir,stock_region='US',signal_file="signal_file",endday='today'):
    """
    根据股票代码生成图片
    """
    out_dir = "/home/hua.fu/geniustrader/output"
    graph_conf = "%s/graph_day.conf" % (conf_dir)
    template_graph_conf = "/tmp/graph_%s.conf" % (signal_file)
    graph_week_conf = "%s/graph_week.conf" % (conf_dir)
    graph_month_conf = "%s/graph_month.conf" % (conf_dir)
    stock_count = len(stock_list)
    template = TemplateManager().prepare(template_file)
    tproc = TemplateProcessor(html_escape=0)
    stock = []
    for symbol in stock_list:
        symbol = symbol.strip()
        img_file = "%s/%s.png" % (out_dir,symbol)
        img_week_file = "%s/%s_WEEK.png" % (out_dir,symbol)
        img_month_file = "%s/%s_MONTH.png" % (out_dir,symbol)
        cmd = "cd /home/hua.fu/geniustrader/Scripts;./graphic.pl --end '%s' --file %s --out '%s' %s" % (endday,graph_conf,img_file,symbol)
        #print "DEBUG graph_cmd = %s" % cmd
        (status,output) = commands.getstatusoutput(cmd)
        cmd = "cd /home/hua.fu/geniustrader/Scripts;./graphic.pl --file %s --out '%s' %s" % (graph_week_conf,img_week_file,symbol)
        #print "DEBUG graph_cmd = %s" % cmd
        (status,output) = commands.getstatusoutput(cmd)
        if status != 0: 
            print "====== Error ======"
            print output
            continue
        stock_dict= {}
        stock_dict['symbol'] = symbol
        stock_dict['img'] = img_file
        stock_dict['img_week'] = img_week_file
        #stock_dict['img_month'] = img_month_file
        stock.append(stock_dict)

    #pprint.pprint(stock)
    tproc.set("market_name","%s Market" % stock_region)
    tproc.set("stock_count",stock_count)
    tproc.set("Stock",stock)
    # save to file
    filename = "%s/%s_%s_STOCK.html" % (out_dir,stock_region,signal_file)
    FILE = open(filename,"w")
    FILE.writelines(tproc.process(template))
    FILE.close()
Пример #4
0
def create_graph(stock_list,template_file,conf_dir,stock_region='US',signal_file="signal_file",endday='today'):
    """
    根据股票代码生成图片
    """
    out_dir = img_out_dir
    graph_conf = "%s/graph_day.conf" % (conf_dir)
    template_graph_conf = "/tmp/graph_%s.conf" % (signal_file)
    graph_week_conf = "%s/graph_week.conf" % (conf_dir)
    graph_month_conf = "%s/graph_month.conf" % (conf_dir)
    stock_count = len(stock_list)
    template = TemplateManager().prepare(template_file)
    tproc = TemplateProcessor(html_escape=0)
    stock = []
    for symbol in stock_list:
        img_file = "%s/%s.png" % (out_dir,symbol)
        img_week_file = "%s/%s_WEEK.png" % (out_dir,symbol)
        img_month_file = "%s/%s_MONTH.png" % (out_dir,symbol)
        stock_dict= {}
        stock_dict['symbol'] = symbol
        stock_dict['img'] = img_file
        stock_dict['img_week'] = img_week_file
        stock_dict['img_month'] = img_month_file
        stock.append(stock_dict)
    #pprint.pprint(stock)
    tproc.set("market_name","%s Market" % stock_region)
    tproc.set("stock_count",stock_count)
    tproc.set("Stock",stock)
    # save to file
    filename = "%s/%s_%s_STOCK.html" % (out_dir,stock_region,signal_file)
    FILE = open(filename,"w")
    FILE.writelines(tproc.process(template))
    FILE.close()

     # 多线程运行
    global clientpool 
    #globals()['clentpool'] = Queue.Queue(0)
    clientpool = Queue.Queue(0)
    ts = []
    for a in stock_list:
        a=a.strip()
        clientpool.put(a)

    for b in xrange(20):
        t = graph_runs(stock,endday,conf_dir)
        t.start()
        ts.append(t)
    for t in ts:
        if t:t.join()
Пример #5
0
def create_graph(stock_list,
                 template_file,
                 conf_dir,
                 stock_region='US',
                 signal_file="signal_file",
                 endday='today'):
    """
    根据股票代码生成图片
    """
    out_dir = img_out_dir
    graph_conf = "%s/graph_day.conf" % (conf_dir)
    template_graph_conf = "/tmp/graph_%s.conf" % (signal_file)
    graph_week_conf = "%s/graph_week.conf" % (conf_dir)
    graph_month_conf = "%s/graph_month.conf" % (conf_dir)
    stock_count = len(stock_list)
    template = TemplateManager(precompile=0).prepare(template_file)
    tproc = TemplateProcessor(html_escape=0)
    stock = []
    for symbol in stock_list:
        symbol = symbol.strip()
        img_file = "%s/%s.png" % (out_dir, symbol)
        img_week_file = "%s/%s_WEEK.png" % (out_dir, symbol)
        img_month_file = "%s/%s_MONTH.png" % (out_dir, symbol)
        #if not os.path.isfile(img_file):
        #if calc_support_resistance(symbol,'day',template_graph_conf):
        #    graph_conf = template_graph_conf
        os.chdir('%s' % script_dir)
        #cmd = "cd %s;perl ./graphic.pl --file %s %s>%s" % (script_dir,graph_conf,symbol,img_file)
        cmd = "perl graphic.pl --file %s %s > %s" % (graph_conf, symbol,
                                                     img_file)
        #print cmd
        (status, output) = commands.getstatusoutput(cmd)
        #print "DEBUG graph_cmd = %s" % cmd
        #res = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
        #print "DEBUG : stderr = %s " % res.stderr.readlines()
        #stock_line = res.stdout.readlines()
        #print stock_line
        (status, output) = commands.getstatusoutput(cmd)
        #sys.exit()
        cmd = "perl  graphic.pl --file %s %s > %s" % (graph_week_conf, symbol,
                                                      img_week_file)
        #print "DEBUG graph_cmd = %s" % cmd
        (status, output) = commands.getstatusoutput(cmd)
        #res = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)

        cmd = "perl  graphic.pl --file %s %s > %s" % (graph_month_conf, symbol,
                                                      img_month_file)
        #print "DEBUG graph_cmd = %s" % cmd
        #res = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
        (status, output) = commands.getstatusoutput(cmd)
        stock_dict = {}
        stock_dict['symbol'] = symbol
        stock_dict['img'] = img_file
        stock_dict['img_week'] = img_week_file
        stock_dict['img_month'] = img_month_file
        stock.append(stock_dict)

    #pprint.pprint(stock)
    tproc.set("market_name", "%s Market" % stock_region)
    tproc.set("stock_count", stock_count)
    tproc.set("Stock", stock)
    # save to file
    filename = "%s/%s_%s_STOCK.html" % (out_dir, stock_region, signal_file)
    FILE = open(filename, "w")
    FILE.writelines(tproc.process(template))
    FILE.close()