RealTick Scripting QuickStart Guide

22
RealTick® Scripting QuickStart Guide

Transcript of RealTick Scripting QuickStart Guide

Page 1: RealTick Scripting QuickStart Guide

RealTick® Scripting QuickStart Guide

Page 2: RealTick Scripting QuickStart Guide

1

© 2012 RealTick LLC. All rights reserved.

ConvergEx Group is a global technology firm. Its companies focus on providing software products and

technology-enabled services in the following areas: global execution, commission management,

independent research, transition management, trade order management, portfolio margining and prime

services. These businesses do not engage in market making, investment banking or “at risk” proprietary

trading. When executing trades, one or more ConvergEx Group companies may operate in an agency,

riskless principal and/or net trading capacity in search of liquidity for customers.

ConvergEx Group in the United States comprises ConvergEx Execution Solutions LLC (member

NYSE/FINRA/SIPC); LiquidPoint, LLC (member CBOE/SIPC); G-Trade Services LLC (member FINRA/SIPC);

Westminster Research Associates LLC (member FINRA/SIPC); Eze Castle Transaction Services LLC (member

FINRA/SIPC); ConvergEx Prime Services LLC (member FINRA/SIPC); Eze Castle Software LLC, RealTick LLC

and ConvergEx Solutions LLC, of which Cogent Consulting, ConnEx, Jaywalk and LDB are divisions.

ConvergEx Group, LLC is a subsidiary of ConvergEx Holdings, LLC.

In London, ConvergEx Group operates its subsidiary ConvergEx Limited, a U.K. broker-dealer that is

registered in England and Wales No 06262150, authorised and regulated by the Financial Services

Authority, and operates in Australia under an exemption from the requirement to hold an Australian

financial services licence under the Corporations Act 2001. In Hong Kong, ConvergEx Group operates its

subsidiary ConvergEx Asia Pacific Limited, a Hong Kong broker-dealer regulated by the Securities & Futures

Commission.

Any trademarks or service marks used by a ConvergEx Group, LLC company are owned by the company

using the mark unless indicated otherwise.

The material, data and information (collectively “ConvergEx Information”) contained on or available

through ConvergEx Group businesses may not be suitable for all investors, are for informational purposes

only and are subject to change at any time, are not intended to provide tax, legal or investment advice,

and do not constitute investment advice or a solicitation or offer to purchase or sell securities. The

ConvergEx Information is believed to be reliable but none of the ConvergEx Group businesses warrant its

completeness or accuracy. Please read your agreement with us carefully, as it contains important

information and disclosures about the product or service covered by it.

Page 3: RealTick Scripting QuickStart Guide

2

© 2012 RealTick LLC. All rights reserved.

Table of Contents

CHAPTER 1: INTRODUCTION ............................................................................4

ABOUT THIS MANUAL .......................................................................4 Sections in this Document .........................................................4

SCRIPTING OVERVIEW .....................................................................4 PROCESS FLOW ..............................................................................5

CHAPTER 2: REQUIREMENTS & APPLICATION SETTINGS ...........................5

REALTICK REQUIREMENTS ...............................................................5 REALTICK APPLICATION SETTINGS ...................................................6

CHAPTER 3: ORDER API DETAIL ......................................................................8

PROPERTIES ...................................................................................8 METHODS .......................................................................................8 PRICE TYPE ..................................................................................17 EXPIRATION TYPE .........................................................................18 VOLUME TYPE ..............................................................................18 RESERVE ORDER ..........................................................................18 CONDITIONAL ORDERS ..................................................................18

CHAPTER 4: XML FILES ...................................................................................19

TRADING SUBDIRECTORY ...............................................................19 XML STATUSES ............................................................................19 XML MAPPING ..............................................................................20

CHAPTER 5: REALTICK PERMISSIONS STATE .............................................20

POLL PERMISSIONS STATE.............................................................20

CHAPTER 6: WINDOW CREATION/MANIPULATION ......................................20

FUNCTIONS ...................................................................................21

CHAPTER 7: SYSTEM INFORMATION .............................................................22

Page 4: RealTick Scripting QuickStart Guide

4

© 2012 RealTick LLC. All rights reserved.

Chapter 1: Introduction

About this Manual This document is intended for third party programmers. It contains instructions for communicating with RealTick using the COM interface built into rt332.exe.

Sections in this Document

The following table lists the sections available in this document.

Chapter Description

Chapter 1: Introduction Defines scripting and fundamentals concerning RealTick and scripting.

Chapter 2: Requirements & Application Settings

Defines requirements and settings in RealTick needed for scripting.

Chapter 3: Order API Detail Discusses using the RealTick automation interface for Order Entry.

Chapter 4: XML Files Discusses configuring RealTick to log orders to an XML file.

Chapter 5: RealTick Permissions State Provides you with the methods and events to determine if RealTick is able to receive commands.

Chapter 6: Window Creation/Manipulation Describes creating/manipulating child windows in RealTick.

Chapter 7: System Information Defines properties that provide system information.

Scripting Overview Scripting for RealTick is implemented through Microsoft COM, a popular automation technology that allows access from many common development environments such as Visual Basic and Visual C++. The RealTick COM automation interface, also known as RealTick Scripting, allows another application to tell RealTick to perform actions that would normally require the user to use the mouse or keyboard.

RealTick (rt332.exe) exposes an out of process COM server, which becomes usable if the RealTick Scripting permission is present on your RealTick login account. The COM server itself, if permissioned, can be used by default to implement certain basic communications with RealTick (discussed in chapters 5- 6) and optionally to communicate with the RealTick Order Entry System (discussed in chapters 3-4). Additional permissions from the brokerage account side may be required before your client application can use RealTick Scripting to place orders.

If RealTick has been properly installed and registered on your system, you can view the programming interface of RealTick even if your account is not yet permissioned. The Object Browser in Visual Basic and

Page 5: RealTick Scripting QuickStart Guide

5

© 2012 RealTick LLC. All rights reserved.

Visual Interdev, as well as the COM Object viewer (oleview) will show all properties, methods, and events. The RealTick COM server implements a single publicly creatable class, Realtick (ProgID: “TAL.Realtick.1”).

To register the RealTick out of process COM server, you must be logged in as Administrator. The command to register the RealTick COM server is:

rt332.exe /regserver

The RealTick COM server notifies client applications of changes by raising COM events. For example, RealTick currently fires events pertaining to Order Entry. When an order is filled, three separate events can be fired to notify the client of the fill, the position change, and the account balance change.

Process Flow An order is submitted from the client application to RealTick. The order is received and routed by RealTick. The status is returned to the client application. The order information is returned to the application by the OnNewTradeEx event. RealTick passes in the OrderId (buy or sell), the Symbol traded, the total amount of shares traded, the average price, and the status of the order.

Client Application RealTick

Order filled.

Chapter 2: Requirements & Application Settings

This chapter discusses requirements and settings in RealTick needed for scripting.

RealTick Requirements The following are the requirements in RealTick you need for scripting:

o The current released version of RealTick should be installed.

Scripting is supported for all versions of RealTick after 7.5.13.1.

o REALTICK/SCRIPTING permission on RealTick logon

Page 6: RealTick Scripting QuickStart Guide

6

© 2012 RealTick LLC. All rights reserved.

o (For Order Entry scripting) REALTICK/ORDERENTRYSCRIPTING permission on RealTick logon

o For the Order Entry Scripting capability to work, each separate account that is to be traded by

Scripting must have the AllowScriptedOrders permission.

RealTick Application Settings The following procedures define settings in RealTick needed for scripting.

Set System Defaults for Scripting

1. Select Set System Defaults from the Control menu on the RealTick Title bar. The Set Defaults dialog box will appear.

Set Defaults Dialog Box

2. Click the Allow Scripting check box.

3. Click the Allow Order Entry Scripting check box.

4. The Require Password for Order Scripting check box should be checked if your application will submit the correct password with each order placed, as a parameter to the SendOrder() method call. It is recommended to leave this box checked. If you uncheck this box, the setting cannot be saved. The box will be checked again the next time you start RealTick and you will have to uncheck it again.

5. If your application will run unattended, check the Allow Unattended Script Orders box. This will disable all modal forms in RealTick. If your application sends an order that RealTick does not understand while running unattended, RealTick will throw back a COM exception, which you can trap in your application.

6. Click OK.

Page 7: RealTick Scripting QuickStart Guide

7

© 2012 RealTick LLC. All rights reserved.

The system defaults are set.

Password Behavior

Normally the best option is to check Require Password for Order Scripting and pass the correct password into each call to SendOrder(). However, this only works if you also passed the same password into the RealTick Logon dialog box to begin your current session. This is not the case if you use AutoLogon, and is also not the case if your application brings up the general TAL logon before bringing up the RealTick Logon. It is not recommended to use AutoLogon on accounts that will run Scripting applications, or to bring up the general TAL logon before bringing up the RealTick Logon. However, if you do those things, the password used to access RealTick is not passed into the RealTick Logon dialog box, and therefore you will have to uncheck Require Password for Order Scripting each time you start RealTick.

Change the Order Confirmation Status

To allow order entry to proceed without user interaction, you may want to change the order confirmation status.

1. Select Order Entry Properties from the Order Book menu.

The Order Entry Properties dialog box will appear.

Order Entry Properties Dialog Box

2. Select the Warnings/Confirmations tab.

3. Verify that Confirm All Trades is NOT checked.

Page 8: RealTick Scripting QuickStart Guide

8

© 2012 RealTick LLC. All rights reserved.

4. Verify that any other Price Warnings or Trade Size Limits that may require user interaction are not set.

5. Click OK.

The Order Confirmation Status is not set.

tal.ini Settings

In the [TRADING] section of the tal.ini, the PendingOrderLimit=parameter can be added or modified to control how many pending orders are allowed to exist before the user interface is notified.

Chapter 3: Order API Detail

This chapter discusses the different members of RealTick that are relative to Order Entry. It also gives scripting examples for Reserve and Conditional orders.

Properties These three properties must be set to 1 in order to turn on their corresponding event. For example, in order to receive an OnNewBalance event, the BalanceUpdate property has to be set to 1.

Property Description

BalanceUpdate Property BalanceUpdate As Long

PositionUpdate Property PositionUpdate As Long

TradeUpdate Property TradeUpdate As Long

Methods The following table describes the different methods relative to Order Entry.

Method Description Notes

Page 9: RealTick Scripting QuickStart Guide

9

© 2012 RealTick LLC. All rights reserved.

CancelAllOrders Function CancelAllOrders(iCacheContex t As Long, bsAccount As String, bsSymbol As String) As Long

ICacheContext is reserved for future use, and should be 0. bsAccount: specifies the account in which you want to cancel all orders. This must be specified. bsSymbol: specifies the symbol for which you want to cancel all orders. If the empty string is passed, cancels orders for all symbols in the specified account. Returns: 0 for success, nonzero for failure.

CancelOrder Sub CancelOrder(bsOrderID As String, bsReason As String)

bsOrderID: the server side ID returned from the OnNewTrade() or OnNewTradeEx() event. bsReason : free text (can be any string you want to pass in). When reporting the cancel, however, RealTick will always report the reason as “CanceledByUser”.

CreateChangeOrder Function CreateChangeOrder(bsOrderID As String) As Long

bsOrderID: the server side ID returned from the OnNewTrade() or OnNewTradeEx() event. Returns: a new client side order handle similar to that created by CreateOrder(). After creating the handle for the change order, call one or more SetOrder* calls to change the properties of the order. You may not call SetOrderSymbol(). If and only if the original order was not placed by the current application instance, you must call SetOrderSymbolAttributes (). Once you are done setting up the change, call SendOrder() on the change order handle.

CreateConditionalOrder Function CreateConditionalOrder(bsCondi tionSymbol As String, iFieldID As Long, iRelation As Long, dVal As Double, lOrderToPlace As Long, bsAccount As String) As Long

See explanation in Conditional Orders section below.

CreateOrder Function CreateOrder() As Long Returns: a client side order handle, on which you call SetOrder*() methods before sending the order.

Method Description Notes CreateOrderEx Function

CreateOrderEx(bsSymbol As String, bsBuySell As String, dPrice As Double, iPriceType As TorderPriceType, dAuxPrice

If you need to pass vOrderType, pass a numeric 0, unless you are placing a MakeMarket (ePrcQuote) order. If you are placing a MakeMarket order, use CreateOrder and set the parameters individually rather than using

Page 10: RealTick Scripting QuickStart Guide

10

© 2012 RealTick LLC. All rights reserved.

As Double, lVolume As Long, iVolType As TOrderVolumeType, bsRoute As String, iExpiration As TOrderExpirationType, bsPref As String, bsAccount As String, [optional] vOrderType) As Long

CreateOrderEx. Returns: a client side order handle with preset properties. You can still call SetOrder*() methods to change or add parameters before sending the order.

CreateOrderFromHotKey Function CreateOrderFromHotKey(bsAcc ount As String, bsSymbol As String, bAlt As Long, bCtl As Long, bShift As Long, cHotKey As String) As Long

Used to take advantage of RealTick’s OES Hot Keys feature.

Returns: a client side order handle with properties preset by the hot key combination specified in the bAlt, bCtl, bShift and cHotKey parameters. Any remaining properties can be set or changed by calling SetOrder*() methods before sending the order.

CreateOrderTicket Function CreateOrderTicket() As Long

This function is used to create a staged order ticket. It works just like CreateOrder(), except it creates an order with a staged order action type. You still call the same SetOrder*() functions to set the properties of the order.

When calling SetOrderAccount() on an order created with CreateOrderTicket(), it sets the account to which this ticket is being assigned. This should normally not be your own account (unlike with CreateOrder()). The trader who is trading in the account to which the ticket is being assigned will get an alert that a new ticket has been assigned, and will be able to see all of the order information in the RealTick ticket minder.

FreeMemOrder FreeMemOrder(lOrder As Long)- no longer used

Sub It is no longer necessary to ever call this method.

GetAccounts Function GetAccounts() As String

Returns a newline delimited list of All BANK;BRANCH;CUSTOMER;DE POSIT accounts assigned to the current logged on user.

Method Description Notes GetBalance Function GetBalance(bsAccount

As String) As Double Gets the current excess equity figure for the specified account.

GetOrders Function GetOrders(bsAccount As String, bsSymbol As String, iEventType As TtradeEventType,

bsAccount is of the form Bank;Branch;Customer;Deposit

Page 11: RealTick Scripting QuickStart Guide

11

© 2012 RealTick LLC. All rights reserved.

iStatusType As TorderStatusType) As String

This function knows about all orders that currently exist anywhere in your RealTickOrderBook. Using the iEventType and iStatusType parameters, you can control which orders are returned to you.

To retrieve orders for all accounts mapped to this user, pass in the empty string for bsAccount. To retrieve orders for all symbols, pass in the empty string for bsSymbol.

If you specify a symbol and have not placed any orders on that symbol, the empty string is returned. Returns: <OrderID>,<Symbol></n> <OrderID>,<Symbol></n> You can call GetOrderFieldData() and pass in the OrderID to retrieve more information about each order.

GetOrderFieldData Function GetOrderFieldData(bsOrderID As String, lFieldID As Long, [lFlags As Long]) As String

This function takes a server side order ID and returns data from a field of an XML file as described in the “XML Files” section below.

lFlags is reserved for future use: pass in 0.

lFieldID: see “XML Files” section below or https://secure.toolkit.taltrade.com/tql/appn.html The field ID must be passed in as numeric data.

bsOrderID: the server side ID returned from the OnNewTrade() or OnNewTradeEx() event.

GetPositionFieldData Function GetPositionFieldData(bsAccount As String, bsSymbol As String, lFieldID As Long, lFlags As Long) As String

lFlags is reserved for future use: pass in 0. lFieldID: see “XML Files” section below or https://secure.toolkit.taltrade.com/tql/appn.html

The field ID must be passed in as numeric data. bsAccount: the BANK;BRANCH;CUSTOMER;DEPOSIT string of the account with the position.

bsSymbol: the symbol of the position.

Method Description Notes GetPositions Function

GetPositions(bsAccount As String, bsSymbol As String) As String

bsAccount is of the form Bank;Branch;Customer;Deposit This function knows about all positions that currently exist anywhere in your RealTick Position Minder. To retrieve positions for all accounts mapped to

Page 12: RealTick Scripting QuickStart Guide

12

© 2012 RealTick LLC. All rights reserved.

this user, pass in the empty string for bsAccount. To retrieve positions for all symbols, pass in the empty string for bsSymbol. If you specify a symbol and do not have any positions on that symbol, the empty string is returned.

Returns: <Symbol>,<Qty>,<AvgPrice></n> <Symbol>,<Qty>,<AvgPrice></n>

SendOrder Sub SendOrder(lOrder As Long, bNoConfirm As Long, bsPassword As String, [vbAsync[)

Sends order created by CreateOrder. If you do not want the order to be confirmed, set bNoConfirm to TRUE. The optional vbAsync parameter is generally no longer used and should be omitted.

SendOrderList Sub SendOrder(bsCSVOrderIDList As String, bNoConfirm As Long, bsPassword As String, [vbAsync[)

Sends a list of orders, each of which were created one at a time by CreateOrder(). The list (bsCSVOrderIDList) is a string which you can concatenate by joining string representations of your numeric order handles into a comma- separated list. The other parameters are the same as SendOrder(). The optional vbAsync parameter is generally no longer used and should be omitted.

SetOrderAccount Sub SetOrderAccount(lOrder As Long, bsAccount As String)

bsAccount is of the form Bank;Branch;Customer;Deposit

SetOrderAuxPrice Sub SetOrderAuxPrice(lOrder As Long, dAuxPrice As Double)

Sets non-limit price used for complex price types such as stop or discretionary. For example, on a stop order, this sets the stop price. On a peg order, this always sets the peg offset.

SetOrderBuySell Sub SetOrderBuySell(lOrder As Long, bsBuySell As String)

BsBuySell: ‘Buy’, ‘Sell’, or ‘SellShort’

SetOrderExpiration Sub SetOrderExpiration(lOrder As Long, iExpiration As TOrderExpirationType)

Sets order expiration to a member of the TorderExpirationType enum.

SetOrderFieldData Sub SetOrderFieldData(lOrder As Long, lFieldID As Long, bsValue As String)

Sets the value of an additional field in the order, adding the field if necessary. The client must know the field ID of the field they want to set (e.g. 23320).

Method Description Notes SetOrderMessage Sub SetOrderMessage(lOrder As

Long, bsMessage As String) Sets XML field 20691 equal to the content of bsMessage. The content of bsMessage is free text.

SetOrderOpenClose Sub SetOrderOpenClose(lOrder Sets open or close status for an option order to a

Page 13: RealTick Scripting QuickStart Guide

13

© 2012 RealTick LLC. All rights reserved.

As Long, iOrderOption As TOrderOpenCloseType)

member of the TorderOpenCloseType enum.

SetOrderOptionAttributes Sub SetOrderOptionAttributes(lOrder As Long, bsUnderSym As String, bsPutCall As String, dStrike As Double, dExpDate As Date)

Sets attributes for an option. This method should only be called when the symbol is an option.

SetOrderPref Sub SetOrderPref(lOrder As Long, bsPref As String)

Sets exchange preference. This method should be called when the route requires it. Normally called when the symbol is an option.

SetOrderPrice Sub SetOrderPrice(lOrder As Long, dPrice As Double)

Sets the limit price for order types that require a limit price. For peg orders, this optionally sets the peg limit.

SetOrderPriceType Sub SetOrderPriceType(lOrder As Long, iPriceType As TOrderPriceType)

Sets the order price type to a member of the TorderPriceType enum.

SetOrderRoute Sub SetOrderRoute(lOrder As Long, bsRoute As String)

Sets the route on which to place the order.

SetOrderSymbol Sub SetOrderSymbol(lOrder As Long, bsSymbol As String)

Sets the ticker symbol for which to place the order.

SetOrderSymbolAttributes Sub SetOrderSymbolAttributes(lOrde r As Long, bsExchListed As String, iSecType As Long, dBasis As Double)

iSecType is a value of TAL Toolkit™ FID 2000 (https://secure.toolkit.taltrade.com/tql/appj.h tml#2000). dBasis is the basis value (value of TAL Toolkit™ FID 1179).

Sets the specified attributes for any symbol. The most common reason to call this function is on a change order (see CreateChangeOrder()) if the original order was not placed by the current application instance.

Method Description Notes SetOrderTag Sub SetOrderTag(lOrder As

Long, bsTag As String) Sets XML field 20692 equal to the content of bsTag. The content of bsTag is free text. This is the method you should use if you want to track your order with your own ID. The advantage of using SetOrderTag() and GetOrderFieldData() to supply and retrieve a user

Page 14: RealTick Scripting QuickStart Guide

14

© 2012 RealTick LLC. All rights reserved.

defined ID is that this ID is the same whether the order is on the client or server. It is still necessary for separate client side (long) and server side (string) ID's to also exist, so that each side doesn't have to worry about duplicating an ID that exists on the other side.

SetOrderTicketID Sub SetOrderTicketID(lOrder As Long, bsTicketID As String)

LOrder should be a local order handle returned from CreateOrder(). BsTicketID is a string identifying a staged order ticket with which you would like to associate this order.

SetOrderVolType Sub SetOrderVolType (lOrder As Long, iVolType As TOrderVolumeType, iShowSize As Long)

iShowSize: the amount you want to show for Reserve Orders (see Reserve Orders section below).

SetOrderVolume Sub SetOrderVolume(lOrder As Long, lVolume As Long)

Sets the order size.

SetTradeEventTypes Sub SetTradeEventTypes(eType As TtradeEventType)

Specify the types of trade events for which you would like to receive an OnNewTrade() or OnNewTradeEx() callback.

Page 15: RealTick Scripting QuickStart Guide

15

© 2012 RealTick LLC. All rights reserved.

OnNewTrade() and OnNewTradeEx() Events

Note on Callbacks

Callback functions themselves should do as little as possible. The RealTick automation server design provides methods such as GetOrders() for controlled access to server side data, so that the client is not forced to do a large amount of data processing inside of callbacks. If necessary, inbound data (such as order ID’s) should be queued so that it can be processed (e.g. GetOrderFieldData() lookups) outside the callback. Most particularly, within your callback, you should not call the RealTick automation server or any other automation server, or raise any message boxes or dialogs.

OnNewTradeEx

The OnNewTrade() and OnNewTradeEx() events fire in response to new messages from the order server about your trade. The difference between these events is that OnNewTradeEx() passes in much more information. You should only implement a callback for one of these events. It is much handier to use OnNewTradeEx(), and we highly recommend you take advantage of this. If you only want to work with OnNewTrade(), you can prevent OnNewTradeEx() from firing by setting FireOrderEventEx=N in the [REALTICK] section of your tal.ini. From this point on, we will discuss this in terms of the OnNewTradeEx() event.

The OnNewTradeEx() event fires in response to the trade event types you may have specified using SetTradeEventTypes(). For example, if you call SetTradeEventTypes(eAll), the event will fire in response to all new messages from the server about your trade, i.e.: when the order hits the server, when it goes live, when each partial or complete fill occurs, and if applicable when the order is canceled, changed or deleted, in addition to a final summary message. If you pass eSummaryOnly, you will only receive the summary message. The third choice is eExecutions, in which case you will only receive fills.

Your application should call SetTradeEventTypes() at least once, on startup. The setting is sticky, so there is no reason to ever call it twice in a row with the same parameter. You only need to call it once, but you can call it as many times as you want if you want to change the setting while your application is running. The variable that is set when you call this function is global to the RealTick instance, so if you have run another Scripting application without shutting down RealTick in between and the other application has called SetTradeEventTypes() and your application has not, your application will use the previous application’s setting, which can cause unpredictable behavior. This can be avoided by making sure your application always calls SetTradeEventTypes() on startup.

If no application has called SetTradeEventTypes(), the default is eSummaryOnly. The definition of the event is:

Event OnNewTradeEx

(stOrderId As String, stBuySell As String, stSymbol As String, lTotalTraded As Long, dAvgPrice As Double, stStatus As String)

Page 16: RealTick Scripting QuickStart Guide

16

© 2012 RealTick LLC. All rights reserved.

Member of RealTick.RealTick

The possible values of stStatus are PENDING, LIVE, COMPLETED and DELETED. There is a separate OnNewTradeEx callback for each partial fill. The dAvgPrice passed into each callback is just for that one callback. (It is “average” in the sense of per share). Each fill is transmitted independently of other fills on the same order, and each fill has the COMPLETED status. If you want to get the aggregate average price of an order that has undergone several partial executions, you need to store the dAvgPrice values you receive from the different callbacks and average them.

The stOrderID that RealTick passes into this event is the remote side ID that can be passed into functions such as CancelOrder() and GetOrderFieldData(). This stOrderID is also the name of the XML file that logs this order if LogOrderToXML=Y is set.

Whenever there are partial fills in succession, the last portion of the stOrderID (after the 3rd hyphen) is incremented by 1. If the first 200 shares fill as 0937-0054-000c-03, the next 200 shares of the same order will fill as 0937-0054-000c-04, and so on. This is guaranteed not to duplicate another order. The only purpose of this "sequence tag" at the end of the stOrderID is to indicate partial fills. This feature doesn't care whether the partial fills were at the same or different price. That information is passed separately (dAvgPrice). It is also possible to have an stOrderID format like 1043ebf-6a-00004-4 (where there is just one digit after the hyphen: so the –4 in this ID is equivalent to the –04 above).

You will also receive messages that pertain to the original order and not to a particular event such as a partial fill. In particular, you should eventually receive a COMPLETED event that points to the original order and not to a particular fill. This event will indicate that all of the shares in the original order have been filled. You can identify these global event messages by the format of the order ID.

If you are receiving partial fill order ID’s of the form 0937-0054-000c- 03, then OnNewTrade[Ex]() messages that pertain to the global order will pass an order ID of the form 0937-0054-000c-00. If you are receiving partial fill order ID’s of the form 1043ebf-6a-00004-4, then OnNewTrade[Ex]() messages that pertain to the global order will pass an order ID of the form 1043ebf-6a-00004.

OnNewPosition() Event When you get a fill that opens, closes, or changes the size of a position, the OnNewPosition() event will fire if you are listening for it. The OnNewPosition() event passes three parameters:

string Symbol double dPosition double dAvgPrice

The event always passes the symbol and the new size of the position (which can be 0, or a positive or negative number).

The event is guaranteed to pass a nonzero value in dAvgPrice if and only if the average price of your position has been changed by this event. If the average price of your position has not been changed by the current event, and is the same as it was before, the OnNewPosition event may pass 0.00 in dAvgPrice. This just means the average price of your position is the same as it was before. This should not be interpreted to mean an actual average price of 0.00.

Page 17: RealTick Scripting QuickStart Guide

17

© 2012 RealTick LLC. All rights reserved.

To listen for the OnNewPosition() event, set the PositionUpdate property to 1. You must also provide a callback function.

OnNewBalance() Event When you get a fill that changes the available equity in one of your accounts, the OnNewBalance() event will fire if you are listening for it. OnNewBalance() passes the following two parameters:

string bsAccount double dBalance

The dBalance figure passed to this event is FID 23041(CBP_REMAINING) on the account designated by bsAccount. This is the field labeled as “Available Equity” in the Account Detail layout of RealTick.

To listen for the OnNewBalance() event, set the BalanceUpdate property to 1. You must also provide a callback function.

Price Type The eOrderPriceType enumeration has the following values:

ePrcLimit = 0, ePrcMarket = 1, ePrcStop = 3, ePrcStopLimit = 4, ePrcBBO = 5, ePrcTopBookIn2 = 6, ePrcTopBookIn1 = 7, ePrcTopBookOut1 = 9, ePrcTopBookOut2 = 10, ePrcPostNoPref = 11, ePrcMid = 12, ePrcBidDelta = 13, ePrcOfferDelta = 14, ePrcBBOOut1 = 15, ePrcBBOOut2 = 16, ePrcDiscretionary = 17, ePrcTrailingStop = 18, ePrcQuote = 19, ePrcPegBid = 20, ePrcPegOffer = 21, ePrcPassiveDiscretionary = 22, ePrcInsideLimit = 23, ePrcTrack = 24, ePrcTopBook = 8, ePrcPegMid = 25, ePrcPegVwap = 26, ePrcPegLast = 27, ePrcMOO = 28, ePrcMOC = 29, ePrcHidden = 30, ePrcTrailingStopLmt = 31

Page 18: RealTick Scripting QuickStart Guide

18

© 2012 RealTick LLC. All rights reserved.

Expiration Type To submit an order you must also specify an expiration from the eOrderExpirationType enumeration:

eExpireIOC = 0, eExpireDAY = 2, eExpireGTC = 1, eExpireDAYPLUS = 3, eExpireNOW = 7, eExpireOPG = 9, eExpireCLO = 15, eExpireFOK = 16

Volume Type You can specify the following Volume Types from the eOrderVolumeType enumeration:

0=eVolPartial 1=eVolAllOrNone 2=eVolReserve 5=eVolImbalance

Reserve Order A Reserve Order is a single order that RealTick breaks up into smaller orders by volume. For example, you can place a single Reserve Order for 1200 and set it to only put out an order for 300 at a time (your Reserve Show Size). Then when the first 300 are filled you show the second 300, and so on. This feature is available on ARCA. Certain order parameters may not be allowed on specific routes and/or at specific times, based on the same rules that apply to manual order entry through RealTick.

Conditional Orders The CreateConditionalOrder call creates a wrapper for conditional placement of another order. The lOrderToPlace parameter is the handle for another order—the one you actually want to place when the condition is met. The other order should be created normally and have all its parameters set normally, but not get sent—its handle should be passed to this function instead of being sent. Here are the meanings of the parameters used to create the conditional “wrapper” order. In this explanation, I might change the order of the parameters, so I can better explain their meanings.

bsConditionSymbol:

The symbol whose activity is used as the basis for triggering the condition.

iFieldID:

The field of bsConditionSymbol that you want to look at.

dVal:

The constant value to which you want to compare the current value of iFieldID for bsConditionSymbol.

iRelation:

The relationship between the current value and dVal, as follows:

Page 19: RealTick Scripting QuickStart Guide

19

© 2012 RealTick LLC. All rights reserved.

#define PRICE_REL_GT 1 //condition is met when value > dVal

#define PRICE_REL_GE 2 //condition is met when value >= dVal

#define PRICE_REL_EQ 3 //etc.

#define PRICE_REL_LE 4 #define PRICE_REL_LT 5

The internal order will automatically be placed when the condition is met.

Code Examples

The most up-to-date RealTick Scripting code examples for VB, VBA and C++ are available within the RealTick

API ® QuickStart Guide at www.realtick.com/api. For any questions, contact TAL Developer Support at

[email protected].

Chapter 4: XML Files

This chapter discusses the XML logging of order information. The XML files that may be stored within the Trading subdirectory also correspond to the information about each order that may be obtained by calling GetOrderFieldData().

To store order information to XML files in the Trading subdirectory, go to the Order Entry Properties | Miscellaneous tab and check “Log Order to XML”. Otherwise, the same information will still be stored in memory and accessible by calling GetOrderFieldData(), but will not be stored to disk.

Trading Subdirectory The XML files are created within subdirectories of the Trading subdirectory. The names of the subdirectories are based on the date of the trade. For example: If RealTick is installed in the C:\Tal directory and today’s date is June 5, 2005, then the XML files will be written to c:\tal\trading\20050605\. The files are given the name of the order number plus an XML extension. The XML files output by RealTick can be used to feed other applications.

The document elements will change slightly depending on the status of the order. So, if you are reading in an order that is LIVE as opposed to COMPLETED, it will not have an AVG Price amount. Some logic can control how this is handled. The Elements for the most part are given numeric names. These correspond to field ID numbers in the RealTick databases. They could be mapped using XSL or manually.

XML Statuses Pending, the very first status, when RealTick knows about the order but the remote side doesn’t know about it yet.

Live, this is an acknowledgement that the order is received but not filled.

Page 20: RealTick Scripting QuickStart Guide

20

© 2012 RealTick LLC. All rights reserved.

Completed, this is filled either partial or entirely.

Deleted, this is cancelled either by the client or as a result of an IOC.

XML Mapping The field Ids in the XML file take the following form: <F1234> where 1234 is the TAL FID (Field ID). A list of FIDs you are likely to see in your order XML files is available at https://secure.toolkit.taltrade.com/tql/appn.html.

Chapter 5: RealTick Permissions State

This chapter provides you with the methods and events to determine if RealTick is running and ready to receive commands.

Poll Permissions State When RealTick is first launched, either manually or by instantiating this interface, it is not always ready to receive commands. The best approach to detect when RealTick is ready to receive commands is to poll the permissions state using GetPermState().

Function GetPermState() as TPermState

Method GetPermState

The ePermState enumeration is as follows:

1 ePermsOK

2 ePermsRevoked

3 eSuspended

4 eUninitialized

5 eVerifyFailed

The initial state is eSuspended. When RealTick is all the way up, the state will become ePermsOK. The OnNewPermState event does not begin working until after the first ePermsOK state is reached. Therefore, you want to poll for the initial ePermsOK state. However, you should implement a callback for the OnNewPermsState event so that you can be alerted of changes to RealTick’s permissions state once RealTick is up and running. Event OnNewPermState(iState As Long) For example, OnNewPermState might call you back with iState = 2 (ePermsRevoked) if the same user logs on again from a different machine.

Chapter 6: Window Creation/Manipulation

This chapter discusses creating/manipulating child windows within RealTick.

Page 21: RealTick Scripting QuickStart Guide

21

© 2012 RealTick LLC. All rights reserved.

This functionality is not recommended for use at the same time as scripting order entry. This is currently supported only for the MarketMaker and MarketMinder window types. Support for additional window types may be added in future RealTick releases.

Functions The first three functions documented below, return a handle for a RealTick window. Currently, RealTick window handles exposed through this interface are the same as the Windows hWnd for the same window. This is subject to change.

For a MarketMaker, szModuleName = mmaker

For a MarketMinder, szModuleName = minder

CreateRealTickWindow

Function CreateRealTickWindow(szModuleName As String) As Long

This function creates a new window of the specified type and returns a handle to it.

FindWindow

Function FindWindow(szModuleName, [szPartialTitle]) As Long This function finds the first (in zOrder) instance of the specified window type, and returns the handle to that instance. If szPartialTitle is specified, it finds the first instance of the specified window type matching the specified partial title. If no window matching the parameters is found on the currently open page, returns 0.

GetActiveWindow

Function GetActiveWindow() As Long

This function returns the handle to the currently selected window on the currently open page.

GetWindowHandle

Function GetWindowHandle(szModuleName As String, szTitle As String) As Long

The szTitle parameter must be the EXACT text that appears in the title bar of the child window. This is exact character for character including punctuation (Minder titles often start with the literal character *). All characters in the string are treated as literal.

SetWindowSymbol

Sub SetWindowSymbol(Handle As Long, bsSymbol As String, bStartData As Long)

This function takes the handle to a window and sets the symbol of that window to the specified symbol. If the window type supports more than one symbol, the specified symbol is appended to the end of the current list.

Page 22: RealTick Scripting QuickStart Guide

22

© 2012 RealTick LLC. All rights reserved.

Example Code

Dim rt As Realtick.Realtick ‘Realtick interface

Dim hMinder As Long ‘Realtick window handle

Dim hMaker As Long ‘Realtick window handle

Set rt = CreateObject(“TAL.Realtick.1”)

‘this call assumes you already have a minder with the title

'"*Minder: Two Column.BVW" on your page hMinder = rt.GetWindowHandle("Minder", "*Minder: Two Column.BVW")

'each SetWindowSymbol should append the symbol to the end

of the list. rt.SetWindowSymbol hMinder, "CSCO", True rt.SetWindowSymbol hMinder, "IBM", True

'this is to create a new MarketMaker on your page and put

MSFT in it hMaker = rt.CreateRealtickWindow("MMaker") rt.SetWindowSymbol hMaker, "MSFT", True

Chapter 7: System Information

This chapter defines properties that provide system information.

o The Application property is a readonly string. o The version property is also a read-only string.