define spreads, guaranteed_spreads, butterflies, and other synthetic instruments
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, ...)
chr string of primary identifier of instrument to be defined.
chr string name of currency denomination
multiplier of the spread (1 / divisor for price weighted baskets)
identifiers
TRUE/FALSE. Should the instrument be assigned in the .instrument
environment?
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
vector of primary_ids of member instruments
type of instrument; wrappers do not require this.
vector of weights for each leg. negative numbers for selling.
minimum price change of the spread
instrument identifier for the root contract, default NULL
identifiers for the member contract suffixes, default NULL,
will be split as members
, see Details
called for side effect. stores an instrument in .instrument environment
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.
instrument, future, option_series.yahoo
# 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