def __init__(self, dbinfo=ct.DB_INFO, redis_host=None): self.dbinfo = dbinfo self.logger = getLogger(__name__) self.index_objs = dict() self.stock_objs = dict() self.updating_date = None self.combination_objs = dict() self.cal_client = CCalendar(dbinfo, redis_host) self.index_info_client = IndexInfo() self.cvaluation_client = CValuation() self.reviewer = CReivew(dbinfo, redis_host) self.comb_info_client = CombinationInfo(dbinfo, redis_host) self.stock_info_client = CStockInfo(dbinfo, redis_host) self.rindex_stock_data_client = RIndexStock(dbinfo, redis_host) self.industry_info_client = IndustryInfo(dbinfo, redis_host) self.rindustry_info_client = RIndexIndustryInfo(dbinfo, redis_host) self.animation_client = CAnimation(dbinfo, redis_host) self.subscriber = Subscriber() self.quote_handler = StockQuoteHandler() self.ticker_handler = TickerHandler() self.connect_client = StockConnect(market_from=ct.SH_MARKET_SYMBOL, market_to=ct.HK_MARKET_SYMBOL, dbinfo=dbinfo, redis_host=redis_host) self.margin_client = Margin(dbinfo=dbinfo, redis_host=redis_host) self.emotion_client = Emotion(dbinfo=dbinfo, redis_host=redis_host) self.sh_exchange_client = StockExchange(ct.SH_MARKET_SYMBOL) self.sz_exchange_client = StockExchange(ct.SZ_MARKET_SYMBOL)
import sys from os.path import abspath, dirname sys.path.insert(0, dirname(dirname(dirname(abspath(__file__))))) import traceback import const as ct import pandas as pd from rstock import RIndexStock from cstock_info import CStockInfo from industry_info import IndustryInfo if __name__ == '__main__': try: mdate = '2019-08-02' cobj = CStockInfo() robj = RIndexStock() iobj = IndustryInfo() black_list = list(ct.BLACK_DICT.keys()) bdf = cobj.get() stock_info = robj.get_data(mdate) idf = iobj.get_csi_industry_data(mdate) df = pd.merge(bdf, idf, how='left', on=['code']) df = pd.merge(stock_info, df, how='inner', on=['code']) df = df[~df.code.isin(black_list)] df = df[(df.profit > 1) & (df.profit < 3) & (df.pday > 30) & (df.timeToMarket < 20150101)] df = df.reset_index(drop=True) #df = df[['code', 'name', 'industry', 'profit', 'pday', 'pind_name', 'sind_name', 'tind_name', 'find_name']] df = df[['code', 'name', 'profit', 'pday', 'find_name']] for name, contains in df.groupby('find_name'): if len(contains) > 2: