buildSpread {FinancialInstrument}R Documentation

Construct a price/level series for pre-defined multi-leg spread instrument

Description

Build price series for spreads, butterflies, or other synthetic instruments, using metadata of a previously defined synthetic instrument.

Usage

buildSpread(spread_id, Dates = NULL, onelot = TRUE, prefer = NULL,
  auto.assign = TRUE, env = .GlobalEnv)

buildBasket(spread_id, Dates = NULL, onelot = TRUE, prefer = NULL,
  auto.assign = TRUE, env = .GlobalEnv)

Arguments

spread_id

The name of the instrument that contains members and memberratio

Dates

Date range on which to subset. Also, if a member's data is not available via get getSymbols will be called, and the values of the from and to arguments will be determined using .parseISO8601 on Dates.

onelot

Should the series be divided by the first leg's ratio?

prefer

Price column to use to build structure.

auto.assign

Assign the spread? If FALSE, the xts object will be returned.

env

Environment holding data for members as well as where spread data will be assigned.

Details

The spread and all legs must be defined instruments.

This function can build multileg spreads such as calendars, butterflies, condors, etc. However, the returned series will be univariate. It does not return multiple columns (e.g. ‘Bid’, ‘Ask’, ‘Mid’) like fn_SpreadBuilder does.

buildBasket is an alias

TODO: allow for multiplier (divisor) that is a vector.

Value

If auto.assign is FALSE, a univariate xts object. Otherwise, the xts object will be assigned to spread_id and the spread_id will be returned.

Note

this could also be used to build a basket or a strip by using only positive values in memberratio

Author(s)

Brian Peterson, Garrett See

See Also

fn_SpreadBuilder spread for instructions on defining the spread

Examples

## Not run: 
currency("USD")
stock("SPY","USD",1)
stock("DIA","USD",1)
getSymbols(c("SPY","DIA")) 

spread("SPYDIA", "USD", c("SPY","DIA"),c(1,-1)) #define it.
buildSpread('SPYDIA') #build it.
head(SPYDIA)


## End(Not run)

[Package FinancialInstrument version 1.3.1 Index]