Exemplo n.º 1
0
 def market_index_percent(self,start):
     '''
         1.默认是上海指数,False,为深圳指数  2. 起始时间
         return:这段时间内大盘的变化幅度
         二期,考虑如何返回板块指数
     '''
     sh = TS.memchaced_data(ts.get_h_data,'sh','000001', index=True) #上证指数
     sz = TS.memchaced_data(ts.get_h_data,'sz','399001', index=True) #深圳综合指数
     self.delta_compute(sh,'上海指数','2015-12-01')
     self.delta_compute(sz,'深圳指数','2015-12-01')
Exemplo n.º 2
0
 def market_index_percent(self, start):
     '''
         1.默认是上海指数,False,为深圳指数  2. 起始时间
         return:这段时间内大盘的变化幅度
         二期,考虑如何返回板块指数
     '''
     sh = TS.memchaced_data(ts.get_h_data, 'sh', '000001',
                            index=True)  #上证指数
     sz = TS.memchaced_data(ts.get_h_data, 'sz', '399001',
                            index=True)  #深圳综合指数
     self.delta_compute(sh, '上海指数', '2015-12-01')
     self.delta_compute(sz, '深圳指数', '2015-12-01')
Exemplo n.º 3
0
 def process(self):
     fo = open('shrink_code', 'w')
     oversold = open('oversold', 'w')
     week_shrink = open('week_shrink', 'w')
     raw_data = TS.memchaced_data(ts.get_stock_basics, 'get_stock_basics')
     raw_data['earn_ratio'] = raw_data['esp'] / raw_data['bvps']
     for code in raw_data.index:
         if code in bad_container:
             continue
         try:
             daydata = ts.get_k_data(code, ktype='D')
             ratio = judge_oversold(daydata)
             if ratio < -0.45:
                 oversold.write("{0}\t{1}\n".format(code, ratio))
             if ratio < 0.2:
                 weekdata = ts.get_k_data(code, ktype='W')
                 if judge_week_shrinkage(code, 0.02):
                     week_shrink.write(code + '\n')
             if ratio > -0.3:
                 continue
             if raw_data.ix[code]['earn_ratio'] < 0.05:
                 continue
             totals = raw_data.ix[code]['totals']
             close = np.array(daydata['close'])[-1]
             if close < 6.5:
                 continue
             if close * totals > 320:
                 continue
             flag, mean = judge_shrinkage(daydata, 0.012)
             if ratio > -0.3:
                 continue
             if flag != -1:
                 fo.write("{0}\t{1}\t{2:.1%}\n".format(flag, code, mean))
         except Exception, e:
             print e
Exemplo n.º 4
0
    def concept_analysis(self, concept_code):
        #1. 获取概念相关的股票
        concept = TS.memchaced_data(ts.get_concept_classified,
                                    'get_concept_classified')
        concept.index = concept['code']
        concept = concept[concept['c_name'] == concept_code]
        #2
        raw_data = copy.deepcopy(self.foundmental_data)
        raw_data = DataFrame(raw_data, index=concept.index)

        #排序
        #raw_data = raw_data.sort(columns='reservedPerShare',ascending=False)
        print '当前排序1. 资本公积金大 2. 股本小 ,策略待思考 3. 去掉了创业板'
        #raw_data = raw_data.sort(columns='totals')
        raw_data = raw_data.sort_values(by=['totals'])
        raw_data = raw_data.sort_values(by=['reservedPerShare'],
                                        ascending=False)
        for code in raw_data.index:
            #if code.startswith('3'):
            #    continue
            gross_profit_rate = None
            if code in self.profit_data.index:
                gross_profit_rate = self.profit_data.ix[code][
                    'gross_profit_rate']
            self.print_stock_info(code, raw_data.ix[code], gross_profit_rate)
Exemplo n.º 5
0
 def init_profit_data(self):
     #1. 初始化财报时间
     season_table = [0,3,4,4,4,1,1,1,2,2,2,3,3]
     now_time = time.localtime()
     season = season_table[now_time.tm_mon]
     year = now_time.tm_year
     if now_time.tm_mon < 5:
         year -= 1
     self.profit_data = TS.memchaced_data(ts.get_profit_data,'get_profit_data',year,season)
     self.profit_data.index = self.profit_data['code']
     print "获取毛利润率财报表时间:{0}年{1}季度".format(year, season)
Exemplo n.º 6
0
 def init_profit_data(self):
     #1. 初始化财报时间
     season_table = [0, 3, 4, 4, 4, 1, 1, 1, 2, 2, 2, 3, 3]
     now_time = time.localtime()
     season = season_table[now_time.tm_mon]
     year = now_time.tm_year
     if now_time.tm_mon < 5:
         year -= 1
     self.profit_data = TS.memchaced_data(ts.get_profit_data,
                                          'get_profit_data', year, season)
     self.profit_data.index = self.profit_data['code']
     print "获取毛利润率财报表时间:{0}年{1}季度".format(year, season)
Exemplo n.º 7
0
    def concept_analysis(self,concept_code):
        #1. 获取概念相关的股票
        concept = TS.memchaced_data(ts.get_concept_classified,'get_concept_classified')
        concept.index = concept['code']
        concept = concept[concept['c_name'] == concept_code]
        #2
        raw_data = copy.deepcopy(self.foundmental_data)
        raw_data = DataFrame(raw_data,index=concept.index)

        #排序
        #raw_data = raw_data.sort(columns='reservedPerShare',ascending=False)
        print '当前排序1. 资本公积金大 2. 股本小 ,策略待思考 3. 去掉了创业板'
        #raw_data = raw_data.sort(columns='totals')
        raw_data = raw_data.sort_values(by=['totals'])
        raw_data = raw_data.sort_values(by=['reservedPerShare'],ascending=False)
        for code in raw_data.index:
            #if code.startswith('3'):
            #    continue
            gross_profit_rate = None
            if code in self.profit_data.index:
                gross_profit_rate = self.profit_data.ix[code]['gross_profit_rate']
            self.print_stock_info(code,raw_data.ix[code],gross_profit_rate)
Exemplo n.º 8
0
 def init_foundmental_data(self):
     self.foundmental_data = TS.memchaced_data(ts.get_stock_basics,
                                               'get_stock_basics')
     self.foundmental_data['earn_ratio'] = self.foundmental_data[
         'esp'] / self.foundmental_data['bvps']
     print "获取基本数据,并且计算净资产收益率"
Exemplo n.º 9
0
 def list_stock_percent(self, stock_list, start):
     for stock, name in stock_list.iteritems():
         stock_data = TS.memchaced_data(ts.get_h_data,stock,stock) #股票数据
         if stock_data is not None:
             self.delta_compute(stock_data, name, start)
Exemplo n.º 10
0
 def init_foundmental_data(self):
     self.foundmental_data = TS.memchaced_data(ts.get_stock_basics,'get_stock_basics')
     self.foundmental_data['earn_ratio'] = self.foundmental_data['esp'] / self.foundmental_data['bvps']
     print "获取基本数据,并且计算净资产收益率"
Exemplo n.º 11
0
 def list_stock_percent(self, stock_list, start):
     for stock, name in stock_list.iteritems():
         stock_data = TS.memchaced_data(ts.get_h_data, stock, stock)  #股票数据
         if stock_data is not None:
             self.delta_compute(stock_data, name, start)