股票涨跌预测方法之四:实际预测

         前一阵子在同学的鼓动下,花了一个多月研究了股票行情的预测方法,熟悉了常见的炒股术语及技术指标,现总结如下,纯属兴趣,如果想依照本文的方法来短线操作获利,请绕道。

         前面模型都已经搭好了,最后一步就是更新当天的股票行情并预测第二天的涨跌,更新操作当然也可以用前面的tushare来做,但是慢啊,慢得难以忍受,所以折腾我几天后,就在电脑上装了一个招商证券智远理财软件,里边可以将当天所有股票行情保存为xls文档,只需要几秒钟,所以就写了从xls导入sqlite的小代码。

        import xlrd   
        book = xlrd.open_workbook(u'./20170414.xls')
        sheet=book.sheet_by_index(0)
        nrows = sheet.nrows    #行总数  
        ncols = sheet.ncols   #列总数 
        
        strDate = '2017-06-14'
        
        cxn = db.connect('all_tushare_data.db') #内存数据库  sqlite.connect(':memory:')    #help(sqlite)
        cur = cxn.cursor()
        #cur.execute("delete from gp_record where date='%s'" %strDate)
        for h in range (1,nrows):
            try:
                v = [str(int(sheet.cell_value(h,0))), 
                    strDate, 
                    float(sheet.cell_value(h,11)), 
                    float(sheet.cell_value(h,12)), 
                    float(sheet.cell_value(h,3)), 
                    float(sheet.cell_value(h,13)), 
                    float(sheet.cell_value(h,7))*100, 
                    float(sheet.cell_value(h,16))]
                cur.execute('insert into gp_record values(?,?,?,?,?,?,?,?)', v)
                print(v)
            except Exception as e:
                print(e)
                pass
        cur.close()
        cxn.commit()
        cxn.close()

然后就是实测,只统计了预测涨幅大于0.01的股票,准确率24%左右,悲哀了,就比20%高那么一点点,无法应用于实践,应该也跟这两天大盘喋喋不休有关,大势所趋嘛,所以,炒股要靠内幕,跟大势,别看我这篇博客,o(∩_∩)o 哈哈

原文地址:https://www.cnblogs.com/zmshy2128/p/7118731.html