Overview

When pricing an opportunity in PrecisionLender, application events are sent to Andi® to notify her of changes to the opportunity. The engine powers allow you to access the engineModel of an application event for calculations.

 

In this Article

 

What is the engineModel?

The engineModel is a JSON object within the opportunityModel that contains the financial account data for an opportunity when an application event occurs. The object contains the following shape:

EngineModel {
id: string;
financialStatement: FinancialStatement{};
allLoansFinancialStatement: AllLoansFinancialStatement{};
allDepositsFinancialStatement: AllDepositsFinancialStatement{};
allOtherFeesFinancialStatement: AllOtherFeesFinancialStatement{};
pricingContext: PricingContext{};
commercialLoanAccounts: CommercialLoanAccount[];
depositAccounts: DepositAccount[];
otherFeesAccounts: OtherFeesAccount[];
isPipelineScenario: boolean;
isCurrentScenario: boolean;
}

 

What are the engine powers?

The engineModel powers allow you to access data from the properties and arrays within the engineModel to target for calculations.
 
The available engineModel powers are:
 

At the opportunity level

  • getCalculationEngine - returns the calculation engine for a given opportunity
  • recalculate - returns the promise to recalculate the engine for a given opportunity based on the parameters defined in your skill code

At the scenario level

  • getCalculationEngine - returns the calculation engine for a given scenario in an opportunity
  • recalculate - returns the promise to recalculate the engine for a given scenario based on the parameters defined in your skill code

At the loan level

  • getCalculationEngine - returns the calculation engine for a given loan account
  • recalculate - returns the promise to recalculate the engine for a given loan account based on the parameters defined in your skill code
  • getCustomerLoanAmortization - returns the entries from the amortization table for a given loan account

At the deposit level

  • getCalculationEngine - returns the calculation engine for a given deposit account
  • recalculate - returns the promise to recalculate the engine for a given deposit account based on the parameters defined in your skill code

At the other (other accounts) level

  • getCalculationEngine - returns the calculation engine for a given other fee based account
  • recalculate - returns the promise to recalculate the engine for a given other fee based account based on the parameters defined in your skill code
 
For each level, getCalculationEngine returns the engineModel for that given level. At the opportunity level, this would include loan, deposit, and other accounts levels. At the loan level, this would only return the model and the loan account level.
 
The engine powers also allow you to access Assumption Sets for an opportunity.
 

When to use the engine powers

You should use the engine powers when you want to perform calculations or obtain financial information about an opportunity to provide insights during pricing.

For example, you may want to display a field tag that notifies the Relationship Manager of how the ROE for a loan in an opportunity would be impacted by increasing the initial rate.

You can also access the engineModel via the following powers if looking to focus more on information rather than calculation:
 

How to call the engine powers

The engine powers will be called via the engine property of the PrecisionLender powers.
//opportunity level
return skillContext.powers.precisionLender.engine.opportunity.getCalculationEngine()
return skillContext.powers.precisionLender.engine.opportunity.recalculate() //scenario level
return skillContext.powers.precisionLender.engine.scenario.getCalculationEngine()
return skillContext.powers.precisionLender.engine.scenario.recalculate() //loan level
return skillContext.powers.precisionLender.engine.loan.getCalculationEngine()
return skillContext.powers.precisionLender.engine.loan.recalculate()
return skillContext.powers.precisionLender.engine.loan.getCustomerLoanAmortization() //deposit level
return skillContext.powers.precisionLender.deposit.opportunity.getCalculationEngine()
return skillContext.powers.precisionLender.deposit.opportunity.recalculate() //other accounts level
return skillContext.powers.precisionLender.other.opportunity.getCalculationEngine()
return skillContext.powers.precisionLender.other.opportunity.recalculate()
Here's an example run code for a skill that uses the opportunity model to identify the first loan account in an opportunity and returns the promise that for a rate increase of 2%, use the loan level recalculate engine power to determine what the new ROE will be and display that information in a field tag to the Relationship Manager.
export function run(skillContext: andiSkills.ISkillContext): andiSkills.RunResponse{

    return  skillContext.powers.precisionLender.opportunity
        .getCurrentOpportunityModel()
        .then((opportunityModel) => {
            // For this example skill we will just take the first loan account
            return opportunityModel.engineModel.commercialLoanAccounts[0];
        })
        .then((loan) => {
            // A static rate increase of 2%
            const rateIncrease = .02;

            // Increase rate
            loan.initialRate += rateIncrease;

            // Recalculate opportunity
            return skillContext.powers.precisionLender.engine.loan
                .recalculate(loan)
                .then(() => {
                        // The data in the loan has now been recalculated based on the new rate increase

                        // Create an informative message about the potential changes
                        const message = `Increase rate by ${rateIncrease * 100}% to achieve an ROE of ${loan.financialStatement.roe}`;

                        // Send the message over via field tag
                        return skillContext.powers.andi.fieldTag.sendFieldTag(
                            andiSkills.FieldTagTypes.Info,
                            "increase-rate-potential-roe",
                            1,
                            message,
                            ["initialRate"],
                            null,
                            function (api, model, compareHash, custom) {
                                var eventData = model.applicationEventData;

                                var shouldIShow = eventData.engineModel.commercialLoanAccounts
                                    && eventData.engineModel.commercialLoanAccounts.length > 0
                                    && eventData.engineModel.commercialLoanAccounts[0].financialStatement.targetROE > eventData.engineModel.commercialLoanAccounts[0].financialStatement.roe;

                                return shouldIShow;
                            },
                            null,
                            null,
                            null,
                            null
                        );

                })       
        });
    
}
 
 
 
Was this article helpful?
0 out of 0 found this helpful