
|
QT Trading API - OPTIONSXPRESS (OPTXPR.TRD)
|

|
SEND COMMANDS (Client Application to QT Server)
The following SEND TYPE commands are supported for optionsXpress:
| NEWORDER | - Sends a New Order to the broker |
| MODIFYORDER | - Modifies an existing order |
| CANCELORDER | - Cancels one or more orders |
| REFTRAN | - Forces a refresh of transactions. No parameters |
| REFBAL | - Forces a refresh of Balances and Positions. No parameters |
NOTIFICATION RESPONSES (QT Server to Application)
The following is a list of Notification TYPES that can be returned:
| ACK | - acknowledgement of a successful order transaction. |
| ERROR | - Error while parsing command or error returned from the broker |
| TRANSACTIONS | - List of transactions for the day |
| BALANCES | - Current Balances information |
| POSITIONS | - Current Positions information |
SEND COMMANDS DETAILS
 |
NEWORDER - Send a New Order to the broker |
 |
|
| Parameter Name | Parameter Values and Description |
| SymbolType | STOCK, OPTION or FUTURE. If not specified, QT figures it out based on the symbol prefix |
| Symbol | Symbol of the security to be traded |
| Action | BUY, SELL, SHORT, COVER BUY_OPEN, BUY_CLOSE, SELL_OPEN, SELL_CLOSE |
| OrderType | LIMIT, MARKET, MKTCLS, STOPMARKET, STOPLIMIT, TSTOP |
| Quantity | Number of Shares or Contracts in the transaction |
| LimitPrice | LIMIT Price for Limit AND Stop Limit orders |
| StopPrice | STOP Price (Activation Price) for STOP orders, or Trail Amount for Trailing Stop |
| StopBasis | If the OrderType is TSTOP, then specify either PERCENT or POINTS to indicate how the specified Trail Amount should be interpreted |
| TStopTrigger | If the OrderType is TSTOP, then specify how the Trailing stop should be triggered: Standard, Bid, Ask, Last. If not specified, User settings in Trading setup will be used |
| TIF | Time In Force: DAY, DAY+, GTC |
| Route | For Stocks: SMART or AUTO, INET, ARCA
For Options: SMART or AUTO, CBOE, AMEX, PHLX, PSE, ISE |
| AON | All or None: YES if set. NO if omitted |
NOTE: Very little error checking is done for API order prior to sending them to the broker.
Some parameter value combinations are not available, such as OrderType: MARKET Route: INET.
Invalid orders will be rejected by the server and the rejection will be returned to you in a NOTIFICATION message.
EXAMPLE:
| |
<TRADEAPI>
<ID>MISCS1</ID>
<ACTION>SEND</ACTION>
<TYPE>NEWORDER</TYPE>
<PARAMS>
<Symbol>DELL</Symbol>
<Action>BUY</Action>
<OrderType>LIMIT</OrderType>
<Quantity>500</Quantity>
<LimitPrice>41.72</LimitPrice>
<TIF>DAY</TIF>
<Route>AUTO</Route>
</PARAMS>
</TRADEAPI>
{FF}
|
|
 |
MODIFYORDER - Modifies an existing order |
 |
|
| Parameter Name | Parameter Values and Description |
| OrderID | REQUIRED - The Order ID of the order being modified. Should be retrieved from TRANSACTIONS |
| OrderType | LIMIT, MARKET, MKTCLS, STOPMARKET, STOPLIMIT, TSTOP |
| Quantity | Number of Shares or Contracts in the transaction |
| LimitPrice | LIMIT Price for Limit AND Stop Limit orders |
| StopPrice | STOP Price (Activation Price) for STOP orders, or Trail Amount for Trailing Stop |
| TIF | Time In Force: DAY, DAY+, GTC |
| AON | All or None: YES if set. NO if omitted |
NOTE: Only the Order ID is required. For the other fields, only the ones that are modified need to be sent.
The others can be omitted or you can send the value that was returned in TRANSACTIONS.
HOWEVER, if making a change to the order type or route and there are fields that were applicable in the original order,
but not in the new order, those fields should be sent with a null value.
EXAMPLE:
| |
<TRADEAPI>
<ID>MISCS1</ID>
<ACTION>SEND</ACTION>
<TYPE>MODIFYORDER</TYPE>
<PARAMS>
<OrderID>47911223</OrderID>
<OrderType>LIMIT</OrderType>
<LimitPrice>41.72</LimitPrice>
<Quantity>300</Quantity>
<TIF>DAY</TIF>
<AON>YES</AON>
</PARAMS>
</TRADEAPI>
{FF}
|
|
 |
CANCELORDER - Cancels one or more orders |
 |
|
| Parameter Name | Parameter Values and Description |
| OrderID | The Order ID of the order to be canceled. |
NOTE: To cancel more than one order at a time, just include multiple OrderID XML tags, one for each order
EXAMPLE:
| |
<TRADEAPI>
<ID>MISCS1</ID>
<ACTION>SEND</ACTION>
<TYPE>CANCELORDER</TYPE>
<PARAMS>
<OrderID>47911221</OrderID>
<OrderID>47911222</OrderID>
<OrderID>47911223</OrderID>
</PARAMS>
</TRADEAPI>
{FF}
|
|
NOTIFICATION RESPONSES
NOTE: The examples below will not show Record ID or Record Length for simplicity, even though they are sent with every message.
 |
ACK - Acknowledgement of a successful order transaction |
 |
|
Result returned in XML.
EXAMPLES:
| |
<TRADEAPI>
<ID>MISCS1</ID>
<TYPE>ACK</TYPE>
<MESSAGE>Transaction Sent</MESSAGE>
</TRADEAPI>
|
OR
| |
<TRADEAPI>
<ID>MISCS1</ID>
<TYPE>ACK</TYPE>
<MESSAGE>Cancel Order Sent - 47911223</MESSAGE>
</TRADEAPI>
|
|
 |
ERROR - Error while parsing command or error returned from the broker |
 |
|
Result returned in XML.
EXAMPLES:
| |
<TRADEAPI>
<ID>MISCS1</ID>
<TYPE>ERROR</TYPE>
<MESSAGE>Unable to get Positions data</MESSAGE>
</TRADEAPI>
|
|
 |
TRANSACTIONS - List of transactions on the account for the day |
 |
|
Result returned in XML.
| Parameter Name | Parameter Values and Description |
| OrderID | Order ID of the order |
| OrderTime | Date/Time the order was Placed |
| Action | BUY, SELL, etc. (Same as in NEWORDER) |
| Symbol | Symbol of the security being traded |
| SymbolType | STOCK, OPTION, FUTURE |
| OrderType | LIMIT, MARKET, etc. (Same as in NEWORDER) |
| Quantity | Number of Shares or Contracts in the transaction |
| FilledQuantity | Number of Shares or Contracts that have been filled |
| UnfilledQuantity | # of Shares or Contracts yet to be filled |
| LimitPrice | LIMIT Price for Limit AND Stop Limit orders |
| StopPrice | STOP Price for STOP orders |
| FillPrice | The execution price (Average if partial fills) |
| TIF | Time In Force: DAY, DAY+, GTC (Same as in NEWORDER) |
| Route | AUTO, INET, etc... (Same as in NEWORDER) |
| OrderStatus | Current Status of the order (Open, Pending, Pending Cancel, Filled, Open: Partially Filled, Cancelled: Partially Filled, Cancelled: Partially Filled) |
| Open | YES/NO - Whether or not this is an OPEN order - Still being processed |
EXAMPLES:
| |
<TRADEAPI>
<ID>MISCS1</ID>
<TYPE>TRANSACTIONS</TYPE>
<TRANSACTIONS>
<ORDER>
<OrderID>47911223</OrderID>
<OrderTime>2005-05-27 11:10:19</OrderTime>
<Action>SELL</Action>
<Symbol>DELL</Symbol>
<SymbolType>STOCK</SymbolType>
<OrderType>LIMIT</OrderType>
<Quantity>500</Quantity>
<FilledQuantity>400</FilledQuantity>
<UnfilledQuantity>100</UnfilledQuantity>
<Open>YES</Open>
<Route></Route>
<OrderStatus>Partial Fill: Open</OrderStatus>
<TIF>DAY</TIF>
<LimitPrice>40.50</LimitPrice>
<FillPrice>40.51</FillPrice>
</ORDER>
</TRANSACTIONS>
</TRADEAPI>
|
|
 |
BALANCES - Current Balances information |
 |
|
Result returned in XML.
EXAMPLES:
| |
<TRADEAPI>
<ID>MISCS1</ID>
<TYPE>BALANCES</TYPE>
<BALANCES>
<AccountID>11223344</AccountID>
<AccountType>MARGIN OPTION</AccountType>
<FuturesCash>0.00</FuturesCash>
<FuturesUnrealizedGainAndLoss>0.00</FuturesUnrealizedGainAndLoss>
<FuturesRequirements>0.00</FuturesRequirements>
<IntraDayBuyingPower>110.93</IntraDayBuyingPower>
<TodaysPurchases>0.00</TodaysPurchases>
<FuturesBuyingPower>15.03</FuturesBuyingPower>
<BuyingPowerStartOfDay>110.93</BuyingPowerStartOfDay>
<NonMarginSec>0.00</NonMarginSec>
<MarginAvailable>15.03</MarginAvailable>
<TotalEquity>110.93</TotalEquity>
<BuyingPower>15.03</BuyingPower>
<MoneyMarketBalance>0.00</MoneyMarketBalance>
<CashBalance>110.89</CashBalance>
<PendingPurchases>95.90</PendingPurchases>
<MarginBalance>0.04</MarginBalance>
<OptionsBalance>0.00</OptionsBalance>
<OtherSecurityBalance>0.00</OtherSecurityBalance>
<OptionsRequirements>0.00</OptionsRequirements>
<CashAvailable>15.03</CashAvailable>
<UnsettledOptions>0.00</UnsettledOptions>
<SecuritiesTotal>0.00</SecuritiesTotal>
<CashTotals>110.93</CashTotals>
<MarginEquityPercentage>100.00%</MarginEquityPercentage>
</BALANCES>
</TRADEAPI>
|
|
 |
POSITIONS - Current Positions information |
 |
|
Result returned in XML.
EXAMPLES:
| |
<TRADEAPI>
<ID>MISCS1</ID>
<TYPE>POSITIONS</TYPE>
<POSITIONS>
<POSITION>
<Symbol>DELL</Symbol>
<SymbolType>STOCK</SymbolType>
<Name>DELL</Name>
<PositionType>LONG</PositionType>
<Quantity>400</Quantity>
<Cost>41.00</Cost>
<ClosePrice>38.45</ClosePrice>
</POSITION>
<POSITION>
<Symbol>GOOG</Symbol>
<SymbolType>STOCK</SymbolType>
<Name>Google</Name>
<PositionType>LONG</PositionType>
<Quantity>500</Quantity>
<Cost>174.23</Cost>
<ClosePrice>450.45</ClosePrice>
</POSITION>
... More POSITION records ...
</POSITIONS>
</TRADEAPI>
|
|
|
|

|

|
|
|
|