rp_preOrder_multiLeg: Preflight Multiple-Leg

View source: R/rPublic.R

rp_preOrder_multiLegR Documentation

Preflight Multiple-Leg

Description

Preflight Multiple-Leg

Usage

rp_preOrder_multiLeg(
  accountId,
  orderType,
  qty,
  leg_symbols,
  leg_types,
  leg_sides,
  leg_indicator,
  leg_ratios,
  tif,
  mins = NULL,
  lmtPrc = NULL
)

Arguments

accountId

= Public Brokerage Account Number

orderType

= The Type of order: Ex. 'MARKET','LIMIT', 'STOP', 'STOP_LIMIT'

qty

= leg_ratio multiple: ex. '2' multiples the leg_ratios by 2X

leg_symbols

= Symbols: ex. c("SPY250815C00631000", "SPY250815C00631000")

leg_types

= Symbol types: ex. c("OPTION", "OPTION")

leg_sides

= The side for each leg: ex. c("BUY", "SELL")

leg_indicator

= Indicates if this is BUY to OPEN/CLOSE ex. c("OPEN", "OPEN")

leg_ratios

= The number of contracts to BUY/SELL: ex. c('5','5')

tif

= The time in for the order: 'DAY' or 'GTD"

mins

= Minutes till order expires.

lmtPrc

= The limit price. Used when orderType = LIMIT or orderType = STOP_LIMIT

Value

Calculates the estimated financial impact of a complex multi-leg trade before execution and returns as a data.frame.

Examples

## Not run: 
 # Fetches costs associated with the type of order being placed
 my_acc <- rp_getAccts()

 # open bull-call spread for 0.25 (buy 2, sell 2)
 rp_preOrder_multiLeg(accountId = my_acc$accountId, orderType = "LIMIT", qty = 2, 
                      leg_symbols = c("SPY250815C00630000","SPY250815C00632000"),
                      leg_types = c("OPTION", "OPTION"), leg_sides = c("BUY","SELL"), 
                      leg_indicator = c("OPEN", "OPEN"), leg_ratios = c(1, 1), 
                      tif = "DAY", lmtPrc = 0.25)

 # open long butterfly for 0.05 
 rp_preOrder_multiLeg(accountId = my_acc$accountId, orderType = "LIMIT", qty = 1, 
                      leg_symbols = c("SPY250815C00630000",
                                      "SPY250815C00631000",
                                      "SPY250815C00632000"), 
                      leg_types = c("OPTION", "OPTION", "OPTION"), 
                      leg_sides = c("BUY","SELL","BUY"), 
                      leg_indicator = c("OPEN","OPEN","OPEN"), 
                      leg_ratios = c(1, 2, 1), tif = "DAY", lmtPrc = 0.05)

# open iron-condor
 rp_preOrder_multiLeg(accountId = my_acc$accountId, orderType = "LIMIT", qty = 1, 
                      leg_symbols = c("SPY250815C00631000","SPY250815C00630000",
                                      "SPY250815C00625000","SPY250815C00624000"), 
                      leg_types = c("OPTION", "OPTION", "OPTION","OPTION"), 
                      leg_sides = c("SELL","BUY","SELL","BUY"), 
                      leg_indicator = c("OPEN","OPEN","OPEN","OPEN"), 
                      leg_ratios = c(1, 1, 1, 1), tif = "DAY", lmtPrc = 0.30)

## End(Not run)

rPublic documentation built on Aug. 23, 2025, 1:12 a.m.