Financial dashboards often begin with prices. A more useful risk system begins with states.
For a Brazilian portfolio, the objective should not be to build a model that produces one confident prediction for the Ibovespa or USD/BRL. The objective should be to identify the environment in which those assets are operating.
A practical regime-detection pipeline can be organized around five data blocks: interest rates, inflation, currency, commodities and market liquidity.
- Build the Interest-Rate Block
The current Selic target is 14.25%, but a system should not store only the policy rate.
It should also collect the DI futures curve, inflation expectations, nominal government-bond yields and estimated real rates. The curve can then be represented through level, slope and curvature features.
A simple feature set might include:
rate_features = {
“selic”: current_selic,
“front_end_slope”: di_1y - selic,
“long_end_slope”: di_5y - di_1y,
“expected_real_rate”: di_2y - expected_inflation,
“curve_volatility”: rolling_std(di_curve_changes)
}
The model should distinguish between a parallel fall in yields and a steepening event in which short-term yields decline while long-term yields rise.
Those two conditions may have very different implications for credit, valuation and portfolio duration.
- Preserve the Structure of Inflation
June’s IPCA-15 rose 0.41%, with the twelve-month measure at 4.80%.
A weak data pipeline would store only those two figures.
A stronger system would preserve category-level information such as food, housing, energy, services, regulated prices and transportation. It would also record diffusion, revisions and the distance between actual inflation and market expectations.
The system should not assume that every inflation increase has the same persistence.
A regulated electricity adjustment, a food-supply shock and broad service inflation belong to different causal groups. They should not receive identical model weights.
- Treat Currency as a Multi-Driver Variable
The official dollar reference rate ended June close to R$5.18.
USD/BRL should not be modeled as a direct function of the Selic rate alone. The currency also responds to the global dollar cycle, commodity prices, fiscal expectations, international risk appetite and hedging demand.
A useful pipeline can create separate driver scores:
currency_state = weighted_score(
carry_signal,
global_dollar_signal,
commodity_signal,
fiscal_risk_signal,
foreign_flow_signal
)
The purpose of this score is not to predict an exact exchange rate.
It is to identify which force currently dominates the currency regime and whether that dominance is stable.
- Separate Commodity Exposure from the Domestic Economy
Brazilian assets often react to oil, iron ore and agricultural prices, but the relationship is not uniform.
Commodity exporters may benefit from stronger external prices while domestic consumers face different effects through fuel, food and inflation expectations.
The data layer should therefore separate commodity prices, terms of trade, export volumes and company-level exposure.
A broad “commodity up” feature is too crude for portfolio-risk analysis.
- Measure Liquidity and Participation
The Ibovespa closed July 1 near 171,689 points. The index level alone cannot show whether market participation is healthy.
A liquidity block should include volume, breadth, bid-ask spreads, foreign flow, concentration and the relationship between cash and futures trading.
A market advance supported by many sectors is different from an advance produced by a few large companies.
Likewise, a small decline with disappearing liquidity may represent more risk than a larger but orderly adjustment.
From Features to Regimes
Once the five blocks are standardized, the system can use clustering, hidden Markov models or supervised classification to identify regimes.
Possible labels might include:
DOMESTIC_EASING
LONG_END_STRESS
CURRENCY_PRESSURE
COMMODITY_SUPPORT
LIQUIDITY_CONTRACTION
MIXED_OR_UNCERTAIN
The final label should always include a confidence score.
If the rate model signals easing while the currency and inflation models signal stress, the system should not force a simple answer. It should classify the environment as mixed and increase uncertainty.
Monitoring Model Failure
Brazilian financial data contains structural breaks. Fiscal frameworks change. Policy communication changes. Commodity cycles change. Global funding conditions change.
Every production system should therefore monitor data drift, feature drift and regime instability.
It should also maintain a human-readable explanation of why a classification changed.
An unexplained output may be statistically sophisticated but operationally weak.
Final Principle
The best financial AI system is not the one that predicts every market move.
It is the one that helps investors recognize when their assumptions are becoming less reliable.
For Brazilian portfolios, regime detection provides a disciplined way to connect rates, inflation, currency, commodities and liquidity without pretending that uncertainty has disappeared.

Top comments (0)