s = re.sub(r'(?<=\]),', r';', s) if not kMinute: s = re.sub(r'(?<=\d),(\d{3})', r'\1', s) s = re.sub(r'(record|:(?=\[)|\[|\]|\{|\}|")', r'', s) l = [] for i in s.split(';'): j = i.split(',') if kMinute: d = [datetime.strptime(j[0], '%Y-%m-%d %H:%M:%S')] else: d = [datetime.strptime(j[0], '%Y-%m-%d').date()] d.extend([float(k) for k in j[1:]]) l.append(d) df = pd.DataFrame(l, columns=keyKData) df.set_index('date', inplace=True) if profile: print('qData.get_k_data(%s, %s) (%s) %.3fs %.3fs' % (symbol, ktype, time.ctime(t0), time.time()-t0, t1-t0)) return df except: printException() return pd.DataFrame() if __name__ == "__main__": if 0: symbol = getStockList() else: symbol = get_stock_all(ascend=1, num=10, page=1) save_hist_data(symbol, fuQuan=True, dateStart=(2015,7,1)) l = load_hist_data(symbol)
with self.stock_lock: for i, c in enumerate(stock_text.Codes): if c[6:9]=='.SH': c='sh'+c[0:6] if c[6:9]=='.SZ': c='sz'+c[0:6] q[c] = {} for f, d in zip(stock_text.Fields, stock_text.Data): g = self.stock_fields[f] e = d[i] self.stock_data[c][g] = e q[c][g] = e self.stock_data[c]['time'] = stock_text.Times[0] q[c]['time'] = stock_text.Times[0] if self.stock_queue and q: self.stock_queue.put(q) def start(self, fields=subscribe, **args): if fields: WindPy.w.wsq(','.join(self.stock_list), ','.join(fields), func=self.windCallback) else: qSina.start(self, **args) def windCallback(self, w): if self.profile: t0 = time.time() self.parse_stock(w) if self.profile: print('%s.windCallback() (%s) %.3fs' % (type(self), time.ctime(t0), time.time()-t0)) if __name__ == "__main__": #qWind(stock_list=qSinaList(), profile=True).bist() qText(qWind(stock_list=getStockList(), profile=True)).bist()