Model Applicability and Variant Router
Install and import#
npm install fintech-algorithmsimport { modelApplicabilityAndVariantRouter } from "fintech-algorithms/fundamental-analysis-and-valuation/integrated-equity-scoring/model-applicability-and-variant-router";Signature#
modelApplicabilityAndVariantRouter(data)Tests each requested scoring model against a frozen applicability rule for the target and returns the variant to run, a reroute, or an unsupported marker for labels the router does not know.
Parameters#
| Name | Type | Notes |
|---|---|---|
data | { target: { is_public?: boolean; sector?: string; market_cap?: number; annual_periods?: number; dividends_known?: boolean; total_assets?: number; framework?: string }; requested_models: string[] } | target supplies the scope facts the rules read — is_public, sector, market_cap, annual_periods, dividends_known, total_assets and framework — and requested_models names the models to route. The recognised labels are altman_z_original, piotroski_f, beneish_m, ohlson_o, dividend_safety and balance_sheet_resilience; any other label routes as unsupported. |
Returns#
{ state: string; method: string; routes: Array<{ model: string; status: string; variant: string | null; population?: string; reason: string }>; eligible_count: number; requested_count: number; coverage: number }
One route per requested model. status is eligible, reroute or unsupported; variant names the frozen convention to use when eligible and is null otherwise; population states the contract a known label targets. eligible_count over requested_count gives coverage, and state is routed when at least one model is eligible, otherwise abstain.
Errors#
- When target is missing or not an object, or requested_models is not a nonempty list — throws TypeError
- When a requested model name is not text — throws TypeError
Complexity: time O(n),
space O(n).
Worked example#
executed Captured by running this function on the input its own test provides. Real output of real code — but not asserted against a published figure.
Input#
{
"target": {
"id": "TGT",
"sector": "industrial",
"is_public": true,
"annual_periods": 3,
"framework": "US-GAAP",
"total_assets": 1000,
"market_cap": 2000,
"dividends_known": true
},
"requested_models": [
"altman_z_original",
"piotroski_f",
"beneish_m",
"ohlson_o",
"dividend_safety",
"balance_sheet_resilience"
]
}Call#
modelApplicabilityAndVariantRouter(data)Returns#
object with 6 fields: state, method, routes, eligible_count, requested_count, coverage
{
"state": "routed",
"method": "explicit-model-applicability-router",
"routes": [
{
"model": "altman_z_original",
"status": "eligible",
"variant": "Use D18-F04-A01 original public-manufacturer coefficients",
"population": "public industrial manufacturer",
"reason": "all required scope facts pass"
},
{
"model": "piotroski_f",
"status": "eligible",
"variant": "Use D18-F04-A02 nine-signal contract",
"population": "non-financial issuer with two annual periods",
"reason": "all required scope facts pass"
},
{
"model": "beneish_m",
"status": "eligible",
"variant": "Use D18-F04-A03 eight-index contract",
"population": "non-financial issuer with two annual periods",
"reason": "all required scope facts pass"
}
],
"eligible_count": 6,
"requested_count": 6,
"coverage": 1
}Other exports#
This module also exports
calculate, pointInTimeStockScoringInputAssembly, stockScoringPeerCohortResolver, fundamentalMetricDirectionAndPeerNormalization, accountingFinancialHealthComposite, earningsQualityComposite, dividendSafetyScore, balanceSheetResilienceScore, distressModelEnsemble, crossModelConflictAndDoubleCountingResolver, overallExplainableStockScore, scoreConfidenceMissingDataPenaltyAndAbstention, marketWideStockScreeningAndRanking, stockScoreHistoryMigrationAndChangeAttribution. Every module additionally exports run as an alias of its
primary function, and a meta object carrying its catalog id, domain, family,
shape and article URL.
Diagrams#
How it works#
This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.
References#
- Financial Ratios, Discriminant Analysis and the Prediction of Corporate Bankruptcy — Edward I. Altman
- Value Investing: The Use of Historical Financial Statement Information to Separate Winners from Losers — Joseph D. Piotroski
- The Detection of Earnings Manipulation — Messod D. Beneish
- Beginners' Guide to Financial Statements — U.S. Securities and Exchange Commission
- Conceptual Framework for Financial Reporting — International Accounting Standards Board
- Evidence boundary