Apama Capital Markets Foundation Documentation : Capital Markets Foundation : Analytics : Using the position service framework : Working with Position events
Working with Position events
The com.apama.position.Position event is a general purpose position object that the default position trackers publish. The Position event contains the following fields:
event Position {
integer minQtyPosition;
float minCashPosition;
integer maxQtyPosition;
float maxCashPosition;
dictionary<string, string> extraParams;
action setFullPosition
(integer minQty, float minCashPosition,
integer maxQty, float maxCashPosition);
action setMaxPosition(integer qty, float cashPosition);
action setMinPosition(integer qty, float cashPosition);
action setPosition(integer qty, float cashPosition);
The table below describes how the default position tracker implementations use the fields in the Position event. However, a custom position tracker implementation can use the data fields in the Position event in any way, to store any values relevant to your application.
These fields contain a cumulative quantity for all orders being tracked. The specific meaning of the value depends on which position tracker is publishing the event. See:
These fields contain a cumulative cash position for all orders being tracked. For each order, the quantity is multiplied by the price and then the results for all orders are added together. The specific meaning of the value depends on which position tracker is publishing the event. See:
Any extra information associated with the position being tracked can be stored in this dictionary. Typically, dictionary content is specific to the position tracker that publishes this event.
setX() actions
These actions are for setting quantity and cash position values in custom position tracker implementations. Also, you might use these actions if you make a trade outside the system and you want to adjust a position to include that trade.
*setFullPosition() - Sets values for minQtyPosition, maxQtyPosition, minCashPosition and maxCashPosition.
*setMaxPosition() - Sets values for maxQtyPosition and maxCashPosition.
*setMinPosition() - Sets values for minQtyPosition and minCashPosition.
*setPosition() - Sets minQtyPosition and maxQtyPosition to the same value. Also sets minCashPosition and maxCashPosition to the same value.
It is important to define slice details correctly so that a subscription tracks what you want it to track. For example, suppose you specify multiple instruments (perhaps APMA, MSFT, TNBT) in the symbol slice. Even if you use the same currency to trade all of them, the value of the minQtyPosition and maxQtyPosition fields will be a mix of quantities for three different symbols, which might be meaningless as a value on its own. If you want to know the number of shares traded for just one of these symbols, you must define the slice accordingly with a single symbol.
When you are using the open, pending, or reserved default position trackers, the minCashPosition and maxCashPosition fields are meaningful when all instruments are traded on a single common currency. If multiple instruments are specified in the symbol slice, and different cash currencies are used for different instruments then the cash position values are not meaningful. For order executions, you can obtain a cash position in a single normalized currency by using the realized profit and loss default position tracker. For pending or reserved orders, you would need to apply custom normalization functions on the position updates to obtain a cash position in a single normalized currency.
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback