TMS Java Programmer’s Guide - InfoReach

Transcription

TMS Java Programmer’s GuideVersion 9.0

INFOREACH TMS Java Programmer’s GuideContentsTMS JAVA PROGRAMMER’S GUIDE . 0INTRODUCTION. 4API TYPES: IN-PROCESS, REMOTE AND LIGHT REMOTE . 4USING “SUBSCRIPTION” SET OF ITMSREMOTECLIENT AND ITMSREMOTEMARKETPORTFOLIOINTERFACES . 5SUBSCRIBING FOR ORDER DATA THROUGH ITMSREMOTECLIENT . 5SUBSCRIBING FOR ORDER DATA THROUGH ITMSREMOTEMARKETPORTFOLIO . 5SUBSCRIBING FOR PORTFOLIO DATA THROUGH ITMSREMOTECLIENT . 6SUBSCRIBING FOR PORTFOLIO DATA THROUGH ITMSREMOTEMARKETPORTFOLIO . 6SUBSCRIBING FOR TARGET DATA THROUGH ITMSREMOTEMARKETPORTFOLIO . 7SUBSCRIBING FOR MARKET DATA THROUGH ITMSREMOTECLIENT . 8SUBSCRIBING FOR CUSTOM DATA THROUGH ITMSREMOTECLIENT . 8SUBSCRIBING FOR POSITION DATA THROUGH ITMSREMOTECLIENT . 9SUBSCRIBING FOR POSITION DATA THROUGH ITMSREMOTEMARKETPORTFOLIO . 10SUBSCRIBING FOR AUTOTRADER DATA THROUGH ITMSREMOTEMARKETPORTFOLIO . 11SUBSCRIBING FOR WAVE DATA THROUGH ITMSREMOTEMARKETPORTFOLIO . 11SUBSCRIBING FOR ACTION ERRORS, WARNINGS, ALERTS . 11LISTENER INTERFACES . 11Interface ITMSOrderEventRemoteListener . 11Interface ITMSMarketPortfolioEventRemoteListener . 12Interface ITMSMarketTargetEventRemoteListener . 13Interface ITMSMarketDataEventListener . 14Interface ITMSCustomRecordDataEventListener . 14Interface ITMSInstrumentPositionEventRemoteListener . 14Interface ITMSCategoryPositionEventRemoteListener . 15Interface ITMSAutoTraderEventRemoteListener . 16Interface ITMSWaveEventRemoteListener . 16Interface IActionEventListener . 17USING “INSTRUCTION” SET OF ITMSREMOTECLIENT API . 17GETTING RESOURCES . 17STAND-ALONE ORDER INSTRUCTIONS . 18PORTFOLIO INSTRUCTIONS . 20Portfolio targets instructions . 20Portfolio order instructions . 22Portfolio wave instructions . 22Portfolio AutoTrader instructions . 23FIX ENGINE INSTRUCTIONS . 24ALERT INSTRUCTIONS . 24TIMER INSTRUCTIONS . 25ACCESSING STATIC DATA . 25ACCESSING MARKET DATA. 25ENTITY OBJECTS AND INTERFACES . 25Interface IRecord . 26TMSNewOrderMessage . 26TMSModifyOrderMessage . 26TMSCancelOrderMessage . 27TMSOutOnOrderMessage . 271Copyright 1996-2016 InfoReach, Inc.

INFOREACH TMS Java Programmer’s GuideTMSRejectOrderMessage . 27Interface ITMSAutoTraderSpec . 27ELTFieldGroup . 27FieldsContainer . 27USING ITMSREMOTECLIENT API FOR REPORT DATA MONITORING . 28REQUESTING REPORT DATA SNAPSHOTS. 28SUBSCRIBING FOR REPORT DATA FLOW . 30EXAMINING RECEIVED RECORD EVENTS . 31UNSUBSCRIBING FROM DATA FLOW . 33CREATING REPORT . 33REMOVING REPORT . 33CHECKING FOR REPORT . 33DEVELOPING CUSTOM ALGORITHMS . 34OVERVIEW . 34GUIDELINES FOR IMPLEMENTING ALGORITHMS . 35Creating development environment . 35Creating AutoTrader. 35Creating AutoTrader GUI . 35Configuring TMS to run custom algorithms . 38Launch TMS server . 40Launch TMS GUI . 40Launch AutoTrader . 40ACCESSING RESOURCSE FROM INSIDE THE AUTOTRADER MODULE . 40SUBSCRIBING AUTOTRADER FOR THE TMS EVENT FLOW . 41SCHEDULING TIMERS . 42LISTENING TO THE TMS EVENT FLOW . 43Interface ITMSMarketPortfolioEventListener . 44Interface ITMSAutoTraderEventListener . 44Interface ITMSOrderEventListener . 45Interface ITMSMarketTargetEventListener. 45Interface ITMSMarketDataEventListener . 46Interface ITMSCustomRecordDataEventListener . 46Interface ITMSTimerHandler . 46Interface IRPTEventListener . 46REQUESTING INFO FROM THE TMS . 47AutoTrader Info . 47Portfolio Info . 47Orders Info . 47Targets Info . 48Position Info . 48Market Data Info . 48Static Data Info . 49Custom Data Info . 49Report Info . 49INSTRUCTING THE TMS TO PERFORM AN ACTION . 49Order Actions . 49Target Actions . 50AutoTrader Actions . 51Portfolio Actions . 52AUDITING AUTOTRADER ACTIVITY . 52ITMSSTAGEDPORTFOLIOSYSTEM . 53ENTITY OBJECTS AND INTERFACES. 53Interface ITMSLocalMarketPortfolio . 542Copyright 1996-2016 InfoReach, Inc.

INFOREACH TMS Java Programmer’s GuideInterface ITMSMarketTarget. 54Interface ITMSOrder . 56Interface ITMSMarketPosition . 58Interface ITMSWave . 58Interface IRecord . 59TMSNewOrderMessage . 59TMSModifyOrderMessage . 59TMSCancelOrderMessage . 60Interface ITMSAutoTraderSpec . 60ELTFieldGroup . 60FieldsContainer . 60USING AUTOTRADER HELPERS . 61SAMPLE ANALYTIC MODULE . 61XML for registering the sample module . 61DEVELOPING CUSTOM REPORT FIELDS . 61USING DEFAULT TMS CLASSES FOR CUSTOM FIELDS . 61Order Report Fields . 62Target Fields . 70DEVELOPING NEW CLASSES FOR CUSTOM FIELDS . 72USING TMS MARKET DATA API . 73WRITING MARKET DATA LISTENER COMPONENTS. 73AUGMENTING MARKET DATA RECORDS WITH CUSTOM VALUES. 76Implementing custom component for record augmentation . 76Displaying custom values in Quote Reports . 78APPENDIX A: SAMPLE TMS ACCESSING APPLICATION . 80APPENDIX B: TMS FIELDS . 80ORDER FIELDS (USED WHEN WORKING WITH ITMSORDER OR IRECORD OBJECTS REPRESENTING TMS ORDERS) . 80PORTFOLIO TARGET FIELDS (USED WHEN WORKING WITH ITMSMARKETTARGET, ITMSLOCALMARKETPORTFOLIO, ORIRECORD OBJECTS REPRESENTING TMS TARGETS OR TMS PORTFOLIOS). 83MARKET QUOTE FIELDS (USED WHEN WORKING WITH IRDRECORD OBJECTS) . 84APPENDIX C: SAMPLE REPORT RESOURCE . 84APPENDIX D: GETTING LEVEL 2 QUOTES THROUGH API . 863Copyright 1996-2016 InfoReach, Inc.

INFOREACH TMS Java Programmer’s GuideIntroductionTMS API allows users to interact programmatically with TMS server components. The API consists of twosets of methods where methods of the first (“subscription”) set can be used to subscribe customapplication component to the TMS event flow, and methods of the other (“instruction”) set can be used todirectly instruct the TMS to perform an action. The event flow exposed to the custom application in realtime includes all order-related information, portfolio-related information, market data events, customrecord events, position-related information, and report data. The events notify the application componentsof any changes taking place in the system and based on that information the instructions can be given tothe TMS to perform a set of actions. Sending/modifying/canceling an order, creating new portfolio,modifying set of portfolio’s targets, starting/pausing an analytic that automatically sends order waves aresome of the actions available to the users’ applications.In addition to the remote API, the mechanism is provided to plug in custom AutoTrader analytics,message preprocessors, filters, id generators, GUI defaulters, etc.API Types: In-Process, Remote and Light RemoteThe in-process (a.k.a. AutoTrader) API allows developing of the AutoTrader analytic modules. Themodules developed with the in-process API will run inside the TMS process space. There is a restriction ofone AutoTrader module per one market portfolio. The developer of the analytic module would not need toworry about the thread safety. In most cases, the analytic modules will be purely algorithmic and won't dotheir own state management. Instead, they would work with the state of the targets and the orders aswell as AutoTrader parameters. By subscribing to the order/target event flow a module gets notificationsand it can make decisions on whether orders should be sent, modified, canceled, etc. Due to the real-timenature of the TMS and the fact that a given portfolio is locked on any given invocation of analytic module,the code should avoid any heavy processing (e.g. expensive calls to external application or databases).The AutoTrader module can modify its own parameters and control state of individual portfolio targets(e.g. pause/resume/terminate).The remote (a.k.a.external) API allows building external applications that do not run inside the TMSprocess space and can communicate with the TMS remotely. The external apps can instruct the TMS tocreate new portfolios, add/remove/modify targets in portfolios, subscribe for event flow, make decisionson whether orders should be sent, modified, canceled, etc.The light remote API is basically a lightweight version of the remote API. Unlike the latter it does notinvolve initializing various TMS sub-systems inside the external application. The overall API is identical,but some sophisticated remote API capabilities are not supported by the light remote API. See readme.html for details.All event notifications to the external applications are asynchronous, no portfolio locks are held, and thusthe state changes inside the TMS processes can take place while the application is processing currentevent. This means that there is a possibility for race conditions (e.g. trying to modify an order while a fillis being processed in TMS).Normally, the external API is used to create applications implementing “macro-models” forportfolio/target generation/modification and the in-process API is used for creating executionlogic (sending/monitoring market orders off the portfolio targets).The sections below describe the external API usage. In section “Developing CustomAlgorithms” the internal API is discussed.4Copyright 1996-2016 InfoReach, Inc.

INFOREACH TMS Java Programmer’s GuideUsing “subscription” set of ITMSRemoteClient andITMSRemoteMarketPortfolio interfacesAn external application can use subscribe() methods of the ITMSRemoteClient interface to monitorsystem-wide order, portfolio, position, market data event flow and it can use subscribe() methods of theITMSRemoteMarketPortfolio interface to monitor portfolio-specific event flow. To get a handle toITMSRemoteClient use method TMSClientSystem.getRemoteClient(name). The name can be obtain bycalling TMSClientSystem.getRemoteClientNames() (see sample JAVA app for more details). To get ahandle to ITMSRemoteMarketPortfolio use method getMarketPortfolio(String portfolioName) of theITMSRemoteClient interface.The following sections describe the methods of the “subscription” set in more details.Subscribing for order data through ITMSRemoteClient void subscribeForOrderData(UserTicket userTicket, ITMSOrderEventRemoteListener listener,boolean includePortfolioOrders) throws TMSExceptionSubscribes the listener module for events carrying the information about new orders orchanges in the existing orders’ fields. For example, each time a fill arrives for an order theFillQty field of an order will change and the method onOrderUpdate() of the application’slistening module will be called. The listening module must implement interfaceITMSOrderEventRemoteListener. See “Listener interfaces” section for more details. Thismethod can be used to only monitor orders that were NOT sent as portfolio target slices ifparameter includePortfolioOrders is set to “false”. If it is set to “true” then events withinformation about all orders in the system will be sent to the listener. void subscribeForOrderData(UserTicket userTicket, ITMSOrderEventRemoteListener listener,String filterExpression) throws TMSExceptionSubscribes the listener module for events carrying the information about new orders orchanges in the existing orders’ fields for those orders that match the specified filteringexpression. For example, given the expression “Instrument ’IBM’”, each time a fill arrivesfor an IBM order the FillQty field of an order will change and the method onOrderUpdate() ofthe application’s listening module will be called. The listening module must implementinterface ITMSOrderEventRemoteListener. See “Listener interfaces” section for more details.If during the lifetime of the order its attribute changed so that it stops matching the filteringexpression then the application’s listening module’s method onOrderFilteredOut() will becalled. void unsubscribeFromOrderData(UserTicket userTicket, ITMSOrderEventRemoteListenerlistener) throws TMSExceptionUnsubscribes the module from order-related event flow.Subscribing for order data through ITMSRemoteMarketPortfolio void subscribeForOrderData(UserTicket userTicket, ITMSOrderEventRemoteListener listener)throws TMSExceptionSubscribes the listener module for events carrying the information about new orders orchanges in the existing orders’ fields for those orders that belong to this portfolio. Forexample, each time a fill arrives for an order the FillQty field of an order will change and themethod onOrderUpdate() of the application’s listening module will be called. The listeningmodule must implement interface ITMSOrderEventRemoteListener. See “Listener interfaces”section for more details. This is used to monitor orders that were sent as this portfolio’s5Copyright 1996-2016 InfoReach, Inc.

INFOREACH TMS Java Programmer’s Guidetarget slices. void subscribeForOrderData(UserTicket userTicket, ITMSOrderEventRemoteListener listener,String filterExpression) throws TMSExceptionSubscribes the listener module for events carrying the information about new orders orchanges in the existing orders’ fields for those orders that belong to this portfolio and matchthe specified filtering expression. For example, given the expression “Instrument ’IBM’”,each time a fill arrives for an IBM order the FillQty field of an order will change and themethod onOrderUpdate() of the application’s listening module will be called. The listeningmodule must implement interface ITMSOrderEventRemoteListener. See “Listener interfaces”section for more details. If during the lifetime of the order its attributes change so that itstops matching the filtering expression then the application’s listening module’s methodonOrderFilteredOut() will be called. void unsubscribeFromOrderData(UserTicket userTicket, ITMSOrderEventRemoteListenerlistener) throws TMSExceptionUnsubscribes the module from order-related event flow.Subscribing for portfolio data through ITMSRemoteClient void subscribeForPortfolioData (UserTicket userTicket,ITMSMarketPortfolioEventRemoteListener listener) throws TMSExceptionSubscribes the module for events carrying the information about new portfolios or any fieldchanges of an existing system portfolio. For example, every time a fill arrives for an orderreleased from target of a portfolio the field FillQty of the portfolio will change and thelistener will be notified. The listening module must implement interfaceITMSMarketPortfolioEventRemoteListener. See “Listener interfaces” section for more details. void subscribeForPortfolioData (UserTicket userTicket,ITMSMarketPortfolioEventRemoteListener listener, boolean includeRecordUpdates, StringfilterExpression, String[] fieldNames) throws TMSExceptionSubscribes the module for events carrying the information about new portfolios or any fieldchanges of an existing system portfolio. By setting includeRecordUpdates parameter tofalse the user can restrict the system to only notify the listening app only about newportfolios and not send events every time something changes in an existing portfolio. It isalso possible to restrict the system to only send events from portfolios matching thespecified filtering expression. The fieldNames parameter can be specified to limit the set offields in the events only to the pertinent ones. The listening module must implementinterface ITMSMarketPortfolioEventRemoteListener. See “Listener interfaces” section formore details. If during the lifetime of the portfolio its attributes change so that it stopsmatching the filtering expression then the application’s listening module’s methodonPortfolioFilteredOut() will be called. void unsubscribeFromPortfolioData(UserTicket userTicket,ITMSMarketPortfolioEventRemoteListener listener) throws TMSExceptionUnsubscribes the module from portfolio-related event flow.Subscribing for portfolio data through ITMSRemoteMarketPortfolio void subscribeForPortfolioData (UserTicket userTicket,ITMSMarketPortfolioEventRemoteListener listener) throws TMSExceptionSubscribes the module for events carrying the information about changes in this portfolio6Copyright 1996-2016 InfoReach, Inc.

INFOREACH TMS Java Programmer’s Guidefields. For example, every time a fill arrives for an order released from target of thisportfolio the field FillQty of the portfolio will change and the listener will be notified. Thelistening module must implement interface ITMSMarketPortfolioEventRemoteListener. See“Listener interfaces” section for more details. void subscribeForPortfolioData (UserTicket userTicket,ITMSMarketPortfolioEventRemoteListener listener, boolean includeRecordUpdates, String[]fieldNames) throws TMSExceptionSubscribes the module for events carrying the information about changes in this portfoliofields. The fieldNames parameter can be specified to limit the set of fields in the eventsonly to the pertinent ones. For example, every time a fill arrives for an order released fromtarget of this portfolio the field FillQty of the portfolio will change and the listener will benotified. If includeRecordUpdates is set to false then only event notifying of this portfolioremoval will be sent to the app. The listening module must implement interfaceITMSMarketPortfolioEventRemoteListener. See “Listener interfaces” section for more details. void unsubscribeFromPortfolioData(UserTicket userTicket,ITMSMarketPortfolioEventRemoteListener listener) throws TMSExceptionUnsubscribes the module from portfolio-related event flow.Subscribing for target data through ITMSRemoteMarketPortfolio void subscribeForTargetData (UserTicket userTicket, ITMSMarketTargetEventRemoteListenerlistener) throws TMSExceptionSubscribes the module for events carrying the information about changes in this portfolio’stargets fields. For example, every time a fill arrives for an order released from target of thisportfolio the field FillQty of the target will change and the listener will be notified. Thelistening module must implement interface ITMSMarketTargetEventRemoteListener. See“Listener interfaces” section for more details. void subscribeForTargetData (UserTicket userTicket, ITMSMarketTargetEventRemoteListenerlistener, boolean includeRecordUpdates, String filterExpression, String[] fieldNames) throwsTMSExceptionSubscribes the module for events carrying the information about changes in this portfolio’stargets fields. For example, every time a fill arrives for an

TMS API allows users to interact programmatically with TMS server components. The API consists of two sets of methods where methods of the first (“subscription”) set can be used to subscribe custom application component to the TMS event flow, an