Create twsOrder object for placeOrder
API call.
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
)
Called for its side-effects.
The id for the order. Use reqIds
.
Identifies the side. ( BUY, SELL, SSHORT )
Order quantity.
Order type. ( MKT, MKTCLS, LMT, LMTCLS, PEGMKT, SCALE, STP, STPLMT, TRAIL, REL, VWAP, TRAILLIMIT )
The LIMIT price for LMT, STPLMT and REL orderType
The STOP price for STPLMT (stop-limit) orders, and the offset for REL (relative) orders
Time in force. (DAY, GTC, IOC, GTD)
Allow orders to trigger outside of regular trading hours.
Specify whether order is open or close only. (Institutional Accounts Only)
The order origin. 0=customer, 1=firm (Institutional Accounts Only)
Identifies OCA group.
The account (Institutional Accounts Only)
The order reference (Institutional Accounts Only)
Specify whether the order is transmitted to the TWS. If FALSE, order is created but not sent. (not implemented)
The orderId of the parent order, used for bracket and auto trailing stop orders.
ISE block order?
Sweep to fill order?
Publicly disclosed order size for Iceberg orders.
How should simulated orders be triggered. Valid values are 0-8. See the official API for details.
Hide order on ISLAND?
Amount off limit for discretionary orders.
Trades Good After Time: YYYYMMDD hh:mm:ss or ""
Trades Good Till Date: YYYYMMDD hh:mm:ss or ""
NA
NA
NA
NA
1 or 2
Only when shortSaleSlot=2
Cancel on Fill with Block = 1 Reduce on Fill with Block = 2 Reduce on Fill without Block = 3
Valid values: I, A, W, J, U, M, K, Y, N. See API.
(Institutional Only)
IBExecution customers only.
IBExecution customers only.
yes=1, no=0
Minimum quantity order type.
Percent offset for REL (relative) orders.
Trade with electronic quotes. yes=1, no=0.
Trade with firm quotes. yes=1, no=0.
The maximum Smart order distance from the NBBO.
BOX only. See API.
BOX only. See API.
The stock reference price. VOL orders. See API.
BOX only. See API.
See API.
See API.
See API.
See API.
See API.
See API.
See API.
See API.
See API.
For TRAILLIMIT orders only.
EFP orders only.
EFP orders only.
For Scale orders. See API.
For Scale orders. See API.
For Scale orders. See API.
See API and guess.
See API and guess.
See API and guess.
Use to request pre-trade commissions and margin information. TRUE/FALSE
Id of the client that placed the order.
TWS id used to identify orders. Constant over a session.
Mark order as exempt from short sale uptick rule.
For hedge orders. Possible values include: D=delta, B=beta, F=FX, P=Pair
Beta = x for Beta hedge orders, ratio = y for Pair hedge order
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.
Used for scale orders
for GTC orders
for GTC orders
Specifies the trailing amount of a trailing stop order as a percentage. See the API docs for guidelines.
See API docs
See API docs
See API docs
See API docs
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.
Used when the hedge involves a stock and indicates whether or not it is sold short.
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.
Used only when deltaNeutralShortSaleSlot = 2.
For extended Scale orders
For extended Scale orders
For extended Scale orders
For extended Scale orders
For extended Scale order
For extended Scale orders
For extended Scale orders
Advanced parameters for Smart combo routing .
Number of parameters
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.
Number of parameters
See API docs
See API docs
See API docs
Jeffrey A. Ryan
Read the API documentation, code, and experiment with the paper accounts. And good luck!
Order API: https://interactivebrokers.github.io/tws-api/order_management.html
placeOrder