示例#1
0
文件: Kmanager.py 项目: zhoupj/flwm
    def pull_data_and_count_kpi(start_date=None,
                                start_code=None,
                                retry=False,
                                retryDict=None):

        shp = SharePuller()
        df = shp.query_from_mysql()

        now = datetime.datetime.now()
        end = now.strftime('%Y-%m-%d')

        dict = {}
        # 拉取数据&保存到DB
        kp = Kpuller()
        # 获取基本数据,按列表计算
        for index, row in df.iterrows():
            code = row['code']
            start = str(row['timeToMarket'])

            if (start_code and code < start_code):
                continue

            if (retry and code not in retryDict['pd']):
                continue

            if (start_date != None and start < start_date):
                start = start_date
            dict[code] = kp.pull(code, start, end)
            time.sleep(1.5)

        KManager.to_csv(dict, 'pd')
示例#2
0
文件: FinManager.py 项目: zhoupj/flwm
 def count_kpi():
     shp = SharePuller();
     df = shp.query_from_mysql();
     for index, row in df.iterrows():
         code = row['code'];
         nma=NetProfitMA();
         nma.run(code,to_mysql=True,type=1);
     nms = NetProfitSort();
     nms8= NetProfitSort8();
     for dt in['2017-09-30','2017-12-31','2018-03-31','2018-06-30','2018-09-30']:
         nms.run(dt,to_mysql=True,type=1)
         nms8.run(dt,to_mysql=True,type=1)
示例#3
0
文件: Kmanager.py 项目: zhoupj/flwm
    def pull_data_hk(start_date=None,
                     start_code=None,
                     retry=False,
                     retryDict=None):
        shp = SharePuller()
        df = shp.query_from_mysql()

        dict = {}
        hkp = HkHoldPuller()
        for dt in DateUtil.getDateSeq(start_date):
            if (retry and dt not in retryDict['ph']):
                continue
            dict[dt] = hkp.pull(dt)
            time.sleep(3)
        KManager.to_csv(dict, 'ph')
示例#4
0
文件: Kmanager.py 项目: zhoupj/flwm
    def count_kpi(start_date,
                  s=True,
                  m=True,
                  start_code=None,
                  retry=False,
                  retryDict=None):
        shp = SharePuller()
        df = shp.query_from_mysql()

        end = datetime.datetime.now().strftime('%Y-%m-%d')

        # ================================
        ## 单指标计算
        # ================================
        if (s):
            dict = {}
            for index, row in df.iterrows():
                code = row['code']
                start = str(row['timeToMarket'])
                if (start_code and code < start_code):
                    continue

                if (retry and code not in retryDict['ks']):
                    continue
                if (start_date != None and start < start_date):
                    start = start_date
                    KManager.kpi_s(code, start_date, pm, dict)

            KManager.to_csv(dict, 'ks')

        # ================================
        ## 多指标计算
        # ================================
        if (m):
            dict = {}
            if (start_date == None):
                start_date = end
                dict[start_date] = KManager.kpi_m(start_date, pm)
            elif (start_date <= end):
                for dt in DateUtil.getDateSeq(start_date):
                    if (retry and code not in retryDict['km']):
                        continue
                    dict[dt] = KManager.kpi_m(dt, pm)
                    #更新数据
                    pm.execute(
                        "update share_data_day set valid=1 where trade_date='%s'"
                        % (dt))
            KManager.to_csv(dict, 'km')
示例#5
0
文件: FinManager.py 项目: zhoupj/flwm
    def pull_data():
        shp = SharePuller();
        df = shp.query_from_mysql();

        now = datetime.datetime.now()
        end = now.strftime('%Y-%m-%d');

        for index, row in df.iterrows():
            code = row['code'];
            start = str(row['timeToMarket']);
            #目前start和and 还未生效
            fy = FinYearPuller();
            fy.pull(code, start, end);
            fs = FinSeasonPuller();
            fs.pull(code, start, end);
            fdp = FundsPuller();
            fdp.pull(code, start, end)
示例#6
0
文件: FinManager.py 项目: zhoupj/flwm
    def count_kpi():
        shp = SharePuller();
        df = shp.query_from_mysql();
        for index, row in df.iterrows():
            code = row['code'];
            nma=NetProfitMA();
            nma.run(code,to_mysql=True,type=1);
        nms = NetProfitSort();
        nms8= NetProfitSort8();
        for dt in['2017-09-30','2017-12-31','2018-03-31','2018-06-30','2018-09-30']:
            nms.run(dt,to_mysql=True,type=1)
            nms8.run(dt,to_mysql=True,type=1)


if(__name__=='__main__'):
    shp = SharePuller();
    df = shp.query_from_mysql();
    for index, row in df.iterrows():
        code = row['code'];
    nms = NetProfitSort();
    nms8 = NetProfitSort8();
    for dt in [ '2018-09-30']:
        nms.run(dt, to_mysql=True, type=1)
        nms8.run(dt, to_mysql=True, type=1)