def get_all_stock_current_price(): if cm.DB_WAY == 'redis': r = redis.Redis(host='127.0.0.1', port=6379) stockList = list(r.smembers(cm.INDEX_STOCK_BASIC)) elif cm.DB_WAY == 'sqlite': engine = create_engine('sqlite:///..\stocks.db3') sql = 'select %s from %s' % (cm.KEY_CODE, cm.INDEX_STOCK_BASIC) df = pd.read_sql_query(sql, engine) stockList = df[cm.KEY_CODE].get_values() stockList_group = util.group_list(stockList, 20) stockClassList = [] for eachList in stockList_group: #print eachList eachClasses = OnlineData.getLiveMutliChinaStockPrice(eachList) if eachClasses != []: stockClassList.extend(eachClasses) print '交易股票总数:%d' % len(stockClassList) return stockClassList
def getAllChinaStock2(): df_list = pd.read_csv(cm.DownloadDir + cm.TABLE_STOCKS_BASIC + '.csv') stockList = df_list['code'].values stockList_group = util.group_list(stockList, 20) print len(stockList_group) print stockList_group[1] stockList = [] for group in stockList_group: df = ts.get_realtime_quotes(group) for se in df.get_values(): stock = st.Stock('') stock.code = se[0] stock.name = se[1] stock.current = se[3] stock.open = se[4] stock.high = se[5] stock.low = se[6] stock.close = se[7] stock.dealAmount = se[8] / 100 stock.time = time.localtime(time.time()) #时间 #print stock stockList.append(stock) return stockList
def getAllChinaStock2(): df_list = pd.read_csv(cm.DownloadDir + cm.TABLE_STOCKS_BASIC + '.csv') stockList = df_list['code'].values; stockList_group = util.group_list(stockList, 20) print len(stockList_group) print stockList_group[1] stockList = [] for group in stockList_group: df = ts.get_realtime_quotes(group) for se in df.get_values(): stock = st.Stock('') stock.code = se[0] stock.name = se[1] stock.current = se[3] stock.open = se[4] stock.high = se[5] stock.low = se[6] stock.close = se[7] stock.dealAmount = se[8]/100 stock.time = time.localtime(time.time()) #时间 #print stock stockList.append(stock) return stockList