Learn R Programming

FinancialInstrument (version 1.3.1)

sort_ids: sort primary_ids of instruments

Description

Primarily intended for use on the primary_ids of future_series instruments. This will sort ids by expiration. All ids that do not contain month and year information will be sorted alphabetically (separately) and appended to the end of the other sorted ids.

Usage

sort_ids(ids, ...)

Arguments

ids

character vector of ids

...

arguments to pass through to parse_id

Value

sorted character vector of the same length as ids

Details

If an instrument is defined, and has a date in its ‘expires’ field, that date will be used as the expiration date. Otherwise, it is assumed that the contract expires on the first day of its expiration month. This means that if some products are defined and other products that expire in the same month are not defined, the ones that are not defined will come first in the vector of sorted ids.

See Also

parse_id

Examples

Run this code
# NOT RUN {
ids <- c("ES_U11",'GLD','SPY',"YM_Jun11",'DIA','VX_V10')
sort_ids(ids)
# }

Run the code above in your browser using DataLab