Skip to content

Commit

Permalink
feat: add lxr_cn_company_fundamental_non_financial()
Browse files Browse the repository at this point in the history
  • Loading branch information
tanchangde committed Jan 19, 2024
1 parent 9534500 commit a298220
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 1 deletion.
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions R/cn-company.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
}
9 changes: 8 additions & 1 deletion R/query-params.R
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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
)
}
5 changes: 5 additions & 0 deletions man/lxr_cn_company.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions tests/testthat/test-cn-company.R
Original file line number Diff line number Diff line change
Expand Up @@ -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")
})

0 comments on commit a298220

Please sign in to comment.