Ejemplo n.º 1
0
    def get_full_financial_statements(
        self,
        corporation_code: str,
        business_year: int,
        report_type: ReportType,
        financial_statement_division: Union[
            FinancialStatementDivision,
            str] = FinancialStatementDivision.FINANCIAL_STATEMENT,
        *,
        rename: Optional[RenameMode] = RenameMode.ENG,
    ) -> pd.DataFrame:
        fs_div = (financial_statement_division.value if isinstance(
            financial_statement_division, FinancialStatementDivision) else
                  financial_statement_division)
        params = {
            "corp_code": corporation_code,
            "bsns_year": str(business_year),
            "reprt_code": report_type.value,
            "fs_div": fs_div,
        }

        df = pd.DataFrame(i for i in self.client.iter_list_resource(
            "fnlttSinglAcntAll", params))
        df = convert_known_numeric_fields(df)
        df = convert_known_ratio_fields(df)
        df = convert_known_date_fields(df)
        df = rename_fields(df, mapping=RENAME_MAPPINGS.get(rename))

        return df
Ejemplo n.º 2
0
    def get_financial_statements_of_major_accounts(
        self,
        corporation_codes: Sequence[str],
        business_year: int,
        report_type: ReportType,
        *,
        rename: Optional[RenameMode] = RenameMode.ENG,
    ) -> pd.DataFrame:
        if len(corporation_codes) > 1:
            params = {
                "corp_code": ','.join(corporation_codes),
                "bsns_year": str(business_year),
                "reprt_code": report_type.value,
            }
            df = pd.DataFrame(i for i in self.client.iter_list_resource(
                "fnlttMultiAcnt", params))
        else:
            params = {
                "corp_code": corporation_codes[0],
                "bsns_year": str(business_year),
                "reprt_code": report_type.value,
            }
            df = pd.DataFrame(i for i in self.client.iter_list_resource(
                "fnlttSinglAcnt", params))

        df = convert_known_numeric_fields(df)
        df = convert_known_ratio_fields(df)
        df = convert_known_date_fields(df)
        df = rename_fields(df, mapping=RENAME_MAPPINGS.get(rename))

        return df
Ejemplo n.º 3
0
    def search(
        self,
        corporation_code: Optional[str] = None,
        date_begin: Optional[date] = None,
        date_end: Optional[date] = None,
        only_last_report: Optional[bool] = None,
        type: Optional[Union[DisclosureType, str]] = None,
        type_detail: Optional[Union[DisclosureTypeDetail, str]] = None,
        market: Optional[Market] = None,
        sort_by: Optional[SortBy] = None,
        ascending: bool = False,
        page: int = 1,
        limit: int = 20,
        *,
        rename: Optional[RenameMode] = RenameMode.ENG,
    ) -> Tuple[pd.DataFrame, dict]:
        params = {
            "corp_code": corporation_code if corporation_code else None,
            "bgn_de": date_begin.strftime("%Y%m%d") if date_begin else None,
            "end_de": date_end.strftime("%Y%m%d") if date_end else None,
            "last_reprt_at": {
                True: "Y",
                False: "N"
            }.get(only_last_report),
            "pblntf_ty": str(type) if type else None,
            "pblntf_detail_ty": str(type_detail) if type_detail else None,
            "corp_cls": market.value if market else None,
            "sort_by": sort_by.value if sort_by else None,
            "ascending":
            ("asc" if ascending else "desc") if ascending else None,
            "page_no": str(page),
            "page_count": str(limit),
        }
        params = {k: v for k, v in params.items() if v is not None}
        search_res = self.client.xml_resource("list", params)

        pagination = {
            "page": dart_atoi(search_res.find("page_no").text),
            "total_page": dart_atoi(search_res.find("total_page").text),
            "page_count": dart_atoi(search_res.find("page_count").text),
            "total_count": dart_atoi(search_res.find("total_count").text),
        }

        df = pd.DataFrame({element.tag: element.text
                           for element in item}
                          for item in search_res.iter("list"))
        df = convert_known_numeric_fields(df)
        df = convert_known_ratio_fields(df)
        df = convert_known_date_fields(df)
        df = rename_fields(df, mapping=RENAME_MAPPINGS.get(rename))

        return df, pagination
Ejemplo n.º 4
0
    def get_company_overview(
            self,
            corporation_code: str,
            *,
            rename: Optional[RenameMode] = RenameMode.ENG) -> pd.DataFrame:
        res = self.client.json_resource("company",
                                        {'corp_code': corporation_code})

        df = pd.DataFrame([res])
        df = convert_known_numeric_fields(df)
        df = convert_known_ratio_fields(df)
        df = convert_known_date_fields(df)
        df = rename_fields(df, mapping=RENAME_MAPPINGS.get(rename))

        return df
    def get_executive_shareholder_reports(
            self,
            corporation_code: str,
            *,
            rename: Optional[RenameMode] = RenameMode.ENG) -> pd.DataFrame:
        params = {"corp_code": corporation_code}

        df = pd.DataFrame(
            i for i in self.client.iter_list_resource("elestock", params))
        df = convert_known_numeric_fields(df)
        df = convert_known_ratio_fields(df)
        df = convert_known_date_fields(df)
        df = rename_fields(df, mapping=RENAME_MAPPINGS.get(rename))

        return df
Ejemplo n.º 6
0
    def get_xbrl_taxonomies(
        self,
        detailed_financial_statement_type: Union[FinancialStatementTypeDetail,
                                                 str],
        *,
        rename: Optional[RenameMode] = RenameMode.ENG,
    ) -> pd.DataFrame:
        params = {"sj_div": str(detailed_financial_statement_type)}

        df = pd.DataFrame(
            i for i in self.client.iter_list_resource("xbrlTaxonomy", params))
        df = convert_known_numeric_fields(df)
        df = convert_known_ratio_fields(df)
        df = convert_known_date_fields(df)
        df = rename_fields(df, mapping=RENAME_MAPPINGS.get(rename))

        return df
Ejemplo n.º 7
0
    def _dispatch_business_report(
        self,
        resource_name: str,
        corporation_code: str,
        business_year: int,
        report_type: ReportType,
        *,
        rename: Optional[RenameMode] = RenameMode.ENG,
    ) -> pd.DataFrame:
        params = {
            "corp_code": corporation_code,
            "bsns_year": str(business_year),
            "reprt_code": report_type.value
        }

        df = pd.DataFrame(
            i for i in self.client.iter_list_resource(resource_name, params))
        df = convert_known_numeric_fields(df)
        df = convert_known_ratio_fields(df)
        df = convert_known_date_fields(df)
        df = rename_fields(df, mapping=RENAME_MAPPINGS.get(rename))

        return df