How it works
Submit the job
Call the
calculateOptimalStructure mutation with the loan ID, objective, and optional constraints.MIN_PITIA, MIN_OUT_OF_POCKET, MIN_DOWN_PAYMENT) and pricing constraints, see Overview - Optimization objectives and Borrower preferences and pricing constraints.
Performance and response time
Most optimal structure is asynchronous: you submit the job, then poll until complete. It is much faster than the full rate sheet, which evaluates the entire rate stack across all products. Response times are typically about 3 seconds, compared to 10-20 seconds for the full rate sheet. Use most optimal structure when you only need the single best structure and want quicker response times.UI/UX recommendations
- Show a loading state - Display a loading indicator while the asynchronous job completes and you poll for the result. A short message like “Finding your best option…” is sufficient; 3 seconds usually doesn’t require the longer copy used for the full rate sheet.
- Avoid repeated calls - Cache or reuse the result until the user or loan data changes (e.g. loan data, borrower preferences, or objective). Don’t refetch on every tab focus or minor UI interaction.
1. Start the calculation (mutation)
MIN_DOWN_PAYMENT and maxLtv, see Fixed loan structures.
2. Get the result (query)
Pollpricing.optimalStructure(id) with the job id until status is complete, then read result and optionally productBreakdown.
Result vs Product Breakdown
| Field | Description |
|---|---|
result | The single best structure for the loan for your objective (e.g., the structure with MIN_PITIA across all products and structures). Use this when you only need “the answer.” |
productBreakdown | The best structure per product for the same objective. Each item is a StructuringResult (eligible, ineligible, or error). See Overview - Pricing response types. |
Polling:
optimalStructure is a job. Poll on status (e.g. COMPLETED, FAILED) and only read result / productBreakdown when the job has finished.Related
- Full rate sheet optimizations - Full rate stack across all products and structures, with eligible and ineligible options and their reasons.
- Pricing optimizations (Overview) - Optimization objectives, constraints, and pricing response types.