Description Usage Arguments Details Value Author(s) References Examples
nepse_index
downloads the index/subindex values from Nepal Stock Exchange.
1 | nepse_index(index = NULL)
|
index |
a character string specifying the index id of the index to be loaded |
The nepse_index
downloads the nepse index/sub-index for the given index
id from Nepal Stock Exchange .The nepse_index
will first check
whether the entered index id is valid. The valid index id ranges from 51 to 63
and index names corresponding to these ids are Banking, Hotels, Others,
HydroPower, Development_Bank, Manufacturing, Sensitive, NEPSE, Insurance,
Finance, Trading, Float, and Sensitive_Float, respectively. The
nepse_index
will return an error if the index id is not valid. The data
for valid index id starts from "2015-01-08" to the most recent transaction date.
nepse_index
will return the object of class dataframe with 3 variables:
index_date
,
index_name
, and
index_value
Nayan Krishna Joshi
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | ## Not run:
# index value for an invalid index id; issues an error with message
# nepse_index('70')
# index value for a valid index id; returns a dataframe
nepse_index("58")
# draw an interactive time series chart of an index value for a valid index id
require(xts)
require(dygraphs)
data_index1 <- nepse_index(58)
data_index1 <- xts(data_index1[, -1], order.by = data_index1[, 1])
nepse_index_graph <- dygraph(data_index1[, "index_value"],
main = "Time series graph of Nepse index")
dyRangeSelector(nepse_index_graph, height = 20, strokeColor = "darkred")
# compute daily, weekly, monthly, quartely, and yearly returns of index values
require(xts)
require(quantmod)
data_index2 <- nepse_index(58)
data_index2 <- data_index2[, c("index_date", "index_value")]
data_index2 <- xts(data_index2[, -1], order.by = data_index2[, 1])
# arithmetic returns
nepse_index_re_arithm <- allReturns(data_index2)
# logarithmic returns
nepse_index_re_log <- allReturns(data_index2, type = "log")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.