예제 #1
0
def printResult(connection, cursor, query_Result_Text):
    print "Results Printing"
    if(cursor.description == None):
        connection.commit()
        query_Result_Text.insert(INSERT, cursor.statusmessage)
    else:
        tabcolnames = [description[0] for description in cursor.description]
        table = pylsytable(tabcolnames)
        rows = cursor.fetchall()
        tabcol_index = 0
        row_num = 0
        for i in rows:
            row_num += 1
            for each in i:
                print str(each) + '\t',
                table.append_data(tabcolnames[tabcol_index], str(each))
                tabcol_index += 1
            print
            tabcol_index = 0

            #printing large result set using pylsytable problem is solved
            if row_num == 100:  #a new table is created to print for every 100lines
                query_Result_Text.insert(INSERT, table)
                row_num = 0
                table = pylsytable(tabcolnames)

        if row_num != 0:
            query_Result_Text.insert(INSERT, table)
        connection.commit()
        query_Result_Text.config(state=DISABLED)
예제 #2
0
def printResult(connection, cursor, query_Result_Text):
    print "Results Printing"
    if (cursor.description == None):
        connection.commit()
        query_Result_Text.insert(INSERT, cursor.statusmessage)
    else:
        tabcolnames = [description[0] for description in cursor.description]
        table = pylsytable(tabcolnames)
        rows = cursor.fetchall()
        tabcol_index = 0
        row_num = 0
        for i in rows:
            row_num += 1
            for each in i:
                print str(each) + '\t',
                table.append_data(tabcolnames[tabcol_index], str(each))
                tabcol_index += 1
            print
            tabcol_index = 0

            #printing large result set using pylsytable problem is solved
            if row_num == 100:  #a new table is created to print for every 100lines
                query_Result_Text.insert(INSERT, table)
                row_num = 0
                table = pylsytable(tabcolnames)

        if row_num != 0:
            query_Result_Text.insert(INSERT, table)
        connection.commit()
        query_Result_Text.config(state=DISABLED)
예제 #3
0
def printResult(conn, cur, result_Text):
    print "Printing results"
    colnames = [desc[0] for desc in cur.description]
    table = pylsytable(colnames)
    rows = cur.fetchall()
    col_index = 0
    row_num = 0
    for i in rows:
        row_num += 1
        for each in i:
            print str(each) + '\t',
            table.append_data(colnames[col_index], str(each))
            col_index += 1
        print
        col_index = 0

        #solve the print problem of using pylsytable when the output data is too large
        if row_num == 100:  #every 100 lines, then we print a table, then create a new table
            result_Text.insert(INSERT, table)
            row_num = 0
            table = pylsytable(colnames)

    if row_num != 0:
        result_Text.insert(INSERT, table)
    conn.commit()
    result_Text.config(state=DISABLED)
def printResult(conn, cur, result_Text):
    print "Printing results"
    colnames = [desc[0] for desc in cur.description]
    table = pylsytable(colnames)
    rows = cur.fetchall()
    col_index = 0
    row_num = 0
    for i in rows:
        row_num += 1
        for each in i:
            print str(each) + '\t',
            table.append_data(colnames[col_index], str(each))
            col_index += 1
        print
        col_index = 0
        
        #solve the print problem of using pylsytable when the output data is too large
        if row_num == 100:  #every 100 lines, then we print a table, then create a new table
            result_Text.insert(INSERT, table)
            row_num = 0
            table = pylsytable(colnames)
    
    if row_num != 0:                   
        result_Text.insert(INSERT, table)
    conn.commit() 
    result_Text.config(state=DISABLED)    
예제 #5
0
파일: F10.py 프로젝트: idoplay/sogaQuant
    def __get_gudong_nums(self, s_code):
        #股东人数变化
        data = self.mysql.getRecord("SELECT * FROM s_stock_shareholdernum WHERE  s_code='%s' order by enddate desc" % s_code)
        print "SELECT * FROM s_stock_shareholdernum WHERE  s_code='%s' order by enddate desc" % s_code
        if len(data) > 0:
            attributes = ["Time", "Peoples", "P_rate", "P_gu"]
            table = pylsytable(attributes)
            _time = []
            _peoples = []
            _p_rate = []
            _p_gu = []
            for x in range(0, len(data)):
                if data[x]['enddate'] < 20141230:
                    continue
                _time.append(data[x]['enddate'])
                _peoples.append(data[x]['totalshamt'])
                if data[x]['askshrto'] > 0:
                    _p_rate.append("\033[1;31;40m+%s\033[0m" % data[x]['askshrto'])
                else:
                    _p_rate.append("\033[0;32;40m%s\033[0m" % data[x]['askshrto'])
                _p_gu.append(data[x]['askavgsh'])

            table.add_data("Time", _time)
            table.add_data("Peoples", _peoples)
            table.add_data("P_rate", _p_rate)
            table.add_data("P_gu", _p_gu)
            print(table.__str__())
예제 #6
0
파일: F10.py 프로젝트: yuzhucu/sogaQuant
    def __get_gudong_nums(self, s_code):
        #股东人数变化
        data = self.mysql.getRecord(
            "SELECT * FROM s_stock_shareholdernum WHERE  s_code='%s' order by enddate desc"
            % s_code)
        print "SELECT * FROM s_stock_shareholdernum WHERE  s_code='%s' order by enddate desc" % s_code
        if len(data) > 0:
            attributes = ["Time", "Peoples", "P_rate", "P_gu"]
            table = pylsytable(attributes)
            _time = []
            _peoples = []
            _p_rate = []
            _p_gu = []
            for x in range(0, len(data)):
                if data[x]['enddate'] < 20141230:
                    continue
                _time.append(data[x]['enddate'])
                _peoples.append(data[x]['totalshamt'])
                if data[x]['askshrto'] > 0:
                    _p_rate.append("\033[1;31;40m+%s\033[0m" %
                                   data[x]['askshrto'])
                else:
                    _p_rate.append("\033[0;32;40m%s\033[0m" %
                                   data[x]['askshrto'])
                _p_gu.append(data[x]['askavgsh'])

            table.add_data("Time", _time)
            table.add_data("Peoples", _peoples)
            table.add_data("P_rate", _p_rate)
            table.add_data("P_gu", _p_gu)
            print(table.__str__())
예제 #7
0
 def __get_daily_order(self, s_code):
     opt_list = self.mysql.getRecord(
         "SELECT * FROM  `s_stock_fenbi_daily` WHERE s_code='%s' order by dateline desc"
         % s_code)
     #print "SELECT * FROM  `s_stock_fenbi_daily` WHERE s_code='%s' order by dateline desc" % s_code
     if len(opt_list):
         attributes = ["Time", "Buy", "Sell", "All"]
         table = pylsytable(attributes)
         _time = []
         _buy = []
         _sell = []
         _all = []
         for x in range(0, len(opt_list)):
             _time.append(opt_list[x]['dateline'])
             _buy.append("%s/%s" %
                         (opt_list[x]['b_price'], opt_list[x]['b_hands']))
             _sell.append("%s/%s" %
                          (opt_list[x]['s_price'], opt_list[x]['s_hands']))
             _c = "{:.2f}".format((opt_list[x]['bs_count'] / 10000), '')
             _all.append(_c)
         table.add_data("Time", _time)
         table.add_data("Buy", _buy)
         table.add_data("Sell", _sell)
         table.add_data("All", _all)
         print(table.__str__())
예제 #8
0
def format_print(data):
    attributes = dict_keys[1]
    table = pylsytable(attributes)
    for temp in data:
        for i in range(len(temp)):
            table.append_data(dict_keys[1][i], temp[dict_keys[0][i]])
    print table
예제 #9
0
def xian_n():
   attributes=["标题","内容","时间"]
   table=pylsytable(attributes)
   table.add_data("标题",[i['name'][0:5] for i in su])
   table.add_data("内容",[i['pwd'][0:8] for i in su])
   table.add_data("时间",[i['nid'][len(i['nid'])-8:len(i['nid'])] for i in su])
   print(table)
예제 #10
0
def output_3():
	global dic,dic2,input_0
	b=['Nonterminal']
	end_str=['id','+','*','(',')','$']
	for i in end_str:
		dic[i]=[' ',' ',' ',' ',' ']
		dic2[i]=[[],[],[],[],[]]
	b.extend(end_str)
	table = pylsytable(b)
	table.add_data('Nonterminal',follow_first.dic_key)
	for key in follow_first.dic_key:
		for i in follow_first.dic_first[key]:
			if i!='e':
				for line in follow_first.list_sum:
					if key in line and line[len(line)-1]==key and line[len(line)-2]!='e':
						n=0
						s=''
						list=[]
						while n<len(line)-1:
							s+=str(line[n])
							list.append(str(line[n]))
							n=n+1
						sss=str(line[0])
						if sss==i or (sss!=i and sss not in end_str):
							# print sss
							num=follow_first.dic_key.index(key)
							dic[i][num]=(key+'->'+s)
							dic2[i][num].extend(list)
							# print dic2[i][num]
							# print s
							# print i,num,':',key+'->'+s
	for strs in end_str:
		for key in follow_first.dic_key:
			if strs in follow_first.dic_follow[key] and strs not in follow_first.dic_first[key]:
				if 'e' in follow_first.dic_first[key]:
					num = follow_first.dic_key.index(key)
					dic[strs][num]=(key+'-> e')
					list_2=[key,'->','e']
					dic2[strs][num].extend(list_2)
				else:
					num = follow_first.dic_key.index(key)
					dic[strs][num] = ('synch')
					dic2[strs][num]=['synch']
	for strs in end_str:
		table.add_data(strs,dic[strs])
	t.Label(root, text="表达式的语法分析表构造完毕 ", justify=t.CENTER, font=ftt2).grid(sticky='W',row=9, column=0,columnspan=1)
	t.Label(root, text="如果查看M[A,a]是synch,在继续分析时栈顶的非终结符号被弹出",justify=t.CENTER, font=ftt2).grid(sticky='W',row=9, column=1,columnspan=3)
	t.Label(root, text=table, justify=t.CENTER, font=ft).grid(row=12, column=0, rowspan=8,columnspan=4)
	u=t.StringVar()
	u.set(' id + id * id')
	input_0=u.get()
	print input_0
	t.Label(root, text="如果M[A,a]是error(相应的语法分析表条目为空时)",justify=t.CENTER, font=ftt2).grid(sticky='N', column=0,columnspan=3)
	t.Label(root, text="预测语法分析过程->检测到错误",justify=t.CENTER, font=ftt2).grid(sticky='N', column=0,columnspan=3)
	t.Entry(root, textvariable=u, state = 'normal').grid(row=23, column=0,sticky='N',columnspan=2)
	t.Button(root, text="进行语法预测分析(包含错误恢复) √", width=32, command=analysis,default='active').grid(sticky='N', column=0,columnspan=2)
	t.Label(root, text="文法表达式完全匹配成功,过程如右", justify=t.CENTER, font=ftt2).grid(sticky='N', column=0, columnspan=3)
	label = t.Label(root, text='Copyright © 2017 ', font=ftt).grid(columnspan=2, column=0, rowspan=2,	                                                                             sticky='N')
	label = t.Label(root, text='All rights reserved by Haocong ', font=ftt).grid(columnspan=2, column=0, rowspan=2, sticky='N')
예제 #11
0
    def stock_bs_big_order(self):
        dateline = sys.argv[2]
        data = self.mysql.getRecord("SELECT *  FROM `s_stock_fenbi_daily` WHERE `dateline` = %s AND (`b_10` > 1 or b_5 > 1 or b_7 >1) order by bs_count desc" % dateline)
        stock = self.mysql.getRecord("select * from s_stock_list where 1")
        self.stock_list = {}

        show_five_order = 0
        if len(sys.argv) == 4:
            show_five_order = 1

        for o in range(0, len(stock)):
            tmp_code = stock[o]['s_code']
            self.stock_list[tmp_code] = stock[o]

        if len(data) > 0:
            attributes = ["Name", "Chg", "Buy", "Sell", "All", "B3", "B5", "B7", "B10"]
            table = pylsytable(attributes)
            _name = []
            _chg = []
            _buy = []
            _sell = []
            _all = []
            _b_3 = []
            _b_5 = []
            _b_7 = []
            _b_10 = []
            for o in range(0, len(data)):
                ms = re.findall(re.compile(r'\*|N|ST|航空|银行'), self.stock_list[data[o]['s_code']]['name'])
                if self.stock_list[data[o]['s_code']]['run_market'] > 15000000000 or self.stock_list[data[o]['s_code']]['listing_date'] == 0 or ms:
                    continue
                if data[o]['bs_count'] < -80000000:
                    continue
                _name.append("%s=%s" % (data[o]['s_code'], self.stock_list[data[o]['s_code']]['name']))
                _chg.append(self.stock_list[data[o]['s_code']]['chg'])
                _buy.append("%s=%s" % (data[o]['b_price'], data[o]['b_hands']))
                _sell.append("%s=%s" % (data[o]['s_price'], data[o]['s_hands']))
                _all.append("{:.2f}".format(data[o]['bs_count']/10000, ''))
                _b_3.append("%s=%s" % (data[o]['b_3'], data[o]['s_3']))
                _b_5.append("%s=%s" % (data[o]['b_5'], data[o]['s_5']))
                _b_7.append("%s=%s" % (data[o]['b_7'], data[o]['s_7']))
                _b_10.append("%s=%s" % (data[o]['b_10'], data[o]['s_10']))
                if show_five_order:
                    print data[o]['s_code']

            table.add_data("Name", _name)
            table.add_data("Chg", _chg)
            table.add_data("Buy", _buy)
            table.add_data("Sell", _sell)
            table.add_data("All", _all)
            table.add_data("B3", _b_3)
            table.add_data("B5", _b_5)
            table.add_data("B7", _b_7)
            table.add_data("B10", _b_10)
            if show_five_order == 0:
                print(table.__str__())
예제 #12
0
def test_squre_root():
    while True:
        attributes = ["a", "mysqrt(a)", "math.sqrt(a)", "diff"]
        table = pylsytable(attributes)
        a = ["1.0", "2.0", "3.0", "4.0", "5.0", "6.0", "7.0", "8.0", "9.0"]
        for i in range(8):
            m = mysqrt(a, 5)
            n = math.sqrt(a)
            y = abs(m - n)
            table.add_data("a", a)
            table.add_data("diff", y)
            table.add_data("mysqrt(a)", m)
            table.add_data("math.sqrt(a)", n)
            table.create_table()
예제 #13
0
def audit_recording(argvs):
    """
    audit users records
    :param argvs:
    :return:
    """
    if '-u' in argvs:
        user_name = argvs[argvs.index("-u") + 1]
    else:
        print_err("invalid usage, should be:\naudit_user -u <username>", logout=True)
        return
    # records = session.query(models.AuditLog).filter(
    #     models.AuditLog.user_id == (
    #         session.query(models.UserProfile.id).filter_by(username=user_name).first())).all().order_by(id).desc()
    user_profile = session.query(models.UserProfile).filter_by(username=user_name).first()
    if not user_profile:
        print_err("Wrong username...", logout=True)
    records = user_profile.audit_logs
    logger.info(records)
    msg = '''\033[32;1m
    ---------------------------------------All records of [%s] ---------------------------------------
    \033[0m''' % user_name
    print(msg)
    if records:
        attributes = ["UserName", "HostName", "IP", "Port", "RemoteUser", "ActionType", "CMD", "DateTime"]
        table = pylsytable(attributes)
        for record in records:
            # record_list = [user_name,
            #                records[0].bind_host.host.hostname,
            #                records[0].bind_host.host.ip,
            #                records[0].bind_host.host.port,
            #                records[0].bind_host.remote_user,
            #                record.action_type.value,
            #                record.cmd,
            #                record.date
            #                ]
            # print(record_list)
            # table.append_data(attributes, record_list)
            table.append_data("UserName", user_name)
            table.append_data("HostName", records[0].bind_host.host.hostname)
            table.append_data("IP", records[0].bind_host.host.ip)
            table.append_data("Port", records[0].bind_host.host.port)
            table.append_data("RemoteUser", records[0].bind_host.remote_user)
            table.append_data("ActionType", record.action_type.value)
            table.append_data("CMD", record.cmd)
            table.append_data("DateTime", record.date)
        logger.info(table)
    else:
        print("No records for %s" % user_name)
예제 #14
0
파일: F10.py 프로젝트: yuzhucu/sogaQuant
    def __get_five_order(self, s_code):
        data = self.mysql.getRecord(
            "SELECT * FROM s_stock_runtime_snap WHERE  s_code='%s' order by dateline desc"
            % s_code)
        if len(data) > 0:
            attributes = ["Time", "Buy", "Sell"]
            table = pylsytable(attributes)
            _time = []
            _buy = []
            _sell = []
            _has_days = []
            _has_day_list = {}
            _diff = []
            for x in range(0, len(data)):
                #最多有效期内的数据
                if len(_time) > MAX_FIVE_ORDER_DAYS:
                    break

                at = str(data[x]['date_str']).split(' ')
                _day = at[0]
                if _day not in _has_days:
                    _has_days.append(_day)
                    _has_day_list[_day] = 0

                #一天最多显示次数
                key = "%s=%s=%s" % (str(
                    data[x]['date_str'])[0:10], str(data[x]['b_amount'])[0:2],
                                    str(data[x]['s_amount'])[0:2])
                if key not in _diff:
                    _diff.append(key)
                else:
                    continue
                if _has_day_list[_day] == MAX_FIVE_ORDER_NUM:
                    continue
                _has_day_list[_day] += 1

                _time.append(data[x]['date_str'])
                _buy.append(data[x]['b_amount'])
                _sell.append(data[x]['s_amount'])

                #print "\t===%s===B:%sW====S:%sW====" % (data[x]['date_str'], data[x]['b_amount'], data[x]['s_amount'])
            table.add_data("Time", _time)
            table.add_data("Buy", _buy)
            table.add_data("Sell", _sell)
            print(table.__str__())
예제 #15
0
    def format_content(data):
        attributes = ["Alarm_ID", "Name", "State", "Priority", "Reason"]
        table = pylsytable(attributes)

        Alarm_ID = data.get('alarm_id')
        Name = data.get('alarm_name')
        State = data.get('current')
        Priority = data.get('severity')
#        Alarm_condition = data.get('reason_data')
        Reason = data.get('reason')

        table.add_data("Alarm_ID", Alarm_ID)
        table.add_data("Name", Name)
        table.add_data("State", State)
        table.add_data("Priority", Priority)
#        table.add_data("Alarm_condition", Alarm_condition)
        table.add_data("Reason", Reason)

        return str(table)
예제 #16
0
파일: F10.py 프로젝트: idoplay/sogaQuant
    def __get_five_order(self, s_code):
        data = self.mysql.getRecord("SELECT * FROM s_stock_runtime_snap WHERE  s_code='%s' order by dateline desc" % s_code)
        if len(data) > 0:
            attributes = ["Time", "Buy", "Sell"]
            table = pylsytable(attributes)
            _time = []
            _buy = []
            _sell = []
            _has_days = []
            _has_day_list = {}
            _diff = []
            for x in range(0, len(data)):
                #最多有效期内的数据
                if len(_time) > MAX_FIVE_ORDER_DAYS:
                    break

                at = str(data[x]['date_str']).split(' ')
                _day = at[0]
                if _day not in _has_days:
                    _has_days.append(_day)
                    _has_day_list[_day] = 0

                #一天最多显示次数
                key = "%s=%s=%s" % (str(data[x]['date_str'])[0: 10], str(data[x]['b_amount'])[0: 2], str(data[x]['s_amount'])[0: 2])
                if key not in _diff:
                    _diff.append(key)
                else:
                    continue
                if _has_day_list[_day] == MAX_FIVE_ORDER_NUM:
                    continue
                _has_day_list[_day] += 1

                _time.append(data[x]['date_str'])
                _buy.append(data[x]['b_amount'])
                _sell.append(data[x]['s_amount'])

                #print "\t===%s===B:%sW====S:%sW====" % (data[x]['date_str'], data[x]['b_amount'], data[x]['s_amount'])
            table.add_data("Time", _time)
            table.add_data("Buy", _buy)
            table.add_data("Sell", _sell)
            print(table.__str__())
예제 #17
0
 def formatPrint(self,cmsQueue,domainIpDict,wafQueue):
     """
     格式化输出
     """
     attributes=["id","domain","cms","waf","ip"]
     table=pylsytable(attributes)
     domainList = domainIpDict.keys()
     cmsDict = self.queueToDict(cmsQueue)
     wafDict = self.queueToDict(wafQueue)
     for i in xrange(len(domainList)):
         table.append_data("id", i+1)
     for domain in domainList:
         table.append_data("cms", cmsDict[domain])
         table.append_data("domain", domain)
         table.append_data("waf", wafDict[domain])
         table.append_data("ip", domainIpDict[domain])
     if self.options.file != None:
         resultFile = open(self.options.file,'w')
         resultFile.write(str(table))
         time.sleep(0.1)
     print "----------- result -----------"
     print(table)
예제 #18
0
파일: __init__.py 프로젝트: imcxl/lst
def lsPath(path=os.path.abspath('.')):
    attributes = ["Mode", "Name", "Size", "Create", "Modify"]
    table = pylsytable(attributes)
    table.add_data("Mode", [])
    table.add_data("Name", [])
    table.add_data("Size", [])
    table.add_data("Create", [])
    table.add_data("Modify", [])

    path = path.decode('utf-8')

    if os.path.isdir(path):
        files = os.listdir(path)
        for f in files:
            table.append_data("Name", [f])
            stat = os.stat(os.path.join(path, f))
            table.append_data("Mode", [modeFormat(stat.st_mode)])
            table.append_data("Size", [sizeFormat(stat.st_size)])
            table.append_data("Create", [timeFormat(stat.st_ctime)])
            table.append_data("Modify", [timeFormat(stat.st_mtime)])

        return table
    else:
        return "The path is not correct, please check it !"
예제 #19
0
            t4.append(value)
        elif i==5:
            t5.append(value)
        elif i==6:
            t6.append(value)
        elif i==7:
            t7.append(value)
        elif i==8:
            t8.append(value)
        elif i==9:
            t9.append(value)
        elif i==10:
            t10.append(value)
#print value.encode('utf-8')
c+=1
#bs4.element.NavigableString
title = [u"实时热点", u"热门电影", u"热门电视剧", u'热门综艺', u'热门动漫', u'热门小说', u'热门游戏', u'热门音乐', u'热门汽车', u'热门人物']
table = pylsytable(title)
table.add_data(u'实时热点',t1)
table.add_data(u"热门电影",t2)
table.add_data(u"热门电视剧",t3)
table.add_data(u"热门综艺",t4)
table.add_data(u"热门动漫",t5)
table.add_data(u"热门小说",t6)
table.add_data(u"热门游戏",t7)
table.add_data(u"热门音乐",t8)
table.add_data(u"热门汽车",t9)
table.add_data(u"热门人物",t10)
table._create_table()
print table
예제 #20
0
 def setUp(self):
     attributes = ["name", "age"]
     self.table = pylsytable(attributes)
예제 #21
0
파일: F10.py 프로젝트: idoplay/sogaQuant
    def gudong_change(self):
        #股东减少排序
        vtype = sys.argv[2]
        show_five_order = 0
        if len(sys.argv) == 4:
            show_five_order = 1

        if vtype == 'A':
            #最后报告时间
            end_date = 20161015
            opt_list = self.mysql.getRecord("SELECT * FROM  `s_stock_shareholdernum`  WHERE bigid IN (SELECT bigid FROM s_stock_shareholdernum WHERE  `enddate` >=%s AND totalshamt >300 and askshrto<0 ORDER BY enddate DESC ) ORDER BY askshrto ASC limit 1500" % end_date)

        elif vtype == 2:
            #当期时间
            opt_list = []
        elif vtype == 3:
            #两连降
            opt_list = []
        elif vtype == 4:
            #三连降
            opt_list = []

        stock = self.mysql.getRecord("select * from s_stock_list where 1")
        stock_list = {}
        for o in range(0, len(stock)):
            tmp_code = stock[o]['s_code']
            stock_list[tmp_code] = stock[o]

        attributes = ["No", "Code", "Name", "Change", "All", "Gu", "Last"]
        table = pylsytable(attributes)
        _no = []
        _code = []
        _name = []
        _chage = []
        _all = []
        _gu = []
        _date = []

        codes = []
        i = 1
        for k in range(0, len(opt_list)):
            if opt_list[k]['s_code'] in codes:
                continue
            '''
            季度选股使用
            #市值大于150亿过滤,股数人数减少小于1000
            _stock_info = stock_list[opt_list[k]['s_code']]
            ms = re.findall(re.compile(r'\*|N|ST|航空|银行|钢铁|煤|药|酒|电力'), _stock_info['name'])
            if _stock_info['run_market'] > 15000000000 or _stock_info['run_market'] < 1500000000 or ms:
                continue
            '''
            if show_five_order == 1:
                print opt_list[k]['s_code']

            codes.append(opt_list[k]['s_code'])
            _no.append(i)
            _code.append(opt_list[k]['s_code'])
            _name.append(stock_list[opt_list[k]['s_code']]['name'])
            _chage.append(opt_list[k]['askshrto'])
            _all.append(opt_list[k]['totalshamt'])
            _gu.append(opt_list[k]['askavgsh'])
            _date.append(opt_list[k]['enddate'])
            i += 1

        table.add_data("No", _no)
        table.add_data("Code", _code)
        table.add_data("Name", _name)
        table.add_data("Change", _chage)
        table.add_data("All", _all)
        table.add_data("Gu", _gu)
        table.add_data("Last", _date)
        if show_five_order == 0:
            print(table.__str__())
예제 #22
0
        mfcc = np.transpose(librosa.feature.mfcc(wav, sr), [1, 0])
        if len(mfcc) > wav_max_len:
            wav_max_len = len(mfcc)
    print("Done.")
    return mfcc, wav_max_len


wav_path = './data/wav/train'
label_files = './data/doc/trans/train.word.txt'
wav_files = get_wav_files(wav_path)
wav_files, labels = get_wav_label(wav_files, label_files)
words_size, label_max_len, labels_vector = get_vocabulary(labels)
#mfcc, wav_max_len = get_mfcc(wav_files)

attributes = ["AttrName", "AttrValue"]
table = pylsytable(attributes)
AttrName = [
    "Longest Speech", "Samples Number", "Vocabulary Size",
    "Longest Sentence Word Number"
]
AttrValue = [wav_max_len, len(wav_files), words_size, label_max_len]
table.add_data("AttrName", AttrName)
table.add_data("AttrValue", AttrValue)
print(table)

pointer = 0


def next_batch(batch_size):
    global pointer
    batches_wavs = []
예제 #23
0
파일: F10.py 프로젝트: yuzhucu/sogaQuant
    def gudong_change(self):
        #股东减少排序
        vtype = sys.argv[2]
        show_five_order = 0
        if len(sys.argv) == 4:
            show_five_order = 1

        if vtype == 'A':
            #最后报告时间
            end_date = 20161015
            opt_list = self.mysql.getRecord(
                "SELECT * FROM  `s_stock_shareholdernum`  WHERE bigid IN (SELECT bigid FROM s_stock_shareholdernum WHERE  `enddate` >=%s AND totalshamt >300 and askshrto<0 ORDER BY enddate DESC ) ORDER BY askshrto ASC limit 1500"
                % end_date)

        elif vtype == 2:
            #当期时间
            opt_list = []
        elif vtype == 3:
            #两连降
            opt_list = []
        elif vtype == 4:
            #三连降
            opt_list = []

        stock = self.mysql.getRecord("select * from s_stock_list where 1")
        stock_list = {}
        for o in range(0, len(stock)):
            tmp_code = stock[o]['s_code']
            stock_list[tmp_code] = stock[o]

        attributes = ["No", "Code", "Name", "Change", "All", "Gu", "Last"]
        table = pylsytable(attributes)
        _no = []
        _code = []
        _name = []
        _chage = []
        _all = []
        _gu = []
        _date = []

        codes = []
        i = 1
        for k in range(0, len(opt_list)):
            if opt_list[k]['s_code'] in codes:
                continue
            '''
            季度选股使用
            #市值大于150亿过滤,股数人数减少小于1000
            _stock_info = stock_list[opt_list[k]['s_code']]
            ms = re.findall(re.compile(r'\*|N|ST|航空|银行|钢铁|煤|药|酒|电力'), _stock_info['name'])
            if _stock_info['run_market'] > 15000000000 or _stock_info['run_market'] < 1500000000 or ms:
                continue
            '''
            if show_five_order == 1:
                print opt_list[k]['s_code']

            codes.append(opt_list[k]['s_code'])
            _no.append(i)
            _code.append(opt_list[k]['s_code'])
            _name.append(stock_list[opt_list[k]['s_code']]['name'])
            _chage.append(opt_list[k]['askshrto'])
            _all.append(opt_list[k]['totalshamt'])
            _gu.append(opt_list[k]['askavgsh'])
            _date.append(opt_list[k]['enddate'])
            i += 1

        table.add_data("No", _no)
        table.add_data("Code", _code)
        table.add_data("Name", _name)
        table.add_data("Change", _chage)
        table.add_data("All", _all)
        table.add_data("Gu", _gu)
        table.add_data("Last", _date)
        if show_five_order == 0:
            print(table.__str__())
예제 #24
0
파일: Common.py 프로젝트: idoplay/sogaQuant
    def show_daily_lhb2(self):
    #显示个股历史龙虎数据
        s_code = self.change_scode(sys.argv[2])
        start_date = 20150610
        show_table_max = 4
        x = self.mysql.getRecord("SELECT a.*,b.codex,b.name FROM  `s_lhb_days_detail` as a left join s_lhb as b on a.yyb_id=b.codex WHERE  a.s_code='%s' and dateline >=%s order by dateline desc " % (s_code, start_date))
        if len(x):
            #先按天归类
            daily_yyb = {}
            daily_yyb2 = {}
            attributes = ["ID", "Name", "Num"]
            table_attr = ["Name"]

            tdheader = ['<tr height="40"><th width="60" bgColor="#CCCCCC" align="center">ID</th>', '<th width="100" bgColor="#CCCCCC" align="center">Name</th>', '<th width="30" bgColor="#CCCCCC" align="center">Num</th>']

            for a in range(0, len(x)):
                key = "D%s" % x[a]['dateline']
                if key not in attributes:
                    attributes.append(key)
                    tdheader.append('<th width="120" bgColor="#CCCCCC" align="center">%s</th>' % key)
                    if len(table_attr) < show_table_max:
                        table_attr.append(key)

                if x[a]['name'] is None:
                    x[a]['name'] = "YYB-%s" % x[a]['yyb_id']
                if x[a]['name'] not in daily_yyb.keys():
                    daily_yyb[x[a]['name']] = []

                daily_yyb[x[a]['name']].append(x[a])
                _name_key = "D%s|%s" % (x[a]['dateline'], x[a]['name'])
                if _name_key not in daily_yyb2.keys():
                    daily_yyb2[_name_key] = []
                daily_yyb2[_name_key].append(x[a])

            tdheader.append('</tr>')

            name_list = []
            table_td_list = {}
            show_table = pylsytable(table_attr)

            #print "====".join(tdheader)
            #sys.exit()
            all_tr_list = []
            for _name, v in daily_yyb.items():
                #制作每一行数据
                _name2 = _name.replace('证券股份有限公司', '')
                _name2 = _name2.replace('证券有限公司', '')
                _name2 = _name2.replace('证券有限责任公司', '')
                _name2 = _name2.replace('证券营业部', '')
                _name2 = _name2.replace('(山东)有限责任公司', '')

                #显示最近5次有龙虎榜
                #is_show_name = 0
                for d in range(1, len(table_attr)):
                    _name_key = "%s|%s" % (table_attr[d], _name)

                    if table_attr[d] not in table_td_list.keys():
                        table_td_list[table_attr[d]] = []

                    BS_str = ''
                    if _name_key in daily_yyb2:
                        #is_show_name = 1
                        BS_strA = "%s%s=%s=%s" % (daily_yyb2[_name_key][0]['type'], daily_yyb2[_name_key][0]['s_sort'], self._format_money(daily_yyb2[_name_key][0]['B_volume']), self._format_money(daily_yyb2[_name_key][0]['S_volume']))
                        BS_strB = ''
                        if len(daily_yyb2[_name_key]) > 1:
                            BS_strB = "%s%s=%s=%s" % (daily_yyb2[_name_key][1]['type'], daily_yyb2[_name_key][1]['s_sort'], self._format_money(daily_yyb2[_name_key][1]['B_volume']), self._format_money(daily_yyb2[_name_key][1]['S_volume']))
                        BS_str = u"%s=%s==" % (BS_strA, BS_strB)
                    table_td_list[table_attr[d]].append(BS_str)

                #print "%s==%s" % (_name2, is_show_name)
                #if is_show_name == 1:
                name_list.append(_name2)

                tr_data = ["%s" % v[0]['yyb_id'], _name2, 0]
                #周期内出现的天数
                _has_num = 0
                for b in range(3, len(attributes)):
                    _name_key = "%s|%s" % (attributes[b], _name)

                    BS_str = ''
                    if _name_key in daily_yyb2:
                        _has_num += 1
                        #营业部做T
                        BS_strA = "%s%s=%s=%s" % (daily_yyb2[_name_key][0]['type'], daily_yyb2[_name_key][0]['s_sort'], self._format_money(daily_yyb2[_name_key][0]['B_volume']), self._format_money(daily_yyb2[_name_key][0]['S_volume']))
                        BS_strB = ''
                        if len(daily_yyb2[_name_key]) > 1:
                            BS_strB = "%s%s=%s=%s" % (daily_yyb2[_name_key][1]['type'], daily_yyb2[_name_key][1]['s_sort'], self._format_money(daily_yyb2[_name_key][1]['B_volume']), self._format_money(daily_yyb2[_name_key][1]['S_volume']))
                        BS_str = u"%s\n%s==\n" % (BS_strA, BS_strB)
                    tr_data.append(BS_str)

                tr_data[2] = _has_num

                _td_str = ['<tr height="40">']
                for c in range(0, len(tr_data)):
                    _td_str.append('<td bgColor="#FFFFFF" align="center">%s</td>' % tr_data[c])
                _td_str.append('</tr>')

                all_tr_list.append("\n".join(_td_str))

        if len(sys.argv) == 3:
            table = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title></title></head><body>\n\
                <table border="1" width="1024">%s\n%s</table></body></html>' % ("\n".join(tdheader), "\n".join(all_tr_list))
            print table
        else:
            for b in range(1, len(table_attr)):
                show_table.add_data(table_attr[b], table_td_list[table_attr[b]])
            #print name_list
            show_table.add_data("Name", name_list)
            print(show_table.__str__())
예제 #25
0
import socket
from pylsy import pylsytable

logstash_hosts = ['127.0.0.1']
logstash_port = '9600'
jvm_url = '/_node/stats/jvm'

def toMB(num):
    return int(num)/1024/1024

def perMS(count, time_in_ms):
    return int(time_in_ms/count)

header = ['host','uptime(min)','HeapUse/Max(MB)', 'YngUse/OldUse(MB)','Yng/OldGCCount'
           ,'Yng/OldGCTime(ms)']
table = pylsytable(header)

for h in logstash_hosts:
    try:
        url = "http://" + h + ':' + logstash_port + jvm_url
        body = urllib2.urlopen(url=url, timeout=5)
        jvm_stats = json.loads(body.read())
        host = socket.gethostname() #jvm_stats['host']
        uptime = int(jvm_stats['jvm']['uptime_in_millis'])/1000/60
        mem = jvm_stats['jvm']['mem']
        gc = jvm_stats['jvm']['gc']
        pools = mem['pools']
        heapMax = toMB(mem['heap_max_in_bytes'])
        heapUsage = toMB(mem['heap_used_in_bytes'])
        heapUse = str(heapUsage) + '/' + str(heapMax)
        yngUsage = toMB(pools['young']['used_in_bytes'])
예제 #26
0
	print '==================================================='
	print 'cannonical LR(0) collection:'
	for key,val in C_dict.items():
		print key,val
	print '==================================================='
	print 'DFA:'
	for key,val in DFA.items():
		print key,val
	print '==================================================='
	print 'Parsing table for expression grammar:'
	attributes = ['status']
	terminals_list.append('#')
	attributes.extend(terminals_list)
	non_terminals_list.pop(0)
	attributes.extend(non_terminals_list)
	table = pylsytable(attributes)
	table.add_data('status', SLR1_tabel.keys())
	for key in SLR1_tabel.keys():
		for each in terminals_list+non_terminals_list:
			if SLR1_tabel[key].has_key(each):
				table.append_data(each, SLR1_tabel[key][each])
			else:
				table.append_data(each, ' ')
	print(table)
	print '==================================================='

	inputed_parse = parse_input()
	print 'Moves of an LR parser on '+inputed_parse+':'
	result,analyse_result_array = do_analyse(SLR1_tabel,inputed_parse,grammer_productions_list)

	#保证输出的间隔比该列的最长序列多2
예제 #27
0
    def stock_bs_big_order(self):
        dateline = sys.argv[2]
        if sys.argv[3] == 'A':
            #无大单尽买入
            sql = "SELECT *  FROM  `s_stock_fenbi_daily` AS a WHERE a.dateline =%s and bs_all>9000000 and b_3=0 and b_5=0 and b_7=0 and b_10=0 and bs_all >0 ORDER BY a.bs_all desc " % dateline
        elif sys.argv[3] == 'B':
            #尽买入
            sql = "SELECT *  FROM `s_stock_fenbi_daily` WHERE `dateline` = %s AND (`b_10` > 0 or b_5 > 0 or b_7 >0) order by bs_all desc" % dateline
        elif sys.argv[3] == 'C':
            #大单买入3KW
            sql = "SELECT *  FROM `s_stock_fenbi_daily` WHERE `dateline` = %s AND zl_b > 30000000 and zl_b > zl_s order by bs_all desc" % dateline
        elif sys.argv[3] == 'D':
            #连续大单流入2KW
            c = self._filter_bs_D()
            if len(c):
                _sql = []
                for _a in range(0, len(c)):
                    _sql.append("'%s'" % c[_a])
                sql = "SELECT *  FROM `s_stock_fenbi_daily` WHERE `dateline` = %s AND s_code in(%s)" % (
                    dateline, ",".join(_sql))
            else:
                self.print_green("No Data...")
                return
        elif sys.argv[3] == 'E':
            #self._filter_bs_E(20161220, 'sz300153')
            #self.stock_bs_skip_order()
            sql = "SELECT * FROM `s_stock_fenbi_daily` WHERE `dateline` = %s and skip_order >5 order by skip_order desc " % dateline

        self.ak = 0

        data = self.mysql.getRecord(sql)
        stock = self.mysql.getRecord("select * from s_stock_list where 1")
        self.stock_list = {}

        show_five_order = 0
        if len(sys.argv) == 5:
            show_five_order = 1

        for o in range(0, len(stock)):
            tmp_code = stock[o]['s_code']
            self.stock_list[tmp_code] = stock[o]

        if len(data) > 0:
            attributes = [
                "Name", "Chg", "Buy", "Sell", "All", "Skip", "B3", "B5", "B7",
                "B10"
            ]
            table = pylsytable(attributes)
            _name = []
            _chg = []
            _buy = []
            _sell = []
            _all = []
            _skip = []
            _b_3 = []
            _b_5 = []
            _b_7 = []
            _b_10 = []
            for o in range(0, len(data)):
                ms = re.findall(re.compile(r'\*|N|ST|航空|银行'),
                                self.stock_list[data[o]['s_code']]['name'])
                if self.stock_list[data[o]['s_code']][
                        'run_market'] > 15000000000 or self.stock_list[
                            data[o]['s_code']]['listing_date'] == 0 or ms:
                    continue
                if data[o]['bs_all'] < -80000000:
                    continue
                self.ak += 1
                #最近5天的主买平均小于1000W
                #res = self._avg_buy(data[o]['s_code'])
                #if res > 0 and res < 12000000:
                #    continue
                _skip.append(data[o]['skip_order'])
                _name.append("%s=%s" %
                             (data[o]['s_code'],
                              self.stock_list[data[o]['s_code']]['name']))
                _chg.append(self.stock_list[data[o]['s_code']]['chg'])
                #_buy.append("%s=%s" % (data[o]['b_price'], data[o]['b_hands']))
                #_sell.append("%s=%s" % (data[o]['s_price'], data[o]['s_hands']))
                _buy.append(data[o]['zl_b'])
                _sell.append(data[o]['zl_s'])
                _all.append("{:.2f}".format(data[o]['bs_all'] / 10000, ''))
                _b_3.append("%s=%s" % (data[o]['b_3'], data[o]['s_3']))
                _b_5.append("%s=%s" % (data[o]['b_5'], data[o]['s_5']))
                _b_7.append("%s=%s" % (data[o]['b_7'], data[o]['s_7']))
                _b_10.append("%s=%s" % (data[o]['b_10'], data[o]['s_10']))
                if show_five_order:
                    print data[o]['s_code']

            table.add_data("Name", _name)
            table.add_data("Chg", _chg)
            table.add_data("Buy", _buy)
            table.add_data("Sell", _sell)
            table.add_data("All", _all)
            table.add_data("Skip", _skip)
            table.add_data("B3", _b_3)
            table.add_data("B5", _b_5)
            table.add_data("B7", _b_7)
            table.add_data("B10", _b_10)
            if show_five_order == 0:
                print(table.__str__())
        print u"==========共有%s=====" % self.ak
예제 #28
0
파일: F10.py 프로젝트: idoplay/sogaQuant
    def __get_daily_order(self, s_code):
        opt_list = self.mysql.getRecord("SELECT * FROM  `s_stock_fenbi_daily` WHERE s_code='%s' order by dateline desc" % s_code)
        #print "SELECT * FROM  `s_stock_fenbi_daily` WHERE s_code='%s' order by dateline desc" % s_code
        if len(opt_list):
            attributes = ["Time", "Buy", "Sell", "XC", "BS", "All", "Skip", "YiDong", "DuiDao", "BO", "SO", "Chg", "HS"]
            table = pylsytable(attributes)
            _time = []
            _buy = []
            _sell = []
            _bs = []
            _all = []
            _skip = []
            _xc = []
            _yd = []
            _dd = []
            _level_A = []
            _level_B = []
            _chg = []
            _hs = []
            day2 = []
            for x in range(0, len(opt_list)):
                _time.append(opt_list[x]['dateline'])
                day2.append(str(opt_list[x]['dateline']))
                #_buy.append("%s/%s" % (opt_list[x]['b_price'], opt_list[x]['b_hands']))
                #_sell.append("%s/%s" % (opt_list[x]['s_price'], opt_list[x]['s_hands']))

                _buy.append(int(opt_list[x]['zl_b']/10000))
                _sell.append(int(-opt_list[x]['zl_s']/10000))
                _bs.append(int(opt_list[x]['zl_b']/10000) + int(-opt_list[x]['zl_s']/10000))
                _c = int(opt_list[x]['bs_all']/10000)
                _all.append(_c)
                _yd.append(opt_list[x]['YiDongCount'])
                _dd.append(opt_list[x]['DuiDaoCount'])
                _xc.append(int(opt_list[x]['kp_xc']/10000))
                _skip.append(opt_list[x]['skip_order'])
                _level_A.append("%s/%s/%s/%s" % (opt_list[x]['b_3'], opt_list[x]['b_5'], opt_list[x]['b_7'], opt_list[x]['b_10']))
                _level_B.append("%s/%s/%s/%s" % (opt_list[x]['s_3'], opt_list[x]['s_5'], opt_list[x]['s_7'], opt_list[x]['s_10']))

            stock_days = self.mysql.getRecord("SELECT * FROM s_stock_trade WHERE  s_code='%s' and dateline in(%s) " % (s_code, ','.join(day2)))
            stock_daily = {}
            for j in range(0, len(stock_days)):
                #d = datetime.datetime.strptime(str(stock_days[j]['dateline']), "%Y%m%d")
                #_dd = self.tools.d_date('%Y-%m-%d', time.mktime(d.timetuple()))
                stock_daily[str(stock_days[j]['dateline'])] = stock_days[j]
            for x in range(0, len(opt_list)):
                _chg.append(stock_daily[str(opt_list[x]['dateline'])]['chg'])
                _huanshou = "{:.2f}".format(stock_daily[str(opt_list[x]['dateline'])]['turnover'], '')
                _hs.append(_huanshou)

            table.add_data("Time", _time)
            table.add_data("Buy", _buy)
            table.add_data("Sell", _sell)
            table.add_data("BS", _bs)
            table.add_data("All", _all)
            table.add_data("Skip", _skip)
            table.add_data("XC", _xc)
            table.add_data("YiDong", _yd)
            table.add_data("DuiDao", _dd)
            table.add_data("BO", _level_A)
            table.add_data("SO", _level_B)
            table.add_data("Chg", _chg)
            table.add_data("HS", _hs)

            #5日流出
            '''
            i = 5
            _daily_B = []
            _daily_S = []
            while i:
                attributes2.append("D%s" % i)
                print _buy[i]
                _daily_B.append(_buy[i])
                _daily_S.append(_sell[i])

                i -= 1
            table2 = pylsytable(attributes2)
            '''

            print(table.__str__())
예제 #29
0
파일: Common.py 프로젝트: zhy0313/sogaQuant
    def show_daily_lhb2(self):
        #显示个股历史龙虎数据
        s_code = self.change_scode(sys.argv[2])
        start_date = 20150610
        show_table_max = 4
        x = self.mysql.getRecord(
            "SELECT a.*,b.codex,b.name FROM  `s_lhb_days_detail` as a left join s_lhb as b on a.yyb_id=b.codex WHERE  a.s_code='%s' and dateline >=%s order by dateline desc "
            % (s_code, start_date))
        if len(x):
            #先按天归类
            daily_yyb = {}
            daily_yyb2 = {}
            attributes = ["ID", "Name", "Num"]
            table_attr = ["Name"]

            tdheader = [
                '<tr height="40"><th width="60" bgColor="#CCCCCC" align="center">ID</th>',
                '<th width="100" bgColor="#CCCCCC" align="center">Name</th>',
                '<th width="30" bgColor="#CCCCCC" align="center">Num</th>'
            ]

            for a in range(0, len(x)):
                key = "D%s" % x[a]['dateline']
                if key not in attributes:
                    attributes.append(key)
                    tdheader.append(
                        '<th width="120" bgColor="#CCCCCC" align="center">%s</th>'
                        % key)
                    if len(table_attr) < show_table_max:
                        table_attr.append(key)

                if x[a]['name'] is None:
                    x[a]['name'] = "YYB-%s" % x[a]['yyb_id']
                if x[a]['name'] not in daily_yyb.keys():
                    daily_yyb[x[a]['name']] = []

                daily_yyb[x[a]['name']].append(x[a])
                _name_key = "D%s|%s" % (x[a]['dateline'], x[a]['name'])
                if _name_key not in daily_yyb2.keys():
                    daily_yyb2[_name_key] = []
                daily_yyb2[_name_key].append(x[a])

            tdheader.append('</tr>')

            name_list = []
            table_td_list = {}
            show_table = pylsytable(table_attr)

            #print "====".join(tdheader)
            #sys.exit()
            all_tr_list = []
            for _name, v in daily_yyb.items():
                #制作每一行数据
                _name2 = _name.replace('证券股份有限公司', '')
                _name2 = _name2.replace('证券有限公司', '')
                _name2 = _name2.replace('证券有限责任公司', '')
                _name2 = _name2.replace('证券营业部', '')
                _name2 = _name2.replace('(山东)有限责任公司', '')

                #显示最近5次有龙虎榜
                #is_show_name = 0
                for d in range(1, len(table_attr)):
                    _name_key = "%s|%s" % (table_attr[d], _name)

                    if table_attr[d] not in table_td_list.keys():
                        table_td_list[table_attr[d]] = []

                    BS_str = ''
                    if _name_key in daily_yyb2:
                        #is_show_name = 1
                        BS_strA = "%s%s=%s=%s" % (
                            daily_yyb2[_name_key][0]['type'],
                            daily_yyb2[_name_key][0]['s_sort'],
                            self._format_money(
                                daily_yyb2[_name_key][0]['B_volume']),
                            self._format_money(
                                daily_yyb2[_name_key][0]['S_volume']))
                        BS_strB = ''
                        if len(daily_yyb2[_name_key]) > 1:
                            BS_strB = "%s%s=%s=%s" % (
                                daily_yyb2[_name_key][1]['type'],
                                daily_yyb2[_name_key][1]['s_sort'],
                                self._format_money(
                                    daily_yyb2[_name_key][1]['B_volume']),
                                self._format_money(
                                    daily_yyb2[_name_key][1]['S_volume']))
                        BS_str = u"%s=%s==" % (BS_strA, BS_strB)
                    table_td_list[table_attr[d]].append(BS_str)

                #print "%s==%s" % (_name2, is_show_name)
                #if is_show_name == 1:
                name_list.append(_name2)

                tr_data = ["%s" % v[0]['yyb_id'], _name2, 0]
                #周期内出现的天数
                _has_num = 0
                for b in range(3, len(attributes)):
                    _name_key = "%s|%s" % (attributes[b], _name)

                    BS_str = ''
                    if _name_key in daily_yyb2:
                        _has_num += 1
                        #营业部做T
                        BS_strA = "%s%s=%s=%s" % (
                            daily_yyb2[_name_key][0]['type'],
                            daily_yyb2[_name_key][0]['s_sort'],
                            self._format_money(
                                daily_yyb2[_name_key][0]['B_volume']),
                            self._format_money(
                                daily_yyb2[_name_key][0]['S_volume']))
                        BS_strB = ''
                        if len(daily_yyb2[_name_key]) > 1:
                            BS_strB = "%s%s=%s=%s" % (
                                daily_yyb2[_name_key][1]['type'],
                                daily_yyb2[_name_key][1]['s_sort'],
                                self._format_money(
                                    daily_yyb2[_name_key][1]['B_volume']),
                                self._format_money(
                                    daily_yyb2[_name_key][1]['S_volume']))
                        BS_str = u"%s\n%s==\n" % (BS_strA, BS_strB)
                    tr_data.append(BS_str)

                tr_data[2] = _has_num

                _td_str = ['<tr height="40">']
                for c in range(0, len(tr_data)):
                    _td_str.append(
                        '<td bgColor="#FFFFFF" align="center">%s</td>' %
                        tr_data[c])
                _td_str.append('</tr>')

                all_tr_list.append("\n".join(_td_str))

        if len(sys.argv) == 3:
            table = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title></title></head><body>\n\
                <table border="1" width="1024">%s\n%s</table></body></html>' % (
                "\n".join(tdheader), "\n".join(all_tr_list))
            print table
        else:
            for b in range(1, len(table_attr)):
                show_table.add_data(table_attr[b],
                                    table_td_list[table_attr[b]])
            #print name_list
            show_table.add_data("Name", name_list)
            print(show_table.__str__())
예제 #30
0
파일: Pankou.py 프로젝트: idoplay/sogaQuant
    def stock_bs_big_order(self):
        dateline = sys.argv[2]
        show_five_order = 0
        if len(sys.argv) == 5:
            show_five_order = 1
        if sys.argv[3] == 'A':
            #无大单尽买入
            sql = "SELECT *  FROM  `s_stock_fenbi_daily` AS a WHERE a.dateline =%s and kp_xc>9000000 and b_3=0 and b_5=0 and b_7=0 and b_10=0 and bs_all >0 ORDER BY a.bs_all desc " % dateline
        elif sys.argv[3] == 'B':
            #大单尽买入
            sql = "SELECT *  FROM `s_stock_fenbi_daily` WHERE `dateline` = %s AND (`b_10` > 0 or b_5 > 0 or b_7 >0) order by bs_all desc" % dateline
        elif sys.argv[3] == 'C':
            #大单买入3KW 50DDJE > 15000000
            sql = "SELECT *  FROM `s_stock_fenbi_daily` WHERE `dateline` = %s AND 10DDJE < -10000000 and 50DDJE>0 order by 50DDJE desc" % dateline
            sql = "SELECT * FROM `s_stock_fenbi_daily` WHERE `dateline` = %s AND 10DDJE < 0 AND 30DDJE>1000000 AND 50DDJE >1000000  order by 50DDJE desc" % dateline
        elif sys.argv[3] == 'D':
            #连续大单流入2KW
            c = self._filter_bs_D()
            if len(c):
                _sql = []
                for _a in range(0, len(c)):
                    _sql.append("'%s'" % c[_a])
                sql = "SELECT *  FROM `s_stock_fenbi_daily` WHERE `dateline` = %s AND s_code in(%s)" % (dateline, ",".join(_sql))
            else:
                self.print_green("No Data...")
                return
        elif sys.argv[3] == 'E':
            #跳单,成交大于1亿
            stock = self.mysql.getRecord("select * from s_stock_list where dateline=%s and amount > 200000000 order by amount desc " % dateline)
            _sql = []
            for o in range(0, len(stock)):
                _sql.append("'%s'" % stock[o]['s_code'])
            sql = "SELECT * FROM `s_stock_fenbi_daily` WHERE `dateline` = %s and skip_order >5 AND s_code in(%s) order by skip_order desc " % (dateline, ",".join(_sql))

        elif sys.argv[3] == 'F':
            #异动次数150
            sql = "SELECT * FROM `s_stock_fenbi_daily` WHERE `dateline` = %s and YiDongCount >150 order by YiDongCount desc " % dateline

        elif sys.argv[3] == 'G':
            #成交大于3亿
            stock = self.mysql.getRecord("select * from s_stock_list where dateline=%s and amount > 300000000 order by amount desc " % dateline)
            _sql = []
            for o in range(0, len(stock)):
                _sql.append("'%s'" % stock[o]['s_code'])
                if show_five_order:
                    _pre_x = stock[o]['s_code'][0:2]
                    if _pre_x == 'sz':
                        _px = "0%s" % stock[o]['s_code'][2:]
                    else:
                        _px = "1%s" % stock[o]['s_code'][2:]
                    print _px

            if show_five_order:
                sys.exit()
            sql = "SELECT *  FROM `s_stock_fenbi_daily` WHERE `dateline` = %s AND s_code in(%s)" % (dateline, ",".join(_sql))
        elif sys.argv[3] == 'H':
            sql = "SELECT * FROM `s_stock_fenbi_daily` WHERE `dateline` = %s and 50DDJE >10000000 and 30DDJE > 0 order by 50DDJE desc " % dateline

        self.ak = 0

        data = self.mysql.getRecord(sql)
        stock = self.mysql.getRecord("select * from s_stock_list where 1")
        self.stock_list = {}

        for o in range(0, len(stock)):
            tmp_code = stock[o]['s_code']
            self.stock_list[tmp_code] = stock[o]
        #print len(data)
        #sys.exit()
        if len(data) > 0:
            attributes = ["Name", "Chg", "B100", "B50", "B30", "B20", "B10", "Buy", "Sell", "XC", "All", "Skip", "B3", "B5", "B7", "B10"]
            table = pylsytable(attributes)
            _name = []
            _chg = []
            _b100 = []
            _b50 = []
            _b30 = []
            _b20 = []
            _b10 = []
            _buy = []
            _sell = []
            _all = []
            _skip = []
            _xc = []
            _b_3 = []
            _b_5 = []
            _b_7 = []
            _b_10 = []
            for o in range(0, len(data)):
                ms = re.findall(re.compile(r'\*|N|ST|航空|银行'), self.stock_list[data[o]['s_code']]['name'])
                if self.stock_list[data[o]['s_code']]['run_market'] > 15000000000 or self.stock_list[data[o]['s_code']]['listing_date'] == 0 or ms:
                    continue
                if data[o]['bs_all'] < -80000000:
                    continue
                self.ak += 1
                #最近5天的主买平均小于1000W
                #res = self._avg_buy(data[o]['s_code'])
                #if res > 0 and res < 12000000:
                #    continue
                _skip.append(data[o]['skip_order'])
                _xc.append(int(data[o]['kp_xc']/10000))
                _a_name = self.stock_list[data[o]['s_code']]['name']
                _name.append("%s=%s" % (data[o]['s_code'], _a_name.encode('utf-8')))
                _chg.append(self.stock_list[data[o]['s_code']]['chg'])
                #_buy.append("%s=%s" % (data[o]['b_price'], data[o]['b_hands']))
                #_sell.append("%s=%s" % (data[o]['s_price'], data[o]['s_hands']))
                _b100.append(int(data[o]['100DDJE']/10000))
                _b50.append(int(data[o]['50DDJE']/10000))
                _b30.append(int(data[o]['30DDJE']/10000))
                _b20.append(int(data[o]['20DDJE']/10000))
                _b10.append(int(data[o]['10DDJE']/10000))

                _buy.append(int(data[o]['zl_b']/10000))
                _sell.append(int(data[o]['zl_s']/10000))
                _all.append("{:.2f}".format(data[o]['bs_all']/10000, ''))
                _b_3.append("%s=%s" % (data[o]['b_3'], data[o]['s_3']))
                _b_5.append("%s=%s" % (data[o]['b_5'], data[o]['s_5']))
                _b_7.append("%s=%s" % (data[o]['b_7'], data[o]['s_7']))
                _b_10.append("%s=%s" % (data[o]['b_10'], data[o]['s_10']))
                if show_five_order:
                    _pre_x = data[o]['s_code'][0:2]
                    if _pre_x == 'sz':
                        _px = "0%s" % data[o]['s_code'][2:]
                    else:
                        _px = "1%s" % data[o]['s_code'][2:]
                    print _px

            table.add_data("Name", _name)
            table.add_data("Chg", _chg)

            table.add_data("B100", _b100)
            table.add_data("B50", _b50)
            table.add_data("B30", _b30)
            table.add_data("B20", _b20)
            table.add_data("B10", _b10)

            table.add_data("Buy", _buy)
            table.add_data("Sell", _sell)
            table.add_data("XC", _xc)
            table.add_data("All", _all)
            table.add_data("Skip", _skip)
            table.add_data("B3", _b_3)
            table.add_data("B5", _b_5)
            table.add_data("B7", _b_7)
            table.add_data("B10", _b_10)
            if show_five_order == 0:
                print table.__str__()
        print "==========Count %s=====" % self.ak
예제 #31
0
파일: F10.py 프로젝트: yuzhucu/sogaQuant
    def __get_daily_order(self, s_code):
        opt_list = self.mysql.getRecord(
            "SELECT * FROM  `s_stock_fenbi_daily` WHERE s_code='%s' order by dateline desc"
            % s_code)
        #print "SELECT * FROM  `s_stock_fenbi_daily` WHERE s_code='%s' order by dateline desc" % s_code
        if len(opt_list):
            attributes = [
                "Time", "Buy", "Sell", "XC", "BS", "All", "Skip", "YiDong",
                "DuiDao", "BO", "SO", "Chg", "HS"
            ]
            table = pylsytable(attributes)
            _time = []
            _buy = []
            _sell = []
            _bs = []
            _all = []
            _skip = []
            _xc = []
            _yd = []
            _dd = []
            _level_A = []
            _level_B = []
            _chg = []
            _hs = []
            day2 = []
            for x in range(0, len(opt_list)):
                _time.append(opt_list[x]['dateline'])
                day2.append(str(opt_list[x]['dateline']))
                #_buy.append("%s/%s" % (opt_list[x]['b_price'], opt_list[x]['b_hands']))
                #_sell.append("%s/%s" % (opt_list[x]['s_price'], opt_list[x]['s_hands']))

                _buy.append(int(opt_list[x]['zl_b'] / 10000))
                _sell.append(int(-opt_list[x]['zl_s'] / 10000))
                _bs.append(
                    int(opt_list[x]['zl_b'] / 10000) +
                    int(-opt_list[x]['zl_s'] / 10000))
                _c = int(opt_list[x]['bs_all'] / 10000)
                _all.append(_c)
                _yd.append(opt_list[x]['YiDongCount'])
                _dd.append(opt_list[x]['DuiDaoCount'])
                _xc.append(int(opt_list[x]['kp_xc'] / 10000))
                _skip.append(opt_list[x]['skip_order'])
                _level_A.append("%s/%s/%s/%s" %
                                (opt_list[x]['b_3'], opt_list[x]['b_5'],
                                 opt_list[x]['b_7'], opt_list[x]['b_10']))
                _level_B.append("%s/%s/%s/%s" %
                                (opt_list[x]['s_3'], opt_list[x]['s_5'],
                                 opt_list[x]['s_7'], opt_list[x]['s_10']))

            stock_days = self.mysql.getRecord(
                "SELECT * FROM s_stock_trade WHERE  s_code='%s' and dateline in(%s) "
                % (s_code, ','.join(day2)))
            stock_daily = {}
            for j in range(0, len(stock_days)):
                #d = datetime.datetime.strptime(str(stock_days[j]['dateline']), "%Y%m%d")
                #_dd = self.tools.d_date('%Y-%m-%d', time.mktime(d.timetuple()))
                stock_daily[str(stock_days[j]['dateline'])] = stock_days[j]
            for x in range(0, len(opt_list)):
                _chg.append(stock_daily[str(opt_list[x]['dateline'])]['chg'])
                _huanshou = "{:.2f}".format(
                    stock_daily[str(opt_list[x]['dateline'])]['turnover'], '')
                _hs.append(_huanshou)

            table.add_data("Time", _time)
            table.add_data("Buy", _buy)
            table.add_data("Sell", _sell)
            table.add_data("BS", _bs)
            table.add_data("All", _all)
            table.add_data("Skip", _skip)
            table.add_data("XC", _xc)
            table.add_data("YiDong", _yd)
            table.add_data("DuiDao", _dd)
            table.add_data("BO", _level_A)
            table.add_data("SO", _level_B)
            table.add_data("Chg", _chg)
            table.add_data("HS", _hs)

            #5日流出
            '''
            i = 5
            _daily_B = []
            _daily_S = []
            while i:
                attributes2.append("D%s" % i)
                print _buy[i]
                _daily_B.append(_buy[i])
                _daily_S.append(_sell[i])

                i -= 1
            table2 = pylsytable(attributes2)
            '''

            print(table.__str__())
예제 #32
0
파일: pylsy_test.py 프로젝트: Hugoxi/Pylsy
 def setUp(self):
     attributes = ["name", "age"]
     self.table = pylsytable(attributes)
예제 #33
0
	submenu.add_command(label="Cut")
	menu.add_cascade(label="Hc->Edit", menu=submenu)
	submenu = t.Menu(menu, tearoff=0)
	submenu.add_command(label="Haocong")
	submenu.add_command(label="Python")
	submenu.add_separator()
	submenu.add_command(label="About")
	menu.add_cascade(label="Hc->Log", menu=submenu)
	menu.add_cascade(label="Hc->Manage", menu=submenu)
	menu.add_cascade(label="Hc->Help", menu=submenu)
	# menu.add_cascade(label="HC->Help", menu=submenu)
	root.config(menu=menu)
	# edit1=t.Text(root)
	# edit1.pack()
	a = ['Name', 'FIRST', 'FOLLOW']
	table = pylsytable(a)
	name = []
	f = open('d:\\python\\test.txt','r')
	s = f.readlines()
	t.Label(root,text="   请输入文法产生式:",font=fttt).grid(sticky='W',rowspan=2)
	u=t.StringVar()
	u1 = t.StringVar()
	u2 = t.StringVar()
	u3 = t.StringVar()
	u4 = t.StringVar()
	e1 = t.Entry(root,textvariable=u)
	u.set("E -> T E'")
	e2 = t.Entry(root,textvariable=u1)
	u1.set("T' -> * F T' | e")
	e3 = t.Entry(root,textvariable=u2)
	u2.set("E' -> + T E' | e")
예제 #34
0
                          passwd='1',
                          db='stu_info',
                          charset='utf8')

cur = content.cursor()
c_db = "create database stu_info"
c_table = "CREATE TABLE user_info (id int(8) NOT NULL AUTO_INCREMENT,name char(80) NOT NULL,sexy char(20) NOT NULL,age int(30) NOT NULL,address char(90) NOT NULL,qq int(60) NOT NULL, PRIMARY KEY (id))ENGINE=MyISAM AUTO_INCREMENT=58 DEFAULT CHARSET=utf8"

try:
    cur.execute(c_db)
    cur.execute(c_table)
except Exception as e:
    print e

data_title = ['id', 'name', 'sexy', 'age', 'address', 'qq']
table = pylsytable(data_title)
id_list = []
name_list = []
sexy_list = []
age_list = []
addr_list = []
qq_list = []


def add_table():
    table.add_data('id', id_list)
    table.add_data('name', name_list)
    table.add_data('sexy', sexy_list)
    table.add_data('age', age_list)
    table.add_data('address', addr_list)
    table.add_data('qq', qq_list)
예제 #35
0
파일: F10.py 프로젝트: yuzhucu/sogaQuant
    def __get_big_order(self, s_code):
        #按天归类,取最近半年
        data = self.mysql.getRecord(
            "SELECT * FROM s_stock_big_order WHERE  s_code='%s' order by datetime desc"
            % s_code)
        #print len(data)
        if len(data) > 0:
            #attributes = ["Day", "Small", "Middle", "Big", "Max"]
            attributes = ["Day", "Buy", "Sell", "Change"]
            table = pylsytable(attributes)
            days = []
            days2 = []
            res = {}
            for x in range(0, len(data)):
                at = str(data[x]['datetime']).split(' ')
                #print at
                _day = at[0]
                #_day = str(data[x]['dateline'])
                #35个交易日的数据
                if len(days2) > MAX_BIG_ORDER_LIST:
                    continue

                if _day not in res.keys():
                    res[_day] = {
                        'B_small': 0,
                        'B_s_money': 0,
                        'B_mid': 0,
                        'B_m_money': 0,
                        'B_big': 0,
                        'B_b_money': 0,
                        'B_max': 0,
                        'B_x_money': 0,
                        'S_small': 0,
                        'S_s_money': 0,
                        'S_mid': 0,
                        'S_m_money': 0,
                        'S_big': 0,
                        'S_b_money': 0,
                        'S_max': 0,
                        'S_x_money': 0,
                        'B_count': 0,
                        'B_money': 0,
                        'S_count': 0,
                        'S_money': 0,
                    }
                    d = datetime.datetime.strptime(_day, "%Y-%m-%d")
                    _dd = self.tools.d_date('%Y%m%d',
                                            time.mktime(d.timetuple()))
                    #print _day
                    days.append(_day)
                    days2.append(_dd)

                res[_day]["%s_count" % data[x]['bs_type']] += 1
                res[_day]["%s_money" %
                          data[x]['bs_type']] += data[x]['bs_money']

                #150W以下
                if data[x]['bs_money'] <= 150:
                    vk = "%s_small" % data[x]['bs_type']
                    vkm = "%s_s_money" % data[x]['bs_type']
                    res[_day][vk] += 1
                    res[_day][vkm] += data[x]['bs_money']
                elif data[x]['bs_money'] <= 500 and data[x]['bs_money'] > 150:
                    vk = "%s_mid" % data[x]['bs_type']
                    vkm = "%s_m_money" % data[x]['bs_type']
                    res[_day][vk] += 1
                    res[_day][vkm] += data[x]['bs_money']
                elif data[x]['bs_money'] < 1000 and data[x]['bs_money'] > 500:
                    vk = "%s_big" % data[x]['bs_type']
                    vkm = "%s_b_money" % data[x]['bs_type']
                    res[_day][vk] += 1
                    res[_day][vkm] += data[x]['bs_money']
                elif data[x]['bs_money'] >= 1000:
                    vk = "%s_max" % data[x]['bs_type']
                    vkm = "%s_x_money" % data[x]['bs_type']
                    res[_day][vk] += 1
                    res[_day][vkm] += data[x]['bs_money']
            '''
            bs_f = []
            bm_f = []
            bb_f = []
            bx_f = []
            for k, v in res.items():
                #print k
                #print v
                bs_f.append("%s=%s=%s=%s" % (v['B_small'], v['B_s_money'], v['S_small'], v['S_s_money']))
                bm_f.append("%s=%s=%s=%s" % (v['B_mid'], v['B_m_money'], v['S_mid'], v['S_m_money']))
                bb_f.append("%s=%s=%s=%s" % (v['B_big'], v['B_b_money'], v['S_big'], v['S_b_money']))
                bx_f.append("%s=%s=%s=%s" % (v['B_max'], v['B_x_money'], v['S_max'], v['S_x_money']))
                #print len(res)

            table.add_data("Day", days)
            table.add_data("Small", bs_f)
            table.add_data("Middle", bm_f)
            table.add_data("Big", bb_f)
            table.add_data("Max", bx_f)
            print(table.__str__())
            '''
            #print res
            #print days
            #_a_days = list(reversed(days))
            #print _a_days
            stock_days = self.mysql.getRecord(
                "SELECT * FROM s_stock_trade WHERE  s_code='%s' and dateline in(%s) "
                % (s_code, ','.join(days2)))
            #print stock_days
            #print "SELECT * FROM s_stock_trade WHERE  s_code='%s' and dateline in(%s) " % (s_code, ','.join(days))
            stock_daily = {}
            for j in range(0, len(stock_days)):
                d = datetime.datetime.strptime(str(stock_days[j]['dateline']),
                                               "%Y%m%d")
                _dd = self.tools.d_date('%Y-%m-%d', time.mktime(d.timetuple()))
                stock_daily[_dd] = stock_days[j]
                #stock_daily[str(stock_days[j]['dateline'])] = stock_days[j]
                #pass
            #print stock_daily['2016-10-10']
            __buy = []
            __sell = []
            __chg = []
            for ak in range(0, len(days)):
                k = days[ak]
                __buy.append("%s/%s" % (res[k]['B_money'], res[k]['B_count']))
                __sell.append("%s/%s" % (res[k]['S_money'], res[k]['S_count']))
                __chg.append(stock_daily[k]['chg'])
            '''
            for k, v in res.items():
                print k
                __buy.append("%s/%s" % (v['B_money'], v['B_count']))
                __sell.append("%s/%s" % (v['S_money'], v['S_count']))
                __chg.append(stock_daily[k]['chg'])
                #print "\t%s\tBUY:%s/%s\t=SELL:%s/%s\t%s==" % (k, v['B_money'], v['B_count'], v['S_money'], v['S_count'], stock_daily[k]['chg'])
            '''
            table.add_data("Day", days)
            table.add_data("Buy", __buy)
            table.add_data("Sell", __sell)
            table.add_data("Change", __chg)
            print(table.__str__())
예제 #36
0
파일: F10.py 프로젝트: idoplay/sogaQuant
    def __get_big_order(self, s_code):
        #按天归类,取最近半年
        data = self.mysql.getRecord("SELECT * FROM s_stock_big_order WHERE  s_code='%s' order by datetime desc" % s_code)
        #print len(data)
        if len(data) > 0:
            #attributes = ["Day", "Small", "Middle", "Big", "Max"]
            attributes = ["Day", "Buy", "Sell", "Change"]
            table = pylsytable(attributes)
            days = []
            days2 = []
            res = {}
            for x in range(0, len(data)):
                at = str(data[x]['datetime']).split(' ')
                #print at
                _day = at[0]
                #_day = str(data[x]['dateline'])
                #35个交易日的数据
                if len(days2) > MAX_BIG_ORDER_LIST:
                    continue

                if _day not in res.keys():
                    res[_day] = {
                        'B_small': 0,
                        'B_s_money': 0,
                        'B_mid': 0,
                        'B_m_money': 0,
                        'B_big': 0,
                        'B_b_money': 0,
                        'B_max': 0,
                        'B_x_money': 0,
                        'S_small': 0,
                        'S_s_money': 0,
                        'S_mid': 0,
                        'S_m_money': 0,
                        'S_big': 0,
                        'S_b_money': 0,
                        'S_max': 0,
                        'S_x_money': 0,

                        'B_count': 0,
                        'B_money': 0,
                        'S_count': 0,
                        'S_money': 0,

                    }
                    d = datetime.datetime.strptime(_day, "%Y-%m-%d")
                    _dd = self.tools.d_date('%Y%m%d', time.mktime(d.timetuple()))
                    #print _day
                    days.append(_day)
                    days2.append(_dd)

                res[_day]["%s_count" % data[x]['bs_type']] += 1
                res[_day]["%s_money" % data[x]['bs_type']] += data[x]['bs_money']

                #150W以下
                if data[x]['bs_money'] <= 150:
                    vk = "%s_small" % data[x]['bs_type']
                    vkm = "%s_s_money" % data[x]['bs_type']
                    res[_day][vk] += 1
                    res[_day][vkm] += data[x]['bs_money']
                elif data[x]['bs_money'] <= 500 and data[x]['bs_money'] > 150:
                    vk = "%s_mid" % data[x]['bs_type']
                    vkm = "%s_m_money" % data[x]['bs_type']
                    res[_day][vk] += 1
                    res[_day][vkm] += data[x]['bs_money']
                elif data[x]['bs_money'] < 1000 and data[x]['bs_money'] > 500:
                    vk = "%s_big" % data[x]['bs_type']
                    vkm = "%s_b_money" % data[x]['bs_type']
                    res[_day][vk] += 1
                    res[_day][vkm] += data[x]['bs_money']
                elif data[x]['bs_money'] >= 1000:
                    vk = "%s_max" % data[x]['bs_type']
                    vkm = "%s_x_money" % data[x]['bs_type']
                    res[_day][vk] += 1
                    res[_day][vkm] += data[x]['bs_money']

            '''
            bs_f = []
            bm_f = []
            bb_f = []
            bx_f = []
            for k, v in res.items():
                #print k
                #print v
                bs_f.append("%s=%s=%s=%s" % (v['B_small'], v['B_s_money'], v['S_small'], v['S_s_money']))
                bm_f.append("%s=%s=%s=%s" % (v['B_mid'], v['B_m_money'], v['S_mid'], v['S_m_money']))
                bb_f.append("%s=%s=%s=%s" % (v['B_big'], v['B_b_money'], v['S_big'], v['S_b_money']))
                bx_f.append("%s=%s=%s=%s" % (v['B_max'], v['B_x_money'], v['S_max'], v['S_x_money']))
                #print len(res)

            table.add_data("Day", days)
            table.add_data("Small", bs_f)
            table.add_data("Middle", bm_f)
            table.add_data("Big", bb_f)
            table.add_data("Max", bx_f)
            print(table.__str__())
            '''
            #print res
            #print days
            #_a_days = list(reversed(days))
            #print _a_days
            stock_days = self.mysql.getRecord("SELECT * FROM s_stock_trade WHERE  s_code='%s' and dateline in(%s) " % (s_code, ','.join(days2)))
            #print stock_days
            #print "SELECT * FROM s_stock_trade WHERE  s_code='%s' and dateline in(%s) " % (s_code, ','.join(days))
            stock_daily = {}
            for j in range(0, len(stock_days)):
                d = datetime.datetime.strptime(str(stock_days[j]['dateline']), "%Y%m%d")
                _dd = self.tools.d_date('%Y-%m-%d', time.mktime(d.timetuple()))
                stock_daily[_dd] = stock_days[j]
                #stock_daily[str(stock_days[j]['dateline'])] = stock_days[j]
                #pass
            #print stock_daily['2016-10-10']
            __buy = []
            __sell = []
            __chg = []
            for ak in range(0, len(days)):
                k = days[ak]
                __buy.append("%s/%s" % (res[k]['B_money'], res[k]['B_count']))
                __sell.append("%s/%s" % (res[k]['S_money'], res[k]['S_count']))
                __chg.append(stock_daily[k]['chg'])
            '''
            for k, v in res.items():
                print k
                __buy.append("%s/%s" % (v['B_money'], v['B_count']))
                __sell.append("%s/%s" % (v['S_money'], v['S_count']))
                __chg.append(stock_daily[k]['chg'])
                #print "\t%s\tBUY:%s/%s\t=SELL:%s/%s\t%s==" % (k, v['B_money'], v['B_count'], v['S_money'], v['S_count'], stock_daily[k]['chg'])
            '''
            table.add_data("Day", days)
            table.add_data("Buy", __buy)
            table.add_data("Sell", __sell)
            table.add_data("Change", __chg)
            print(table.__str__())
예제 #37
0
    passwd = '1',
    db = 'stu_info',
    charset = 'utf8')

cur = content.cursor()
c_db = "create database stu_info"
c_table = "CREATE TABLE user_info (id int(8) NOT NULL AUTO_INCREMENT,name char(80) NOT NULL,sexy char(20) NOT NULL,age int(30) NOT NULL,address char(90) NOT NULL,qq int(60) NOT NULL, PRIMARY KEY (id))ENGINE=MyISAM AUTO_INCREMENT=58 DEFAULT CHARSET=utf8"

try:
    cur.execute(c_db)
    cur.execute(c_table)
except Exception as e:
    print e

data_title = ['id','name','sexy','age','address','qq'] 
table = pylsytable(data_title)
id_list = []
name_list = []
sexy_list = []
age_list = []
addr_list = []
qq_list = []

        
def add_table():
    table.add_data('id', id_list)
    table.add_data('name', name_list)
    table.add_data('sexy', sexy_list)
    table.add_data('age', age_list)
    table.add_data('address', addr_list)
    table.add_data('qq', qq_list)