buildSpread: Construct a price/level series for pre-defined multi-leg...

Description Usage Arguments Details Value Note Author(s) See Also Examples

View source: R/buildSpread.R

Description

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

Usage

1
2
3
4
5
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

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
## 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)

FinancialInstrument documentation built on May 2, 2019, 5:24 p.m.