From a298220121c8b11741b2835ae027def76c77acb7 Mon Sep 17 00:00:00 2001 From: Tan Changde Date: Fri, 19 Jan 2024 08:11:22 +0800 Subject: [PATCH] feat: add lxr_cn_company_fundamental_non_financial() --- NAMESPACE | 1 + R/cn-company.R | 7 +++++++ R/query-params.R | 9 ++++++++- man/lxr_cn_company.Rd | 5 +++++ tests/testthat/test-cn-company.R | 10 ++++++++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index 1a77be6..29c5217 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -16,6 +16,7 @@ export(lxr_cn_company_fs_other_financial) export(lxr_cn_company_fs_security) export(lxr_cn_company_fund_collection_shareholders) export(lxr_cn_company_fund_shareholders) +export(lxr_cn_company_fundamental_non_financial) export(lxr_cn_company_fundamental_statistics) export(lxr_cn_company_indices) export(lxr_cn_company_industries) diff --git a/R/cn-company.R b/R/cn-company.R index 4b9ade6..c0aa0cc 100644 --- a/R/cn-company.R +++ b/R/cn-company.R @@ -42,6 +42,8 @@ #' * `lxr_cn_company_allotment()` gets allotment information. #' * `lxr_cn_company_customers()` gets customer information. #' * `lxr_cn_company_suppliers()` gets supplier information. +#' * `lxr_cn_company_fundamental_non_financial()` gets fundamental data for +#' non-financial companies, such as PE, PB, etc. #' #' @return A string of the API endpoint. #' @rdname lxr_cn_company @@ -218,3 +220,8 @@ lxr_cn_company_suppliers <- function() { "https://open.lixinger.com/api/cn/company/suppliers" } +#' @rdname lxr_cn_company +#' @export +lxr_cn_company_fundamental_non_financial <- function() { + "https://open.lixinger.com/api/cn/company/fundamental/non_financial" +} diff --git a/R/query-params.R b/R/query-params.R index 40dbef7..4e2ee3c 100644 --- a/R/query-params.R +++ b/R/query-params.R @@ -29,6 +29,12 @@ lxr_query_params <- function(endpoint) { ), required_params = c("stockCodes", "metricsList") ) + fundamental_params <- list( + valid_params = c( + "date", "startDate", "endDate", "adjustForwardDate", + "adjustBackwardDate", "limit", "stockCodes", "metricsList"), + required_params = c("stockCodes", "metricsList") + ) switch(endpoint_name, cn_company = list( @@ -82,6 +88,7 @@ lxr_query_params <- function(endpoint) { cn_company_fund_collection_shareholders = common_params, cn_company_allotment = common_params, cn_company_customers = common_params, - cn_company_suppliers = common_params + cn_company_suppliers = common_params, + cn_company_fundamental_non_financial = fundamental_params ) } diff --git a/man/lxr_cn_company.Rd b/man/lxr_cn_company.Rd index 67b0e89..d79980c 100644 --- a/man/lxr_cn_company.Rd +++ b/man/lxr_cn_company.Rd @@ -30,6 +30,7 @@ \alias{lxr_cn_company_fund_collection_shareholders} \alias{lxr_cn_company_customers} \alias{lxr_cn_company_suppliers} +\alias{lxr_cn_company_fundamental_non_financial} \title{China Mainland company API endpoints} \usage{ lxr_cn_company() @@ -89,6 +90,8 @@ lxr_cn_company_fund_collection_shareholders() lxr_cn_company_customers() lxr_cn_company_suppliers() + +lxr_cn_company_fundamental_non_financial() } \value{ A string of the API endpoint. @@ -135,5 +138,7 @@ shareholding information. \item \code{lxr_cn_company_allotment()} gets allotment information. \item \code{lxr_cn_company_customers()} gets customer information. \item \code{lxr_cn_company_suppliers()} gets supplier information. +\item \code{lxr_cn_company_fundamental_non_financial()} gets fundamental data for +non-financial companies, such as PE, PB, etc. } } diff --git a/tests/testthat/test-cn-company.R b/tests/testthat/test-cn-company.R index 1545e20..fedd5f2 100644 --- a/tests/testthat/test-cn-company.R +++ b/tests/testthat/test-cn-company.R @@ -211,3 +211,13 @@ test_that("test cn_company_suppliers", { ) expect_s3_class(result, "tbl_df") }) + +test_that("test cn_company_fundamental_non_financial", { + result <- lxr_query( + endpoint = lxr_cn_company_fundamental_non_financial(), + date = "2024-01-18", + stock_codes = c("300750", "600519", "600157"), + metrics_list = c("pe_ttm", "mc") + ) + expect_s3_class(result, "tbl_df") +})