Skip to content

Commit

Permalink
syb idx
Browse files Browse the repository at this point in the history
  • Loading branch information
ShichenXie committed Mar 3, 2024
1 parent 6171f0a commit 2a9708a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 25 deletions.
3 changes: 2 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# pedquant 0.2.4.999

* the md_stock_symbol supports to query the constituent stock symbols of index
* fixed a bug in pq_plot function to support candle chart
* the md_stock_symbol supports to query the constituent symbols of Chinese securities index

# pedquant 0.2.4

Expand Down
28 changes: 4 additions & 24 deletions R/md_stock_symbol.R
Original file line number Diff line number Diff line change
Expand Up @@ -150,21 +150,21 @@ md_stock_symbol_exchange = function(XCHG=NULL, print_step=1L) {
#' ex_syb2 = md_stock_symbol()
#'
#' # constituent stock symbol of index
#' dtidx = md_stock_symbol(index = c('000016', '000300', '000905', '930050'))
#' dtidx = md_stock_symbol(index = c('930050', '000300', '000905', '000852'))
#' }
#'
#' @export
md_stock_symbol = function(exchange=NULL, ...) {
index = list(...)[['index']]

if (!is.null(exchange)) {
if (is.null(index)) {
datlst = md_stock_symbol_exchange(exchange)
datlst = lapply(datlst, function(x) {
cols = c('symbol', 'name', 'date', 'open', 'high', 'low', 'close', 'volume', 'amount', 'turnover', 'market', 'mktcode', 'pe_forward', 'pe_ttm', 'pe_lyr', 'pb', 'cap_total', 'cap_market')

x[, intersect(cols, names(x)), with = FALSE]
} )
} else if (!is.null(index)) {
} else {
datlst = md_stock_symbol_index(index)
}

Expand All @@ -177,27 +177,7 @@ md_stock_symbol = function(exchange=NULL, ...) {

# stock symbol constituent of index
# China securities index, csindex

# query constituent of securities index
#
# \code{md_stock_symbol_index} provides an interface to query the current constituent of securities index.
#
# @param symbol the symbol of securities index. It supports Chinese securities index only at this moment.
#
# @source \url{http://www.csindex.com.cn/zh-CN}
#
# @examples
# \donttest{
# dt50 = md_stock_symbol_index("000016")
#
# dt300 = md_stock_symbol_index("000300")
#
# dt500 = md_stock_symbol_index("000905")
# }
#
# @import data.table
# @export
#
# https://www.csindex.com.cn/#/indices/family
stk_syb_idx1 = function(syb) {
exchange = stock_symbol = NULL

Expand Down

0 comments on commit 2a9708a

Please sign in to comment.