[rules-users] Help with Accumulate function

dwipin dwipin.c at tcs.com
Thu Apr 7 02:44:40 EDT 2011


Hi, 
  I am having trouble implementing this rule with the accumulate function.
My rule requirement is - 
Aggregate all PnlAttributionAmounts with a type of "UNEXPLAINED" for all
Positions for a given day. 

Below is the code I have for this - 

$position : Position(date == $currDate) 
$posScn : PositionScenario(scenario == 'SCEN-EOD', position == $position ) 
$posScnGrp : PositionScenarioCurrencyGroup(positionScenario == $posScn,
currencyType == CurrencyTypes.TRANSACTIONAL) 
$posPnlAmt : PositionPnlAmount(pnlAmountType == "DTD",
positionScenarioCurrencyGroup == $posScnGrp) 
$attibAmtType : AttributionAmountType(attributionAmountType ==
"UNEXPLAINED/RESIDUALPNL") 

$totalPnlAttibAmt : BigDecimal() 
        from accumulate( 
                PositionPnlAttributionAmount(positionPnlAmount ==
$posPnlAmt, attributionAmountType == $attibAmtType, $pnlAttibAmt :
financialValue) 
                ,sum($pnlAttibAmt) 
        ) 

eval ($totalPnlAttibAmt > 1000) 

When I do it this way, the rule gets executed 6 times, basically for every
fact that evaluated to true. How do I restrict this? The rule should be
executed only if the final eval results in true. 

Thanks for any help, 
Dwipin. 


--
View this message in context: http://drools-java-rules-engine.46999.n3.nabble.com/Help-with-Accumulate-function-tp2789194p2789194.html
Sent from the Drools - User mailing list archive at Nabble.com.



More information about the rules-users mailing list