IBPlaceOrder( <Direction>, <OrderType>, <Symbol>, <Qty>, <LimitPrice>, <TimeInForce>, <IBExchange>, <IBType>, <IBExpiration>, <AuxPrice>, <DiscretionaryAmount>, <Hidden>, <FAAccount>, <FAGroup>, <FAProfile>, <FAMethod>, <FAPercentage>, <IBCurrency>, <OCAGroup>);
<Direction> |
"BUY" or "SELL" |
<OrderType> |
IB Market types "MKT" = Market Order "MKTCLS" = Market On Close Order "LMT" = Limit Order "LMTCLS" = Limit On Close "PEGMKT" = Pegged to Buy on Best Offer/Sell on Best Bid "STP" = Stop Order "STPLMT" = Stop Limit Order "TRAIL" = Trailing Order "REL" = Relative Order "VWAP" = Volume-Weighted Avg Price Order
see IB Docs for definitions of orders... |
<Symbol> |
The symbol you want to trade (See Special SYMBOLOGY instructions for IB) |
<Qty> |
The QUANTITY you want to trade (positive #) |
<LimitPrice> |
The selected LIMIT PRICE (for LIMIT orders only) |
<TimeInForce> |
Gain Order Options "GTC" "EOD"
IB Order Options "GTC" = Good Till Cancelled "DAY" = Day Order "FOK" = Fill or Kill
see IB Docs for definitions of orders... |
<IBExchange> |
The selected EXCHANGE to execute the trade through ** IB Only |
<IBType> |
The type of security/market being traded ** IB Only "STK" "OPT" "FUT" "IND" "FOP" "CASH" "BAG" |
<IBExpiration> |
"YYYYMM" for example "200703" or "200706" ** IB Only Notice - this should be passed a "" for all futures contract orders and the symbol should reflect the expiration
example:
EntryOrderID=mentts.call("PlaceOrder","IB","SELL","MKT","ESH7",1,0,"GTC","GLOBEX","FUT","",0); Sells 1 ES March 07 contract at Market |
<IBAuxPrice> |
The Auxilary price for the the STOPLIMIT ** IB Only |
| <Discretionary Amount> | The the amount of "Discretion" for Discretionary Orders ** IB Only - Selected Exchanges Only |
| <Hidden> | 1 for Hidden Orders or 0 for non-Hidden Orders ** IB Only |
| <FAAccount> | The FA Account for this Order ** IB FA Accounts Only |
| <FAGroup> | The FA Group for this Order ** IB FA Accounts Only |
| <FAProfile> | The FA Profile for this Order ** IB FA Accounts Only |
| <FAMethod> | The FA Method for this Order ** IB FA Accounts Only |
| <FAPercentage> | The FA Percentage for this Order ** IB FA Accounts Only |
| <IBCurrency> | The Currency type for the traded instrument ** IB Only |
| <OCAGroup> | The OCA Group Identifier for this order ** IB Only |
This function places a new order to the selected broker with the selected parameters. Users should then use the following MTS functions..
GetBrokerStatus() to verify
MTS is connected to the selected broker
IBPlaceOrder() to place an IB Specific order
PlaceOrder() to place a Generic order
PlaceOrderAssoc() to place a new ASSOC(iated) order
ModifyOrderAssoc() to modify an ASSOC order
GetOrderStatus() to get/verify the order status
GetFillPrice() to get the fill price of the order
GetFillAmount() to get the # of filled shares/contracts of the order
Cancel() to properly cancel the order
GetCurrentPosition() to verify the current position of the trading system
Return Values
OrderID MTS returns a valid OrderID for any succesfully submitted order
< 0 MTS returns a NEGATIVE NUMBER for any REJECTED order
IB Example
var DefEntryContracts = 100;
LEntryOrderID = mentts.call("IBPlaceOrder","BUY","LMT","WDC",DefEntryContracts,22.00,"GTC","ISLAND", "STK", "", 0, 0.05, 1, "", "", "", "", "", "USD", "");
This command places a HIDDEN DISCRETIONARY BUY LIMIT order for 100 WDC @ 22.00 with a discretionary amount of 0.05 on the ISLAND exchange into IB as at GTC order.
LEntryOrderID = mentts.call("IBPlaceOrder","BUY","MKT","IBM",DefEntryContracts,0,"GTC","SMART", "STK", "", 0, 0, 0, "", "", "", "", "", "USD", "");
This command places a BUY MARKET order for 100 IBM into IB as at GTC order.