Apama Capital Markets Foundation Documentation : Capital Markets Foundation : Order Management : Risk Firewall : Setting up risk firewall evaluation rules : Adding rule instances to rule classes
Adding rule instances to rule classes
After you register a rule class with a risk firewall, you add one or more instances of that rule class to that risk firewall. Note that for custom rule classes, the addition of at least one rule class instance is not always a requirement. See Implementing custom risk firewall rule classes.
A rule class instance specifies a set of configuration parameter values to use when evaluating an order to determine if it complies with the rule class. For example, for the OrderPriceLimitRiskFirewallRule, you might add an instance that specifies that
*SLICE_SYMBOL = "SOW"
*PRICE_LIMIT_PARAMETER = 20.0
*PRICE_WARNING_PARAMETER = 15.0
Orders for SOW with prices set at 15.0 or less would be approved. Orders with prices that are more than 15.0 but not more than 20.0 would be approved with a warning while orders with prices that are more than 20.0 would be rejected.
Before you can add a rule class instance to a risk firewall, you must create a com.apama.utils.Params object that contains the parameter settings for the rule class instance. When you add the rule class instance to the risk firewall, you specify this Params object. For example, the steps for adding an instance of the default OrderPriceLimitRiskFirewallRule are as follows:
1. Create a com.apama.firewall.rules.OrderPriceLimitRiskFirewallConsts object.
2. Create a com.apama.utils.Params object.
3. Add the rule class instance configuration parameters to the Params object.
4. Specify the Params object when you add the rule class instance to the risk firewall.
To add a rule class instance to a risk firewall, execute one of the following actions:
*com.apama.firewall.RiskFirewall.addRuleInstance() — adds a rule class instance to a risk firewall.
*com.apama.firewall.RiskFirewall.addRuleInstanceCb() — adds a rule class instance to a risk firewall and then executes the specified callback if addition of the rule class instance is successful.
These actions are asynchronous and their availability is pending until the risk firewall is created and the relevant rule class is registered. It is an error if the time period specified by the CONFIG_TIMEOUT_DURATION parameter elapses before the risk firewall is created or before the relevant rule class is registered. These actions are not available when you are connected to a remote risk firewall instance. Both actions take these two parameters:
*ruleClassName — The name of a rule class. For each default rule class, its name is defined in its associated xxxConsts event, which defines the configuration parameters for that rule class. Alternatively, you can call getRuleClassName() on the RuleClass instance.
*config — A com.apama.utils.Params object that contains configuration parameter settings for this rule class instance. The risk firewall uses these parameter settings to evaluate an incoming order. For each default rule class, there is an associated event that specifies the configuration parameters for that rule class. The following events are provided in the com.apama.firewall.rules package:
ClientCreditLimitRiskFirewallRule
ClientCreditLimitRiskFirewallRuleConsts
 
OrderOperationRatioRiskFirewallRule
OrderOperationRatioRiskFirewallRuleConsts
 
OrderPriceLimitRiskFirewallRule
OrderPriceLimitRiskFirewallRuleConsts
 
OrderQuantityLimitRiskFirewallRule
OrderQuantityLimitRiskFirewallRuleConsts
 
OrderThrottleLimitRiskFirewallRule
OrderThrottleLimitRiskFirewallRuleConsts
 
OrderToTradeRatioRiskFirewallRule
OrderToTradeRatioRiskFirewallRuleConsts
 
OrderValueLimitRiskFirewallRule
OrderValueLimitRiskFirewallRuleConsts
 
PositionLimitRiskFirewallRule
PositionLimitRiskFirewallRuleConsts
 
ReservationEnforcerRiskFirewallRule
ReservationEnforcerRiskFirewallRuleConsts
In addition, the addRuleInstanceCb() action takes a callback as its third parameter.
Both actions return a unique, integer instanceId, which you can use later if you need to modify or remove this rule class instance.
The following code provides an example of adding a rule class instance:
// Add a rule class instance.
com.apama.firewall.rules.OrderPriceLimitRiskFirewallRuleConsts priceLimitConsts
:= new com.apama.firewall.rules.OrderPriceLimitRiskFirewallRuleConsts;
 
// Set configuration parameters to issue a
// warning when an order price is more than 15.0 and to
// reject an order with a price more than 20.0.
coma.apama.utils.Params ruleParams := new com.apama.utils.Params;
ruleParams.addFloatParam( priceLimitConsts.PRICE_LIMIT_PARAMETER, 20.0 );
ruleParams.addFloatParam( priceLimitConsts.PRICE_WARNING_PARAMETER, 15.0 );

// Set a symbol parameter.
sequence<string> symbol := ["SOW"];
ruleParams.addParam(com.apama.firewall.Consts.SLICE_SYMBOL, symbol);
 
// Add the rule class instance to a risk firewall represented by rfw.
integer instanceId := rfw.addRuleInstance(
priceLimitConsts.RULE_CLASS_NAME, ruleParams );
Copyright © 2013-2016 Software AG, Darmstadt, Germany.

Product LogoContact Support   |   Community   |   Feedback