Exemple #1
0
def stStatistics():
    with scheduler.app.app_context():
        
        try:
            datas = FinancialDao().getAllNameChangeDatas()
#             datas = NameChangeLoad().load()
            OnlyST().stCount( datas )
            StarST().starStCount( datas )
        except Exception as err:
                StatisticsLog.getLog().error( err )
Exemple #2
0
    def deleteOldStStatistics(self, stType):
        StatisticsLog().getLog().info("开始删除旧st数据")

        statisticsDBSession = StatisticsDBConnection().getStatisticsDBSession()

        statisticsDBSession.query(StBean).filter(
            StBean.stType == stType).delete()

        statisticsDBSession.commit()
        statisticsDBSession.close()

        StatisticsLog().getLog().info("删除旧st数据完毕")
Exemple #3
0
    def saveStDatas(self, stDatas):

        StatisticsLog().getLog().info("开始保存st数据")

        statisticsDBSession = StatisticsDBConnection().getStatisticsDBSession()

        for st in stDatas:
            statisticsDBSession.add(st)

        statisticsDBSession.commit()
        statisticsDBSession.close()

        StatisticsLog().getLog().info("保存st数据完毕")
Exemple #4
0
    def getIndexDatas(self, SQL):

        StatisticsLog().getLog().info("开始获取指数基础数据")

        mySqlDBSession = MySqlDBConnection().getMysqlDBSession()
        result = mySqlDBSession.execute(text(SQL))

        datas = []
        for row in result:
            datas.append([row[0], row[1], row[2], row[3], row[4]])

        result.close()
        mySqlDBSession.close()

        StatisticsLog().getLog().info("获取指数数据完毕")

        return datas
Exemple #5
0
    def getStockDatas(self, SQL, tsCode):

        StatisticsLog().getLog().info("开始获取股票基础数据")

        mySqlDBSession = MySqlDBConnection().getMysqlDBSession()
        result = mySqlDBSession.execute(text(SQL), {"tsCode": tsCode})

        datas = []
        for row in result:
            datas.append([row[0], row[1], row[2], row[3], row[4]])

        result.close()
        mySqlDBSession.close()

        StatisticsLog().getLog().info("获取股票基础数据完毕")

        return datas
Exemple #6
0
    def getTsCodes(self):

        StatisticsLog().getLog().info("开始获取股票基础数据")

        mySqlDBSession = MySqlDBConnection().getMysqlDBSession()
        result = mySqlDBSession.execute(
            text("select ts_code from stock_basic"))
        mySqlDBSession.close()

        datas = []
        for row in result:
            datas.append(row[0])

        result.close()
        mySqlDBSession.close()

        StatisticsLog().getLog().info("获取股票基础数据完毕")

        return datas
Exemple #7
0
    def getStStatisticsDatas(self, SQL):
        StatisticsLog().getLog().info("开始获取st统计数据")

        statisticsDBSession = StatisticsDBConnection().getStatisticsDBSession()
        result = statisticsDBSession.execute(text(SQL))

        datas = []
        for row in result:
            datas.append([
                row[0], row[1], row[2], row[3], row[4], row[5], row[6], row[7],
                row[8], row[9], row[10], row[11], row[12], row[13], row[14],
                row[15], row[16], row[17], row[18], row[19], row[20], row[21],
                row[22], row[23], row[24], row[25], row[26]
            ])

        result.close()
        statisticsDBSession.close()

        StatisticsLog().getLog().info("获取st统计数据完毕")

        return datas
Exemple #8
0
    def getAllNameChangeDatas(self):

        StatisticsLog().getLog().info("开始加载股票曾用名数据")

        mySqlDBSession = MySqlDBConnection().getMysqlDBSession()
        #         result = mySqlDBSession.execute( text( "select ts_code, name, start_date, end_date, change_reason from name_change where ts_code='600539.SH' order by ts_code, start_date asc" ) )
        result = mySqlDBSession.execute(
            text(
                "select ts_code, name, start_date, end_date, change_reason from name_change order by ts_code, start_date asc"
            ))

        datas = []
        for row in result:
            datas.append([row[0], row[1], row[2], row[3], row[4]])

        result.close()
        mySqlDBSession.close()

        StatisticsLog().getLog().info("股票曾用名数据加载完毕")

        return datas
Exemple #9
0
    def load(self):

        dataResult = []
        tsCodes = FinancialDao().getTsCodes()
        tsCodes = ["002194.SZ"]
        for tsCode in tsCodes:
            if self.__NO_LOAD_TSCODE.count(tsCode) == 0:

                StatisticsLog().getLog().info("加载 {} 曾用名数据".format(tsCode))
                nameChangeDatas = self.__getNameChangeDatas(tsCode)
                for row in nameChangeDatas:

                    name = row[1]
                    if name.find("ST") > -1:
                        dataResult.extend(
                            self.__sortByStartDateAsc(nameChangeDatas))
                        print(dataResult)
                        break

                time.sleep(2)

        return dataResult