Learn R Programming

FinancialInstrument (version 1.3.1)

synthetic: synthetic instrument constructors

Description

define spreads, guaranteed_spreads, butterflies, and other synthetic instruments

Usage

synthetic(primary_id = NULL, currency = NULL, multiplier = 1,
  identifiers = NULL, assign_i = TRUE, overwrite = TRUE, ...,
  members = NULL, type = "synthetic")

synthetic.instrument(primary_id, currency, members, memberratio, ..., multiplier = 1, tick_size = NULL, identifiers = NULL, assign_i = TRUE, type = c("synthetic.instrument", "synthetic"))

spread(primary_id = NULL, currency = NULL, members, memberratio, tick_size = NULL, ..., multiplier = 1, identifiers = NULL, assign_i = TRUE)

butterfly(primary_id = NULL, currency = NULL, members, tick_size = NULL, identifiers = NULL, assign_i = TRUE, ...)

guaranteed_spread(primary_id = NULL, currency = NULL, root_id = NULL, suffix_id = NULL, members = NULL, memberratio = c(1, -1), ..., multiplier = NULL, identifiers = NULL, assign_i = TRUE, tick_size = NULL)

ICS_root(primary_id, currency = NULL, members, multiplier = NULL, identifiers = NULL, assign_i = TRUE, overwrite = TRUE, tick_size = NULL, ...)

ICS(primary_id, assign_i = TRUE, identifiers = NULL, ...)

Arguments

primary_id

chr string of primary identifier of instrument to be defined.

currency

chr string name of currency denomination

multiplier

multiplier of the spread (1 / divisor for price weighted baskets)

identifiers

identifiers

assign_i

TRUE/FALSE. Should the instrument be assigned in the .instrument environment?

overwrite

if FALSE and an instrument with the same primary_id is already defined, an error will be thrown and no instruments will be created.

any other passthrough parameters

members

vector of primary_ids of member instruments

type

type of instrument; wrappers do not require this.

memberratio

vector of weights for each leg. negative numbers for selling.

tick_size

minimum price change of the spread

root_id

instrument identifier for the root contract, default NULL

suffix_id

identifiers for the member contract suffixes, default NULL, will be split as members, see Details

Value

called for side effect. stores an instrument in .instrument environment

Details

Simple derivatives like option or future contracts typically have one underlying instrument. While properties like strike and expiration vary for these derivative contracts or series, the underlying is well understood.

More complex derivatives are typically modeled as baskets of underlying products, and are typically traded over-the-counter or as proprietary in-house products.

The general synthetic function is intended to be extended to support these arbitrary baskets of assets.

spread guaranteed_spread and butterfly are wrappers for synthetic.instrument. synthetic.instrument will make a call to synthetic to create the final instrument.

The suffix_id parameter of wrapper functions such as guaranteed_spread is presumed to be a string describing the members. It will be strsplit using the regex "[-;:_,\.]" to create the members vector, and potentially combined with a root_id.

Most wrappers will build primary_id if it is NULL, either by combining root_id and suffix_id, or by passing members in a call to make_spread_id

ICS will build an Intercommodity Spread. Although the expiration date and ratio may change, the members of a given ICS will not change. Therefore, ICS_root can be used to hold the members of an Intercommodity Spread. If an ICS_root has not been defined, then members will be a required argument for ICS

We welcome assistance from others to model more complex OTC derivatives such as swap products.

See Also

instrument, future, option_series.yahoo

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
stock('SPY','USD',1)
stock('DIA','USD',1)
spread('SPY.DIA','USD',c('SPY','DIA'),c(1,-1))
# }

Run the code above in your browser using DataLab