From 9014ba976bf4fd2d2e51e84519b56f19adcfa9e1 Mon Sep 17 00:00:00 2001 From: tanchangde Date: Sun, 4 Feb 2024 18:07:05 +0800 Subject: [PATCH] feat(hk-company): get the short-selling data --- NAMESPACE | 1 + R/hk-company.R | 7 +++++++ R/query-params.R | 3 ++- man/lxr_hk_company.Rd | 4 ++++ tests/testthat/test-hk-company.R | 9 +++++++++ 5 files changed, 23 insertions(+), 1 deletion(-) diff --git a/NAMESPACE b/NAMESPACE index 5f4776f..7ea2c49 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -65,6 +65,7 @@ export(lxr_hk_company_fundamental_reit) export(lxr_hk_company_fundamental_security) export(lxr_hk_company_fundamental_statistics) export(lxr_hk_company_hot_mm_ah) +export(lxr_hk_company_hot_ss) export(lxr_hk_company_hot_tr_dri) export(lxr_hk_company_indices) export(lxr_hk_company_industries) diff --git a/R/hk-company.R b/R/hk-company.R index 9bd9e84..0289eca 100644 --- a/R/hk-company.R +++ b/R/hk-company.R @@ -49,6 +49,7 @@ #' financial data. #' * `lxr_hk_company_hot_tr_dri()` obtain dividend reinvestment yield data. #' * `lxr_hk_company_hot_mm_ah()` obtain interconnectivity data. +#' * `lxr_hk_company_hot_ss()` get the short-selling data. #' #' @return A string of the API endpoint. @@ -225,3 +226,9 @@ lxr_hk_company_hot_tr_dri <- function() { lxr_hk_company_hot_mm_ah <- function() { "https://open.lixinger.com/api/hk/company/hot/mm_ah" } + +#' @rdname lxr_hk_company +#' @export +lxr_hk_company_hot_ss <- function() { + "https://open.lixinger.com/api/hk/company/hot/ss" +} diff --git a/R/query-params.R b/R/query-params.R index 88fef43..19558a5 100644 --- a/R/query-params.R +++ b/R/query-params.R @@ -154,6 +154,7 @@ lxr_query_params <- function(endpoint) { hk_company_fs_reit = fs_params, hk_company_fs_other_financial = fs_params, hk_company_hot_tr_dri = min_params, - hk_company_hot_mm_ah = min_params + hk_company_hot_mm_ah = min_params, + hk_company_hot_ss = min_params ) } diff --git a/man/lxr_hk_company.Rd b/man/lxr_hk_company.Rd index 9a0364c..c186aff 100644 --- a/man/lxr_hk_company.Rd +++ b/man/lxr_hk_company.Rd @@ -30,6 +30,7 @@ \alias{lxr_hk_company_fs_other_financial} \alias{lxr_hk_company_hot_tr_dri} \alias{lxr_hk_company_hot_mm_ah} +\alias{lxr_hk_company_hot_ss} \title{Hong Kong company API endpoints} \usage{ lxr_hk_company() @@ -89,6 +90,8 @@ lxr_hk_company_fs_other_financial() lxr_hk_company_hot_tr_dri() lxr_hk_company_hot_mm_ah() + +lxr_hk_company_hot_ss() } \value{ A string of the API endpoint. @@ -142,5 +145,6 @@ financial data. financial data. \item \code{lxr_hk_company_hot_tr_dri()} obtain dividend reinvestment yield data. \item \code{lxr_hk_company_hot_mm_ah()} obtain interconnectivity data. +\item \code{lxr_hk_company_hot_ss()} get the short-selling data. } } diff --git a/tests/testthat/test-hk-company.R b/tests/testthat/test-hk-company.R index c34edfc..773263f 100644 --- a/tests/testthat/test-hk-company.R +++ b/tests/testthat/test-hk-company.R @@ -299,3 +299,12 @@ test_that("test hk_company_hot_mm_ah", { expect_s3_class(result, "tbl_df") expect_true(nrow(result) > 0) }) + +test_that("test hk_company_hot_ss", { + result <- lxr_query( + endpoint = lxr_hk_company_hot_ss(), + stock_codes = "00700" + ) + expect_s3_class(result, "tbl_df") + expect_true(nrow(result) > 0) +})