Last data update: 2014.03.03

R: Construct a primary_id for a 'spread' 'instrument' from the...
make_spread_idR Documentation

Construct a primary_id for a spread instrument from the primary_ids of its members

Description

Construct a primary_id for a spread instrument from the primary_ids of its members

Usage

make_spread_id(x, root = NULL, format = NULL, sep = "_")

Arguments

x

character vector of member primary_ids

root

Optional character string of root_id to use.

format

String indicating how to format the suffix_ids of the spread. If NULL (the default), or FALSE, no formatting will be done. See format_id for other accepted values for format

sep

character string to separate root_id and suffix_id

Value

character string that can be used as a primary_id for a spread instrument

Author(s)

Garrett See

See Also

spread, build_spread_symbols, build_series_symbols

Examples

ids <- c('VX_aug1','VX_U11')
make_spread_id(ids, format='CY')
make_spread_id(ids, format=FALSE)
make_spread_id(c("VIX_JAN11","VIX_FEB11"),root='VX',format='CY')

Results


R version 3.3.1 (2016-06-21) -- "Bug in Your Hair"
Copyright (C) 2016 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> library(FinancialInstrument)
Loading required package: quantmod
Loading required package: xts
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

Loading required package: TTR
Version 0.4-0 included new data defaults. See ?getSymbols.
> png(filename="/home/ddbj/snapshot/RGM3/R_CC/result/FinancialInstrument/make_spread_id.Rd_%03d_medium.png", width=480, height=480)
> ### Name: make_spread_id
> ### Title: Construct a primary_id for a 'spread' 'instrument' from the
> ###   primary_ids of its members
> ### Aliases: make_spread_id
> 
> ### ** Examples
> 
> ids <- c('VX_aug1','VX_U11')
> make_spread_id(ids, format='CY')
[1] "VX_Q1.U1"
> make_spread_id(ids, format=FALSE)
[1] "VX_aug1.U11"
> make_spread_id(c("VIX_JAN11","VIX_FEB11"),root='VX',format='CY')
[1] "VX_F1.G1"
> 
> 
> 
> 
> 
> dev.off()
null device 
          1 
>