stock_fetcher.py 文件源码

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

项目:strategy 作者: kanghua309 项目源码 文件源码
def _save(stock, conn):
    try:
        print "save ----- :", stock
        marketday = stocksinfo.at[stock, 'timeToMarket']
        startday = pd.Timestamp(str(marketday))
        # print marketday,startday,str(startday)[:10]
        # df = ts.get_h_data(code, start=str(startday)[:10], retry_count = 5)
        df = ts.get_h_data(stock, start=str(startday)[:10], retry_count=5, pause=1)
        df = df.sort_index(ascending=True)
        # ma_list = [5,10,20,60]
        # for ma in ma_list:
        #    df['MA_' + str(ma)] = pd.rolling_mean(df.close, ma)
        # print df[['open','high','close','low','volume']].head(2)
        df[['open', 'high', 'close', 'low', 'volume']].to_sql(stock, conn, if_exists='append')
    except Exception, arg:
        print "exceptions:", stock, arg
        errorlist.append(stock)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号