Apama 10.3.1 | Apama Capital Markets Foundation Documentation | Capital Markets Foundation | Analytics | Using the position service framework | Using default position trackers | Implementing independent default position trackers
 
Implementing independent default position trackers
In your application, it is possible to have duplicate subscriptions. That is, there can be multiple subscriptions to the same named default position tracker with the same configuration details. For example, you might have 10 duplicate subscriptions in 10 different contexts. By default, the position service framework uses a single position tracker instance for duplicate subscriptions.
However, different parts of an application might require independent position trackers. For example, you might need an open position tracker for client orders, and another open position tracker for internal orders. Or you might be writing a trading algorithm and you want to reset or modify a position independently of a position that is using the risk firewall and that you settle at zero at the end of each day.
To implement an independent default position tracker, specify the com.apama.position.tracker. GenericPositionTrackerConstants.TRACKER_CONFIG_SUBSCRIPTION_NAME constant value in the configuration object you specify when you subscribe to the position tracker. This configuration parameter lets you specify a unique name (within your application) for a subscription. The position service framework creates a tracker instance to handle that subscription independently of any other subscriptions that have the same configuration. For example:
com.apama.position.tracker.GenericPositionTrackerConstants consts :=
new com.apama.position.tracker.GenericPositionTrackerConstants;

com.apama.position.PositionConfigParams config :=
new com.apama.position.PositionConfigParams;

config.addParam( consts.TRACKER_CONFIG_SUBSCRIPTION_NAME,
"MyIndependentSubscription" );
Now if you specify config in a subscription, you get a new instance of the position tracker with a new subscription based on the unique configuration. If you subscribe again using the same configuration, which includes the same subscription name, the configurations match. So that same position tracker is used for this second, matching, subscription. To set up an independent position tracker for a single subscription you must specify a unique name for each subscription.

Copyright © 2013-2019 | Software AG, Darmstadt, Germany and/or Software AG USA, Inc., Reston, VA, USA, and/or its subsidiaries and/or its affiliates and/or their licensors.