Deal Triggers
Overview
One the pieces of logic that occurs in a structured security is that the security may set certain triggers. A trigger
is a yes/no (or true/false boolean) that indicates whether a given condition has occurred. When a trigger has been
tripped, it will change the routing of the cash flows.
Implementation
A simple way to keep track of triggers is to define them outside
your for loop that loops through the dated cash flows. Then within the loop, test for the trigger and set the trigger
value to the tested condition. The trigger variable can then be used to change the logic of the cash flow routing.
let trigger = false;
for(let item of cashFlows){
//if some condition occurs, set trigger to true
if(item.payment > cash){
trigger = true;
//do different logic here to process payments
}
}