QuoteTracker. Real-Time Intraday Charts, Quotes, Alerts, News Monitoring and Portfolio Management.

 

SCREENS
BETA SITE
DOWNLOAD
TESTIMONIALS
REGISTRATION
INVESTOR
RESOURCES

SALES



QT Trading API - Version 1.000


TD AMERITRADE NOTE:
If you are using QuoteTracker API for Trading through TD AMERITRADE, you may benefit from connecting to TD AMERITRADE API directly. (You can continue to use QT API if you wish) In order to do that, please email TD AMERITRADE API Support and indicate your TD AMERITRADE Username or Account #, and the development environment that you are using.

NOTE: QT VERSION 3.5.9H has a major change. NOTIFICATION Message was changed to code XN, All records with Record ID starting with X will have a 4 byte record length.
 

INTRODUCTION

This document describes how to login, place trades, and receive transaction, position and account information with brokers supported for QuoteTracker ™ Integrated Trading using QuoteTracker ™ Trading API

PLEASE NOTE: QuoteTracker must be registered for it to accept incoming API connections. You can register here.
If you are a commercial product developer, please contact us about the development and we will provide a registration code for testing purposes.
"Commercial Product" refers to something that will be marketed to the general public. Not for personal or internal use.
 

BASIC PROTOCOL & NOTATION

The trading API is a subset of QuoteTracker Streaming API, so please refer to the Streaming API Documentation for basic protocol notation and connection information
 

TRADING SESSIONS

Once you are connected and logged into the Streaming API session, you can START multiple trading sessions. Each trading session can be with a different broker, or same broker but different account. When starting the trade session, you have to specify the broker configuration file to use and the User ID, Password (and Account Number if needed) for the account that should be logged in. The account in question does NOT have to be pre-defined in QuoteTracker.
 

INBOUND MESSAGES (Client Application to QT Server)

All messages, commands, transactions, etc. sent from the client application TO QT Server should be in XML Format. All Trade API commands will be inside of TRADEAPI top level tag, with an ACTION tag inside it. All other tags will depend on the value of the ACTION tag. QuoteTracker accepts the following top level ACTION commands:

START- Starts a new trading session
STOP- Stops an existing trading session
SEND- Sends a command to QuoteTracker (NEWORDER, CANCEL, etc)

OUTBOUND MESSAGES (QT Server to Application)

QT will return various types of data records both to requests outlined in Inbound Messages as well as unrequested notification messages, such as Shutdown, disconnect, and other status messages. The following is a list of all messages returned:

OK- ID=OK (ASCII): Session START/STOP acknowledgement.
NOTIFICATION- ID=XN (ASCII): Notification - all results, errors (from broker or parsing), etc.
ERROR- ID=ER (ASCII): Any Errors

BROKER SPECIFIC COMMUNICATION

Because of the differences in offerings between brokers and the drastic differences in the type of information that the brokers make available about the transactions, balances and positions, it is necessary to make the various commands and data responses specific to each broker. We try to use common tags and tag values wherever possible.

TD AMERITRADE - AMTRADE.TRD
Interactive Brokers - IB.TRD
Lowtrades - LOWTRADES.TRD - QT Ver 3.6.1G and above
MB Trading - MBT.TRD and EFX.TRD - QT Ver 3.5.8 and above
optionsXpress - OPTXPR.TRD
Penson/Meridian - RML Trading (RMLPN.TRD), OC Securities (OCSEC.TRD)

INBOUND MESSAGE DESCRIPTIONS (Client Application to QT Server)

Start a new trading session (START) Back to Top

 Field Name  Field Description 
 ACTION START
 ID A unique Session ID generated by the Client Application that will be used to reference this session in all subsequent communications
 TRDFILE The name of the Trading Configuration File for the broker for which the session should be established (example: AMTRADE.TRD)
 NAME User ID for the brokerage account that this session will access
 PASS Password for the brokerage account that this session will access
 ACCT Account number for the brokerage account that this session will access
 REFRESH Refresh rate (in seconds) for the transaction info. Only relevant for auto-refreshing TRD files, such as AMTRADE.TRD. If not specified, then the user specified settings in QT are used

You must START the trading session prior to sending any other TRADEAPI commands.

PLEASE NOTE: If connecting to multiple accounts at the same broker at the same time, you should make sure that the START commands for each account are called serially. If you call one while another is still running, the session may end up getting tied to the wrong account. You should ALWAYS wait until you get a login successful or login failed notification for the START command before calling another START command
EXAMPLE:
     <TRADEAPI>
    <ACTION>START</ACTION>
    <ID>AMTDS1</ID>
    <TRDFILE>AMTRADE.TRD</TRDFILE>
    <NAME>AMTDUserName</NAME>
    <PASS>AMTDPassword</PASS>
    <REFRESH>10</REFRESH>
</TRADEAPI>
{FF}

 
STOP an existing trading session (STOP) Back to Top

 Field Name  Field Description 
 ACTION STOP
 ID Session ID specified when the session was STARTed 

NOTE: its best to explicitly stop the session. Just terminating the socket connection for the API will NOT terminate the session. QuoteTracker will still be connected to the broker and will continue to receive account info updates until the session is explicitly terminated or QuoteTracker is shut down.

EXAMPLE:
     <TRADEAPI>
    <ACTION>STOP</ACTION>
    <ID>AMTDS1</ID>
</TRADEAPI>
{FF}

 
Send a command/transaction to the broker (SEND) Back to Top

 Field Name  Field Description 
 ID Session ID specified when the session was STARTed 
 ACTION SEND
 TYPE The TYPE of action to be performed. Example: NEWORDER, MODIFYORDER, CANCELORDER
 PARAMS Various parameters (in indented XML tags) as defined by the specific Action Type and broker

EXAMPLE:
     <TRADEAPI>
    <ID>AMTDS1</ID>
    <ACTION>SEND</ACTION>
    <TYPE>NEWORDER</TYPE>
    <PARAMS>
        <SymbolType>STOCK</SymbolType>
        <Symbol>DELL</Symbol>
        <Action>BUY</Action>
        <OrderType>LIMIT</OrderType>
        <Quantity>500</Quantity>
        <LimitPrice>41.72</LimitPrice>
        <TIF>GTD</TIF>
        <TIFDate>12/29/2004</TIFDate>
        <Route>SMART</Route>
    </PARAMS>
</TRADEAPI>
{FF}

 

OUTBOUND MESSAGE DESCRIPTIONS (QT Server to Client Application)

NOTE: The examples below will not show Record ID or Record Length for simplicity, even though they are sent with every message.

OK    ID=OK (ASCII) Back to Top

Result returned in XML.
 Field Name  Field Description 
 ID Session ID specified when the session was STARTed  
 ACTION The action being acknowledged 

Acknowledges when the trade session is started or stopped.
EXAMPLES:
     <TRADEAPI>
    <ID>AMTDS1</ID>
    <ACTION>STARTED</ACTION>
</TRADEAPI>

 
NOTIFICATION Message    ID=XN (ASCII) Back to Top

Result returned in XML.
 Field Name  Field Description 
 ID Session ID specified when the session was STARTed  
 TYPE Type of data being sent back 
 If TYPE=ERROR
 MESSAGE Error Message Text
 If TYPE=ACK
 MESSAGE Acknowledgement Text
 If TYPE=TRANSACTIONS
 MESSAGE  .... Tags specific to the broker 
 If TYPE=BALANCES
 MESSAGE  .... Tags specific to the broker 
 If TYPE=POSITIONS
 MESSAGE  .... Tags specific to the broker 

Basically all communication from QuoteTracker back to the client application will be sent via this message.
EXAMPLES:
     <TRADEAPI>
    <ID>AMTDS1</ID>
    <LOGIN>login successful</LOGIN>
</TRADEAPI>

OR

     <TRADEAPI>
    <ID>AMTDS1</ID>
    <LOGIN>login failed: NO</LOGIN>
</TRADEAPI>
In the case of this specific reply, whatever the reason for the login failure will be after the "login fialed: " text. Default (unspecified) failure will just have NO

OR

     <TRADEAPI>
    <ID>AMTDS1</ID>
    <TYPE>ERROR</TYPE>
    <MESSAGE>Unable to get Positions data</MESSAGE>
</TRADEAPI>

OR

     <TRADEAPI>
    <ID>AMTDS1</ID>
    <TYPE>BALANCES</TYPE>
    <BALANCES>
        <Entry>
            <Name>Available Funds</Name>
            <StartOfDay>45,203.19</StartOfDay>
            <Current>23,129.19</Current>
            <Projected>23,129.19</Projected>
        </Entry>
        ... More Entries ...
    </BALANCES>
</TRADEAPI>