Contact Us   Site Map
myTrack SDK FX - Tools Services Partners
C Docs
Overview
Functions
Brokerage
Appendix
C/C++
C Home
Downloads
Docs (html)
Platforms
Visual Basic
C/C++
Java
General
General Info
Resources
Billing
FAQ
Support
myTrack SDK Documentation

myTrack SDK
Programmer’s Reference
Version 3.00

PACT Consulting
12/07/2001

For a description of this version’s enhancements see ‘Version 3.00 Enhancements
See running the windows NT demos for important information about running the demo programs
Please report bugs, enhancements or suggestions to sdksupport@pactconsulting.com


Contents

Brokerage Related Functions
mtBrokerUseContest()mtBrokerUseRealAcct()
mtBrokerRequestAcctIDs()mtBrokerRequestAcctSummary()
mtBrokerRequestAcctPositions()mtBrokerCashTransactions()
mtRequestMarketMakers()mtBrokerEnterOrder()
Brokerage Order Response MessagesMtBrokerEnterCondOrder()
mtBrokerCancelOrder()mtBrokerRequestTransactionData()
mtBrokerRequestOrder()Documentation Table of Contents


mtBrokerUseContest()
Tells the system that you want to use only the contest accounts

Prototype:

int mtBrokerUseContest(void);

Syntax:

errCode = mtBrokerUseContest();

This will affect ALL broker functions used until calling mtBrokerUseRealAcct().

The simulator is helpful when you are developing your application and do not want to test on a real account.


mtBrokerUseRealAcct()
Tells the system that you want to use real accounts, not the simulator.

Prototype:

int mtBrokerUseRealAcct(void);

Syntax:

errCode = mtBrokerUseRealAcct();

Warning: after calling this function you are no longer in contest mode. You’re doing real live trading! We strongly suggest you thoroughly test your application in contest mode before going live.

This will affect ALL broker functions used, until calling mtBrokerUseContest().


mtBrokerRequestAcctIDs()
Returns list of valid trading accounts for your myTrack ID

Prototype:

int mtBrokerRequestAcctIds (short brqn); // broker request #

Syntax:

errCode = mtBrokerRequestAcctIds(brqn);

The server responds with one message of type MSG_BROKER_ACCT_IDS per valid account:
{
short error;
short num;number of Ids in message
char acct[20][16];account id's (up to 20 max)
} BROKER_ACCT_IDS;


mtBrokerRequestAcctSummary()
Request an account summary

Prototype:

int mtBrokerRequestAcctSummary(short brqn, // broker request #
char * acctId); // account ID

Syntax:

errCode = mtBrokerRequestAcctSummary(brqn, acctId);

The server responds with one message of type MSG_BROKER_ACCT_SUMMARY:
{
short error;
short spare;
double cost;
double marketValue;
double realizedPL;
double unrealizedPL;
double cash;
double buyingPower;
double BPwithOpenOrders;
char cAccount[16];
} BROKER_ACCT_SUMMARY;


mtBrokerRequestAcctPositions()
Requests a list of positions for an account

Will return open, closed, or all positions for a specified account. A long and short position for a specific ticker will be returned as 2 position records.

Prototype:

int mtBrokerRequestAcctPositions(short brqn,
char * acctId, // account id
char flag // 1 - open, 2 - closed, 3 - all
);

Syntax:

errCode = mtBrokerRequestAcctPositions(brqn, acctId, flag);

The server responds with one message of type MSG_BROKER_ACCT_POSITION for each position:
{
short error;
char eof;1 - valid position, 2 - no more positions
(message where eof = 2 does not contain a position)
char spare;
BROKER_POSITION position;a position record
} BROKER_ACCT_POSITION;

The BROKER_POSITION packet is as follows:
{
char acct[16];
char ticker[10];
char instrumentType;see instrumentType defines
char spare1;
int qty;quantity of shares or # of option contracts
float avgPrice;average price
float unrealPL;unrealized profit & loss
float realPL;realized p&l
char spare2[12];
char longShort1 - long, 2 - short
} BROKER_POSITION;

instrumentType
STOCKS1MONEY_MARKETS5
OPTIONS2INST_INFO6
BONDS3INST_FUTURES7
MUTUAL_FUNDS4
 


mtBrokerCashTransactions()
Requests list of cash transactions between given dates

Prototype:

int mtBrokerCashTransactions (short brqn,
char * acctId, // account id
char * sdate, // Start date mm/dd/yy
char * edate // end date mm/dd/yy
);

Syntax:

errCode = mtBrokerCashTransactions(brqn, acctId, sdate, edate);

The server will return one or more messages of type MSG_BROKER_CASH_TRANSACTION:
{
short error;
char eof;1 - valid transaction, 2 - no more transactions
char spare;
BROKER_CASH_TRANSACTION trans;cash transaction packet
} BROKER_ACCT_CASH_TRANSACTION;

The BROKER_CASH_TRANSACTION packet is as follows:
{
char acct[16];
short date[3];
double amount;
char description[60];
} BROKER_CASH_TRANSACTION;


mtRequestMarketMakers()
Request Market Maker definitions to use for brokerage order routing
See mtBrokerEnterOrder() for routing instructions

Prototype:

int mtRequestMarketMakers (int rqn,
char flag); // indicates which Market/Network requesting MMs for

see below for valid flags

Syntax:

errCode = mtRequestMarketMakers(rqn, flag);

Market Defines (used in flag):
#define NASDAQrequesting nasdaq mm's
#define OTC_BBrequesting otc_bb mm's
#define LISTEDrequesting listed mm's
#define OPTIONSrequesting options mm's
#define ECNrequesting ECN destinations

The server responds with a MARKET_MAKER message for each mm available in the Market/Network specified by the flag.
{ short error;
char flag;which market is being sent, same as request
char eod;end of data: 1 - more to come, 2 - last entry
char code;see below
char name[20];name of market maker
short fee;10's of cents per share i.e. 7 = $.007. only for ECN's
} MARKET_MAKER;

MARKET_MAKER.code: when routing an order use this code to specify MM's and enable ECN's.


mtBrokerEnterOrder()
Enters an order

Response for a successful order is one or more messages of the following types:

MSG_BROKER_ACK_ORDER_BY_MYTRACK
MSG_BROKER_ACK_ORDER_BY_BROKER
MSG_BROKER_ORDER_EXEC

Response for a rejected order is one or more messages of the following types (at least one message will be sent):

MSG_BROKER_ACK_ORDER_BY_MYTRACK
MSG_BROKER_ERROR_MESSAGE

See Brokerage Order Response Messages for details.

Prototype:

int mtBrokerEnterOrder (short brqn, // broker request #
BROKER_ORDER * Order // passed structure
);

Syntax:

ErrCode = mtBrokerEnterOrder(brqn, Order);

The structure passed to this call to make the order is:
{
char turnaround[4];use to identify orders, see below
char acct[16];account id
char ticker[10];ticker - i.e. "IBM", for options "IBM AT"
char actionCode;1 - buy, 2 - sell, 3 - buy to cover, 4 - sell short
char instrumentType;see instrumentType defines
char fillKill;1 - fill or kill, otherwise 0
char AllNone;1 - all or none, otherwise 0
char orderType;see orderType defines
char dayGTC;0 - day order, 1 - good till cancel
char mmNasdaq;specific Nasdaq destination. 0 - system default, otherwise use MARKET_MAKER.code
char mmOtc;specific OTC BB destination. 0 - system default, otherwise use MARKET_MAKER.code
char mmListed;specific Listed destination. 0 - system default, otherwise use MARKET_MAKER.code
char mmOptions;specific destination for Options. 0 - system default, otherwise use MARKET_MAKER.code
short ecnMap;enable ECN: turn on bits corresponding to MARKET_MAKER.code to specify routing destinations; see below
char MarketMaker[4];for orders placed from the nasdaqII or order book windows
int orderQty;# of shares or # of option contracts
float limitPrice;if limit order, if not - set to 0
float stopPrice;if stop order
char spare1[12];
The fields below are set by the server
char orderId[16];unique ID for this order
short orderDate[3];order date - month day year
short spare2;
int orderTime;10ths of seconds from midnight
int filledQty;quantity executed (will increase as order executes)
char spare3[12];
} BROKER_ORDER;

orderType defines:
#define MARKET_ORDER1#define STOP_MARKET_ORDER4
#define LIMIT_ORDER2#define MARKET_SWEEP_ORDER5
#define STOP_LIMIT_ORDER3#define LIMIT_SWEEP_ORDER6

char turnaround[4]:
This is used to map the OrderID to the RQN of the mtBrokerEnterOrder(). It is needed since the Broker messages do not contain the RQN used in mtBrokerEnterOrder().
Use as follows:

  1. When you place the order you supply the 'turnaround'. This can be any value you choose (EX: the RQN of the order, time...).
  2. When the ACK msg from myTrack returns it will contain the OrderID and the 'turnaround' which you can now use to track the Broker messages to the mtBrokerEnterOrder() call.
Brokerage Order Response Messages:

For rejected orders:
At least one message will be sent, message will be one of the following types:

MSG_BROKER_ACK_ORDER_BY_MYTRACK: order acknowledgement from myTrack
{
BROKER_ORDER order;not valid for a rejected order
char errorCode;See broker error codes
char numBytesText;# of bytes in misc text
char miscText[80];error/rejection description
} BROKER_ACK_ORDER;

MSG_BROKER_ERROR_MESSAGE: error message from broker
{
char numBytes;# of bytes in error text
char errorText[80];reason for order rejection
} BROKER_ERROR_MESSAGE;

No other messages will be sent for a rejected order.

For successful orders:
The first message will be a MSG_BROKER_ACK_ORDER_BY_MYTRACK, which will contain in the ‘order’ component the original values you supplied to mtBrokerEnterOrder(), and the myTrack assigned values for the orderID and orderDate.

MSG_BROKER_ACK_ORDER_BY_MYTRACK: order acknowledgement from myTrack
{
BROKER_ORDER order;the original order, myTrack adds the orderID and orderDate
char errorCode;0 for successful orders
char numBytesText;length of text
char miscText[80];order routing information
} BROKER_ACK_ORDER;

The acknowledgment from myTrack will be followed by a message MSG_BROKER_ACK_ORDER_BY_BROKER, which will update in the “order” component the values the broker has assigned for orderTime.

MSG_BROKER_ACK_ORDER_BY_BROKER: order acknowledgment from the broker
{
BROKER_ORDER order;the original order, the broker updates the orderTime
char errorCode;0 - no error
char numBytesText;length of text
char miscText[80];usually blank
} BROKER_ACK_ORDER; <>As an order executes, the server will send additional (unsolicited) messages of the type MSG_BROKER_ORDER_EXEC. The 'order' component in this structure will contain the elements of the original order, but the filledQty will increase as the order executes.
The ‘trans’ component will populate the transaction elements.

MSG_BROKER_ORDER_EXEC: order execution message
{
BROKER_ORDER order;the original order
BROKER_TRANSACTION trans;the transaction for this execution
char numBytesText;length of text
char miscText[80];order execution info
} BROKER_ORDER_EXEC;

If the order is cancelled by the broker for any reason you will receive a MSG_BROKER_ORDER_CANCELLED

MSG_BROKER_ORDER_CANCELLED:
{
BROKER_ORDER order;the original order
char errorCode;0 - no error
char numBytesText;length of text
char miscText[80];will contain error/rejection description
} BROKER_ORDER_CANCEL;

IMPORTANT:

  1. Before your application places its first order make sure:
    1. set the account type: simulator - mtBrokerUseContest() or real accounts - mtBrokerUseRealAcct()
    2. call mtBrokerRequestAcctIds()
  2. Check for rejected orders by parsing for a non-zero errorCode on the myTrack ack message, AND by handling messages of type MSG_BROKER_ERROR_MESSAGE.
Changing the default routing settings:
Please Note:
  • Specifying the order routing destinations can result in additional fees, changes in order processing etc.
  • You must specify your settings in every order that you wish to change from Track Data’s default order routing system. Settings will not be stored/retrieved by the trading system.
  • There are certain conditions that must be met for the individual destinations.
  • Make sure you fully understand this feature before attempting to use.
See myTrack Help (F1) or contact Track Data Trading Department for further information.

Setting the default Routing and enabling ECN's:

  1. Call mtRequestMarketMakers()
    • Set flag to the market for which you want a list of Destinations. (Nasdaq, OTC, Listed… see Market Defines in mtRequestMarketMaker())
    • The server will return MARKET_MAKER messages for all destinations in that market.
  2. Set the BROKER_ORDER.mmXXX to the MARKET_MAKER.code of the destination you wish to set as the default routing destination.
  3. If you are setting an ECN as a default you will also have to enable that particular ECN in the ecnMap:
    1. Call mtRequestMarketMakers(), flag = ECN (5)
    2. Turn on the bit in BROKER_ORDER.ecnMap corresponding to the ECN’s MarketMaker.code.
    3. The bit for SelectNet is 14 (0 base, 0-15), this value is not returned by mtRequestMarketMakers().
  4. Place the order.

Routing to specific MMs/ECNs:

You can route your order to specific ECNs using the MarketMaker[4] field:

  1. Enable the bit for SelectNet in the BROKER_ORDER.ecnMap (bit 14, 0 base). SelectNet will be used to route to the assorted ECN destinations.
  2. Set the MarketMaker[4] field to the 4 char MM/ECN id (ex: ISLD, BRUT…).
  3. Place the order.

Notes:

  • The ‘MM exclusion’ feature has not yet been implemented.
  • Order routing does not apply to simulated trading.

mtBrokerEnterCondOrder()
Enter a conditional order.

Prototype:

int mtBrokerEnterCondOrder (short brqn,
BROKER_ORDER * Order1 // first order, see BROKER_ORDER structure
BROKER_ORDER * Order2 // second order
int condFlag // type of condition. 1 - OSO, 2 - OCO
);

Syntax:

errCode = mtBrokerEnterCondOrder(brqn, Order1, Order2, condFlag);

In an OSO trade, the first trade is submitted and executed then the second trade is submitted. The server will respond with a MSG_BROKER_ACK_ORDER_BY_MYTRACK and MSG_BROKER_ACK_ORDER_BY_BROKER for the first order. When that order is executed you will receive a MSG_BROKER_ORDER_EXEC for the first order and MSG_BROKER_ACK_ORDER_BY_MYTRACK and MSG_BROKER_ACK_ORDER_BY_BROKER for the second order. When the second order is executed you will receive a MSG_BROKER_ORDER_EXEC for the second order.

In an OCO trade, the orders must be non-market orders and both orders are submitted to the broker. The execution of one will trigger the cancellation of the other. The control responds with MSG_BROKER_ACK_ORDER_BY_MYTRACK and MSG_BROKER_ACK_ORDER_BY_BROKER for each order. For the order that gets executed first, you will receive a MSG_BROKER_ORDER_EXEC, you will get a MSG_BROKER_ACK_ORDER_BY_BROKER for the cancellation of the other order.

For more info on conditional orders, run the myTrack program and select:
chat / Functions / View Topics / trade / trade types


mtBrokerCancelOrder()
Cancels an open order

Prototype:

int mtBrokerCancelOrder (short brqn,
char * acctId, // account id
char * OrderId // passed order id
);

Syntax:

errCode = mtBrokerCancelOrder(brqn, acctId, orderId);

The server will first return MSG_BROKER_ACK_CANCEL_BY_MYTRACK, to indicate acknowledgement of the receipt of the cancellation order by myTrack. The server will then return either MSG_BROKER_ACK_CANCEL_BY_BROKER to indicate acknowledgement of the receipt of the cancellation order by the broker, or MSG_BROKER_REJ_CANCEL_BY_BROKER, which indicates that the cancel has been rejected by the broker. All of these messages have the form:
{
BROKER_ORDER order;
char errorCode;0 - ok
char numBytesText;length of text
char miscText[80];will contain error/rejection text if cancel is not accepted.
} BROKER_ACK_CANCEL;

If the broker accepts the cancel, then the final status of the cancellation will be confirmed by a message of type MSG_BROKER_ORDER_CANCEL:
{
BROKER_ORDER order;
char errorCode;0 - ok
char numBytesText;length of text
char miscText[80];
} BROKER_ORDER_CANCEL;


mtBrokerRequestTransactionData()
Requests transaction history

Prototype:

int mtBrokerRequestTransactionData(short brqn,
char * acctId, // account id
char * symbol, // Optional ticker symbol
char * sdate, // Start date mm/dd/yy
char * edate // End date mm/dd/yy
);

Syntax:

errCode = mtBrokerRequestTransactionData(brqn, acctId, symbol, sdate, edate);

The server will return one or more messages of type MSG_BROKER_TRANSACTION:
{
short error;
char eof;1 - transaction, 2 - no more transactions
char spare;
BROKER_TRANSACTION trans;a transaction packet
} BROKER_ACCT_TRANSACTION;

The BROKER_ACCT_TRANSACTION structure: {
char orderId[16];
char acct[16];
char instrumentType;see instrumentType defines
char transType;see below
char ticker[10];
short transDate[3];
short spare1;
int transTime;
int qty;
float tradePrice;
float commissions;
float fees;
float actionCode;1 - buy, 2 - sell, 3 - buy to cover, 4- sell short
char spare2[23];
} BROKER_TRANSACTION;

The defined transaction types in field transType are:
ACKD_BY_BKR1CANCEL_ACKD_BY_BKR11
EXECUTED_BY_BKR2CANCEL_REJECTED_BY_BKR12
CANCELLED_BY_USER3NOTHING_DONE13
REJECTED_BY_BKR4CREDIT_MMKT14
CANCELLED_BY_BKR5DEBIT_MMKT15
CREDIT_CASH6ACAT_IN16
DEBIT_CASH7ACAT_OUT17
REJECTED_BY_TDC8TRADE_REVERSED18
CANCEL_ACKD_BY_TDC10REVERSE19
 


mtBrokerRequestOrder()
Requests order information for an account

Prototype:

int mtBrokerRequestOrder(short brqn,
char * acctId, // account id
char * sdate, // Start date mm/dd/yy
char * edate, // End date mm/dd/yy
BYTE RequestType // 1 = open orders,
2 = completed orders, 3 = other orders
);

Syntax:

errCode = mtBrokerRequestOrder(brqn, acctId, sdate, edate, requestType);

The server will return one or more messages of type MSG_BROKER_ORDER_DATA:
{
short error;
char flag;1 - open order, 2 - end of orders,
3 - completed order
char spare;
BROKER_ORDER_RECORD order;
} BROKER_ACCT_ORDER;

The BROKER_ORDER_RECORD structure: {
char turnaround[4];
char acct[16];
char ticker[10];
BYTE actionCode;see action code defines
BYTE instType;see instType defines
char orderID[16];
short orderDate[3];
short closedDate[3];
short settleDate[3];
int orderTime;milliseconds past midnight
int closedTime;
int orderQty;
int filledQty;
float limitPrice;
float stopPrice;
float execPrice;execution price
BYTE fillKill;1 - FillOrKill, otherwise 0
BYTE AllNone;1 - AllOrNone, otherwise 0
BYTE dayGTC;0 - day order, 1 - GTC
BYTE orderType;see order types
UCHAR orderStatus;
BYTE bRejectionCode;
float commissions;
float fees;
float price;
char brokerConfirm[16];
} BROKER_ORDER_RECORD;



Complete Documentation Table of Contents

Overview
SDK FunctionalityArchitecture
InstallationGetting Started
Running the Windows NT DemosProgramming Basics
Function Summary
getVersion() (2.41)mtGetVersion() (3.00)
mtInit()mtDeInit()
mtSetHost()mtSetProxy()
mtSetUsingTunnel()mtIsConnected()
mtConnectToServer()mtDisconnect()
mtGetMessage()mtGetStats()
mtRequestLogon()mtRequestLogoff()
mtRequestHistoricalData()mtRequestQuoteData()
mtRequestBackground()mtRequestIntradayUpdate()
mtRequestNewsHeadlines()mtRequestNewsByTicker()
mtRequestNewsStory()mtRequestNewsVendors()
mtRequestSymbolLookup()mtRequestOptionData()
mtRequestOptionLinks()mtRequestFutureFamilyData()
mtRequestIntradayData()mtRequestIntradayDataTime()
mtRequestDataWarehouse()mtRequestTransactionLog()
mtRequestNasdaqLevel_2()mtRequestOrderBook()
mtRequestNewsByVendor()mtRequestHistoricalNews_Ticker()
mtRequestHistoricalNews_Story()mt3rdParty_MarketPulse()
mt3rdParty_ZacksEarnings()mt3rdParty_EdgarOnline()
mt3rdParty_ HemingtonScott()mtRequestVolatilityDisplay()
mtRequestCompositeFamilyData()mtRequestYesterdaysLogs()
 
Market CodesSales Codes
Error codesBrokerage error codes
myTrack DLL descriptionRevision History