Exemplo n.º 1
0
    def format_realtime_quotes(self, realtime_quotes_data):
        result = dict()
        stocks_detail = ''.join(realtime_quotes_data)
        grep_result = self.realtime_quotes_format_zs.finditer(stocks_detail)
        for stock_match_object in grep_result:
            groups = stock_match_object.groups()
            price_A1 = eval(groups[0])
            price_A2 = eval(groups[1])
            perform = eval('[\'\'%s]' % (',\'0\'' * 26))
            g = eval(groups[2])
        grep_result = self.realtime_quotes_format.finditer(stocks_detail)
        for stock_match_object in grep_result:
            groups = stock_match_object.groups()
            price_A1 = eval(groups[0])
            price_A2 = eval(groups[1])
            perform = eval(groups[2])
            g = eval(groups[3])

        q = Quote()
        if 'zs' == price_A1[0][:2]:
            q.symbol = zs_symbol_of(price_A1[0][-6:])
        if 'cn' == price_A1[0][:2]:
            q.symbol = symbol_of(price_A1[0][-6:])
        q.code = code_from_symbol(q.symbol)
        q.name = price_A1[1].decode('utf-8')
        q.now = to_float(price_A1[2])
        q.open = to_float(price_A2[3])
        q.close = to_float(price_A2[1])
        q.high = to_float(price_A2[5])
        q.low = to_float(price_A2[7])
        q.buy = to_float(perform[12])
        q.sell = to_float(perform[10])
        q.volume = to_int(price_A2[8]) * 100
        q.turnover = to_float(price_A2[12]) * 10000
        q.bid1_volume = to_int(perform[13]) * 100
        q.bid1 = to_float(perform[12])
        q.bid2_volume = to_int(perform[15]) * 100
        q.bid2 = to_float(perform[14])
        q.bid3_volume = to_int(perform[17]) * 100
        q.bid3 = to_float(perform[16])
        q.bid4_volume = to_int(perform[19]) * 100
        q.bid4 = to_float(perform[18])
        q.bid5_volume = to_int(perform[21]) * 100
        q.bid5 = to_float(perform[20])
        q.ask1_volume = to_int(perform[11]) * 100
        q.ask1 = to_float(perform[10])
        q.ask2_volume = to_int(perform[9]) * 100
        q.ask2 = to_float(perform[8])
        q.ask3_volume = to_int(perform[7]) * 100
        q.ask3 = to_float(perform[6])
        q.ask4_volume = to_int(perform[5]) * 100
        q.ask4 = to_float(perform[4])
        q.ask5_volume = to_int(perform[3]) * 100
        q.ask5 = to_float(perform[2])
        t = '%s-%s-%s %s:%s:%s' % (g[0], g[1], g[2], g[3], g[4], g[5])
        q.time = date_time.str_to_time(t)

        result[q.code] = q

        return result
Exemplo n.º 2
0
    def format_realtime_quotes(self, realtime_quotes_data):
        result = dict()
        stocks_detail = ''.join(realtime_quotes_data)
        grep_result = self.realtime_quotes_format.finditer(stocks_detail)
        for stock_match_object in grep_result:
            q = Quote()
            groups = stock_match_object.groups()
            l = json.loads(groups[1])
            ask_bid = []
            for i in l:
                ab = re.split(r',', i)
                ask_bid.append(ab)

            s = re.split(r',', groups[0])
            q.symbol = symbol_of(s[1])
            q.code = code_from_em_symbol(s[1] + s[0])
            q.name = s[2]
            q.now = float(s[3])
            q.open = float(s[8])
            q.close = float(s[9])
            q.high = float(s[10])
            q.low = float(s[11])
            q.buy = float(ask_bid[5][0])
            q.sell = float(ask_bid[4][0])
            q.volume = int(s[17]) * 100
            q.turnover = float(s[19]) * 10000
            q.bid1_volume = int(ask_bid[5][1]) * 100
            q.bid1 = float(ask_bid[5][0])
            q.bid2_volume = int(ask_bid[6][1]) * 100
            q.bid2 = float(ask_bid[6][0])
            q.bid3_volume = int(ask_bid[7][1]) * 100
            q.bid3 = float(ask_bid[7][0])
            q.bid4_volume = int(ask_bid[8][1]) * 100
            q.bid4 = float(ask_bid[8][0])
            q.bid5_volume = int(ask_bid[9][1]) * 100
            q.bid5 = float(ask_bid[9][0])
            q.ask1_volume = int(ask_bid[4][1]) * 100
            q.ask1 = float(ask_bid[4][0])
            q.ask2_volume = int(ask_bid[3][1]) * 100
            q.ask2 = float(ask_bid[3][0])
            q.ask3_volume = int(ask_bid[2][1]) * 100
            q.ask3 = float(ask_bid[2][0])
            q.ask4_volume = int(ask_bid[1][1]) * 100
            q.ask4 = float(ask_bid[1][0])
            q.ask5_volume = int(ask_bid[0][1]) * 100
            q.ask5 = float(ask_bid[0][0])
            q.time = date_time.str_to_time(s[27])

            result[q.code] = q

        return result
Exemplo n.º 3
0
    def format_realtime_quotes(self, realtime_quotes_data):
        result = dict()
        stocks_detail = ''.join(realtime_quotes_data)
        grep_result = self.realtime_quotes_format.finditer(stocks_detail)
        for stock_match_object in grep_result:
            stock = stock_match_object.groups()
            q = Quote()
            q.symbol = stock[0]
            q.code = code_from_symbol(stock[0])
            q.name = stock[1]
            q.open = float(stock[2])
            q.close = float(stock[3])
            q.now = float(stock[4])
            q.high = float(stock[5])
            q.low = float(stock[6])
            q.buy = float(stock[7])
            q.sell = float(stock[8])
            q.volume = int(stock[9])
            q.turnover = float(stock[10])
            q.bid1_volume = int(stock[11])
            q.bid1 = float(stock[12])
            q.bid2_volume = int(stock[13])
            q.bid2 = float(stock[14])
            q.bid3_volume = int(stock[15])
            q.bid3 = float(stock[16])
            q.bid4_volume = int(stock[17])
            q.bid4 = float(stock[18])
            q.bid5_volume = int(stock[19])
            q.bid5 = float(stock[20])
            q.ask1_volume = int(stock[21])
            q.ask1 = float(stock[22])
            q.ask2_volume = int(stock[23])
            q.ask2 = float(stock[24])
            q.ask3_volume = int(stock[25])
            q.ask3 = float(stock[26])
            q.ask4_volume = int(stock[27])
            q.ask4 = float(stock[28])
            q.ask5_volume = int(stock[29])
            q.ask5 = float(stock[30])
            #q.date = date_time.str_to_date(stock[31])
            q.time = date_time.str_to_time(stock[31] + ' ' + stock[32])

            result[q.code] = q

        return result
Exemplo n.º 4
0
 def __init__(self):
     # 完整代码
     self.symbol = ''
     # 股票代码
     self.code = ''
     # 股票名字
     self.name = ''
     # 当前价格
     self.now = 0
     # 今日开盘价
     self.open = 0
     # 昨日收盘价
     self.close = 0
     # 今日最高价
     self.high = 0
     # 今日最低价
     self.low = 0
     # 竞买价,即“买一”报价
     self.buy = 0
     # 竞卖价,即“卖一”报价
     self.sell = 0
     # 成交的股票数,由于股票交易以一百股为基本单位,所以在使用时,通常把该值除以一百
     self.volume = 0
     # 成交金额,单位为“元”,为了一目了然,通常以“万元”为成交金额的单位,所以通常把该值除以一万
     self.turnover = 0
     # 买一申报量
     self.bid1_volume = 0
     # 买一报价
     self.bid1 = 0
     # 买二申报量
     self.bid2_volume = 0
     # 买二报价
     self.bid2 = 0
     # 买三申报量
     self.bid3_volume = 0
     # 买三报价
     self.bid3 = 0
     # 买四申报量
     self.bid4_volume = 0
     # 买四报价
     self.bid4 = 0
     # 买五申报量
     self.bid5_volume = 0
     # 买五报价
     self.bid5 = 0
     # 卖一申报量
     self.ask1_volume = 0
     # 卖一报价
     self.ask1 = 0
     # 卖二申报量
     self.ask2_volume = 0
     # 卖二报价
     self.ask2 = 0
     # 卖三申报量
     self.ask3_volume = 0
     # 卖三报价
     self.ask3 = 0
     # 卖四申报量
     self.ask4_volume = 0
     # 卖四报价
     self.ask4 = 0
     # 卖五申报量
     self.ask5_volume = 0
     # 卖五报价
     self.ask5 = 0
     # 日期
     # self.date = date_time.str_to_date('1900-01-01')
     # 时间
     self.time = date_time.str_to_time('1900-01-01 00:00:00')
     return