Esempio n. 1
0
    return_list.sort(key=lambda x : (x['close_portion'], x['fall_portion']), reverse = True)
    for return_item in return_list[0:50]:
        logging.getLogger("chance").info("%s", format_log("top_return", return_item))

    return_pd = pd.DataFrame(return_list)
    #print return_pd
    filename = "./return_" + str(day) + "_" + str(location) + ".csv"
    return_pd.to_csv(filename, index=False)

if __name__ == "__main__":
    if len(sys.argv) < 2:
        print "Usage: " + sys.argv[0] + " <conf> [location] [day]"
        sys.exit(1)

    config_info = Util.load_config(sys.argv[1])
    print config_info
    config_info['DB']['port'] = int(config_info['DB']['port'])
    config_info['REDIS']['port'] = int(config_info['REDIS']['port'])

    # 初始化日志
    print config_info['LOG'], config_info['LOG']['conf']
    logging.config.fileConfig(config_info['LOG']['conf'])
                                                            
    location = 1                                                        
    day = get_current_day(location) 
    if len(sys.argv) >= 3:
        location = int(sys.argv[2])
    if len(sys.argv) >= 4:
        day = int(sys.argv[3])    
        
Esempio n. 2
0
        print "Usage: " + sys.argv[0] + " <conf> <location> [day] [refresh]"
        sys.exit(1)

    location = int(sys.argv[2])
    if len(sys.argv) >= 4:
        day = int(sys.argv[3])
    else:
        day = int("{0:%Y%m%d}".format(datetime.date.today()))

    need_refresh = True
    if len(sys.argv) >= 5:
        refresh = int(sys.argv[4])
        if refresh <= 0:
            need_refresh = False

    config_info = Util.load_config(sys.argv[1])        
    db_config = config_info['DB']
    db_config['port'] = int(db_config['port'])

    redis_config = config_info['REDIS']
    redis_config['port'] = int(redis_config['port'])
    print db_config, redis_config

    today_data_list = get_stock_data(db_config, day)
    print len(today_data_list)

    if len(today_data_list) > 0:
        stock_list = get_stock_list(db_config, 0, location)
        vary_stock_list = refresh_stock_histdata(redis_config, db_config, stock_list, today_data_list, day, location, need_refresh)