GetValue: Get the zsl Value in Several Ways

Description Usage Arguments Details Value

Description

Get the zsl value from the database in several ways, including get the sigle code's single day's value, get single code's series, and so on.

Usage

1
2
3
4
5
zslGetSingle(code, date, ch)

zslGetSeries(code, start, end, ch, xts = TRUE, zero.fill = FALSE)

zslGetBundle(codes, start, end, ch)

Arguments

code

character, the bond code in Wind sytle, which is six digits with ".SH" or ".SZ" to indicate the exchange

date

Date, the effect date of the ratio to be obtained

ch

the RODBC connection object

start

the start of the period, Date object of like "YYYY-MM-DD"

end

the end of the period, Date object of like "YYYY-MM-DD"

xts

logical, default is TRUE, return the final series as xts object

zero.fill

logical, default is FALSE, if TRUE the returned series will be filled by zero to replace those NA value while the length of the series is equal to the period

Details

The functions use the code to identify the bond, not the name. And the code must be in Wind style, or with regex '[0-9]{6}\.S[HZ]'.

For zslGetSingle, it uses params code and date to get single value of the "code" and "date". The date should be exchange's trading date, of course the function can also automatically find the closest trading day before it if it is not. If there is no value returned, message will be given, "code" and "date" should be re-checked carefully. Obviously, the result is a single numeric value.

For zslGetSeries, it gets the series values. Surely, the params including "start" and "end", but it can be given or missed. If both are given, the values of specific period are returned; if only "start" or "end" is given and the other is missed, the values after "start" or before "end" are returned; if both are missed, all values of the bond are returned. For the convenience, the result is an xts object as default.

If the exact period series is required, which means that the series dates must contain all exchange trading days between "start" and "end", set param zero.fill to TRUE. If there exists NA value, it will be replaced by "0". This is useful when being used in for loop or *ply functions, as the retured series all have the same length.

For zslGetBundle, it returns the "bundled" series of more than one bond. The params start and end must be given, and the returned the times series is an xts object of this period.

Value

The returned value(s) are different according to the use of functions, see the "details."


baixueyuan/zsl documentation built on May 11, 2019, 5:27 p.m.