SecondDraw.py 文件源码

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

项目:sogaQuant 作者: idoplay 项目源码 文件源码
def min_data(self):
        sql_data = "select * FROM s_stock_runtime WHERE dateline =20160607 and s_code='sz000048' "
        tmpdf = pandas.read_sql(sql_data, self.mysql.db)
        pandas.set_option('display.width', 400)
        # ???????period_type??????'W'??'M'????'Q'?????'5min'?12??'12D'
        period_type = 'W'
        #????

        # ??date????index
        tmpdf.set_index('date_str', inplace=True)
        period_stock_data = tmpdf.resample('1Min', how='last')
        #period_stock_data =
        #print len(period_stock_data)
        #print period_stock_data['B_1_price'].sum()
        period_stock_data['MA_1'] = pandas.rolling_mean(period_stock_data['B_1_price'], 1)
        #period_stock_data = tmpdf.resample('5Min', how='last')
        print period_stock_data
        sys.exit()
        df = pandas.DataFrame(columns=('k', 'v'))
        data = {}
        j = 0
        for i in range(len(tmpdf)):
            #print tmpdf.iloc[i]
            _min = tmpdf.iloc[i].min_sec
            #print _min
            if _min > 150000 and '150000' in data.keys():
                continue
            _min = str(_min)

            _min = _min[0:-2]
            #print _min
           # sys.exit()
            #[0:-2]

            _min_str = "%s00" % _min
            #data[_min_str] =

            if _min_str not in data.keys():
                #data = {'k': _min_str, 'v': tmpdf.iloc[i].B_1_price}
                j += 1

            data[_min_str] = {'v': tmpdf.iloc[i].B_1_price}

            df.loc[j] = {'k': _min_str, 'v': tmpdf.iloc[i].B_1_price}
            #j += 1
            #data.append(_v)
            #sys.exit()
        print df
        #print tmpdf
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号