Ejemplo n.º 1
0
    def save(self):
        dfs, unit, instructi = self.recognize()
        if dfs.get('股票') is not None:
            df = dfs.get('股票')
            type = 'stock'
            stock = df.iloc[0, 0]
            date = df.iloc[0, 1]
            price = df.iloc[0, 2]
            num = df.iloc[0, 3]
            to_market_date = df.iloc[0, 4]
            number_permit_trade = df.iloc[0, 5]
            transact_termin_date = df.iloc[0, 6]

            value_dict = dict(
                stk_cd_id=self.stk_cd_id,
                acc_per=self.acc_per,
                type=type,
                stock=stock,
                date=date,
                price=price,
                num=num,
                to_market_date=to_market_date,
                number_permit_trade=number_permit_trade,
                transact_termin_date=transact_termin_date,
            )
            create_and_update('SecurIssuanc', **value_dict)
        else:
            pass
        save_instructi(instructi, models.ChangInShareAndSharehold,
                       self.stk_cd_id, self.acc_per, 'secur_issuanc')
Ejemplo n.º 2
0
 def save(self):
     df, unit, instructi = recognize_df_and_instucti(self.indexcontent)
     if df is not None and len(df) > 1:
         df = df.drop([0])
         major_assets = list(df.iloc[:, 0])
         change_reasons = list(df.iloc[:, len(df.columns) - 1])
         for major_asset, change_reason in zip(major_assets,
                                               change_reasons):
             value_dict = dict(stk_cd_id=self.stk_cd_id,
                               acc_per=self.acc_per,
                               major_asset=major_asset,
                               change_reason=change_reason)
             create_and_update('CompaniBusiOverview', **value_dict)
             # if models.CompaniBusiOverview.objects.filter(stk_cd_id=self.stk_cd_id, acc_per=self.acc_per):
             #     obj = models.CompaniBusiOverview.objects.get(stk_cd_id=self.stk_cd_id, acc_per=self.acc_per)
             #     obj.major_asset = major_asset
             #     obj.change_reason = change_reason
             #     obj.save()
             # else:
             #     models.CompaniBusiOverview.objects.create(
             #         stk_cd_id=self.stk_cd_id,
             #         acc_per=self.acc_per,
             #         major_asset=major_asset,
             #         change_reason=change_reason
             #        )
     else:
         pass
     save_instructi(instructi, models.CompaniBusiOverview, self.stk_cd_id,
                    self.acc_per, 'major_chang_in_major_asset')
Ejemplo n.º 3
0
 def save(self):
     df, unit, instructi = recognize_instucti(self.indexcontent)
     save_instructi(instructi, models.CompaniBusiOverview, self.stk_cd_id,
                    self.acc_per, 'major_busi_model_indu')
Ejemplo n.º 4
0
 def save(self):
     df, unit, instructi = recognize_instucti(self.indexcontent)
     save_instructi(instructi, models.CompaniBusiOverview, self.stk_cd_id,
                    self.acc_per, 'core_competit')
Ejemplo n.º 5
0
    def save(self):
        dfs, unit, instructi = self.recognize()
        if dfs.get('持股5%以上') is not None:
            df = dfs.get('持股5%以上')
            sharehold_name_pos = list(
                np.where(df.iloc[0, :].str.contains('股东名称'))[0])
            increas_and_decreas_pos = list(
                np.where(df.iloc[0, :].str.contains('报告期内增减'))[0])
            end_hold_num_pos = list(
                np.where(df.iloc[0, :].str.contains('期末持股数量'))[0])
            ratio_pos = list(np.where(df.iloc[0, :].str.contains('比例'))[0])
            restrict_share_pos = list(
                np.where(df.iloc[0, :].str.contains('持有有限售条件'))[0])
            natur_of_sharehold_pos = list(
                np.where(df.iloc[0, :].str.contains('股东性质'))[0])
            pledg_or_freez_pos = list(
                np.where(df.iloc[0, :].str.contains('质押或冻结情况'))[0])

            stragy_investor = list(
                np.where(df.iloc[:, 0].str.contains('战略投资者'))[0])
            sharehold_relat_pos = list(
                np.where(df.iloc[:, 0].str.contains('上述股东关联关系或一致行动的说明'))[0])
            sharehold_relat = df.iloc[sharehold_relat_pos[0], 2]

            df = df.iloc[2:stragy_investor[0], :] if len(
                stragy_investor) > 0 else df.drop([0, 1, len(df) - 1])

            sharehold_names = list(df.iloc[:, sharehold_name_pos[0]])
            increas_and_decreases = list(df.iloc[:,
                                                 increas_and_decreas_pos[0]])
            end_hold_nums = list(df.iloc[:, end_hold_num_pos[0]])
            ratios = list(df.iloc[:, ratio_pos[0]])
            restrict_shares = list(df.iloc[:, restrict_share_pos[0]])
            pledg_or_freez_statuses = list(df.iloc[:, pledg_or_freez_pos[0]])
            pledg_or_freez_nums = list(df.iloc[:, pledg_or_freez_pos[1]])
            natur_of_shareholds = list(df.iloc[:, (natur_of_sharehold_pos[0])])

            for (sharehold_name, increas_and_decreas, end_hold_num, ratio, \
                 restrict_share, pledg_or_freez_status, pledg_or_freez_num, natur_of_sharehold) \
                    in zip(sharehold_names, increas_and_decreases, end_hold_nums, ratios, \
                           restrict_shares, pledg_or_freez_statuses, pledg_or_freez_nums, natur_of_shareholds):
                value_dict = dict(
                    stk_cd_id=self.stk_cd_id,
                    acc_per=self.acc_per,
                    sharehold_name=sharehold_name,
                    increas_and_decreas=num_to_decimal(increas_and_decreas),
                    end_hold_num=num_to_decimal(end_hold_num),
                    ratio=num_to_decimal(ratio),
                    restrict_share=num_to_decimal(restrict_share),
                    pledg_or_freez_status=pledg_or_freez_status,
                    pledg_or_freez_num=num_to_decimal(pledg_or_freez_num),
                    natur_of_sharehold=natur_of_sharehold,
                )
                create_and_update('TopTenSharehold', **value_dict)

            save_instructi(sharehold_relat, models.ChangInShareAndSharehold,
                           self.stk_cd_id, self.acc_per, 'sharehold_relat')
        else:
            pass

        if dfs.get('无限售条件') is not None:
            df = dfs.get('无限售条件')
            sharehold_name_pos = list(
                np.where(df.iloc[0, :].str.contains('股东名称'))[0])
            hold_num_pos = list(
                np.where(df.iloc[0, :].str.contains('持有无限售条件'))[0])
            type_pos = list(np.where(df.iloc[0, :].str.contains('股份种类'))[0])

            unlimit_sharehold_relat_pos = list(
                np.where(df.iloc[:, 0].str.contains('前10名无限售流通股股东之间'))[0])
            unlimit_sharehold_relat = df.iloc[unlimit_sharehold_relat_pos[0],
                                              1]

            pattern = re.compile('^[\d,\.]*?$')
            start_pos = list(
                np.where(df.iloc[:, hold_num_pos[0]].str.match(pattern)
                         | df.iloc[:, hold_num_pos[0]].str.match('nan'))[0])

            sharehold_names = list(df.iloc[start_pos[0]:start_pos[-1],
                                           sharehold_name_pos[0]])
            hold_nums = list(df.iloc[start_pos[0]:start_pos[-1],
                                     hold_num_pos[0]])
            types = list(df.iloc[start_pos[0]:start_pos[-1], type_pos[0]])
            type_nums = list(df.iloc[start_pos[0]:start_pos[-1], type_pos[1]])

            for (sharehold_name, hold_num, type, type_num) \
                    in zip(sharehold_names, hold_nums, types, type_nums):
                value_dict = dict(
                    stk_cd_id=self.stk_cd_id,
                    acc_per=self.acc_per,
                    sharehold_name=sharehold_name,
                    hold_num=hold_num if hold_num != 'nan' else 0,
                    type=type,
                    type_num=type_num if type_num != 'nan' else 0,
                )
                create_and_update('TopTenUnlimitSharehold', **value_dict)
            save_instructi(unlimit_sharehold_relat,
                           models.ChangInShareAndSharehold, self.stk_cd_id,
                           self.acc_per, 'unlimit_sharehold_relat')
        else:
            pass

        if dfs.get('first') is not None:
            df = dfs.get('first')
            print(df)
            report_end_sharehold_num_pos = list(
                np.where(df.iloc[0, :].str.contains('报告期末普通股股东总数'))[0])
            disclos_last_month_sharehold_num_pos = list(
                np.where(df.iloc[0, :].str.contains('报告披露日前上一月末普通股股东总数'))[0])

            report_end_sharehold_num = df.iloc[
                0, report_end_sharehold_num_pos[0] + 1]
            disclos_last_month_sharehold_num = df.iloc[
                0, disclos_last_month_sharehold_num_pos[0] + 1]
            value_dict = dict(
                stk_cd_id=self.stk_cd_id,
                acc_per=self.acc_per,
                report_end_sharehold_num=report_end_sharehold_num,
                disclos_last_month_sharehold_num=
                disclos_last_month_sharehold_num,
            )
            create_and_update('ChangInShareAndSharehold', **value_dict)
        else:
            pass
Ejemplo n.º 6
0
    def save(self):
        dfs, unit, instructi = self.recognize()
        # print(dfs)
        if dfs.get('topten') is not None:
            df = dfs.get('topten')
            sharehold_name_pos = list(
                np.where(df.iloc[0, :].str.contains('股东名称'))[0])
            increas_and_decreas_pos = list(
                np.where(df.iloc[0, :].str.contains('报告期内增减'))[0])
            end_hold_num_pos = list(
                np.where(df.iloc[0, :].str.contains('期末持股数量'))[0])
            ratio_pos = list(np.where(df.iloc[0, :].str.contains('比例'))[0])
            restrict_share_pos = list(
                np.where(df.iloc[0, :].str.contains('持有有限售条件股份数量'))[0])
            natur_of_sharehold_pos = list(
                np.where(df.iloc[0, :].str.contains('股东性质'))[0])

            df = df.drop([0, 1])

            sharehold_names = list(df.iloc[:, sharehold_name_pos[0]])
            increas_and_decreases = list(df.iloc[:,
                                                 increas_and_decreas_pos[0]])
            end_hold_nums = list(df.iloc[:, end_hold_num_pos[0]])
            ratios = list(df.iloc[:, ratio_pos[0]])
            restrict_shares = list(df.iloc[:, restrict_share_pos[0]])
            pledg_or_freez_statuses = list(df.iloc[:, (restrict_share_pos[0] +
                                                       1)])
            pledg_or_freez_nums = list(df.iloc[:, (restrict_share_pos[0] + 2)])
            natur_of_shareholds = list(df.iloc[:, (natur_of_sharehold_pos[0])])

            for (sharehold_name, increas_and_decreas, end_hold_num, ratio, \
                           restrict_share,pledg_or_freez_status,pledg_or_freez_num,natur_of_sharehold) \
                    in zip(sharehold_names, increas_and_decreases, end_hold_nums, ratios, \
                           restrict_shares,pledg_or_freez_statuses,pledg_or_freez_nums,natur_of_shareholds ):
                value_dict = dict(
                    stk_cd_id=self.stk_cd_id,
                    acc_per=self.acc_per,
                    sharehold_name=sharehold_name,
                    increas_and_decreas=increas_and_decreas
                    if increas_and_decreas != 'nan' else 0,
                    end_hold_num=end_hold_num if end_hold_num != 'nan' else 0,
                    ratio=num_to_decimal(ratio),
                    restrict_share=restrict_share
                    if restrict_share != 'nan' else 0,
                    pledg_or_freez_status=pledg_or_freez_status,
                    pledg_or_freez_num=pledg_or_freez_num
                    if pledg_or_freez_num != 'nan' else 0,
                    natur_of_sharehold=natur_of_sharehold,
                )
                create_and_update('TopTenSharehold', **value_dict)
        else:
            pass

        if dfs.get('unlimit_sale') is not None:
            df = dfs.get('unlimit_sale')
            sharehold_name_pos = list(
                np.where(df.iloc[0, :].str.contains('股东名称'))[0])
            hold_num_pos = list(
                np.where(df.iloc[0, :].str.contains('持有无限售条件流通股的数量'))[0])

            sharehold_relat_pos = list(
                np.where(df.iloc[:, 0].str.contains('上述股东关联关系或一致行动的说明'))[0])
            sharehold_relat = df.iloc[sharehold_relat_pos[0], 1]

            df = df.drop([0, 1, len(df) - 1])

            sharehold_names = list(df.iloc[:, sharehold_name_pos[0]])
            hold_nums = list(df.iloc[:, hold_num_pos[0]])
            types = list(df.iloc[:, (hold_num_pos[0] + 1)])
            type_nums = list(df.iloc[:, (hold_num_pos[0] + 2)])


            for (sharehold_name,hold_num,type,type_num) \
                    in zip(sharehold_names,hold_nums,types,type_nums):
                value_dict = dict(
                    stk_cd_id=self.stk_cd_id,
                    acc_per=self.acc_per,
                    sharehold_name=sharehold_name,
                    hold_num=hold_num if hold_num != 'nan' else 0,
                    type=type,
                    type_num=type_num if type_num != 'nan' else 0,
                )
                create_and_update('TopTenUnlimitSharehold', **value_dict)

            save_instructi(sharehold_relat, models.ChangInShareAndSharehold,
                           self.stk_cd_id, self.acc_per, 'sharehold_relat')

        else:
            pass
Ejemplo n.º 7
0
    def save(self):
        df, unit, instructi = recognize_df_and_instucti(self.indexcontent)
        if df is not None and len(df) > 0:
            quantiti_befor_chang_pos = list(
                np.where((df.iloc[0, :].str.contains('本次变动前'))
                         & (df.iloc[1, :].str.contains('数量')))[0])
            issu_new_share_pos = list(
                np.where(df.iloc[1, :].str.contains('发行新股'))[0])
            give_share_pos = list(
                np.where(df.iloc[1, :].str.contains('送股'))[0])
            turnov_from_cpf_pos = list(
                np.where(df.iloc[1, :].str.contains('公积金转股'))[0])
            other_pos = list(np.where(df.iloc[1, :].str.contains('其他'))[0])
            subtot_chang_pos = list(
                np.where(df.iloc[1, :].str.contains('小计'))[0])
            quantiti_after_chang_pos = list(
                np.where((df.iloc[0, :].str.contains('本次变动后'))
                         & (df.iloc[1, :].str.contains('数量')))[0])

            choice_dict = {
                '一、有限售条件股份': 'restrict_sale',
                '1、国家持股': 'state_hold',
                '2、国有法人持股': 'state_own_legal_pers',
                '3、其他内资持股': 'other_domest_capit',
                '其中:境内非国有法人持股': 'domest_non_state_own',
                '境内自然人持股': 'domest_natur_person',
                '4、外资持股': 'foreign_hold',
                '其中:境外法人持股': 'oversea_legal_person',
                '境外自然人持股': 'oversea_natur_person',
                '二、无限售条件流通股份': 'unlimit_sale',
                '1、人民币普通股': 'rmb_ordinari_share',
                '2、境内上市的外资股': 'domest_list_foreign',
                '3、境外上市的外资股': 'overseas_list_foreig',
                '4、其他': 'others',
                '三、普通股股份总数': 'total_number',
            }
            df = df.drop([0, 1])
            projects = []
            for item in df.iloc[:, 0]:
                for key in choice_dict.keys():
                    if similar(str(item), str(key)):
                        projects.append(choice_dict[key])

            quantiti_befor_changs = list(df.iloc[:,
                                                 quantiti_befor_chang_pos[0]])
            issu_new_shares = list(df.iloc[:, issu_new_share_pos[0]])
            give_shares = list(df.iloc[:, give_share_pos[0]])
            turnov_from_cpfs = list(df.iloc[:, turnov_from_cpf_pos[0]])
            others = list(df.iloc[:, other_pos[0]])
            subtot_changs = list(df.iloc[:, subtot_chang_pos[0]])
            quantiti_after_changs = list(df.iloc[:,
                                                 quantiti_after_chang_pos[0]])

            for (project,quantiti_befor_chang,issu_new_share,give_share,turnov_from_cpf,
                           other,subtot_chang ,quantiti_after_chang) \
                    in zip(projects,quantiti_befor_changs,issu_new_shares,give_shares,turnov_from_cpfs,
                           others,subtot_changs ,quantiti_after_changs):
                value_dict = dict(
                    stk_cd_id=self.stk_cd_id,
                    acc_per=self.acc_per,
                    name=project,
                    quantiti_befor_chang=quantiti_befor_chang
                    if quantiti_befor_chang != 'nan' else 0,
                    issu_new_share=issu_new_share
                    if issu_new_share != 'nan' else 0,
                    give_share=give_share if give_share != 'nan' else 0,
                    turnov_from_cpf=turnov_from_cpf
                    if turnov_from_cpf != 'nan' else 0,
                    other=other if other != 'nan' else 0,
                    subtot_chang=subtot_chang if subtot_chang != 'nan' else 0,
                    quantiti_after_chang=quantiti_after_chang
                    if quantiti_after_chang != 'nan' else 0,
                )
                create_and_update('ChangInOrdinariShare', **value_dict)
        else:
            pass
        save_instructi(instructi, models.ChangInShareAndSharehold,
                       self.stk_cd_id, self.acc_per, 'change_desc')
Ejemplo n.º 8
0
 def save(self):
     df, unit, instructi = recognize_instucti(self.indexcontent)
     save_instructi(instructi, models.ChangInShareAndSharehold,
                    self.stk_cd_id, self.acc_per, 'share_change_desc')
Ejemplo n.º 9
0
 def save(self):
     df, unit, instructi = recognize_instucti(self.indexcontent)
     save_instructi(instructi, models.BondDesc, self.stk_cd_id,
                    self.acc_per, 'bank_credit_condit')
Ejemplo n.º 10
0
 def save(self):
     df, unit, instructi = recognize_instucti(self.indexcontent)
     save_instructi(instructi, models.BondDesc, self.stk_cd_id,
                    self.acc_per, 'corpor_bond_rate')
Ejemplo n.º 11
0
 def save(self):
     df, unit, instructi = recognize_df_and_instucti(self.indexcontent)
     save_instructi(instructi, models.BondDesc, self.stk_cd_id,
                    self.acc_per, 'use_of_rais_fund')