Apama Capital Markets Foundation Documentation : Capital Markets Foundation : Analytics : Using the position service framework : Using default position trackers : Creating and subscribing to the pending position tracker
Creating and subscribing to the pending position tracker
The default implementation of the pending position tracker tracks the cumulative quantity and cash position of unfilled orders that are not of the reserved type. These unfilled orders represent how much your open position for the same slice information could change if those orders complete. To use the pending position tracker, you create an instance of it and then you subscribe to it by using a position service interface object (com.apama.position.PSInterface).
To create an instance of a pending position tracker, execute the create() action defined in com.apama.position.tracker.PendingPositionTrackerFactory. The create() action takes three parameters:
Parameter
Description
mainContext
A reference to the main context. When the Position Management Service bundle is in your application the correlator automatically sets up the position service manager in the main context.
trackerName
A string that specifies a name for this tracker. This name must be unique in your application.
cbCreated
This callback action returns a boolean parameter that indicates whether creation of the tracker was successful, followed by a string parameter that can hold a message that can be logged.
After a pending position tracker is set up, subscribe to it by calling the subscribeAndMonitor() action or the subscribe() action, which are both defined in com.apama.position.PSInterface. Both actions subscribe to the specified tracker. The subscribeAndMonitor() action also registers an update callback each time there is an update to the position being tracked. A tracker can accept any number of subscriptions. The subscribeAndMonitor() action takes the following parameters:
*trackerName is the name of the pending position tracker to subscribe to. This is the unique name that was specified when the tracker was created.
*trackerType indicates the type of tracker you are subscribing to. When subscribing to an instance of the default pending position tracker, specify the tracker type as the constant TRACKER_TYPE string defined in the com.apama.position.tracker.PendingPositionTrackerConstants event.
*config is a com.apama.position.PositionConfigParams object that contains any configuration for this subscription, such as the slice criteria you want to match orders against.
*updateCallback is a user-defined update callback action that the tracker will call when there is an update to the position subscribed to.
*subscribedCb is a user-defined callback action that the tracker calls in response to the subscription request.
Code for creating a pending position tracker and then subscribing to it is almost the same as the code for creating and subscribing to an open position tracker. The differences are that you use the PendingPositionTrackerFactory.create() action and when subscribing you use the TRACKER_TYPE string defined in the PendingPositionTrackerConstants event. See the sample code in Creating and subscribing to the open position tracker.
When there is a change in the position being tracked, the update callback (or callbacks) that have been registered for the subscription will be called. This callback action contains a com.apama.position.Position event object that defines the current position for that subscription. The Position event field values indicate the following:
Field
Description
minQtyPosition
Sum of the quantities of all unfilled short orders. This is the quantity that would be sold if all unfilled sell orders for this position were executed. This value indicates how much shorter the position would become if all orders filled. This is always a negative number.
maxQtyPosition
Sum of the quantities of all unfilled long orders. This is the quantity that would be bought if all unfilled buy orders for this position were executed. This value indicates how much longer the position would become if all orders filled. This is always a positive number.
minCashPosition
Sum of (quantity times price) for all unfilled short orders. This is the amount you would be short if all unfilled sell orders for this position were executed. This value indicates how much shorter the cash position would become if all orders filled. The pending position tracker calculates cash position based on the most recent filled order for the position being tracked.
maxCashPosition
Sum of (quantity times price) for all unfilled long orders. This is the amount you would be long if all unfilled buy orders for this position were executed. This value indicates how much longer the cash position would become if all orders filled. The pending position tracker calculates cash position based on the most recent filled order for the position being tracked.
A Position event's min and max fields let you separately track short positions and long positions. If you are interested in a net value instead of separate long and short values add the appropriate min and max event field values together.
The following table shows how the quantity for corresponding open and pending positions might change.
Order State
Open Position
Pending minQtyPosition
Pending maxQtyPosition
Start
+5
0
0
Buy 6 order placed
+5
0
6
Sell 15 order placed
+5
-15
6
Buy 6 order filled
+11
-15
0
Sell 15 order filled
-4
0
0
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback