Apama Capital Markets Foundation Documentation : Capital Markets Foundation : Order Management : Smart Order Router : Creating a strategy instance
Creating a strategy instance
To create a strategy instance, obtain a object from the factory, which can then be used to query and create a specific strategy.
// Create a new StrategyHelperInterface
com.apama.sor.strategy.StrategyHelperInterface strategyHelperIface :=
(new com.apama.sor.strategy.StrategyHelperFactory).createInterface();
Once the StrategyHelperInterface has been created, you can create a new strategy instance and implement the full set of the strategy callbacks required.
Implementable callbacks include:
*strategyError() – Called if there has been an error in processing the new order (for example, if the order was rejected, or an attempt was made to modify/cancel an order with an invalid order ID).
*setChildOrderHandler() – Called after the Strategy has been created, and allows for overriding the handling of child orders before they are placed on the venue.
The following code extract shows how you might create a new strategy with callback actions:
// Define the variables to be used to create the Strategy

com.apama.sor.utils.Auditor auditor;
com.apama.sor.strategy.StrategyHelperCallbacks userDefinedCallbacks :=
com.apama.sor.strategy.StrategyHelperCallbacks(myStrategyErrorCallback,
myStrategyChildOrderHandlerCallback );

// Create a new Strategy Helper Interface
com.apama.sor.strategy.StrategyInterface strategyIface :=
strategyHelperIface.createStrategy(“MY_STRATEGY”, context.current(),
auditor, userDefinedCallbacks );
In some cases, you will not want to do anything specific for some of these callback actions. So to reduce the amount of code that you have to write, which in turn reduces the complexity, you can alternatively use the default implementations of some of the callback actions. The StrategyHelperInterface, contains default callback implementations. You can override only the appropriate actions.
This example shows how to override the "strategyError" callback action and leave the default behaviors for the other callbacks:
// Define the variables to be used to create the Strategy

com.apama.sor.utils.Auditor auditor;
com.apama.sor.strategy.StrategyHelperCallbacks userDefinedCallbacks :=
strategyHelperIface.getDefaultHelperCallbacks();
userDefinedCallbacks.strategyError := myStrategyErrorCallback;

// Create a new Strategy Helper Interface
com.apama.sor.strategy.StrategyInterface strategyIface :=
strategyHelperIface.createStrategy(“MY_STRATEGY”, context.current(),
auditor, userDefinedCallbacks );
Copyright © 2013-2017 Software AG, Darmstadt, Germany. (Innovation Release)

Product LogoContact Support   |   Community   |   Feedback