Learn R Programming

IBrokers (version 0.10-2)

twsOrder: Create twsOrder Object

Description

Create twsOrder object for placeOrder API call.

Usage

twsOrder(orderId,
         action = "BUY", 
         totalQuantity = "10", 
         orderType = "LMT",
         lmtPrice = "0.0", 
         auxPrice = "0.0",
         tif = "",
         outsideRTH = "0",
         openClose = "O",
         origin = .twsOrderID$CUSTOMER,
         ocaGroup = "",
         account = "",
         orderRef = "",
         transmit = TRUE,
         parentId = "0",
         blockOrder = "0",
         sweepToFill = "0",
         displaySize = "0",
         triggerMethod = "0",
         hidden = "0",
         discretionaryAmt = "0.0",
         goodAfterTime = "",
         goodTillDate = "",
         faGroup = "", 
         faMethod = "",
         faPercentage = "",
         faProfile = "",
         shortSaleSlot = "0",
         designatedLocation = .twsOrderID$EMPTY_STR,
         ocaType = "0",
         rule80A = "",
         settlingFirm = "",
         clearingAccount = "",
         clearingIntent = "",
         allOrNone = "0",
         minQty = "",
         percentOffset = "",
         eTradeOnly = "0",
         firmQuoteOnly = "0",
         nbboPriceCap = "",
         auctionStrategy = "0",
         startingPrice = "",
         stockRefPrice = "",
         delta = "",
         stockRangeLower = "",
         stockRangeUpper = "",
         overridePercentageConstraints = "0",
         volatility = "",
         volatilityType = "",
         deltaNeutralOrderType = "",
         deltaNeutralAuxPrice = "",
         continuousUpdate = "0",
         referencePriceType = "",
         trailStopPrice = "",
         basisPoints = "",
         basisPointsType = "",
         scaleInitLevelSize = "",
         scaleSubsLevelSize = "",
         scalePriceIncrement = "",
         notHeld = FALSE,
         algoStrategy = "",
         algoParams = NULL,
         whatIf = FALSE,
         clientId = "",
         permId = "",
         exemptCode = "-1",
         hedgeType = "",
         hedgeParam = "",
         optOutSmartRouting = FALSE,
         scaleTable = "",
         activeStartTime = "",
         activeStopTime = "",
         trailingPercent = "",
         deltaNeutralConId = "0",
         deltaNeutralSettlingFirm = "",
         deltaNeutralClearingAccount = "",
         deltaNeutralClearingIntent = "",
         deltaNeutralOpenClose = "",
         deltaNeutralShortSale = "0",
         deltaNeutralShortSaleSlot = "0",
         deltaNeutralDesignatedLocation = "",
         scalePriceAdjustValue = "0",
         scalePriceAdjustInterval = "0",
         scaleProfitOffset = "0",
         scaleAutoReset = "0",
         scaleInitPosition = "0",
         scaleInitFillQty = "0",
         scaleRandomPercent = "0",
         smartComboRoutingParams = NULL,
         smartComboRoutingParamsCount = "0",
         orderComboLegs = NULL,
         orderComboLegsCount = "0",
         comboLegs = NULL,
         comboLegsCount = "0",
         orderMiscOptions = NULL
         )

Value

Called for its side-effects.

Arguments

orderId

The id for the order. Use reqIds.

action

Identifies the side. ( BUY, SELL, SSHORT )

totalQuantity

Order quantity.

orderType

Order type. ( MKT, MKTCLS, LMT, LMTCLS, PEGMKT, SCALE, STP, STPLMT, TRAIL, REL, VWAP, TRAILLIMIT )

lmtPrice

The LIMIT price for LMT, STPLMT and REL orderType

auxPrice

The STOP price for STPLMT (stop-limit) orders, and the offset for REL (relative) orders

tif

Time in force. (DAY, GTC, IOC, GTD)

outsideRTH

Allow orders to trigger outside of regular trading hours.

openClose

Specify whether order is open or close only. (Institutional Accounts Only)

origin

The order origin. 0=customer, 1=firm (Institutional Accounts Only)

ocaGroup

Identifies OCA group.

account

The account (Institutional Accounts Only)

orderRef

The order reference (Institutional Accounts Only)

transmit

Specify whether the order is transmitted to the TWS. If FALSE, order is created but not sent. (not implemented)

parentId

The orderId of the parent order, used for bracket and auto trailing stop orders.

blockOrder

ISE block order?

sweepToFill

Sweep to fill order?

displaySize

Publicly disclosed order size for Iceberg orders.

triggerMethod

How should simulated orders be triggered. Valid values are 0-8. See the official API for details.

hidden

Hide order on ISLAND?

discretionaryAmt

Amount off limit for discretionary orders.

goodAfterTime

Trades Good After Time: YYYYMMDD hh:mm:ss or ""

goodTillDate

Trades Good Till Date: YYYYMMDD hh:mm:ss or ""

faGroup

NA

faMethod

NA

faPercentage

NA

faProfile

NA

shortSaleSlot

1 or 2

designatedLocation

Only when shortSaleSlot=2

ocaType

Cancel on Fill with Block = 1 Reduce on Fill with Block = 2 Reduce on Fill without Block = 3

rule80A

Valid values: I, A, W, J, U, M, K, Y, N. See API.

settlingFirm

(Institutional Only)

clearingAccount

IBExecution customers only.

clearingIntent

IBExecution customers only.

allOrNone

yes=1, no=0

minQty

Minimum quantity order type.

percentOffset

Percent offset for REL (relative) orders.

eTradeOnly

Trade with electronic quotes. yes=1, no=0.

firmQuoteOnly

Trade with firm quotes. yes=1, no=0.

nbboPriceCap

The maximum Smart order distance from the NBBO.

auctionStrategy

BOX only. See API.

startingPrice

BOX only. See API.

stockRefPrice

The stock reference price. VOL orders. See API.

delta

BOX only. See API.

stockRangeLower

See API.

stockRangeUpper

See API.

overridePercentageConstraints

See API.

volatility

See API.

volatilityType

See API.

deltaNeutralOrderType

See API.

deltaNeutralAuxPrice

See API.

continuousUpdate

See API.

referencePriceType

See API.

trailStopPrice

For TRAILLIMIT orders only.

basisPoints

EFP orders only.

basisPointsType

EFP orders only.

scaleInitLevelSize

For Scale orders. See API.

scaleSubsLevelSize

For Scale orders. See API.

scalePriceIncrement

For Scale orders. See API.

notHeld

See API and guess.

algoStrategy

See API and guess.

algoParams

See API and guess.

whatIf

Use to request pre-trade commissions and margin information. TRUE/FALSE

clientId

Id of the client that placed the order.

permId

TWS id used to identify orders. Constant over a session.

exemptCode

Mark order as exempt from short sale uptick rule.

hedgeType

For hedge orders. Possible values include: D=delta, B=beta, F=FX, P=Pair

hedgeParam

Beta = x for Beta hedge orders, ratio = y for Pair hedge order

optOutSmartRouting

Use to opt out of default SmartRouting for orders routed directly to ASX. This attribute defaults to false unless explicitly set to true. When set to false, orders routed directly to ASX will NOT use SmartRouting. When set to true, orders routed directly to ASX orders WILL use SmartRouting.

scaleTable

Used for scale orders

activeStartTime

for GTC orders

activeStopTime

for GTC orders

trailingPercent

Specifies the trailing amount of a trailing stop order as a percentage. See the API docs for guidelines.

deltaNeutralConId

See API docs

deltaNeutralSettlingFirm

See API docs

deltaNeutralClearingAccount

See API docs

deltaNeutralClearingIntent

See API docs

deltaNeutralOpenClose

Specifies whether the order is an Open or a Close order and is used when the hedge involves a CFD and and the order is clearing away.

deltaNeutralShortSale

Used when the hedge involves a stock and indicates whether or not it is sold short.

deltaNeutralShortSaleSlot

Has a value of 1 (the clearing broker holds shares) or 2 (delivered from a third party). If you use 2, then you must specify a deltaNeutralDesignatedLocation.

deltaNeutralDesignatedLocation

Used only when deltaNeutralShortSaleSlot = 2.

scalePriceAdjustValue

For extended Scale orders

scalePriceAdjustInterval

For extended Scale orders

scaleProfitOffset

For extended Scale orders

scaleAutoReset

For extended Scale orders

scaleInitPosition

For extended Scale order

scaleInitFillQty

For extended Scale orders

scaleRandomPercent

For extended Scale orders

smartComboRoutingParams

Advanced parameters for Smart combo routing .

smartComboRoutingParamsCount

Number of parameters

orderComboLegs

List of Per-leg price following the same sequence combo legs are added. The combo price must be left unspecified when using per-leg prices.

orderComboLegsCount

Number of parameters

comboLegs

See API docs

comboLegsCount

See API docs

orderMiscOptions

See API docs

Author

Jeffrey A. Ryan

Details

Read the API documentation, code, and experiment with the paper accounts. And good luck!

References

Order API: https://interactivebrokers.github.io/tws-api/order_management.html

See Also

placeOrder