select_stock.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:stock 作者: Rockyzsu 项目源码 文件源码
def _break_line(self, codes, k_type):
        delta_day = 60 * 7 / 5
        end_day = datetime.date(datetime.date.today().year, datetime.date.today().month, datetime.date.today().day)
        start_day = end_day - datetime.timedelta(delta_day)

        start_day = start_day.strftime("%Y-%m-%d")
        end_day = end_day.strftime("%Y-%m-%d")
        print start_day
        print end_day
        all_break = []

        for i in codes:
            try:
                df = ts.get_hist_data(code=i, start=start_day, end=end_day)
                if len(df)==0:
                    continue
            except Exception,e:
                print e
                continue
            else:
                self.working_count=self.working_count+1
                current = df['close'][0]
                ma5 = df['ma5'][0]
                ma10 = df['ma10'][0]
                ma20 = df['ma20'][0]
                ma_dict = {'5': ma5, '10': ma10, '20': ma20}
                ma_x = ma_dict[k_type]
                #print ma_x
                if current < ma_x:
                    print u'??'
                    print i, " current: ", current
                    print self.base[self.base['code'] == i]['name'].values[0], " "
                    print "holding place: " , ma_x
                    print "Break MA", k_type, "\n"
                    all_break.append(i)
        return all_break

    # ????????????????
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号